-
Notifications
You must be signed in to change notification settings - Fork 0
/
calcwithsinglevalmem.tlv
64 lines (49 loc) · 2.24 KB
/
calcwithsinglevalmem.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
\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/ecba3769fff373ef6b8f66b3347e8940c859792d/tlv_lib/calculator_shell_lib.tlv'])
\SV
m4_makerchip_module // (Expanded in Nav-TLV pane.)
\TLV
//$reset = *reset;
|calc
@0
$reset = *reset;
@1
$valid = $reset ? 0 : >>1$valid + 1;
$valid_or_reset = $reset || $valid;
?$valid_or_reset
@1
//$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];
$val1[31:0] = >>2$out[31:0];
@2
$mem[31:0] = $reset ? 0 :
($op[2:0] == 3'b101)? $val1[31:0]:
>>2$mem[31:0];
$out[31:0] = ($op[2:0] == 3'b000)? $sum[31:0]:
($op[2:0] == 3'b001)? $diff[31:0]:
($op[2:0] == 3'b010)? $prod[31:0]:
($op[2:0] == 3'b011)? $quot[31:0]:
($op[2:0] == 3'b100)? >>2$mem[31:0]:
>>2$out[31:0];
// YOUR CODE HERE
// ...
// Macro instantiations for calculator visualization(disabled by default).
// Uncomment to enable visualisation, and also,
// NOTE: If visualization is enabled, $op must be defined to the proper width using the expression below.
// (Any signals other than $rand1, $rand2 that are not explicitly assigned will result in strange errors.)
// You can, however, safely use these specific random signals as described in the videos:
// o $rand1[3:0]
// o $rand2[3:0]
// o $op[x:0]
m4+cal_viz(@2) // 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