Forum Discussion

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

Best way to interface my CPU

Hello, I am wondering what is the best way to interface my 32-bit RISC CPU. I need to interface it with the sdram memory, the flash memory, and possibly the sram memory. I will also need to dedicate a portion of the memory to a VGA controller which will output a video signal. I am wondering what is the best method to achieving this.

I looked into possibly using QSYS to setup this config, (JUST replace the NIOS 2 processor with mine) however I am not sure if I should do it due to the amount of work it will take to set up the processor interfaces (I am also going to update the CPU all the time so I will need to pick a method that will make updating all the components easy).

I looked into doing it in VHDL, but I am not sure if it will be easy. I already got a VGA controller working however I will need to make the memory controllers which will be much more difficult.

I forgot to include this, but I am using a terasic de1 board currently.

Can somebody please help me solve this ordeal?

47 Replies

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

    Also when I disassembled it, this is what I got:

    
    0007fc10:   call 0x80008
    0007fc14:   call 0x80008
    0007fc18:   call 0x80008
    0007fc1c:   call 0x80008
    0007fc20:   call 0x80008
    0007fc24:   call 0x80008
    0007fc28:   call 0x80008
    0007fc2c:   call 0x80008
    0007fc30:   call 0x80008
    0007fc34:   call 0x80008
    0007fc38:   call 0x80008
    0007fc3c:   call 0x80008
    0007fc40:   call 0x80008
    0007fc44:   call 0x80008
    0007fc48:   call 0x80008
    0007fc4c:   call 0x80008
    0007fc50:   call 0x80008
    0007fc54:   call 0x80008
    0007fc58:   call 0x80008
    0007fc5c:   call 0x80008
    0007fc60:   call 0x80008
    0007fc64:   call 0x80008
    0007fc68:   call 0x80008
    0007fc6c:   call 0x80008
    0007fc70:   call 0x80008
    0007fc74:   call 0x80008
    0007fc78:   call 0x80008
    0007fc7c:   call 0x80008
    0007fc80:   call 0x80008
    0007fc84:   call 0x80008
    0007fc88:   call 0x80008
    0007fc8c:   call 0x80008
    0007fc90:   call 0x80008
    0007fc94:   call 0x80008
    0007fc98:   call 0x80008
    0007fc9c:   call 0x80008
    0007fca0:   call 0x80008
    0007fca4:   call 0x80008
    0007fca8:   call 0x80008
    0007fcac:   call 0x80008
    0007fcb0:   call 0x80008
    0007fcb4:   call 0x80008
    0007fcb8:   call 0x80008
    0007fcbc:   call 0x80008
    0007fcc0:   call 0x80008
    0007fcc4:   call 0x80008
    0007fcc8:   call 0x80008
    0007fccc:   call 0x80008
    0007fcd0:   call 0x80008
    0007fcd4:   call 0x80008
    0007fcd8:   call 0x80008
    0007fcdc:   call 0x80008
    0007fce0:   call 0x80008
    0007fce4:   call 0x80008
    0007fce8:   call 0x80008
    0007fcec:   call 0x80008
    0007fcf0:   call 0x80008
    0007fcf4:   call 0x80008
    0007fcf8:   call 0x80008
    0007fcfc:   call 0x80008
    0007fd00:   call 0x80008
    0007fd04:   call 0x80008
    0007fd08:   call 0x80008
    0007fd0c:   call 0x80008
    0007fd10:   call 0x80008
    0007fd14:   call 0x80008
    0007fd18:   call 0x80008
    0007fd1c:   call 0x80008
    0007fd20:   call 0x80008
    0007fd24:   call 0x80008
    0007fd28:   call 0x80008
    0007fd2c:   call 0x80008
    0007fd30:   call 0x80008
    0007fd34:   call 0x80008
    0007fd38:   call 0x80008
    0007fd3c:   call 0x80008
    0007fd40:   call 0x80008
    0007fd44:   call 0x80008
    0007fd48:   call 0x80008
    0007fd4c:   call 0x80008
    0007fd50:   call 0x80008
    0007fd54:   call 0x80008
    0007fd58:   call 0x80008
    0007fd5c:   call 0x80008
    0007fd60:   call 0x80008
    0007fd64:   call 0x80008
    0007fd68:   call 0x80008
    0007fd6c:   call 0x80008
    0007fd70:   call 0x80008
    0007fd74:   call 0x80008
    0007fd78:   call 0x80008
    0007fd7c:   call 0x80008
    0007fd80:   call 0x80008
    0007fd84:   call 0x80008
    0007fd88:   call 0x80008
    0007fd8c:   call 0x80008
    0007fd90:   call 0x80008
    0007fd94:   call 0x80008
    0007fd98:   call 0x80008
    0007fd9c:   call 0x80008
    0007fda0:   call 0x80008
    0007fda4:   call 0x80008
    0007fda8:   call 0x80008
    0007fdac:   call 0x80008
    0007fdb0:   call 0x80008
    0007fdb4:   call 0x80008
    0007fdb8:   call 0x80008
    0007fdbc:   call 0x80008
    0007fdc0:   call 0x80008
    0007fdc4:   call 0x80008
    0007fdc8:   call 0x80008
    0007fdcc:   call 0x80008
    0007fdd0:   call 0x80008
    0007fdd4:   call 0x80008
    0007fdd8:   call 0x80008
    0007fddc:   call 0x80008
    0007fde0:   call 0x80008
    0007fde4:   call 0x80008
    0007fde8:   call 0x80008
    0007fdec:   call 0x80008
    0007fdf0:   call 0x80008
    0007fdf4:   call 0x80008
    0007fdf8:   call 0x80008
    0007fdfc:   call 0x80008
    0007fe00:   call 0x80008
    0007fe04:   call 0x80008
    0007fe08:   call 0x80008
    0007fe0c:   call 0x80008
    0007fe10:   call 0x80008
    0007fe14:   call 0x80008
    0007fe18:   call 0x80008
    0007fe1c:   call 0x80008
    0007fe20:   call 0x80008
    0007fe24:   call 0x80008
    0007fe28:   call 0x80008
    0007fe2c:   call 0x80008
    0007fe30:   call 0x80008
    0007fe34:   call 0x80008
    0007fe38:   call 0x80008
    0007fe3c:   call 0x80008
    0007fe40:   call 0x80008
    0007fe44:   call 0x80008
    0007fe48:   call 0x80008
    0007fe4c:   call 0x80008
    0007fe50:   call 0x80008
    0007fe54:   call 0x80008
    0007fe58:   call 0x80008
    0007fe5c:   call 0x80008
    0007fe60:   call 0x80008
    0007fe64:   call 0x80008
    0007fe68:   call 0x80008
    0007fe6c:   call 0x80008
    0007fe70:   call 0x80008
    0007fe74:   call 0x80008
    0007fe78:   call 0x80008
    0007fe7c:   call 0x80008
    0007fe80:   call 0x80008
    0007fe84:   call 0x80008
    0007fe88:   call 0x80008
    0007fe8c:   call 0x80008
    0007fe90:   call 0x80008
    0007fe94:   call 0x80008
    0007fe98:   call 0x80008
    0007fe9c:   call 0x80008
    0007fea0:   call 0x80008
    0007fea4:   call 0x80008
    0007fea8:   call 0x80008
    0007feac:   call 0x80008
    0007feb0:   call 0x80008
    0007feb4:   call 0x80008
    0007feb8:   call 0x80008
    0007febc:   call 0x80008
    0007fec0:   call 0x80008
    0007fec4:   call 0x80008
    0007fec8:   call 0x80008
    0007fecc:   call 0x80008
    0007fed0:   call 0x80008
    0007fed4:   call 0x80008
    0007fed8:   call 0x80008
    0007fedc:   call 0x80008
    0007fee0:   call 0x80008
    0007fee4:   call 0x80008
    0007fee8:   call 0x80008
    0007feec:   call 0x80008
    0007fef0:   call 0x80008
    0007fef4:   call 0x80008
    0007fef8:   call 0x80008
    0007fefc:   call 0x80008
    0007ff00:   call 0x80008
    0007ff04:   call 0x80008
    0007ff08:   call 0x80008
    0007ff0c:   call 0x80008
    0007ff10:   call 0x80008
    0007ff14:   call 0x80008
    0007ff18:   call 0x80008
    0007ff1c:   call 0x80008
    0007ff20:   call 0x80008
    0007ff24:   call 0x80008
    0007ff28:   call 0x80008
    0007ff2c:   call 0x80008
    0007ff30:   call 0x80008
    0007ff34:   call 0x80008
    0007ff38:   call 0x80008
    0007ff3c:   call 0x80008
    0007ff40:   call 0x80008
    0007ff44:   call 0x80008
    0007ff48:   call 0x80008
    0007ff4c:   call 0x80008
    0007ff50:   call 0x80008
    0007ff54:   call 0x80008
    0007ff58:   call 0x80008
    0007ff5c:   call 0x80008
    0007ff60:   call 0x80008
    0007ff64:   call 0x80008
    0007ff68:   call 0x80008
    0007ff6c:   call 0x80008
    0007ff70:   call 0x80008
    0007ff74:   call 0x80008
    0007ff78:   call 0x80008
    0007ff7c:   call 0x80008
    0007ff80:   call 0x80008
    0007ff84:   call 0x80008
    0007ff88:   call 0x80008
    0007ff8c:   call 0x80008
    0007ff90:   call 0x80008
    0007ff94:   call 0x80008
    0007ff98:   call 0x80008
    0007ff9c:   call 0x80008
    0007ffa0:   call 0x80008
    0007ffa4:   call 0x80008
    0007ffa8:   call 0x80008
    0007ffac:   call 0x80008
    0007ffb0:   call 0x80008
    0007ffb4:   call 0x80008
    0007ffb8:   call 0x80008
    0007ffbc:   call 0x80008
    0007ffc0:   call 0x80008
    0007ffc4:   call 0x80008
    0007ffc8:   call 0x80008
    0007ffcc:   call 0x80008
    0007ffd0:   call 0x80008
    0007ffd4:   call 0x80008
    0007ffd8:   call 0x80008
    0007ffdc:   call 0x80008
    0007ffe0:   call 0x80008
    0007ffe4:   call 0x80008
    0007ffe8:   call 0x80008
    0007ffec:   call 0x80008
    0007fff0:   call 0x80008
    0007fff4:   call 0x80008
    0007fff8:   call 0x80008
    0007fffc:   call 0x80008
    00080000:   call 0x80008
    00080004:   call 0x80008
    00080008:   call 0x80008
    0008000c:   call 0x80008
    00080010:   call 0x80008
    00080014:   call 0x80008
    00080018:   call 0x80008
    0008001c:   call 0x80008
    00080020:   call 0x80008
    00080024:   call 0x80008
    00080028:   call 0x80008
    0008002c:   call 0x80008
    00080030:   call 0x80008
    00080034:   call 0x80008
    00080038:   call 0x80008
    0008003c:   call 0x80008
    00080040:   call 0x80008
    00080044:   call 0x80008
    00080048:   call 0x80008
    0008004c:   call 0x80008
    00080050:   call 0x80008
    00080054:   call 0x80008
    
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Does anybody have a solution? I am sure that you can try the project I gave to you (If I gave it to you) and see that it won't work.

    Also on another note I am wondering about his one issue. The memory controller uses 16 bit data, but my CPU uses 32-bit data. Will the QSYS system detect that issue and add logic to convert 32 data to 16 bit and vice versa, or do I actually have to add customlogic to convert it.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I don't have the right hardware to run your project on. I did find a problem though. You have set up the onchip_memory for the exception vectors and the .text section, but this memory is read-only. This means that when you upload your software, you won't be able to change the exception vectors or to write the application to memory. This could cause the CPU to hang. Try to set it to RAM, or to use one of the other memories (but not the SRAM, as you didn't connect the instruction master to this one).

    Did you configure the STDOUT channel to the Jtag Uart in the BSP settings? This should be automatic, but you never know.

    The fact that the memory is 16 bits shouldn't be a problem, QSys can adapt to that. You can try and configure the BSP to put everything in the onchip memory (once you have set it up to RAM) and put a memory test software example there. From that you should be able to test your external memories.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    EDIT: Made a mistake I ran my other CPU project

    EDIT: I also get this error:

    
    .gdbinit: No such file or directory.
    
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Is there anybody who can help with this. So far it looks like it may be an error with the Altera software.

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

    You haven't said which of my suggestions you actually tried and what the results where, so it's difficult to help you.

    If you are using a development kit I'd suggest to start a new project and add things one at a time. First run the default project with a hello world application and check that the CPU is running and printing something. Then add your component, and check that the CPU is still working and printinf something, before you try to access your component.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Assuming your processor has an OCI core in it you could try opening a command window and then running `nios2-download` with no options. This should find the processor, pause it then resume it.

    If it doesn't then you probably have a problem with the timing or the clocks to your processor (it might be that you have a locked slave but that's less likely)