04-20-2018 10:29 AM
Hello,
I am developing a sample program that will demonstrate the ability of transferring data between PowerPC and Custom IP using bram. I have a few questions how the brams are implemented, and how to access them.
(1) I generated two dual-port bram using core generator. Each bram has width of 2 byte, and depth of 160k. If I understand this correctly, each bram should have a total size of 2*160k = 320kbytes. However, in the information section from the block memory generator, it says it needs to use 80 of the 36K BRAMS to implement this. The total size of these bram is 80 * 36K = 2880K ?
(2) Another question is to what address do I use to address these 2 brams. I understand that I can use something like:
TESTMEMORYVHDL_mReadMemory(XPAR_TESTMEMORYVHDL_0_MEM0_BASEADDR)
to address the first element in the first bram, and use "XPAR_TESTMEMORY_VHDL_0_MEM1_BASEADDR" to access the second bram since the signal Bus2IP_CS will be set correctly. However, how do I access the next element within the bram, Do I add 1, 2, or 4 to the base address?
(3) Since Bus2IP_Addr and Bus2IP_Data both are32-bit. I need to trim the signals to feed into the brams.
buffer0_addra <= Bus2IP_Addr(C_SLV_AWIDTH-20 to C_SLV_AWIDTH-3); buffer1_addra <= Bus2IP_Addr(C_SLV_AWIDTH-20 to C_SLV_AWIDTH-3); buffer0_dina <= Bus2IP_Data; buffer1_dina <= Bus2IP_Data;
The reason I used C_SLV_ADWITH-3 was because that's how the sample code (if I used the sample bram code for memory space) trims the address signal. Also, I tried to do buffer0_dina <= Bus2IP_Data(0 to 15), it doesn't seem to work. What are the correct ways to pass these signals to bram
04-22-2018 03:23 AM
(1) The RAMs are 36Kbits each, and you're asking for 320KBytes. Absolute minimum utilization for 320KBytes would be 320*8/36 = 72 BRAMs. However, this is only manageable in the awkward 9-bit, 18-bit, or 36-bit addressing modes. In the more easily-used 1-bit or 16-bit modes, the BRAM capacity is only 32Kbits each, and so 320KBytes requires 80 of them.
04-23-2018 01:42 PM
Thank you so much for the reply. I totally forgot about bit vs byte.
Since then, I have trimmed my Bus2IP signals like following:
buffer0_addra <= Bus2IP_Addr(C_SLV_AWIDTH-19 to C_SLV_AWIDTH-2); buffer1_addra <= Bus2IP_Addr(C_SLV_AWIDTH-19 to C_SLV_AWIDTH-2); buffer0_dina <= Bus2IP_Data(16 to 31); buffer1_dina <= Bus2IP_Data(16 to 31); mem_IP2Bus_data(0 to 15) <= X"0000"; mem_IP2Bus_data(16 to 31) <= buffer0_douta when (Bus2IP_CS(0) = '1') else buffer1_douta when (Bus2IP_CS(1) = '1') else (others => '0')
However, when my C program does the following
for (index = 0; index < numData; index++){ TESTMEMORYVHDL_mWriteMemory(XPAR_TESTMEMORYVHDL_0_MEM0_BASEADDR+(memoryOffset*index), index); } for (index = 0; index < numData; index++){ data[index] = TESTMEMORYVHDL_mReadMemory(XPAR_TESTMEMORYVHDL_0_MEM0_BASEADDR+(memoryOffset*index)); }
I have tried with memoryOffset = 1,2,4 (I think it should be 2 in this case since word size for the bram is 2 byte). However, when I print the variable "data" out. The result is not what I expect.
Any help is greatly appreciated. Thank you very much.
04-24-2018 03:24 PM
I was playing around with the lines :
buffer0_dina <= Bus2IP_Data(16 to 31); buffer1_dina <= Bus2IP_Data(16 to 31);
I wasn't sure whether I needed Bus2IP_Data(0 to 15) or Bus2IP_data(16 to 31). So I was trying different combinations but failed and went ahead and did some hardcoding:
buffer0_dina <= x"F0F0" when (Bus2IP_Addr = x"41000000") else x"F2F2" when (Bus2IP_Addr = x"41000002") else x"F4F4" when (Bus2IP_Addr = x"41000004") else (others => ('1')) when (Bus2IP_Addr(30) = '0') else (others => ('0'));
if I understand correctly, if I do "mrd 0x41000000" it supposed to return F2F2F0F0 [0x41000000 is the base address of that memory defined in XPS].
However, the following result returned:
>> mrd 0x41000000 10 41000000: 0000F0F0 41000004: 0000F4F4 41000008: 0000FFFF 4100000C: 0000FFFF 41000010: 0000FFFF 41000014: 0000FFFF 41000018: 0000FFFF 4100001C: 0000FFFF 41000020: 0000FFFF 41000024: 0000FFFF
It seems like I could not modify the first 16-bit word within any of the 32-bit word.
Can someone tell me what I did wrong please ? Any help is greatly appreciated. Thank you very much.