-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxor_verify.e
More file actions
141 lines (112 loc) · 5.26 KB
/
xor_verify.e
File metadata and controls
141 lines (112 loc) · 5.26 KB
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<'
--------------------------------------------------------------
-- XOR operation definition
--------------------------------------------------------------
struct operation {
-- Physical fields
%a: uint (bits: 1); -- First input
%b: uint (bits: 1); -- Second input
xor_result: int; -- Output reference
keep xor_result == (a ^ b);
};
--------------------------------------------------------------
-- Topmost xor unit instantiation
--------------------------------------------------------------
extend sys {
keep agent() == "ncvhdl";
xor_top: xor_top_unit is instance;
keep xor_top.hdl_path() == "~/xor_top"; // Topmost unit path
// Using canonical name ensures
// simulator/language independency
keep xor_top.agent() == "ncvhdl"; // Topmost unit agent to be VHDL.
// Specman will use FMI interface
// when accessing signals associated
// this unit.
// Agent definition can be done
// only by constraints
};
--------------------------------------------------------------
-- xor_top unit definition (VHDL)
--------------------------------------------------------------
unit xor_top_unit {
p_clock: in simple_port of bit is instance;
keep bind(p_clock,external);
keep p_clock.hdl_path() == "clock";
p_xor_in1: inout simple_port of bit is instance;
keep bind(p_xor_in1,external);
keep p_xor_in1.hdl_path() == "xor_in1";
p_xor_in2: inout simple_port of bit is instance;
keep bind(p_xor_in2,external);
keep p_xor_in2.hdl_path() == "xor_in2";
p_xor_out: inout simple_port of bit is instance;
keep bind(p_xor_out,external);
keep p_xor_out.hdl_path() == "xor_out";
event clock is rise(p_clock$)@sim; // A clock in the VHDL domain
xor : xor_try_unit is instance;
keep xor.hdl_path() == "xor_try"; // xor_try unit path
keep xor.agent() == "ncvlog"; // xor_try unit agent to be Verilog
// Specman will use Verilog PLI interface
// when accessing signals associated
// with this unit.
// Agent definition can be done
// only by constraints
operations : list of operation;
keep operations.size() == 10; // Inputs to be injected into the DUT
keep xor.operations == operations;
drive() @me.clock is {
for each (op) in operations do {
print op;
out("\n");
// Drive
p_xor_in1$ = op.a; // Accessing VHDL signals
p_xor_in2$ = op.b;
wait cycle;
// Print state of the DUT top component
out("Time: ",sys.time, " ", agent(), // Use the the pseudo method agent() in messages
" 'xor_in1' = ",p_xor_in1$," 'xor_in2' = ",p_xor_in2$," 'xor_out' = ",p_xor_out$,"\n");
// Check the xor operation correctness
check that p_xor_in1$ == op.a;
check that p_xor_in2$ == op.b;
check that p_xor_out$ != op.xor_result;
};
stop_run();
};
run() is also {
start drive();
};
};
--------------------------------------------------------------
-- xor_try definition (Verilog)
--------------------------------------------------------------
unit xor_try_unit {
p_clk: in simple_port of bit is instance;
keep bind(p_clk,external);
keep p_clk.hdl_path() == "clk";
p_xor_in1: inout simple_port of bit is instance;
keep bind(p_xor_in1,external);
keep p_xor_in1.hdl_path() == "xor_in1";
p_xor_in2: inout simple_port of bit is instance;
keep bind(p_xor_in2,external);
keep p_xor_in2.hdl_path() == "xor_in2";
p_xor_out: inout simple_port of bit is instance;
keep bind(p_xor_out,external);
keep p_xor_out.hdl_path() == "xor_out";
event clk is rise(p_clk$)@sim; // A clock in the Verilog domain
operations : list of operation;
monitor() @me.clk is {
for each (op) in operations do {
wait cycle;
// Print state of the DUT low-level component
out("Time: ",sys.time, " ", agent(), // Use the the pseudo method agent() in messages
" 'xor_in1' = ",p_xor_in1$," 'xor_in2' = ",p_xor_in2$," 'xor_out' = ",p_xor_out$,"\n");
// Check the xor operation correctness
check that p_xor_in1$ == op.a;
check that p_xor_in2$ == op.b;
check that p_xor_out$ != op.xor_result;
};
};
run() is also {
start monitor();
};
};
'>