Forum Discussion

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

need help with my own peripheral device

I have finished writing a peripheral device.

it communicates with niosII cpu using avalon-mm bus.

but when i read from it, i can't get the value i want.

and writing to it also has no effect on it.

the reg.h file i have defined is:

/*************************************/# include <io.h># define IOADDR_ALTERA_AVALON_MM_DAQ_BOARD_COMMAND(base) __IO_CALC_ADDRESS_DYNAMIC(base, 0)# define IOWR_ALTERA_AVALON_MM_DAQ_BOARD_COMMAND(base, data) IOWR_32DIRECT(base,0,data)# define IORD_ALTERA_AVALON_MM_DAQ_BOARD_COMMAND(base) IORD_32DIRECT(base,0)# define IOADDR_ALTERA_AVALON_MM_DAQ_BOARD_DATA(base) __IO_CALC_ADDRESS_DYNAMIC(base, 4)# define IORD_ALTERA_AVALON_MM_DAQ_BOARD_DATA(base) IORD_32DIRECT(base,4)

The vhd file is attached.

4 Replies

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

    The best way to debug something like this is to add SignalTap probes on the Avalon bus and your component's external interfaces, and see what is happening.

    When you created your component, did you remember to increase the read wait cycles from the default 1 to 2?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Have you made sure that you aren't holding the component in reset? I see that you have used a "if reset = '1' then" jobby. Whenever I've written components I've always opted for a "if reset = '0' then". I do this as the examples I learned from all used active low reset. Just a suggestion, and apologies if this is a rubbish suggestion.....

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

    When you build an SOPC component, signals are active high, except if you add '_n' to the name. i.e. if you call your reset signal 'reset', then it is active high. If you call it 'reset_n', then it is active low, and SOPC builder will invert the signal for you.

    I prefer to use active high signals when I can, and when I don't/can't, I always add a _n to the name, even if I'm not working with SOPC builder. In my opinion using things like "if reset = '0' then" is less intuitive and makes code more difficult to maintain.