-
Notifications
You must be signed in to change notification settings - Fork 0
/
basicmuxcalc.tlv
33 lines (27 loc) · 1.05 KB
/
basicmuxcalc.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-0.1) // 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;
//...
//$out[4:0] = $in1[3:0] + $in2[3:0];
//$out2[7:0] = $sel ? $in4[7:0] : $in3[7:0];
$val1[31:0] = $rand1[3:0];
$val2[31:0] = $rand2[3: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] = ($sel[1:0] == 2'b00) ? $sum[31:0] : ($sel[1:0] == 2'b01) ? $diff[31:0] : ($sel[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