- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Using of Dual Port RAM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-21-2012 04:52 AM
Hello!
Can anyone explain me how to use the block Dual Port RAM in Simulink? I am especially confused with meaning of ports addra and addrb.
Thanks!
Evgenia.
Solved! Go to Solution.
Re: Using of Dual Port RAM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-21-2012 05:08 AM
Hello, Evgenia.
Dual Port RAM is ordinary RAM block with two access input/output ports: port A and port B. So you can independently access to common memory space through these two ports. For example, you can have concurrent reading of one memory cell using port A and writing of other memory cell using port B.
AddrA is address line of port A. AddrB is address line of port B.
There is a detailed description of Dual Port RAM block in System Generator Reference Guide:
http://www.xilinx.com/support/documentation/sw_man
Vitaly.
Re: Using of Dual Port RAM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-21-2012 06:34 AM
Hello, Vitaly,
I applied sine waveform to addrb port, then I sum two signals from A and B and apply this to addra port.
I choose with the help of MCode, when wea and web are enable:
if x < 1000
z = true;
else
z = false;
The result is not what I expected...
Re: Using of Dual Port RAM
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-21-2012 06:55 AM - edited 03-21-2012 07:03 AM
Evgenia, what are your expectations?
How are Counter, Counter1 and Dual Port RAM blocks configured ?
What are initial values of the counters? If initial values are equal, then you will get write-write collision (simultaneous write attempt at same memory cell, which will result in NaN output).
Vitaly.
Re: Using of Dual Port RAM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-21-2012 07:16 AM
I expected increasing of the signal amplitude every cycle.
Configurations are:
RAM: Port A - read before write, port B - read after write;
Counter: initial value - 0, up to 1000;
Counter1: initial value - 1000, up to 2000;
Counter2: initial value - 0, up to 2000.
Re: Using of Dual Port RAM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-21-2012 07:30 AM
Ok, Evgenia.
What are parameters of 'AddSub' block?
What is at output of your model? Could you attach MDL file?
Vitaly.
Re: Using of Dual Port RAM
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-21-2012 07:37 AM - edited 03-28-2012 05:00 AM
Vitaly,
thank you for your patient, all the parameters are in the attached file.
Evgenia.
Re: Using of Dual Port RAM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-21-2012 08:11 AM
Am I right that the bitwidths of counters are 8 bit? I.e., the counter is able to count from 0 to 255 and can't reach value 1000.
Vitaly.
Re: Using of Dual Port RAM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-28-2012 04:59 AM
Vitaly, thank you for your help very much. I checked the bitwidths and modified the model and now it works ok.
But now I need to modify the model because I want to divide the AddSub output signal to 2 and apply it to dina port of Dual Port RAM. The problem is that i need to divide from the second cycle, because during the first cycle port A output is empty.
I am using MCode block. The MatLab code is following:
function z = divst(x, i);
if (i < 512)
z = x;
else
z = xl_force(x, xlSigned, 11);
end
When I start simulation I get a message: 'Illegal type of port dinb', because output of the block MCode has type Fix_17_11 while I was expecting Fix_16_11.
Also I am wondering what block I can use for variable i. For now I put counter, but I understand that it is not good solution.
Best regards,
Evgenia.
Re: Using of Dual Port RAM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-29-2012 07:11 AM
Hello, Evgenia.
If you would like to divide samples by 2, if some condition is true, and do not divide if this condition is false, then you should shift bits of these samples.
Lets assume, you have 16 bits (at input and output): b15, b14, ..., b1, b0.
1) If you wouldn't like to have division, then output samples should be as input: out15 = in15, out14 = in14, ..., out1 = in1, out0 = in0.
2) If you would like to divide by 2, then output samples should be shifted: out15 = in15, out14 = in15, ..., out1 = in2, out0 = in1. And in0 sample should be dropped in that case.
The function xl_force() does nothing with samples. It just sets properties of data type in such manner, that Simulink knows that these samples should be interpreted differently (different data type, different binary point, and hence different range of decimal values).
So in your model, you should actually shift bits of samples in one case, and do not shift otherwise. To do it, use function xfix({xlSigned, 16, 10}, x) and xfix({xlSigned, 16, 10}, x/2).
evgenia89 wrote:Also I am wondering what block I can use for variable i. For now I put counter, but I understand that it is not good solution.
Why not? You need to implement a delay. So one option is to use a counter, and other is to have a series of registers (but it's huge solution for long delay). Just make sure that your counter will stop after the condition is met.
Vitaly.











