generated from stevehoover/MYTH_Workshop_Assignments
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalculator_solutions.tlv
46 lines (41 loc) · 1.45 KB
/
calculator_solutions.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
\m4_TLV_version 1d: tl-x.org
\SV
// This code can be found in: https://github.com/stevehoover/RISC-V_MYTH_Workshop
m4_include_lib(['https://raw.githubusercontent.com/stevehoover/RISC-V_MYTH_Workshop/bd1f186fde018ff9e3fd80597b7397a1c862cf15/tlv_lib/calculator_shell_lib.tlv'])
\SV
m4_makerchip_module // (Expanded in Nav-TLV pane.)
\TLV
|calc
@0
$reset = *reset;
@1
$valid = $reset ? 0 : >>1$valid + 1;
$valid_or_reset = $valid || $reset;
?$valid_or_reset
@1
$val1[31:0] = >>2$out;
$val2[31:0] = $rand2[3:0];
$sum[31:0] = $val1 + $val2;
$diff[31:0] = $val1 - $val2;
$prod[31:0] = $val1 * $val2;
$quot[31:0] = $val1 / $val2;
@2
$out[31:0] =
($op[2:0] == 0) ? $sum :
($op[2:0] == 1) ? $diff :
($op[2:0] == 2) ? $prod :
($op[2:0] == 3) ? $quot :
($op[2:0] == 4) ? $mem :
($op[2:0] == 5) ? $RETAIN :
0;
@2
$mem[31:0] =
$reset ? 0 :
($op[2:0] == 5) ? >>2$out :
>>1$mem;
m4+cal_viz(@3) // Arg: Pipeline stage represented by viz, should be atleast equal to last stage of CALCULATOR logic.
// Assert these to end simulation (before Makerchip cycle limit).
*passed = *cyc_cnt > 40;
*failed = 1'b0;
\SV
endmodule