How to use a Ram.

K

Konx

Guest
Hi everyone.

I'm trying to use a block RAM, generated by Xilinx Core Generator, but
I'm not very expert in Verilog language...

What I want to do is the following:
- create a RAM: the ram has 8192 position (so, 13-bit address) and
every position can store 49 bit (done).
- on one FPGA pin, I have the incoming _serial_ data: at every
falling edge of the clk (and when the TOKEN signal is = 1, or another
control signal is = 1) one data is arriving. The token signal is long
enough to permit the arrivals of 48 bit.
- at the moment I want to store this 48 bit inside an array, then
write in the last bit a 1 and then store this 49-bit array inside the
first address.
- then, token goes to zero, and I wait until the next time TOKEN go
back to 1 to receive again others 48 bits.

So, my final situation should be: 8192 address in the RAM, completely
filled with 49-bit data.

Now, more or less I have the idea of how to do this (basically, "for"
cycle with "if" condition to check the last bit and see if the
position in the RAM is already filled). The problem is to translate
this algorithm in Verilog language.

This is the description of my istantiated block:

memory M1 (
.clka(clk),
.rsta(reset),
.ena(token), //this pin enables write/read/reset operation, probably
is not necessary
.wea(token), // Bus [0:0] - this pin enables write operation
.addra(addra), // Bus [12 : 0]
.dina(out), // Bus[48:0] - The Input pin of the memory is connected
to the out pin of the
// testbench, because this is the pin where the data are
arriving
.douta(douta)); // Bus [48:0]


Then, I set the initial condition:

initial
begin
read_state=1'b0;
reset<=1'b0;
clk<=1'b0;
hit<=1'b0;
token<=1'b0;
trigger<=1'b0;
data [47:0] <=48'b000000000000000000000000000000000000000000000000;
i=0;
hit_counting_mode<=1'b0;
addra [12:0] <=13'b0000000000000;
end

Then, there is the readout part of the code, that at the moment is
something like this:

always@(negedge clk)
begin
if(read_state&&(i<48)&&dina[48]==0)
begin
data<=out;
dina<=out;
i<=i+1;
end
if(read_state&&(i==48)&&dina[48]==0)
begin
dina[48]<=1;
end
if(~read_state)
i<=0;
end

More or less this should work, but what I don't really understand is
how to put the data inside the first address of the RAM, and then
increase the address for the next incomin data.

Do you have any suggestion? I hope the problem is clear enough.

Thank you

Francesco.
 
What I want to do is the following:
- create a RAM: the ram has 8192 position (so, 13-bit address) and
every position can store 49 bit (done).
Perhaps the following app notes could be of interest?

http://www.xilinx.com/support/documentation/application_notes/xapp463.pdf
http://www.google.ca/url?q=http://www.xilinx.com/support/documentation/application_notes/xapp204.pdf
http://rtds.cs.tamu.edu/web_462/labs/blockram.ppt
http://forums.xilinx.com/xlnx/board/message?board.id=DEENBD&thread.id=685
http://www.fpgacpu.org/usenet/bb.html


Nicholas
 
On 29 Nov, 01:48, Nicholas Kinar <n.ki...@usask.ca> wrote:
What I want to do is the following:
- create a RAM: the ram has 8192 position (so, 13-bit address) and
every position can store 49 bit (done).

Perhaps the following app notes could be of interest?
[cut]

Thanks for your answer Nicholas!

I've read the links, but still my question remain: maybe it was not so
clear, so I try to reformulate it:

given a well-described one-port, synchronous RAM, how can I say to the
ram: "store the incoming data inside the first address, and the
following data inside the second address, and so on?"

I've seen a lot of examples and probably it has something to do with
the declaration of a reg signal like this:

reg [7:0] mem [0:255];

but honestly, I don't understand...

thank you again

Francesco.
 
I've seen a lot of examples and probably it has something to do with
the declaration of a reg signal like this:

reg [7:0] mem [0:255];
Is this what you want to do? Perhaps this would be of assistance:

http://forums.xilinx.com/xlnx/board/message?board.id=Virtex&thread.id=4780
 
On Mon, 30 Nov 2009 02:37:34 -0800 (PST), Konx <cescozep@gmail.com>
wrote:

On 29 Nov, 01:48, Nicholas Kinar <n.ki...@usask.ca> wrote:
What I want to do is the following:
- create a RAM: the ram has 8192 position (so, 13-bit address) and
every position can store 49 bit (done).

Perhaps the following app notes could be of interest?

[cut]

Thanks for your answer Nicholas!

I've read the links, but still my question remain: maybe it was not so
clear, so I try to reformulate it:

given a well-described one-port, synchronous RAM, how can I say to the
ram: "store the incoming data inside the first address, and the
following data inside the second address, and so on?"

I've seen a lot of examples and probably it has something to do with
the declaration of a reg signal like this:

reg [7:0] mem [0:255];

but honestly, I don't understand...

thank you again

Francesco.
I"d say a well-described one-port RAM (synchronous or otherwise) would
have a data interface (a single bi-directional bus or two
uni-directional ones) and an address interface to indicate where the
next transaction is going to occur. It also would have a control
signal to select whether you want a read transaction or a write
transaction. It seems that your data source just produces one piece of
data every clock and you want to store it in the RAM. To do this the
only thing you need is to have a counter which acts as the address for
the RAM and for every piece of data your source produces, increment
the counter and supply it to the RAM. Maybe something like this:

reg [7:0] dataout; // assume 8 bit data
source us(clk, dataout, valid);

always @(posedge clk)
if (valid) cntr <= cntr + 1;

sram ur(.clk(clk), .address(cntr), .we(valid), .datain(dataout), ...);

This logic would increment the cntr for every valid incoming data and
write it to the sram.

Hope this helps.

--
Muzaffer Kal

DSPIA INC.
ASIC/FPGA Design Services

http://www.dspia.com
 
Konx wrote:
On 29 Nov, 01:48, Nicholas Kinar <n.ki...@usask.ca> wrote:
What I want to do is the following:
- create a RAM: the ram has 8192 position (so, 13-bit address) and
every position can store 49 bit (done).
Perhaps the following app notes could be of interest?

[cut]

Thanks for your answer Nicholas!

I've read the links, but still my question remain: maybe it was not so
clear, so I try to reformulate it:

given a well-described one-port, synchronous RAM, how can I say to the
ram: "store the incoming data inside the first address, and the
following data inside the second address, and so on?"

I've seen a lot of examples and probably it has something to do with
the declaration of a reg signal like this:

reg [7:0] mem [0:255];

but honestly, I don't understand...

thank you again

Francesco.

Is this what you want to do? Perhaps this would be of assistance:

http://forums.xilinx.com/xlnx/board/message?board.id=Virtex&thread.id=4780
 
Konx wrote:
On 29 Nov, 01:48, Nicholas Kinar <n.ki...@usask.ca> wrote:
What I want to do is the following:
- create a RAM: the ram has 8192 position (so, 13-bit address) and
every position can store 49 bit (done).
Perhaps the following app notes could be of interest?

[cut]

Thanks for your answer Nicholas!

I've read the links, but still my question remain: maybe it was not so
clear, so I try to reformulate it:

given a well-described one-port, synchronous RAM, how can I say to the
ram: "store the incoming data inside the first address, and the
following data inside the second address, and so on?"

I've seen a lot of examples and probably it has something to do with
the declaration of a reg signal like this:

reg [7:0] mem [0:255];

but honestly, I don't understand...

thank you again

Francesco.

Is this what you want to do? Perhaps this would be of assistance:

http://forums.xilinx.com/xlnx/board/message?board.id=Virtex&thread.id=4780
 
Konx wrote:
On 29 Nov, 01:48, Nicholas Kinar <n.ki...@usask.ca> wrote:
What I want to do is the following:
- create a RAM: the ram has 8192 position (so, 13-bit address) and
every position can store 49 bit (done).
Perhaps the following app notes could be of interest?

[cut]

Thanks for your answer Nicholas!

I've read the links, but still my question remain: maybe it was not so
clear, so I try to reformulate it:

given a well-described one-port, synchronous RAM, how can I say to the
ram: "store the incoming data inside the first address, and the
following data inside the second address, and so on?"

I've seen a lot of examples and probably it has something to do with
the declaration of a reg signal like this:

reg [7:0] mem [0:255];

but honestly, I don't understand...

thank you again

Francesco.
Is this what you want to do? Perhaps this would be of assistance:

http://forums.xilinx.com/xlnx/board/message?board.id=Virtex&thread.id=4780
 
Konx wrote:
On 29 Nov, 01:48, Nicholas Kinar <n.ki...@usask.ca> wrote:
What I want to do is the following:
- create a RAM: the ram has 8192 position (so, 13-bit address) and
every position can store 49 bit (done).
Perhaps the following app notes could be of interest?

[cut]

Thanks for your answer Nicholas!

I've read the links, but still my question remain: maybe it was not so
clear, so I try to reformulate it:

given a well-described one-port, synchronous RAM, how can I say to the
ram: "store the incoming data inside the first address, and the
following data inside the second address, and so on?"

I've seen a lot of examples and probably it has something to do with
the declaration of a reg signal like this:

reg [7:0] mem [0:255];

but honestly, I don't understand...

thank you again

Francesco.


Is this what you want to do? Perhaps this would be of assistance:

http://forums.xilinx.com/xlnx/board/message?board.id=Virtex&thread.id=4780
 
Konx wrote:
On 29 Nov, 01:48, Nicholas Kinar <n.ki...@usask.ca> wrote:
What I want to do is the following:
- create a RAM: the ram has 8192 position (so, 13-bit address) and
every position can store 49 bit (done).
Perhaps the following app notes could be of interest?

[cut]

Thanks for your answer Nicholas!

I've read the links, but still my question remain: maybe it was not so
clear, so I try to reformulate it:

given a well-described one-port, synchronous RAM, how can I say to the
ram: "store the incoming data inside the first address, and the
following data inside the second address, and so on?"

I've seen a lot of examples and probably it has something to do with
the declaration of a reg signal like this:

reg [7:0] mem [0:255];

but honestly, I don't understand...

thank you again

Francesco.
Is this what you want to do? Perhaps this would be of assistance:

http://forums.xilinx.com/xlnx/board/message?board.id=Virtex&thread.id=4780
 

Welcome to EDABoard.com

Sponsor

Back
Top