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 55#
66# *****************************************************************************
77
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+
817# Design template
918project (mydesign)
1019
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+
1128# All synthesizable source files must be listed here (not in libraries)
1229add_executable (mydesign example.cpp)
1330
14- # Test source directory
15- target_include_directories (mydesign PUBLIC $ENV{ICSC_HOME} /examples/template)
16-
1731# Add compilation options
1832# target_compile_definitions(mydesign PUBLIC -DMYOPTION)
1933# target_compile_options(mydesign PUBLIC -Wall)
@@ -25,4 +39,4 @@ target_include_directories(mydesign PUBLIC $ENV{ICSC_HOME}/examples/template)
2539# and @mydesign that runs general SystemC simulation
2640# ELAB_TOP parameter accepts hierarchical name of DUT
2741# (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 99
1010struct Dut : sc_module
1111{
12+ typedef sc_uint < 16 > data_t ;
13+
1214 sc_in < bool > clk {"clk" };
1315 sc_in < bool > rstn {"rstn" };
1416
15- sc_signal < sc_uint < 16 >> s {"s" };
17+ sc_in < data_t > inp {"inp" };
18+ sc_out < data_t > outp {"outp" };
19+
1620
1721 SC_CTOR (Dut )
1822 {
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);
2125
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
2428 }
29+
30+ sc_signal < data_t > tmps {"tmps" };
2531
2632 void threadProc ()
2733 {
2834 // Reset signal/output port values here
35+ tmps = 0 ;
2936 wait ();
3037
3138 while (true) {
3239 // Place sequential logic here
40+ tmps = inp ;
3341 wait ();
3442 }
3543 }
3644
3745 void methodProc () {
3846 // Place combinational logic here
47+ outp = tmps .read () + data_t (1 );
3948 }
4049
41- };
50+ };
Original file line number Diff line number Diff line change 77
88// Design template
99
10- #include " dut.h"
1110#include < systemc.h>
11+ #include " dut.h"
1212
1313// ICSC requires DUT top should be instantiated inside wrapper (typically TB)
1414// and all DUT ports are bound.
1515struct Tb : sc_module
1616{
17+ typedef Dut::data_t data_t ;
18+
1719 sc_in_clk clk{" clk" };
1820 sc_signal<bool > rstn{" rstn" };
21+
22+ sc_signal<data_t > inp{" inp" };
23+ sc_signal<data_t > outp{" outp" };
1924
2025 Dut dut_inst{" dut_inst" };
2126
27+
2228 SC_CTOR (Tb)
2329 {
2430 dut_inst.clk (clk);
2531 dut_inst.rstn (rstn);
32+ dut_inst.inp (inp);
33+ dut_inst.outp (outp);
2634
2735 SC_CTHREAD (test_proc, clk.pos ());
2836 }
2937
30- // Assert and de-assert reset for DUT
3138 void test_proc ()
3239 {
40+ cout << " test_proc() started" << endl;
41+
42+ // Assert and de-assert reset for DUT
3343 rstn = 0 ;
44+ inp = 0 ;
3445 wait ();
3546 rstn = 1 ;
3647
3748 // 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;
3855 }
3956};
4057
@@ -45,4 +62,4 @@ int sc_main (int argc, char **argv)
4562 tb.clk (clk);
4663 sc_start ();
4764 return 0 ;
48- }
65+ }
You can’t perform that action at this time.
0 commit comments