Forum Discussion

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

New to NIOS

Hello all,

I am a moderately experienced fpga programmer but brand new to NIOS.

So, I have used SOPC to generate a NIOS II and designated onchip memory to go with it. From Eclipse I have been able to run the HelloWorld program (by linking to the .sopc file) and run the program onto the fpga.

Now, I want to know how to write code in main() to access the onchip memory in my NIOS II in the fpga.

Ultimately I want to write a register I define in my fpga so I can control things in my hardware from C code i write in eclipse.

I don't know where to start.

4 Replies

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

    See chapter 9 of

    Nios II Software Developer's Handbook

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

    Please allow me to give you a bit more detail because I've been there and still not sure how to proceed.

    I'm using the Nios II/e along with jtag uart, sysid and onchip memory.

    My objective here is to write to the onchip memory a value that I can

    access and pinout to an LED on my cyclone III fpga.

    So 2 issues as I see it:

    1) how do I actually write to the onchip memory from my nios II

    (i.e what is the syntax of a write and do i need some external libs)

    2) once i write to the onchip memory, how do i actually access that memory from outside of my sopc project. How do I interface with the rest of my fpga?? Currently my nios system only has a reset and a clock port. How in the world am I to access the contents of memory of the onchip memory and then connect that to a pin on my fpga?

    nios_test_system_1

    (

    .clk_0 (clk40),

    .reset_n (1)

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

    For that particular action, you're going to want to instantiate an output PIO, 1 bit wide (assuming 1 LED), and hook it up to your LED at the top level.

    In your Nios II code, you'd just use a PIO macro to write a 1 or 0 to control the LED. Look at the count_binary example for a decent sample of how to do this.

    Cheers,

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

    thank you. that was exactly what i needed. i have my LED's blinking happily :)