| 1 | [wiki:Component SocLib Components General Index] |
| 2 | |
| 3 | = !VciDma Functional Description = |
| 4 | |
| 5 | This VCI component is both a target and an initiator. |
| 6 | * Addressing as a target allows to configure it for a transfer. |
| 7 | * Initiator will do the transfer |
| 8 | |
| 9 | There is only one DMA context handled at a time |
| 10 | |
| 11 | An IRQ is optionally asserted when transfer is finished. |
| 12 | |
| 13 | This hardware component cheks for segmentation violation, and can be used |
| 14 | as a default target. |
| 15 | |
| 16 | = Memory region layout = |
| 17 | |
| 18 | * `DMA_SRC`: ADDRESS![3:0] = 0x0 |
| 19 | The source of memory copy. |
| 20 | |
| 21 | * `DMA_DST`: ADDRESS![3:0] = 0x4 |
| 22 | The destination of memory copy |
| 23 | |
| 24 | * `DMA_LEN`: ADDRESS![3:0] = 0x8 |
| 25 | Length of transfer, in bytes. Writing to this register initiates the transfer, you should write to it after src and dst. |
| 26 | This register gets back to 0 when transfer is finished. |
| 27 | |
| 28 | * `DMA_IRQ_ENABLED`: ADDRESS![3:0] = 0xC |
| 29 | * Written to: A boolean enabling the IRQ line (0 is disabling) |
| 30 | * Read from: A boolean indicating the completion of the transfer, (0 is completed) |
| 31 | |
| 32 | = Component usage = |
| 33 | |
| 34 | For extensibility issues, you should access the DMA using globally-defined offsets. |
| 35 | |
| 36 | You should include file source:trunk/soclib/include/soclib/dma.h from your software, it |
| 37 | defines `DMA_SRC`, `DMA_DST`, `DMA_LEN`, `DMA_IRQ_ENABLED`. |
| 38 | |
| 39 | Sample code: |
| 40 | {{{ |
| 41 | #include "soclib/dma.h" |
| 42 | |
| 43 | static const volatile void* dma_address = 0xc0000000; |
| 44 | |
| 45 | void * memcpy(void *dst, const void *src, const size_t len) |
| 46 | { |
| 47 | volatile int *dma = ((int*)dma_address); |
| 48 | |
| 49 | dma[DMA_DST] = (uint32_t)dst; |
| 50 | dma[DMA_SRC] = (uint32_t)dma; |
| 51 | dma[DMA_LEN] = (uint32_t)len; |
| 52 | while ( dma[DMA_LEN] ) |
| 53 | ; |
| 54 | return dst; |
| 55 | } |
| 56 | |
| 57 | }}} |
| 58 | |
| 59 | (add -I/path/to/soclib/include to your compilation command-line) |
| 60 | |
| 61 | = Component definition = |
| 62 | |
| 63 | Available in source:trunk/soclib/desc/soclib/vci_dma.sd |
| 64 | |
| 65 | == Usage == |
| 66 | |
| 67 | !VciDma has no other parameter than VCI ones, it may be used like others, see [wiki:SoclibCc/VciParameters SoclibCc/VciParameters] |
| 68 | {{{ |
| 69 | Uses( 'vci_dma', **vci_parameters ) |
| 70 | }}} |
| 71 | |
| 72 | = !VciDma CABA Implementation = |
| 73 | |
| 74 | The caba implementation is in |
| 75 | * source:trunk/soclib/systemc/include/caba/target/vci_dma.h |
| 76 | * source:trunk/soclib/systemc/src/caba/target/vci_dma.cc |
| 77 | |
| 78 | == Template parameters: == |
| 79 | |
| 80 | * The VCI parameters |
| 81 | |
| 82 | == Constructor parameters == |
| 83 | {{{ |
| 84 | VciDma( |
| 85 | sc_module_name name, // Component Name |
| 86 | const soclib::common::IntTab & index, // Target index |
| 87 | const soclib::common::MappingTable &mt, // MappingTable |
| 88 | const size_t burst_size ); // Number of bytes transfered in a burst |
| 89 | }}} |
| 90 | |
| 91 | == Ports == |
| 92 | |
| 93 | * sc_in<bool> '''p_resetn''' : Global system reset |
| 94 | * sc_in<bool> '''p_clk''' : Global system clock |
| 95 | * soclib::caba::!VciTarget<vci_param> '''p_vci_target''' : The VCI target port |
| 96 | * soclib::caba::!VciInitiator<vci_param> '''p_vci_initiator''' : The VCI initiator port |
| 97 | * sc_out<bool> '''p_irq''' : Interrupt port |