Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12618 Discussions

Accessing custom component from DMA

Altera_Forum
Honored Contributor II
967 Views

In our design we have included a custom component into the SOPC design. The custom component (IMM, instance IMM_x) is connected to the write master port of a DMA. The DMA reads data from data_memory which is different from program_memory. SOPC interface is shown in attached file. Here is the definition of the custom component as seen in system.h 

 

 

--- Quote Start ---  

# define __IMM 

 

/* 

* IMM_x configuration 

*/ 

# define ALT_MODULE_CLASS_IMM_x IMM# define IMM_X_BASE 0x0# define IMM_X_IRQ -1# define IMM_X_IRQ_INTERRUPT_CONTROLLER_ID -1# define IMM_X_NAME "/dev/IMM_x"# define IMM_X_SPAN 536870912# define IMM_X_TYPE "IMM" 

 

 

/* 

* IMM_x configuration as viewed by DMA_x_write_master 

*/ 

# define DMA_X_WRITE_MASTER_IMM_X_BASE 0x0# define DMA_X_WRITE_MASTER_IMM_X_IRQ -1# define DMA_X_WRITE_MASTER_IMM_X_IRQ_INTERRUPT_CONTROLLER_ID -1# define DMA_X_WRITE_MASTER_IMM_X_NAME "/dev/IMM_x"# define DMA_X_WRITE_MASTER_IMM_X_SPAN 536870912# define DMA_X_WRITE_MASTER_IMM_X_TYPE "IMM" 

--- Quote End ---  

 

 

Can somebody tell me, how can I program it in C. I mean how should I configure the DMA to write to IMM_x. Thanks
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
280 Views

Well usually when using that DMA I just bit bang the slave port which has a register map show in page 243 here: http://www.altera.com/literature/ug/ug_embedded_ip.pdf 

 

I'll leave it to you to read but basically you just need to state where to read from, where to write to, the transfer length in bytes, and various control bits like reading/writing to fixed location, data width, etc... 

 

Sorry I haven't used this DMA in ages so I can't be of more help, usually I stick to my own DMA....
0 Kudos
Altera_Forum
Honored Contributor II
280 Views

 

--- Quote Start ---  

Well usually when using that DMA I just bit bang the slave port which has a register map show in page 243 here: http://www.altera.com/literature/ug/ug_embedded_ip.pdf 

 

I'll leave it to you to read but basically you just need to state where to read from, where to write to, the transfer length in bytes, and various control bits like reading/writing to fixed location, data width, etc... 

 

Sorry I haven't used this DMA in ages so I can't be of more help, usually I stick to my own DMA.... 

--- Quote End ---  

 

 

Thanks. I have already gone through this document. I am confused in the part about how to define my custom made module in the receiving channel. Can I do like this: 

 

 

--- Quote Start ---  

 

alt_dma_txchan txchan; 

void* tx_data_to = IMM_X_BASE; //is it correct??????? 

 

alt_dma_txchan_ioctl(txchan, ALT_DMA_SET_MODE_32, NULL); 

alt_dma_txchan_ioctl(txchan, ALT_DMA_TX_ONLY_ON, tx_data_to); 

alt_dma_txchan_ioctl(txchan, ALT_DMA_RX_ONLY_OFF, NULL); 

 

--- Quote End ---  

 

 

Thanks
0 Kudos
Altera_Forum
Honored Contributor II
280 Views

If I remember correctly then those look like the correct flags to pass in. Typically I access the DMA directly using the register macros provided with the driver since I typically like my DMA overhead to be at a minimum. Usually it takes around four accesses to the slave port to get the DMA moving, using the driver it'll be much more and since it's not a scatter-gather DMA you can't hide that overhead. 

 

Page 153 in this document explains setting up the channel in more detail: http://www.altera.com/literature/hb/nios2/n2sw_nii5v2.pdf
0 Kudos
Reply