Forum Discussion
Newbie memory question
Hi,
I got a Terasic DE0-nano board with a Cyclone IV FPGA. My design is writing data in the memory. I use a NIOS II softcore too and I'd like it to read the FPGA memory and the data I wrote in a hardware-way. Can I do that? Thanks.27 Replies
- Altera_Forum
Honored Contributor
Yes it's possible.
Usually the dev kits will come with a sample design, and the NIOS tool has a simple memory checker you run to get started. Pete - Altera_Forum
Honored Contributor
OK I've found such an example but it seems to me (I'm not sure of that) that it's for an external memory and I want to access the internal FPGA memory. I need to know the signals and the protocol.
- Altera_Forum
Honored Contributor
Binome, if you need to access a component (like an internal memory instance) from both hardware and software it's recommended that you use Qsys for that. You can use the "On-Chip Memory" component and connect it to your NiosII data master interface, this way the processor can read/write this memory through software.
In order to access this memory using your hardware component you can adapt your component to use the Avalon Memory-Mapped interface protocol. You can found information about it in the Avalon Interface Specification: http://www.altera.com/literature/manual/mnl_avalon_spec.pdf Your hardware component can be imported into Qsys by creating a custom component. You can find information about it here: http://www.altera.com/literature/hb/qts/qsys_components.pdf Also, there are free online video trainings on the Altera website, please check the Introduction to Qsys and Custom IP Development Using Avalon and AXI Interfaces - Altera_Forum
Honored Contributor
Thank you for all these explanations.
What I don't understand is the differences between Quartus II,Nios II, SOPC, QSys,... Wouldn't it be nice if the MegaWizard of Quartus II could create a microprocessor directly? Can I have a symbol for my processor to make it appear in my schematic top-level? Why have I to create an Avalon interface for the hardware part to communicate with the memory? Can't I create the memory with the MegaWizard in Quartus II and implement the signals directly in the hardware? - Altera_Forum
Honored Contributor
Sure Binome, let's go:
Qsys is the next generation of SOPC Builder, so you can forget about SOPC Builder and use Qsys only. It's an integration tool that is potentially faster to build bigger systems with than schematics. That's because when you use schematics you must connect each wire by itself, while using Qsys you can connect interfaces with a bunch of wires and get automatic arbitration, bus width adjustment, etc. You can get a lot more information about Qsys in the "Introduction to Qsys" online training I told you about, you just have to register for free, so here's the link: http://www.altera.com/education/training/courses/oqsys1000 There are some IPs you have in MegaWizard and are not available in Qsys, and also the opposite. So a Nios processor is one of these components: it's only available inside Qsys. And the reason why is that it's much easier to create a complet SoC system inside Qsys than schematics or HDL. You can, however, open Qsys and insert a Nios processor only and export all processor interfaces to the outside world, and then generate a symbol for this. When you try to connect this symbol in your schematic you will understand why you shouldn't ;) I think you should give Qsys a chance. Maybe you need some time to learn how to use it, but for sure it will save you much more time later, as it's really faster to integrate and reuse components. I work with Altera tools all day long and it has been some years we don't have a single project without a Qsys system on it, even when there's no processor. I think the online training I sent you the link is the right starting point for you, give it a try! - Altera_Forum
Honored Contributor
Binome,
I got a Terasic DE0-nano board with a Cyclone IV FPGA. My design is writing data in the memory. I use a NIOS II softcore too and I'd like it to read the FPGA memory and the data I wrote in a hardware-way. Can I do that? I have used the SDRAM with a Nios a few time. So yes it is possible. In fact only the other day I wrote a blog post about it here: http://geobyjmhembeddedengineer.blogspot.co.uk/2014/05/connecting-sdram-to-nios-ii-on-de0-nano.html There is also a good app note by altera: ftp://ftp.altera.com/up/pub/altera_material/11.0/tutorials/verilog/de0-nano/using_the_sdram.pdf Hope this helps geobyjmh - Altera_Forum
Honored Contributor
Geobyjmh,
your blog is really good for my need ! I memorize the url. Thanks. And do you know how the Nios II cpu can read simply the FPGA memory, not the board SDRAM? - Altera_Forum
Honored Contributor
You can:
* insert your FPGA memory inside Qsys (On-Chip Memory) -- but then you would have a hard time getting your custom component outside Qsys to write to that memory, unless you use a bridge (below) * insert an Avalon Bridge and connect Nios to it's slave interface, then export the master interface. Use the Avalon signals to connect it to your MegaWizard memory in the top level. This is the only way I've found in years to connect your processor to something outside Qsys. I've just tried with the Avalon Pipeline Bridge but the signals won't match your memory interface, you need a bridge with the right subset of signals. As there's none, I've made one for you -- just rename to .tcl and put it in the same directory as your .qsys. It took me not more than five minutes to make this component, that's why I insist that you read the documents and watch the free trainings I told you about, as they will teach you how to do it, as you will certainly need it sooner or later. - Altera_Forum
Honored Contributor
There's something I don't get:
I've read the documents and practiced some tutorials. I've added an Avalon-MM pipeline bridge and connected it as you told me in my Qsys system. The symbol has ten new signals (waitrequest, readdata, readdatavalid, burstcount, writedata, address, write, read, byteenable, debugaccess) but my top-level on-chip memory has only 6 (clock, data, rdaddress, wradress, wren, q). How should I connect them? - Altera_Forum
Honored Contributor
Binome, these signals are connected automatically inside Qsys and are not necessarily meant to be exported.
That's why I've attached my own custom Avalon MM Bridge in my previous reply -- it doesn't have these additional symbols for different types of Avalon MM transactions (like variable latency and bus width adjustment). If you use my bridge it should be straightforward to connect the signals, otherwise you might like to read more about Avalon Interface -- http://www.altera.com/literature/manual/mnl_avalon_spec.pdf