| 1 | = How to use SoCView = |
| 2 | |
| 3 | To use the debugger simulator, you have to make a few small changes in your SystemC platform : |
| 4 | |
| 5 | == 1. The simulation loop == |
| 6 | |
| 7 | Just replace the simulation loop at the end of your top cell by calling the function ''debug()'' |
| 8 | |
| 9 | before : |
| 10 | |
| 11 | {{{ |
| 12 | sc_start(0); |
| 13 | for (int i = 0; i < ncycles ; i++) |
| 14 | { |
| 15 | sc_start(1); |
| 16 | |
| 17 | /* ... */ |
| 18 | } |
| 19 | |
| 20 | /* ... */ |
| 21 | |
| 22 | return EXIT_SUCCESS; |
| 23 | }}} |
| 24 | |
| 25 | after : |
| 26 | |
| 27 | {{{ |
| 28 | sc_start(0); |
| 29 | |
| 30 | debug(); |
| 31 | return EXIT_SUCCESS; |
| 32 | }}} |
| 33 | |
| 34 | == 2. Naming the signals == |
| 35 | |
| 36 | You'll have to name all the signals inside your design to be able to recognize them when debugging. Otherwise the simulator will rename them with generic names (signal_0, signal_1 ...) |
| 37 | |
| 38 | You have two methods to do it : |
| 39 | |
| 40 | * name them in the constructor, as you would naturally do in SystemC |
| 41 | |
| 42 | * use the function ''rename()'' |
| 43 | |
| 44 | The function rename() is used especially for renaming signals declared as n-dimensional array of signals, which you can't do in standard SystemC. |
| 45 | |
| 46 | Here's an example of haw to do both methods |
| 47 | |
| 48 | {{{ |
| 49 | /*******************/ |
| 50 | /* The Constructor */ |
| 51 | /*******************/ |
| 52 | |
| 53 | SC_HAS_PROCESS(MY_COMPONENT); |
| 54 | |
| 55 | MY_COMPONENT (sc_module_name insname): |
| 56 | clk("Clock"), // the standard way of naming signals |
| 57 | reset("Reset") |
| 58 | |
| 59 | { |
| 60 | #ifdef NONAME_RENAME |
| 61 | // clk.rename("Clock"); // you can use function rename to name simple signals instead of doing it the standard way |
| 62 | // reset.rename("Reset"); |
| 63 | |
| 64 | char newname[100]; |
| 65 | |
| 66 | for (int i=0; i<tab_size; i++ ) |
| 67 | { |
| 68 | sprintf(newname, "Tab_Signal_%2.2d", i); |
| 69 | tab_signal[i].rename(newname); |
| 70 | } |
| 71 | #endif |
| 72 | |
| 73 | SC_METHOD (my_method); |
| 74 | sensitive << clk.pos(); |
| 75 | |
| 76 | /* ... */ |
| 77 | |
| 78 | } |
| 79 | |
| 80 | }}} |
| 81 | |
| 82 | |
| 83 | Note the use of ''#ifdef NONAME_RENAME'' to keep the compatibility of your code with SystemC/OSCI |
| 84 | |
| 85 | == 3. The Makefile == |
| 86 | |
| 87 | Some flags need to be added to compile the simulator |
| 88 | |
| 89 | * for Compilation Flags, add ''-I${SOCVIEW}/include'' |
| 90 | * for Linker Flags, add ''-lreadline -lhistory'' |
| 91 | |
| 92 | Now to compile your design, replace the ${SYSTEMC} by the path to the SOCVIEW simulator. |