| 120 | | Example to come |
| | 120 | Let's have an example system with two basic components communicating through a fifo. |
| | 121 | |
| | 122 | [[Image(cosim-pf1.png,nolink)]] |
| | 123 | |
| | 124 | We'll use |
| | 125 | * SoCLib SystemC Fifo Ports, |
| | 126 | * a VHDL `fifo_gen` component, |
| | 127 | * a VHDL-SystemC `fifo_gen_wrapper` wrapper, |
| | 128 | * a SystemC `fifo_wrapper` hosting a pure-C++. |
| | 129 | |
| | 130 | This basic system has to be modeled as the following tree: |
| | 131 | |
| | 132 | [[Image(cosim-pf2.png,nolink)]] |
| | 133 | |
| | 134 | It contains: |
| | 135 | `fifo_gen`:: |
| | 136 | The VHDL component writing to the Fifo |
| | 137 | `fifo_gen_wrapper`:: |
| | 138 | The VHDL/SystemC wrapper to export `fifo_gen` to the SystemC world |
| | 139 | `fifo_reader`:: |
| | 140 | A SystemC component reading from the fifo |
| | 141 | `topcell`:: |
| | 142 | A SystemC component implementing the topcell |
| | 143 | `system_driver`:: |
| | 144 | A SystemC component controlling `reset` and `clock` signals |
| | 145 | |
| | 146 | In order to simulate this system we need to: |
| | 147 | * Reset the work directory, to make sure, |
| | 148 | {{{ |
| | 149 | $ rm -rf work transcript modelsim.ini fifo_gen_wrapper/fifo_gen.h vsim.wlf |
| | 150 | }}} |
| | 151 | * Initialize modelsim `work` directory, |
| | 152 | {{{ |
| | 153 | $ vlib work |
| | 154 | $ vmap work work |
| | 155 | }}} |
| | 156 | * Compile the VHDL module with vcom. |
| | 157 | {{{ |
| | 158 | $ vcom fifo_gen/fifo_gen.vhd |
| | 159 | }}} |
| | 160 | * Generate the SystemC wrapper of the `fifo_gen` VHDL module with `scgenmod` |
| | 161 | {{{ |
| | 162 | $ scgenmod -sc_uint -bool fifo_gen > fifo_gen_wrapper/fifo_gen.h |
| | 163 | }}} |
| | 164 | * Compile the SystemC system driver with soclib-cc, all dependancies are pulled with it. |
| | 165 | `.sd` metadata are needed (even for the VHDL/SystemC wrapper), see in tarball. |
| | 166 | {{{ |
| | 167 | $ soclib-cc -1 caba:system_driver -t sccom -v -o sccom-link.o |
| | 168 | }}} |
| | 169 | * Open modelsim with the platform |
| | 170 | {{{ |
| | 171 | $ vsim -novopt -sclib work system_driver |
| | 172 | }}} |
| | 173 | |
| | 174 | See the attached tarball for the complete example |