-
Notifications
You must be signed in to change notification settings - Fork 6
/
tt_um_empty_template.tlv
147 lines (112 loc) · 5.24 KB
/
tt_um_empty_template.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
\m5_TLV_version 1d: tl-x.org
\m5
use(m5-1.0)
// ########################################################
// # #
// # Empty template for Tiny Tapeout Makerchip Projects #
// # #
// ########################################################
// ========
// Settings
// ========
//-------------------------------------------------------
// Build Target Configuration
//
var(my_design, tt_um_example) /// The name of your top-level TT module, to match your info.yml.
var(target, ASIC) /// Note, the FPGA CI flow will set this to FPGA.
//-------------------------------------------------------
var(in_fpga, 1) /// 1 to include the demo board. (Note: Logic will be under /fpga_pins/fpga.)
var(debounce_inputs, 0) /// 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.
// ======================
// 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 Tiny Tapeout Lab.
m4_include_lib(['https:/']['/raw.githubusercontent.com/os-fpga/Virtual-FPGA-Lab/35e36bd144fddd75495d4cbc01c4fc50ac5bde6f/tlv_lib/tiny_tapeout_lib.tlv'])
\TLV my_design()
// ==================
// | |
// | YOUR CODE HERE |
// | |
// ==================
// Note that pipesignals assigned here can be found under /fpga_pins/fpga.
// Connect Tiny Tapeout outputs. Note that uio_ outputs are not available in the Tiny-Tapeout-3-based FPGA boards.
*uo_out = 8'b0;
m5_if_neq(m5_target, FPGA, ['*uio_out = 8'b0;'])
m5_if_neq(m5_target, FPGA, ['*uio_oe = 8'b0;'])
// Set up the Tiny Tapeout lab environment.
\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, $, , my_design)
// Label the switch inputs [0..7] (1..8 on the physical switch panel) (top-to-bottom).
m5+tt_input_labels_viz(['"UNUSED", "UNUSED", "UNUSED", "UNUSED", "UNUSED", "UNUSED", "UNUSED", "UNUSED"'])
\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, uo_out;
m5_if_neq(m5_target, FPGA, ['logic [7:0] uio_in, 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];
m5_if_neq(m5_target, FPGA, ['assign uio_in = 8'b0;'])
logic ena = 1'b0;
logic rst_n = ! reset;
/*
// Or, to provide specific inputs at specific times (as for lab C-TB) ...
// BE SURE TO COMMENT THE ASSIGNMENT OF INPUTS ABOVE.
// BE SURE TO DRIVE THESE ON THE B-PHASE OF THE CLOCK (ODD STEPS).
// Driving on the rising clock edge creates a race with the clock that has unpredictable simulation behavior.
initial begin
#1 // Drive inputs on the B-phase.
ui_in = 8'h0;
#10 // Step 5 cycles, past reset.
ui_in = 8'hFF;
// ...etc.
end
*/
// 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
m5_if_eq(m5_target, FPGA, ['/']['*']) // The FPGA is based on TinyTapeout 3 which has no bidirectional I/Os (vs. TT6 for the ASIC).
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)
m5_if_eq(m5_target, FPGA, ['*']['/'])
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;
\TLV
/* verilator lint_off UNOPTFLAT */
m5_if(m5_in_fpga, ['m5+tt_lab()'], ['m5+my_design()'])
\SV_plus
// ==========================================
// If you are using Verilog for your design,
// your Verilog logic goes here.
// Note, output assignments are in my_design.
// ==========================================
\SV
endmodule