Browse Source

Changes to get converter working and to provide verilator as

Eyck Jentzsch 1 year ago
parent
commit
6fa22dca91
4 changed files with 43 additions and 13 deletions
  1. 24
    0
      incl/scc/signal_initiator_mixin.h
  2. 5
    6
      incl/scc/time2tick.h
  3. 12
    4
      incl/tlm/tlm_signal_conv.h
  4. 2
    3
      src/verilator_callbacks.cpp

+ 24
- 0
incl/scc/signal_initiator_mixin.h View File

@@ -48,6 +48,30 @@ public:
48 48
 
49 49
     using BASE_TYPE::bind;
50 50
 
51
+    void write_now(tlm_signal_type value){
52
+        auto*  gp = tlm::tlm_signal_gp<tlm_signal_type>::create();
53
+        gp->set_command(tlm::TLM_WRITE_COMMAND);
54
+        gp->set_value(value);
55
+        gp->acquire();
56
+        tlm::tlm_phase phase{tlm::BEGIN_REQ};
57
+        auto delay{sc_core::SC_ZERO_TIME};
58
+        (*this)->nb_transport_fw(*gp, phase, delay);
59
+        gp->release();
60
+    }
61
+
62
+    template<typename EXT_TYPE>
63
+    void write_now(tlm_signal_type value, EXT_TYPE* ext){
64
+        auto*  gp = tlm::tlm_signal_gp<tlm_signal_type>::create();
65
+        gp->set_command(tlm::TLM_WRITE_COMMAND);
66
+        gp->set_value(value);
67
+        if(ext) gp->set_extension(ext);
68
+        gp->acquire();
69
+        tlm::tlm_phase phase{tlm::BEGIN_REQ};
70
+        auto delay{sc_core::SC_ZERO_TIME};
71
+        (*this)->nb_transport_fw(*gp, phase, delay);
72
+        gp->release();
73
+    }
74
+
51 75
     /**
52 76
      *
53 77
      * @param cb the callback function

+ 5
- 6
incl/scc/time2tick.h View File

@@ -10,7 +10,8 @@
10 10
 
11 11
 #include "utilities.h"
12 12
 
13
-class time2tick: public sc_core::sc_module {
13
+namespace scc {
14
+struct time2tick: public sc_core::sc_module {
14 15
     SC_HAS_PROCESS(time2tick);
15 16
     sc_core::sc_in<sc_core::sc_time> clk_i;
16 17
     sc_core::sc_out<bool> clk_o;
@@ -28,13 +29,11 @@ private:
28 29
                 t=clk_i.read();
29 30
             }
30 31
             clk_o=true;
31
-            wait(t);
32
+            wait(t/2);
32 33
             clk_o=false;
33
-            wait(t);
34
+            wait(t-t/2);
34 35
         }
35 36
     }
36 37
 };
37
-
38
-
39
-
38
+}
40 39
 #endif /* _SCC_TIME2TICK_H_ */

+ 12
- 4
incl/tlm/tlm_signal_conv.h View File

@@ -16,7 +16,7 @@
16 16
 namespace tlm {
17 17
 
18 18
 template<typename TYPE>
19
-class tlm_signal2sc_signal:
19
+struct tlm_signal2sc_signal:
20 20
         public sc_core::sc_module,
21 21
         public tlm_signal_fw_transport_if<TYPE, tlm_signal_baseprotocol_types<TYPE>> {
22 22
 
@@ -30,7 +30,11 @@ class tlm_signal2sc_signal:
30 30
 
31 31
     sc_core::sc_out<TYPE> s_o;
32 32
 
33
-    tlm_signal2sc_signal(sc_core::sc_module_name nm) : sc_core::sc_module(nm) {
33
+    tlm_signal2sc_signal(sc_core::sc_module_name nm)
34
+    : sc_core::sc_module(nm)
35
+    , NAMED(t_i)
36
+    , NAMED(s_o)
37
+    {
34 38
         t_i.bind(*this);
35 39
         SC_METHOD(que_cb);
36 40
         sensitive<<que.event();
@@ -50,7 +54,7 @@ private:
50 54
 };
51 55
 
52 56
 template<typename TYPE>
53
-class sc_signal2tlm_signal:
57
+struct sc_signal2tlm_signal:
54 58
         public sc_core::sc_module,
55 59
         public tlm_signal_bw_transport_if<TYPE, tlm_signal_baseprotocol_types<TYPE>> {
56 60
 
@@ -64,7 +68,11 @@ class sc_signal2tlm_signal:
64 68
 
65 69
     tlm_signal_initiator_socket<TYPE> t_o;
66 70
 
67
-    sc_signal2tlm_signal(sc_core::sc_module_name nm) : sc_core::sc_module(nm) {
71
+    sc_signal2tlm_signal(sc_core::sc_module_name nm)
72
+    : sc_core::sc_module(nm)
73
+    , NAMED(s_i)
74
+    , NAMED(t_o)
75
+    {
68 76
         t_o.bind(*this);
69 77
         SC_METHOD(sig_cb);
70 78
         sensitive<<s_i;

+ 2
- 3
src/verilator_callbacks.cpp View File

@@ -11,11 +11,10 @@
11 11
 void vl_stop (const char* filename, int linenum, const char* hier) {
12 12
     Verilated::gotFinish(true);
13 13
     Verilated::flushCall();
14
-    sc_stop();
15
-}
14
+    if (!sc_core::sc_end_of_simulation_invoked()) sc_core::sc_stop();}
16 15
 
17 16
 void vl_finish (const char* filename, int linenum, const char* hier) {
18 17
     Verilated::gotFinish(true);
19 18
     Verilated::flushCall();
20
-    sc_stop();
19
+    if (!sc_core::sc_end_of_simulation_invoked()) sc_core::sc_stop();
21 20
 }