File tree Expand file tree Collapse file tree 3 files changed +53
-13
lines changed Expand file tree Collapse file tree 3 files changed +53
-13
lines changed Original file line number Diff line number Diff line change 5
5
#
6
6
# *****************************************************************************
7
7
8
+ cmake_minimum_required (VERSION 3.12 )
9
+
10
+ enable_testing ()
11
+
12
+ if (NOT DEFINED ENV{ICSC_HOME} )
13
+ message ("ICSC_HOME is not defined!" )
14
+ return ()
15
+ endif ()
16
+
8
17
# Design template
9
18
project (mydesign )
10
19
20
+ ## SVC package contains ScTool and SystemC libraries
21
+ find_package (SVC REQUIRED )
22
+
23
+ # C++ standard must be the same as in ScTool, $(SystemC_CXX_STANDARD) contains 17
24
+ set (CMAKE_CXX_STANDARD 17 )
25
+
26
+ #include_directories($ENV{ICSC_HOME}/include)
27
+
11
28
# All synthesizable source files must be listed here (not in libraries)
12
29
add_executable (mydesign example.cpp )
13
30
14
- # Test source directory
15
- target_include_directories (mydesign PUBLIC $ENV{ICSC_HOME} /examples/template )
16
-
17
31
# Add compilation options
18
32
# target_compile_definitions(mydesign PUBLIC -DMYOPTION)
19
33
# target_compile_options(mydesign PUBLIC -Wall)
@@ -25,4 +39,4 @@ target_include_directories(mydesign PUBLIC $ENV{ICSC_HOME}/examples/template)
25
39
# and @mydesign that runs general SystemC simulation
26
40
# ELAB_TOP parameter accepts hierarchical name of DUT
27
41
# (that is SystemC name, returned by sc_object::name() method)
28
- svc_target (mydesign ELAB_TOP tb.dut_inst )
42
+ svc_target (mydesign INIT_LOCAL_VARS ELAB_TOP tb.dut_inst )
Original file line number Diff line number Diff line change 9
9
10
10
struct Dut : sc_module
11
11
{
12
+ typedef sc_uint < 16 > data_t ;
13
+
12
14
sc_in < bool > clk {"clk" };
13
15
sc_in < bool > rstn {"rstn" };
14
16
15
- sc_signal < sc_uint < 16 >> s {"s" };
17
+ sc_in < data_t > inp {"inp" };
18
+ sc_out < data_t > outp {"outp" };
19
+
16
20
17
21
SC_CTOR (Dut )
18
22
{
19
- SC_CTHREAD (threadProc , clk .pos ());
20
- async_reset_signal_is (rstn , false);
23
+ SC_CTHREAD (threadProc , clk .pos ());
24
+ async_reset_signal_is (rstn , false);
21
25
22
- SC_METHOD (methodProc );
23
- sensitive << s ; // Add all signal/ports read in method function here
26
+ SC_METHOD (methodProc );
27
+ sensitive << tmps ; // Add all signal/ports read in method function here
24
28
}
29
+
30
+ sc_signal < data_t > tmps {"tmps" };
25
31
26
32
void threadProc ()
27
33
{
28
34
// Reset signal/output port values here
35
+ tmps = 0 ;
29
36
wait ();
30
37
31
38
while (true) {
32
39
// Place sequential logic here
40
+ tmps = inp ;
33
41
wait ();
34
42
}
35
43
}
36
44
37
45
void methodProc () {
38
46
// Place combinational logic here
47
+ outp = tmps .read () + data_t (1 );
39
48
}
40
49
41
- };
50
+ };
Original file line number Diff line number Diff line change 7
7
8
8
// Design template
9
9
10
- #include " dut.h"
11
10
#include < systemc.h>
11
+ #include " dut.h"
12
12
13
13
// ICSC requires DUT top should be instantiated inside wrapper (typically TB)
14
14
// and all DUT ports are bound.
15
15
struct Tb : sc_module
16
16
{
17
+ typedef Dut::data_t data_t ;
18
+
17
19
sc_in_clk clk{" clk" };
18
20
sc_signal<bool > rstn{" rstn" };
21
+
22
+ sc_signal<data_t > inp{" inp" };
23
+ sc_signal<data_t > outp{" outp" };
19
24
20
25
Dut dut_inst{" dut_inst" };
21
26
27
+
22
28
SC_CTOR (Tb)
23
29
{
24
30
dut_inst.clk (clk);
25
31
dut_inst.rstn (rstn);
32
+ dut_inst.inp (inp);
33
+ dut_inst.outp (outp);
26
34
27
35
SC_CTHREAD (test_proc, clk.pos ());
28
36
}
29
37
30
- // Assert and de-assert reset for DUT
31
38
void test_proc ()
32
39
{
40
+ cout << " test_proc() started" << endl;
41
+
42
+ // Assert and de-assert reset for DUT
33
43
rstn = 0 ;
44
+ inp = 0 ;
34
45
wait ();
35
46
rstn = 1 ;
36
47
37
48
// Add testbench code here
49
+ inp = 10 ;
50
+ wait (2 );
51
+ inp = 0 ;
52
+ sc_assert (outp.read () == 11 );
53
+ sc_stop ();
54
+ cout << " test_proc() finished!" << endl;
38
55
}
39
56
};
40
57
@@ -45,4 +62,4 @@ int sc_main (int argc, char **argv)
45
62
tb.clk (clk);
46
63
sc_start ();
47
64
return 0 ;
48
- }
65
+ }
You can’t perform that action at this time.
0 commit comments