generated from stevehoover/MYTH_Workshop_Assignments
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sequential_calculator.tlv
40 lines (31 loc) · 1.23 KB
/
sequential_calculator.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
34
35
36
37
38
39
40
sequential calculator
https://makerchip.com/sandbox/0o2fXhzKX/0j2hwy
\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
|calc
@0
$reset = *reset;
$val1[31:0] = >>1$out[31: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] = $reset ? 32'b0 : (($op[1:0]==2'b00) ? $sum :
($op[1:0]==2'b01) ? $diff :
($op[1:0]==2'b10) ? $prod : $quot);
// Assert these to end simulation (before Makerchip cycle limit).
*passed = *cyc_cnt > 10;
*failed = 1'b0;
\SV
endmodule