Forum Discussion

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

SOPC Builder

ciao to everybody

I'm trying to build a new system with cpu nios 2 , sdram ,tristate bridge

and my user component

I import my component vhdl file and i declare 2 port that in slave are input

but in sopc i declare "writedata" .

I flag on for generate header files ect

At the end i click on "Generate" and sopc gerates for me my new system

After i go to check in cpu_sdk the three folders

-inc

-lib

-src

Here i can find many .h and .c files , about PIO , LCD , UART

but i didn't found no one file i'm interesting

How can i do?

How can i interface my application C/C++ in Nios II IDE with my

user component ? http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/sad.gif

thanks for helps

walter

ciao

13 Replies

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

    now i&#39;m trying your example

    i create a new quartus 2 project, import your vhdl file and set it

    as top-level , start compilation and finish good .

    I open SOPC builder and import this component , and declare

    the port slave like you wrote .

    Add it in my system , and ready to generate .

    One question :

    in the SOPC builder , Avalon bus slave reserve for the component 16 word registers

    base address =0x00000800

    end=0x0000080F

    I use only register 0 ,1,2 ,3 , but what does they means other 11 registers?

    http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/huh.gif http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/huh.gif

    ciao

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

    address width is 2

    writedata width is 32 (4 Byte)

    addressrange is (2^2)*4 = 16 addresses

    in your case controlregister is at base address=0x00000800

    reg1 (base divider) is at address=0x00000804

    ...

    but you don&#39;t have to take this in account, if you use the MACROS

    IOWR and IORD.

    e.g.

    IOWR(AV_CLOCK_0_BASE,CPU_CLK_DIVIDER,50000);

    calculates the absolute address AV_CLOCK_0_BASE+4*CPU_CLK_DIVIDER

    (in your case 0x00000800)+(4*1)=0x00000804

    avalon interface is little endian

    "Little Endian" means that the low-order byte of the number is stored in

    memory at the lowest address, and the high-order byte at the highest address.

    (The little end comes first.)

    writing 32 bit (e.g. 0x12345678) into controlregister writes:

    *(0x00000800)=0x78 Byte0

    *(0x00000801)=0x56 Byte1

    *(0x00000802)=0x34 Byte2

    *(0x00000803)=0x12 Byte3

    hope this helps