generated from stevehoover/MYTH_Workshop_Assignments
-
Notifications
You must be signed in to change notification settings - Fork 0
/
combinational_calculator.tlv
47 lines (40 loc) · 1.3 KB
/
combinational_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
41
42
43
44
45
46
47
combinational calculator
https://www.makerchip.com/sandbox/0DkfBh54w/0Q1hPj#
\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;
//define smaller random numbers 4bit and assign to val1/val2
// 31-4 bits of val1/val2 will be zero and 0-9 bits will be rand1/rand2
//values
$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 == 0)
? $sum[31:0] :
($op == 1)
? $diff[31:0] :
($op == 2)
? $prod[31:0] :
($op == 3)
? $quot[31:0] :
//default
32'b0;
// Assert these to end simulation (before Makerchip cycle limit).
*passed = *cyc_cnt > 10;
*failed = 1'b0;
\SV
endmodule