Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
21615 Discussions

need help with my own peripheral device

Altera_Forum
Honored Contributor II
1,490 Views

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.
0 Kudos
4 Replies
Altera_Forum
Honored Contributor II
682 Views

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?
0 Kudos
Altera_Forum
Honored Contributor II
682 Views

Yes, I did increase it. 

thanks and I'll try SignalTap.
0 Kudos
Altera_Forum
Honored Contributor II
682 Views

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.....

0 Kudos
Altera_Forum
Honored Contributor II
682 Views

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.
0 Kudos
Reply