I'm working on a lab in Verilog and one of the tasks tells me to write different contents to 2 different addresses.
Here is my code:
module labM;
reg [31:0] address, memIn;
reg clk, read, write;
integer i;
wire [31:0] memOut;
mem data(memOut, address, memIn, clk, read, write);
initial
begin
write=1;
memIn = 32'h12345678;
address = 16;
clk=1;
#1;
memIn = 32'h89abcdef;
address = 24;
#1;
write=0; read=1; address=16;
repeat(3)
begin
#1 $display("Address %d contains %h", address, memOut);
address = address + 4;
end
end
endmodule
mem works as follows:
In order to read a word, set its address on address and set read. After some delay, the word's content will become stable on memOut. To write, set the data to be written on memIn, set the destination address on address, and set write. The data will be written on the destination at the next positive edge of clk.
The output of the above is the correct value for address 16, but addresses 20 and 24 is "xxxxxxxx".
I've been stuck on this for a while, and I don't understand why I can't re-assign memIn.
Any help would be much appreciated.
Thanks.