-
Notifications
You must be signed in to change notification settings - Fork 9
/
tt_um_calc_shell.tlv
131 lines (94 loc) · 4.38 KB
/
tt_um_calc_shell.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
\m5_TLV_version 1d: tl-x.org
\m5
use(m5-1.0)
// #################################################################
// # #
// # Starting-Point Code for MEST Course Tiny Tapeout Calculator #
// # #
// #################################################################
// ========
// Settings
// ========
var(my_design, tt_um_example) /// The name of your top-level TT module, to match your info.yml.
var(debounce_inputs, 0)
/// Legal values:
/// 1: Provide synchronization and debouncing on all input signals.
/// 0: Don't provide synchronization and debouncing.
/// m5_if_defined_as(MAKERCHIP, 1, 0, 1): Debounce unless in Makerchip.
var(in_fpga, 1) /// For Makerchip development: 1 to include the demo board in VIZ (in which case, logic will be under /fpga_pins/fpga).
// ======================
// Computed From Settings
// ======================
// If debouncing, a user's module is within a wrapper, so it has a different name.
var(user_module_name, m5_if(m5_debounce_inputs, my_design, m5_my_design))
var(debounce_cnt, m5_if_defined_as(MAKERCHIP, 1, 8'h03, 8'hff))
\SV
// =================
// Include Libraries
// =================
// Tiny Tapeout Lab.
m4_include_lib(https:/['']/raw.githubusercontent.com/os-fpga/Virtual-FPGA-Lab/35e36bd144fddd75495d4cbc01c4fc50ac5bde6f/tlv_lib/tiny_tapeout_lib.tlv)
// Calculator VIZ.
m4_include_lib(https:/['']/raw.githubusercontent.com/efabless/chipcraft---mest-course/main/tlv_lib/calculator_shell_lib.tlv)
\TLV calc()
// ==================
// | |
// | YOUR CODE HERE |
// | |
// ==================
// Note that pipesignals assigned here can be found under /fpga_pins/fpga (if in_fpga is set to 1 above).
m5+cal_viz(@1, m5_if(m5_in_fpga, /fpga, /top))
// Connect Tiny Tapeout outputs. Note that uio_ outputs are not available in the Tiny-Tapeout-3-based FPGA boards.
*uo_out = 8'b0;
*uio_out = 8'b0;
*uio_oe = 8'b0;
\SV
// ================================================
// A simple Makerchip Verilog test bench driving random stimulus.
// Modify the module contents to your needs.
// ================================================
module top(input logic clk, input logic reset, input logic [31:0] cyc_cnt, output logic passed, output logic failed);
// Tiny tapeout I/O signals.
logic [7:0] ui_in, uio_in, uo_out, uio_out, uio_oe;
logic [31:0] r; // a random value
always @(posedge clk) r <= m5_if_defined_as(MAKERCHIP, 1, ['$urandom()'], ['0']);
assign ui_in = r[7:0];
assign uio_in = 8'b0;
logic ena = 1'b0;
logic rst_n = ! reset;
// Instantiate the Tiny Tapeout module.
m5_user_module_name tt(.*);
assign passed = top.cyc_cnt > 80;
assign failed = 1'b0;
endmodule
// Provide a wrapper module to debounce input signals if requested.
m5_if(m5_debounce_inputs, ['m5_tt_top(m5_my_design)'])
\SV
// =======================
// The Tiny Tapeout module
// =======================
module m5_user_module_name (
input wire [7:0] ui_in, // Dedicated inputs - connected to the input switches
output wire [7:0] uo_out, // Dedicated outputs - connected to the 7 segment display
input wire [7:0] uio_in, // IOs: Bidirectional Input path
output wire [7:0] uio_out, // IOs: Bidirectional Output path
output wire [7:0] uio_oe, // IOs: Bidirectional Enable path (active high: 0=input, 1=output)
input wire ena, // will go high when the design is enabled
input wire clk, // clock
input wire rst_n // reset_n - low to reset
);
wire reset = ! rst_n;
// List all potentially-unused inputs to prevent warnings
wire _unused = &{ena, clk, rst_n, 1'b0};
\TLV tt_lab()
// Connect Tiny Tapeout I/Os to Virtual FPGA Lab.
m5+tt_connections()
// Instantiate the Virtual FPGA Lab.
m5+board(/top, /fpga, 7, $, , calc)
// Label the switch inputs [0..7] (1..8 on the physical switch panel) (top-to-bottom).
m5_if(m5_in_fpga, ['m5+tt_input_labels_viz(['"Value[0]", "Value[1]", "Value[2]", "Value[3]", "Op[0]", "Op[1]", "Op[2]", "="'])'])
\TLV
/* verilator lint_off UNOPTFLAT */
m5_if(m5_in_fpga, ['m5+tt_lab()'], ['m5+calc()'])
\SV
endmodule