joanna_seczkowska
Newbie level 6
memory in verilog
reg [13] RAM [2];
How big this ram actually is?
is it 14bits by 3 slots
or 14x8 slots ?
by incrementing counter we get cell adresses from 0 to 7 and by shifting 1
we get 3 x 14 bit memory ocupation.
What is right?
I thought that it is 14x3 but after studying the fifo verilog code:
https://www.asic-world.com/examples/verilog/syn_fifo.html#Synchronous_FIFO
I found the code:
always @ (posedge clk or posedge rst)
49 begin : WRITE_POINTER
50 if (rst) begin
51 wr_pointer <= 0;
52 end else if (wr_cs && wr_en ) begin
53 wr_pointer <= wr_pointer + 1;
54 end
55 end
Added after 16 minutes:
When I simulate memory in modelsim I get:
for addresses 0,1,2 right value for addrress 3
I 've got x.
I write to memory like:
reg [13:0] memory [2:0]
ptr = (ptr + 1) & 3;
Memory[ptr] = data_in;
then I read it:
output = Memory[ptr -1] + Moemory[ptr];
Modelsim shows only 3 [13:0] values for array
memory, so simple incrementation go out of range.
I checked another topic and it shows standard incrementation is correct:
reg [13] RAM [2];
How big this ram actually is?
is it 14bits by 3 slots
or 14x8 slots ?
by incrementing counter we get cell adresses from 0 to 7 and by shifting 1
we get 3 x 14 bit memory ocupation.
What is right?
I thought that it is 14x3 but after studying the fifo verilog code:
https://www.asic-world.com/examples/verilog/syn_fifo.html#Synchronous_FIFO
I found the code:
always @ (posedge clk or posedge rst)
49 begin : WRITE_POINTER
50 if (rst) begin
51 wr_pointer <= 0;
52 end else if (wr_cs && wr_en ) begin
53 wr_pointer <= wr_pointer + 1;
54 end
55 end
Added after 16 minutes:
When I simulate memory in modelsim I get:
for addresses 0,1,2 right value for addrress 3
I 've got x.
I write to memory like:
reg [13:0] memory [2:0]
ptr = (ptr + 1) & 3;
Memory[ptr] = data_in;
then I read it:
output = Memory[ptr -1] + Moemory[ptr];
Modelsim shows only 3 [13:0] values for array
memory, so simple incrementation go out of range.
I checked another topic and it shows standard incrementation is correct: