Forum Discussion

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

Nios II Simulation issue -- Software issue

Hello everyone,

I deisgned a Nios II-based system under SOPC Builder, to which I connected my own custom logic. This logic is Avalon-capable and is mapped (0x22000 - 0x2207f).

My Nios II contains a cpu, ALTSYNCRAM on-chip memory, a jtag_uart, a timer and an interface to custom logic.

my goal is to write and read data from the nios to this custom ip, that basically consists in dumb registers.

To achieve that, I wrote a small piece of C-code software, that continuously write data at address 0x22000 and read it right after.


while
(1)
{
 
//Read transaction
reg1 = IORD_16DIRECT(0x22000,0x0);
printf("Valeur registre 1 before write trans.: %d\n",reg1);
//Ecriture
IOWR_16DIRECT(0x22000,0x0,0x0C);
 
//Relecture
reg1 = IORD_16DIRECT(0x22000,0x0);
printf("Valeur registre 1 after write trans.: %d\n",reg1);
 
}
 

The Nios generation goes well, as well as the code compilation under Nios II IDE. The .hex and .dat memory init files are generated.

The problem is that I should see a never-ending sequence of write and read transactions when simulating the design under Modelsim, and I don't see any R/W operations at all.

It feels like ModelSim does not see any software code at all.

My question is : Is there a way to ensure that ModelSim seesthe.hex/.dat files as it should?

Thanks a lot!

3 Replies

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

    put the .hex file in the same directory as the modelsim .mpf file(assuming you use .mpf file) The on-chip memory hdl file will also may need to have its path to the .hex file modified. May need to have a version for synthesis and a version for simulation of the on-chip memory hdl file.

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

    Thanks for the reply, first of all.

    I've edited the HDL file of the on_chip memory (basically just a altsyncram instantiation) and spotted the init file STRING that contains the path to the.hex init file.

    In the HDL file generated by SOPC Builder, the default path to locate the init .hex file is "../onchip_mem.hex".

    This path is relative. My question is :

    Does the ".." refer to the current path given by pwd command under ModelSim?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I believe ../ is one above the current path given by pwd.

    It should work if you remove the ../ in the hdl file and put the hex file in the location given by the pwd command. Doing this will probably cause problems for Quartus but you can always change it back in the hdl file.