| 1 | [wiki:Component SocLib Components General Index] |
| 2 | |
| 3 | = VciPCI = |
| 4 | |
| 5 | == 1) Functional Description == |
| 6 | |
| 7 | This VCI target is a memory mapped peripheral that serves as a bridge with the PCI bus. |
| 8 | |
| 9 | The memory segment allocated to this component must be aligned on 4K bytes boundary. |
| 10 | |
| 11 | This VCI target contains 5 memory mapped registers: |
| 12 | |
| 13 | * PCI_VALUE |
| 14 | |
| 15 | This 32 bits register corresponds to two 4 KB FIFO, one to write the data (FIFOW) sent to the PCI bus and one to read (FIFOR) the data received from the PCI bus. A write in a full FIFO lost the data and a read in an ampty FIFO returns 0! |
| 16 | |
| 17 | * PCI_MODE |
| 18 | |
| 19 | This register describes the DMA mode: |
| 20 | o PCI_DMA_WRITE_IRQ = DMA operated from the PCI bus to the FIFOR with an IRQ at the end of the transfer. |
| 21 | |
| 22 | o PCI_DMA_WRITE_NO_IRQ = DMA operated from the PCI bus to the FIFOR with no IRQ at the end of the transfer. |
| 23 | |
| 24 | o PCI_DMA_READ_IRQ = DMA operated from the FIFOW to the PCI bus with an IRQ at the end of the transfer. |
| 25 | |
| 26 | o PCI_DMA_READ_NO_IRQ = DMA operated from FIFOW to the PCI bus with no IRQ at the end of the transfer. |
| 27 | |
| 28 | o PCI_DMA_LOOPBACK = DMA operated automatically from the FIFOR when data are available, to the PCI bus with no IRQ at the end of the transfer. With this mode you can send data to a PCI target configured in loopback which send it back with default PCI physical address 23 (decimal). |
| 29 | |
| 30 | |
| 31 | * PCI_ADR |
| 32 | |
| 33 | This 32 bits register defines the physical address on the PCI bus where to send/receive data. It must be equal to the BASE ADRESS (BADR0) of one PCI target. |
| 34 | |
| 35 | * PCI_RESETIRQ |
| 36 | |
| 37 | Any write request in this Boolean register will reset the pending IRQ. A read request returns the zero value when there is no pending interrupt, and returns a non zero value if there is a pending interrupt. |
| 38 | |
| 39 | * PCI_NB |
| 40 | |
| 41 | This 32 bits register defines the size of the DMA transfer in bytes (from 0 Byte to 4 Kbyte) and launches the DMA if FIFO are ready. |
| 42 | |
| 43 | |
| 44 | == 2) Component definition & usage == |
| 45 | |
| 46 | You should include file soclib/pci.h from your software, it defines PCI_VALUE, PCI_MODE, PCI_ADR, PCI_RESETIRQ. |
| 47 | |
| 48 | Sample code: |
| 49 | |
| 50 | |
| 51 | {{{ |
| 52 | #include "soclib/pci.h" |
| 53 | |
| 54 | static const volatile void* pci_address = 0xc0000000; |
| 55 | |
| 56 | static pci_test() |
| 57 | { |
| 58 | soclib_io_set(pci_address,PCI_NB,0); // size of transfer = 0 first to avoid DMA launch |
| 59 | soclib_io_set(pci_address,PCI_ADR,23); // PCI physical address of the target |
| 60 | soclib_io_set(pci_address,PCI_VALUE,8); // 4 data values written in the FIFO (8,12,14,16) |
| 61 | soclib_io_set(pci_address,PCI_VALUE,12); |
| 62 | soclib_io_set(pci_address,PCI_VALUE,14); |
| 63 | soclib_io_set(pci_address,PCI_VALUE,16); |
| 64 | soclib_io_set( pci_address,PCI_MODE,PCI_DMA_READ_NO_IRQ ); // DMA mode |
| 65 | soclib_io_set(pci_address,PCI_NB,16); // size in bytes of the transfer (4 32-bit words): the DMA is launched! |
| 66 | } |
| 67 | }}} |
| 68 | |
| 69 | |
| 70 | (add -I/path/to/soclib/include to your compilation command-line) |
| 71 | |
| 72 | source:trunk/soclib/soclib/module/internal_component/vci_pci/caba/metadata/vci_pci.sd |
| 73 | |
| 74 | See [wiki:SoclibCc/VciParameters SoclibCc/VciParameters] |
| 75 | {{{ |
| 76 | Uses( 'vci_ram', **vci_parameters ) |
| 77 | }}} |
| 78 | == 3) CABA Implementation == |
| 79 | |
| 80 | === CABA sources === |
| 81 | |
| 82 | * interface : source:trunk/soclib/soclib/module/internal_component/vci_pci/caba/source/include/vci_pci.h |
| 83 | * implementation : source:trunk/soclib/soclib/module/internal_component/vci_pci/caba/source/src/vci_pci.cpp |
| 84 | |
| 85 | === CABA Constructor parameters === |
| 86 | |
| 87 | |
| 88 | {{{ |
| 89 | VciPci( |
| 90 | sc_module_name name, // Component Name |
| 91 | const soclib::common::IntTab & index, // Target index |
| 92 | const soclib::common::MappingTable &mt, // MappingTable |
| 93 | size_t badrval); // BASE Address register init value (BADR0) |
| 94 | }}} |
| 95 | |
| 96 | |
| 97 | === CABA Ports === |
| 98 | |
| 99 | * sc_in<bool> p_resetn : Global system reset |
| 100 | * sc_in<bool> p_clk : Global system clock |
| 101 | * soclib::caba::!VciTarget<vci_param> p_vci : The VCI port |
| 102 | * sc_out<bool> p_irq : Interrupts port |
| 103 | * sc_inout<sc_lv<4> > p_Cbe : Command/Bytes Enable PCI port |
| 104 | * sc_in_clk p_clkpci : PCI clock |
| 105 | * sc_in<bool> p_Sysrst : PCI reset |
| 106 | * sc_in<bool> p_Idsel : PCI chip select |
| 107 | * sc_inout<sc_logic> p_Frame : PCI Frame |
| 108 | * sc_inout<sc_logic> p_Devsel : PCI Device Select |
| 109 | * sc_inout<sc_logic> p_Irdy : PCI Initiator Ready |
| 110 | * sc_in<bool> p_Gnt : PCI Grant |
| 111 | * sc_inout<sc_logic> p_Trdy : PCI Target Ready |
| 112 | * sc_inout<sc_logic> p_Inta : PCI Interrupt |
| 113 | * sc_inout<sc_logic> p_Stop : PCI Stop |
| 114 | * sc_out<bool> p_Req : PCI request |
| 115 | * sc_inout<sc_logic> p_Par : PCI Parity |
| 116 | * sc_inout<sc_lv<32> > p_AD32 : PCI main bus (32 bits) for address and data |
| 117 | |
| 118 | == 4) TLM-T Implementation == |
| 119 | |
| 120 | The TLM-T implementation is not available. |