-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_0.cpp
90 lines (57 loc) · 1.59 KB
/
test_0.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
int test0(int argc, char** argv, char** env) {
STANDARD_TB_START();
HiggsHelper<top_t>* t = new HiggsHelper<top_t>(top,&main_time,tfp);
preReset(top);
t->reset(40);
postReset(top);
int total_runtime = 300; // in ns
// cout << *t->main_time << "\n";
const uint64_t time_a = *t->main_time; // what time is it after the reset?
// because tick() is actually 2 ns, we += 2
// this means you can never check ns against an odd number
for(uint64_t ns = time_a; ns < total_runtime; ns+=2) {
///
/// Example where we trigger after t_min
///
uint64_t d = 6; // duration of trigger
uint64_t ta1 = 100;
uint64_t tb1 = 150;
if( ns == ta1 ) {
top->input_a = 1;
}
if( ns == ta1+d ) {
top->input_a = 0;
}
if( ns == tb1 ) {
top->input_b = 1;
}
if( ns == tb1+6 ) {
top->input_b = 0;
}
///
/// Example where we trigger before t_min
///
uint64_t ta2 = 200;
uint64_t tb2 = 210;
if( ns == ta2 ) {
top->input_a = 1;
}
if( ns == ta2+d ) {
top->input_a = 0;
}
if( ns == tb2 ) {
top->input_b = 1;
}
if( ns == tb2+6 ) {
top->input_b = 0;
}
t->tick(1); // 1 tick is actually 2 ns
}
// Final model cleanup
top->final();
// Close trace if opened
if (tfp) { tfp->close(); }
// Destroy model
delete top; top = NULL;
exit(0);
}