-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathexample.cpp
65 lines (52 loc) · 1.44 KB
/
example.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/******************************************************************************
* Copyright (c) 2020, Intel Corporation. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception.
*
*****************************************************************************/
// Design template
#include <systemc.h>
#include "dut.h"
// ICSC requires DUT top should be instantiated inside wrapper (typically TB)
// and all DUT ports are bound.
struct Tb : sc_module
{
typedef Dut::data_t data_t;
sc_in_clk clk{"clk"};
sc_signal<bool> rstn{"rstn"};
sc_signal<data_t> inp{"inp"};
sc_signal<data_t> outp{"outp"};
Dut dut_inst{"dut_inst"};
SC_CTOR(Tb)
{
dut_inst.clk(clk);
dut_inst.rstn(rstn);
dut_inst.inp(inp);
dut_inst.outp(outp);
SC_CTHREAD(test_proc, clk.pos());
}
void test_proc()
{
cout << "test_proc() started" << endl;
// Assert and de-assert reset for DUT
rstn = 0;
inp = 0;
wait();
rstn = 1;
// Add testbench code here
inp = 10;
wait(2);
inp = 0;
sc_assert(outp.read() == 11);
sc_stop();
cout << "test_proc() finished!" << endl;
}
};
int sc_main (int argc, char **argv)
{
sc_clock clk{"clk", sc_time(1, SC_NS)};
Tb tb("tb");
tb.clk(clk);
sc_start();
return 0;
}