Sign In

Don't have a Xilinx account yet?

  • Choose to receive important news and product information
  • Gain access to special content
  • Personalize your web experience on Xilinx.com

Create Account

Username

Password

Forgot your password?
XClose Panel
Xilinx Home
Reply
Regular Visitor
alexdetrano
Posts: 29
Registered: ‎06-02-2009
0
Accepted Solution

Using RAM Blocks to manipulate data

Hello,

 

I'm not sure if I'm going about this in the  right way, but I'll give it a shot.  I have a sequence of 100 numbers (1:100) and I want to grab the first 10, then the third ten, then the fifth ten, so that my data will be (1:10)(30:40) (60:70), etc.  How can I do this?  I think a RAM block might come in handy here; I write the whole sequence to the RAM block, so that the first 100 memory locations would be my whole data, then use a counter of some sort to read out memory address 1:10, then address 30:40, etc.  Am I thinking about this properly?  I looked at the single port RAM block and the hlep file didn't really help...perhaps a dual port RAM block is necesssary?  These RAM blocks are a little overwhlemeing, any help from some xilinx gurus out there would be much appreciated.  Thanks!

 

Alexander

Contributor
walid_farid
Posts: 39
Registered: ‎04-14-2009

Re: Using RAM Blocks to manipulate data

Hello,

 

 I think you can do this using a single-port block ram initialized with the values 1:100 and then you can simply write a state machine which access the addresses you want to get the corresponding data. The state machine can be written either using the Mcode block (The state m/c is written in Matlab) or the Sysgen Black Box (The state m/c to be written in verilog or vhdl.

 

Regards,

 Walid F. 

Visitor
gotcha25
Posts: 10
Registered: ‎03-23-2009
0

Re: Using RAM Blocks to manipulate data

hello, i am doing  something like that. I have to receive  continue data  and work for block. In this case i receive a block  of 52 bytes and  i have to eliminate the last 12 bytes. I am using 2 single port RAM but the resuts are not successful. The output data must be continuo. (Receive 52 bytes and the output have 40 bytes and next to the last byte i have the first byte of the 2nd block ).

 

thanks...

Visitor
erochasousa
Posts: 8
Registered: ‎10-14-2009

Re: Using RAM Blocks to manipulate data

[ Edited ]

You can put a counter counting from 0 to 29 and glue it into a ROM storing pointers. The ROM is connected directly to the Memory address input.

 

The pointers can be [1:10  30:40 60:70]-1

 

Whenever I need to rearrange the format of a serial data input, for example after a FFT, I need to make something like "fftshift" from Matlab, I use this ROM-storing-pointers strategy.

 

You can use a dual-port RAM if the input data is coming continuosly all the time...

 

You can also use a FIFO. Just work the write signal. Keep 'we' high when the inputs 1:10 , 30:40 and 60:70 are coming. Then just read at the output. If you want continuous data like gotcha25, your read signal should have a lower rate then we signal.

 

For a 100-sample input data, you are outputting 30 samples. So the normalized sample rates '10' (for read signal) and '3' (for we signal). 

 

Hope this helps 

Message Edited by erochasousa on 10-14-2009 07:45 AM
Message Edited by erochasousa on 10-14-2009 08:13 AM
Visitor
gotcha25
Posts: 10
Registered: ‎03-23-2009
0

Re: Using RAM Blocks to manipulate data

Thanks for your help erochasousa, i solved my problem using a dual port ram  with a diffrente rate for write  and read.. And what happen if i can reverse this operation. The input now  has 40 bytes and i want in the output 52 bytes??the additional 12 bytes could be any value, for example 00...With this operation the rate for the output must be the same when i have the initial 52 bytes
Contributor
evgenia89
Posts: 36
Registered: ‎02-06-2012
0

Re: Using RAM Blocks to manipulate data

Hello,

I am trying to do the similar things. I use FIFO and I need to read 100 samples to this and then to calculate average value. The problem is how to calculate this average, because the function mean(x) works with arrays and I don't know how to convert my input digital signal to array.

Thank you for any help!

Super Contributor
vlavruhin
Posts: 195
Registered: ‎12-08-2010
0

Re: Using RAM Blocks to manipulate data

Hello, Evgenia.

 

It's better to start new thread.

 

Do you want to calculate average value using blocks of the System Generator for further netlist generation? Or to find average value using standard Matlab function (mean(x))?

Best Regards,
Vitaly.
Contributor
evgenia89
Posts: 36
Registered: ‎02-06-2012
0

Re: Using RAM Blocks to manipulate data

Vitaly,

I think it's better to use System Generator blocks, but the using of mean(x) is also possible because of block MCode where I can write the code.

Super Contributor
vlavruhin
Posts: 195
Registered: ‎12-08-2010
0

Re: Using RAM Blocks to manipulate data

Evgenia,

 

'MCode' block supports only restricted subset of Matlab language as you can see on page 224 of System Generator Reference Guide:

http://www.xilinx.com/support/sw_manuals/sysgen_ref.pdf

 

But there is an 'Accumulator' block which can be used to solve your problem.

 

Averaging is basically accumulation:

 

mean(X) = (X_1 + X_2 + ... + X_N) / N,

accumulated_sum(X) = X_1 + X_2 + ... + X_N.

 

Accumulator expects single samples at its input (not array).

Just make sure to chose proper bitwidth of accumulator in order to prevent overflow.

Best Regards,
Vitaly.
Contributor
evgenia89
Posts: 36
Registered: ‎02-06-2012
0

Re: Using RAM Blocks to manipulate data

Thank you, Vitaly, it really can help in solving the problem.

But the thing is that I need to put into a memory any amount of points (let's say 1000), and then to calculate average of all these point. It should be one number but it seems that the block 'Accumulator' works for every point independently:

accumulator.jpg

 

1st line - input signal;

2nd line - counter;

3d line - output of accumulator.

 

Or maybe I don't understand anything.