data/full_repos/permissive/51595169/VerilogSource/EmbededSystem/MEM_256B.v
1: b'%Warning-STMTDLY: data/full_repos/permissive/51595169/VerilogSource/EmbededSystem/MEM_256B.v:113: Unsupported: Ignoring delay on this delayed statement.\n #1 MFC = 1; \n ^\n                  ... Use "/* verilator lint_off STMTDLY */" and lint_on around source to disable this message.\n%Error: Exiting due to 1 warning(s)\n        ... See the manual and https://verilator.org for more assistance.\n'
module memory (inout [31:0] Data, output reg MFC, input MFA, ReadWrite, input [7:0] Address, input wordByte,Reset);








reg [31:0] Data_Buff;
reg [7:0] Mem[0:255];

wire [7:0] dataByte[0:3];

reg [7:0] tempAddress;

assign dataByte[0] = Data[31:24];
assign dataByte[1] = Data[23:16];
assign dataByte[2] = Data[15:8];
assign dataByte[3] = Data[7:0];
assign Data = Data_Buff;
integer i; 



integer   fd, code, index;
reg [7:0] data[3:0];

always@(posedge Reset) begin 
	$display("Dumping ROM...");
	index = 0;
	while (index < 255) begin
		$display("%d Memory Content Binary=%b Decimal=%d,Hex=%h",index,Mem[index],Mem[index],Mem[index]);
		index = index + 1;
	end
	$display("Loading test program to ROM...");
	fd = $fopen("memory.dat","r"); 
	index = 0;
	while (!($feof(fd))) begin
		code = $fscanf(fd, "%b %b %b %b\n", data[0],data[1],data[2],data[3]);
		Mem[index]=data[0];
		Mem[index+1]=data[1];
		Mem[index+2]=data[2];
		Mem[index+3]=data[3];
		$display("%d Reading from file=%b %b %b %b, Memory Content=%b",index,data[0],data[1],data[2],data[3],Mem[index]);
		index = index + 4;
	end
	while (index < 255) begin
		Mem[index]=0;
		index = index + 1;
	end
  	$fclose(fd);
  	$display("Test Program loaded in ROM...");
	$display("Memory");
	index = 0;
	while (index < 255) begin
		$display("%d Memory Content Binary=%b Decimal=%d,Hex=%h",index,Mem[index],Mem[index],Mem[index]);
		index = index + 1;
	end
  	$display("Finished");
	Data_Buff = 32'hzzzz_zzzz;
end


always @ (posedge MFA)

if(MFA) begin
	$display("Memory Function Active");
	MFC = 0;Data_Buff = 32'hzzzz_zzzz;
	$display("Memory Function Complete: %b", MFC);

    if(ReadWrite==0)begin

	  if(!wordByte) begin
		$display("Store a byte");
		Mem[Address] <= dataByte[3];
		Mem[Address+1] <= 8'b0;
		Mem[Address+2] <= 8'b0;
		Mem[Address+3] <= 8'b0;
		$display("Storing Least significant byte %h in address %d", dataByte[3], Address);
		$display("Mem[Address]: %h", Mem[Address]);
		end

	  else begin
		$display("Store a word");
		Mem[Address] <= dataByte[3];
		Mem[Address+1] <= dataByte[2];
		Mem[Address+2] <= dataByte[1];
		Mem[Address+3] <= dataByte[0];
		$display("Mem[Address]: %h", Mem[Address]);	
		$display("Mem[Address+1]: %h", Mem[Address+1]);	
		$display("Mem[Address+2]: %h", Mem[Address+2]);	
		$display("Mem[Address+3]: %h", Mem[Address+3]);	
	end


end else begin
	 if(wordByte) begin
			  Data_Buff[31:24] <= Mem[Address];
			  Data_Buff[23:16] <= Mem[Address+1];
			  Data_Buff[15:8] <= Mem[Address+2];
			  Data_Buff[7:0] <= Mem[Address+3];
	 end else begin
			  Data_Buff[7:0] <= Mem[Address];
			  Data_Buff[15:8] <= 8'b0;
			  Data_Buff[23:16] <= 8'b0;
			  Data_Buff[31:24] <= 8'b0;
			end
	end 

$display("Memory Function Complete: %b", MFC);
while(MFA==1)begin 
	#1 MFC = 1; 
end
MFC = 0; 
Data_Buff = 32'hzzzz_zzzz;
end


endmodule
module memory (inout [31:0] Data, output reg MFC, input MFA, ReadWrite, input [7:0] Address, input wordByte,Reset);









reg [31:0] Data_Buff;
reg [7:0] Mem[0:255];

wire [7:0] dataByte[0:3];

reg [7:0] tempAddress;

assign dataByte[0] = Data[31:24];
assign dataByte[1] = Data[23:16];
assign dataByte[2] = Data[15:8];
assign dataByte[3] = Data[7:0];
assign Data = Data_Buff;
integer i; 



integer   fd, code, index;
reg [7:0] data[3:0];

always@(posedge Reset) begin 
	$display("Dumping ROM...");
	index = 0;
	while (index < 255) begin
		$display("%d Memory Content Binary=%b Decimal=%d,Hex=%h",index,Mem[index],Mem[index],Mem[index]);
		index = index + 1;
	end
	$display("Loading test program to ROM...");
	fd = $fopen("memory.dat","r"); 
	index = 0;
	while (!($feof(fd))) begin
		code = $fscanf(fd, "%b %b %b %b\n", data[0],data[1],data[2],data[3]);
		Mem[index]=data[0];
		Mem[index+1]=data[1];
		Mem[index+2]=data[2];
		Mem[index+3]=data[3];
		$display("%d Reading from file=%b %b %b %b, Memory Content=%b",index,data[0],data[1],data[2],data[3],Mem[index]);
		index = index + 4;
	end
	while (index < 255) begin
		Mem[index]=0;
		index = index + 1;
	end
  	$fclose(fd);
  	$display("Test Program loaded in ROM...");
	$display("Memory");
	index = 0;
	while (index < 255) begin
		$display("%d Memory Content Binary=%b Decimal=%d,Hex=%h",index,Mem[index],Mem[index],Mem[index]);
		index = index + 1;
	end
  	$display("Finished");
	Data_Buff = 32'hzzzz_zzzz;
end


always @ (posedge MFA)

if(MFA) begin
	$display("Memory Function Active");
	MFC = 0;Data_Buff = 32'hzzzz_zzzz;
	$display("Memory Function Complete: %b", MFC);

    if(ReadWrite==0)begin

	  if(!wordByte) begin
		$display("Store a byte");
		Mem[Address] <= dataByte[3];
		Mem[Address+1] <= 8'b0;
		Mem[Address+2] <= 8'b0;
		Mem[Address+3] <= 8'b0;
		$display("Storing Least significant byte %h in address %d", dataByte[3], Address);
		$display("Mem[Address]: %h", Mem[Address]);
		end

	  else begin
		$display("Store a word");
		Mem[Address] <= dataByte[3];
		Mem[Address+1] <= dataByte[2];
		Mem[Address+2] <= dataByte[1];
		Mem[Address+3] <= dataByte[0];
		$display("Mem[Address]: %h", Mem[Address]);	
		$display("Mem[Address+1]: %h", Mem[Address+1]);	
		$display("Mem[Address+2]: %h", Mem[Address+2]);	
		$display("Mem[Address+3]: %h", Mem[Address+3]);	
	end


end else begin
	 if(wordByte) begin
			  Data_Buff[31:24] <= Mem[Address];
			  Data_Buff[23:16] <= Mem[Address+1];
			  Data_Buff[15:8] <= Mem[Address+2];
			  Data_Buff[7:0] <= Mem[Address+3];
	 end else begin
			  Data_Buff[7:0] <= Mem[Address];
			  Data_Buff[15:8] <= 8'b0;
			  Data_Buff[23:16] <= 8'b0;
			  Data_Buff[31:24] <= 8'b0;
			end
	end 

$display("Memory Function Complete: %b", MFC);
while(MFA==1)begin 
	#1 MFC = 1; 
end
MFC = 0; 
Data_Buff = 32'hzzzz_zzzz;
end


endmodule