-
Notifications
You must be signed in to change notification settings - Fork 0
/
comibational_calc.tlv
34 lines (28 loc) · 1.14 KB
/
comibational_calc.tlv
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
\m5_TLV_version 1d: tl-x.org
\m5
// =================================================
// Welcome! New to Makerchip? Try the "Learn" menu.
// =================================================
//use(m5-1.0) /// uncomment to use M5 macro library.
\SV
// Macro providing required top-level module definition, random
// stimulus support, and Verilator config.
m5_makerchip_module // (Expanded in Nav-TLV pane.)
\TLV
$reset = *reset;
$val1[31:0] = $rand1[3:0];
$val2[31:0] = $rand2[3:0];
$op[1:0] = $rand3[1:0];
$sum[31:0] = $val1[31:0] + $val2[31:0];
$diff[31:0] = $val1[31:0] - $val2[31:0];
$prod[31:0] = $val1[31:0] * $val2[31:0];
$quot[31:0] = $val1[31:0] / $val2[31:0];
$out[31:0] = ($op[1:0]==2'b00) ? $sum[31:0] :
($op[1:0]==2'b01) ? $diff[31:0] :
($op[1:0]==2'b10) ? $prod[31:0] :
$quot[31:0];
// Assert these to end simulation (before Makerchip cycle limit).
*passed = *cyc_cnt > 40;
*failed = 1'b0;
\SV
endmodule