| 1 | = Cosimulation using SoCLib components and RTL models = |
| 2 | |
| 3 | You may use CABA models together with RTL models using !ModelSim. This |
| 4 | needs the following parts: |
| 5 | * a set of SystemC models |
| 6 | * a set of Verilog/VHDL models |
| 7 | * glue wrappers where needed, exporting a RTL model to SystemC or SystemC to RTL (not covered in this guide) |
| 8 | * a SystemC clock driver (we had some issues with vhdl clock driver), i.e. a module bagotting clock signal |
| 9 | |
| 10 | SystemC modules are SoCLib ones and are usually compiled with |
| 11 | SoCLib-cc. They come with pure-c++ dependancies which must be linked |
| 12 | together with the modules. |
| 13 | |
| 14 | Due to its simulator core design, !ModelSim has to compile SystemC |
| 15 | modules a special way, and has a dedicated tool to compile SystemC/C++ |
| 16 | files: `sccom`. |
| 17 | |
| 18 | Soclib-cc has three main jobs: |
| 19 | * Select modules and dependancies from a platform description file, |
| 20 | * Explicitly instantiate C++ templates, |
| 21 | * Call the C++ compiler. Only this step is implemented in `sccom`. |
| 22 | |
| 23 | The flow is as in the picture: |
| 24 | |
| 25 | [[Image(flow.png,nolink)]] |
| 26 | |
| 27 | soclib-cc handles most of this automagically if correctly |
| 28 | configured. This guide explains how to set things up. |
| 29 | |
| 30 | Moreover, the C/C++ only dependancies are not |
| 31 | directly compileable with the dedicated !ModelSim tool, but can be |
| 32 | ''injected'' at the last time, for the linkage phase (`sccom -link`). |
| 33 | |
| 34 | = How to configure SoCLib-cc to call !ModelSim compiler driver = |
| 35 | |
| 36 | Sometimes, the C++-only dependencies of SystemC modules need to Know |
| 37 | about SystemC types. Therefore, SystemC includes must be |
| 38 | available. |
| 39 | |
| 40 | soclib-cc needs new configuration sections for |
| 41 | * the compiler used by sccom |
| 42 | * the path to !ModelSim's SystemC implementation |
| 43 | * used flags |
| 44 | * object file names pattern in sccom work directory |
| 45 | |
| 46 | For all these, we must create 3 new configurations in soclib-cc's |
| 47 | configuration file: |
| 48 | * a compiler |
| 49 | * a SystemC library |
| 50 | * a build environment |
| 51 | |
| 52 | {{{ |
| 53 | # Definition of the compiler used for ModelSim-usable SoCLib components. |
| 54 | # We use sccom for components compilation and linkage, gcc/g++ for utilities |
| 55 | config.toolchain_sccom = Config( |
| 56 | base = config.toolchain, |
| 57 | # Must use this. |
| 58 | tool_map = { |
| 59 | 'SCCOM_CC':'sccom', |
| 60 | 'SCCOM_CXX':'sccom', |
| 61 | 'CC':'gcc', |
| 62 | 'CXX':'g++', |
| 63 | 'CC_LINKER':'sccom', |
| 64 | 'CXX_LINKER':'sccom', |
| 65 | }, |
| 66 | # Modelsim cant do parallel builds :'( |
| 67 | max_processes = 1, |
| 68 | # No cflags are needed, sccom forces them |
| 69 | cflags = [], |
| 70 | # Special features, it has a -link invocation needed at end... |
| 71 | libs = ['-link'], |
| 72 | ) |
| 73 | |
| 74 | # Definition of the ModelSim SystemC implementation. Must modify the |
| 75 | # path according to the ModelSim current installation. |
| 76 | config.systemc_sccom = Config( |
| 77 | base = config.systemc, |
| 78 | # This special vendor attributes enables some quirks in soclib-cc |
| 79 | vendor = 'sccom', |
| 80 | # This is the path of the produced .o files when compiled with sccom. |
| 81 | # You have to try it by hand, and adapt |
| 82 | sc_workpath = "work/_sc/linux_gcc-4.1.2", |
| 83 | # Mandatory quirks |
| 84 | dir = "", |
| 85 | os = "", |
| 86 | libs = [], |
| 87 | # cflags have to be deducted from actual invocation |
| 88 | # Try using sccom -v by hand |
| 89 | cflags = ['-I/users/soft/mentor/modelsim-6.5c/modeltech/include/systemc', |
| 90 | '-I/users/soft/mentor/modelsim-6.5c/modeltech/include'], |
| 91 | ) |
| 92 | |
| 93 | # Definition of a new build environment, which can be referenced with 'soclib-cc -t' |
| 94 | config.sccom = Config( |
| 95 | base = config.build_env, |
| 96 | toolchain = config.toolchain_sccom, |
| 97 | systemc = config.systemc_sccom, |
| 98 | # Where temporary files lies, beware that if you set a global path, |
| 99 | # you'll need a mechanism to make user-unique directories. |
| 100 | repos = "/tmp/", |
| 101 | ) |
| 102 | }}} |
| 103 | |
| 104 | = SystemC modules in !ModelSim limitations = |
| 105 | |
| 106 | All modules that may be used from the outside of the SystemC-part |
| 107 | (from RTL or from GUI) have to be declared with a special macro |
| 108 | (`SC_MODULE_EXPORT`). |
| 109 | |
| 110 | There is no `sc_main()` function in modelsim-based simulators. The top |
| 111 | module must be a `sc_module` with no interfaces. This probably needs a |
| 112 | rewrite of your netlists. |
| 113 | |
| 114 | If you use DSX-generated netlists, this is done transparently. |
| 115 | |
| 116 | = Usage = |
| 117 | |
| 118 | Now we configured soclib-cc, we can compile a complete SystemC system. |
| 119 | |
| 120 | Example to come |