Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
16 years ago

How to Connect to SOPC Avalong Bus from outside of SOPC

I'm using the SDRAM with Nios and SOPC, but I also need to write to the SDRAM via logic that is outside the SOPC.

How is this typically done? I'm assuming I would need to create a peripheral in sopc that brings out the avalon bus, and then on the top level the logic that wishes to write to the bus (sdram) would need to interface to those signals, but I'm not exactly sure about all the details.

Anyone ever done something like this?

15 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    it should be a lot faster with on chip ram... Is this ram shared with something else?

    --- Quote End ---

    Nope, the on-chip 32-bit wide memory is connected only to the master template. I took a snapshot of what I'm seeing..

    basically I have a 100Mhz state machine that whenever a 10Mhz data clk goes high, I increment the data, and the address (by 4), and set the data valid/go pulse high (the write length is constant at 4. This addr/data is presented half a clock after dataclock goes high.

    At this point these signals to the master template don't change until just before the next data clock.. at which time I deassert go, and wait for the next data clock to present the new data.

    When I pause the template/Nios to look at the onchip memory, the transfers are taking place as evident by the incrementing data, however, instead of 1 new value per location, I see new data being written into 6 consecutive addresses. On signaltap I see the addresses correctly incrementing by 4 (32-bit data) and the data incrementing by 1. However the on chip memory is not incrementing by 1 at every address.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Doh! Its working fine now.. just had to strobe the Go pulse at 100Mhz!

    Rather than sampling the level, it would have been nice if the template only does 1 transfer per rising edge..... that way the user logic isn't required to sync to the internal template clock.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Just as a heads up I see a common mistake made when users integrate their own memory controllers. Be sure to specify the maximum pending reads properly for your slave port (assuming you support pipelined reads). If you select too low of a value and your slave port doesn't throttle back using waitrequest you will see data dropped. So if you SDRAM supports up to 6 reads in flight then you can set the max pending reads to something like 8. Overestimating this value does no harm to your system besides adding an overkill amount of buffering but underestimating can lead to a functional failure. To give you some examples the SDR SDRAM controller in SOPC Builder uses a max pending reads of 6 or 7 (I forget) and the DDR SDRAM controllers use 16.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    To give you some examples the SDR SDRAM controller in SOPC Builder uses a max pending reads of 6 or 7 (I forget) and the DDR SDRAM controllers use 16.

    --- Quote End ---

    Pardon me for my question..but how do you know about the max pending reads for SDR SDRAM Controller? Is is stated in the setting page of the SDRAM controller or somewhere? I didnt found it..
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    It should be in the controller ptf file. Also it looks like the DDR controllers use 32 now. To find the value I normally open the sopc file in a file editor and search for the slave port.