-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlab7.sv
184 lines (141 loc) · 5.52 KB
/
lab7.sv
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
//-------------------------------------------------------------------------
// ECE 385 - Summer 2021 Lab 7 Top-level --
// --
// Updated Fall 2021 as Lab 7 --
// For use with ECE 385 --
// UIUC ECE Department --
//-------------------------------------------------------------------------
module lab7 (
///////// Clocks /////////
input MAX10_CLK1_50,
///////// KEY /////////
input [ 1: 0] KEY,
///////// SW /////////
input [ 9: 0] SW,
///////// LEDR /////////
output [ 9: 0] LEDR,
///////// HEX /////////
output [ 7: 0] HEX0,
output [ 7: 0] HEX1,
output [ 7: 0] HEX2,
output [ 7: 0] HEX3,
output [ 7: 0] HEX4,
output [ 7: 0] HEX5,
///////// SDRAM /////////
output DRAM_CLK,
output DRAM_CKE,
output [12: 0] DRAM_ADDR,
output [ 1: 0] DRAM_BA,
inout [15: 0] DRAM_DQ,
output DRAM_LDQM,
output DRAM_UDQM,
output DRAM_CS_N,
output DRAM_WE_N,
output DRAM_CAS_N,
output DRAM_RAS_N,
///////// VGA /////////
output VGA_HS,
output VGA_VS,
output [ 3: 0] VGA_R,
output [ 3: 0] VGA_G,
output [ 3: 0] VGA_B,
///////// ARDUINO /////////
inout [15: 0] ARDUINO_IO,
inout ARDUINO_RESET_N
);
//=======================================================
// REG/WIRE declarations
//=======================================================
logic SPI0_CS_N, SPI0_SCLK, SPI0_MISO, SPI0_MOSI, USB_GPX, USB_IRQ, USB_RST;
logic [3:0] hex_num_5, hex_num_4, hex_num_3, hex_num_2, hex_num_1, hex_num_0; //4 bit input hex digits
logic [1:0] signs;
logic [1:0] hundreds;
logic [7:0] keycode;
//=======================================================
// Structural coding
//=======================================================
assign ARDUINO_IO[10] = SPI0_CS_N;
assign ARDUINO_IO[13] = SPI0_SCLK;
assign ARDUINO_IO[11] = SPI0_MOSI;
assign ARDUINO_IO[12] = 1'bZ;
assign SPI0_MISO = ARDUINO_IO[12];
assign ARDUINO_IO[9] = 1'bZ;
assign USB_IRQ = ARDUINO_IO[9];
//Assignments specific to Sparkfun USBHostShield-v13
//assign ARDUINO_IO[7] = USB_RST;
//assign ARDUINO_IO[8] = 1'bZ;
//assign USB_GPX = ARDUINO_IO[8];
//Assignments specific to Circuits At Home UHS_20
assign ARDUINO_RESET_N = USB_RST;
assign ARDUINO_IO[8] = 1'bZ;
//GPX is unconnected to shield, not needed for standard USB host - set to 0 to prevent interrupt
assign USB_GPX = 1'b0;
//HEX drivers to convert numbers to HEX output
HexDriver hex_driver5 (hex_num_5, HEX5[6:0]);
assign HEX5[7] = 1'b1;
HexDriver hex_driver4 (hex_num_4, HEX4[6:0]);
assign HEX4[7] = 1'b1;
HexDriver hex_driver3 (hex_num_3, HEX3[6:0]);
assign HEX3[7] = 1'b1;
HexDriver hex_driver2 (fps, HEX2[6:0]);
assign HEX2[7] = 1'b1;
HexDriver hex_driver1 (SW[0], HEX1[6:0]);
assign HEX1[7] = 1'b1;
HexDriver hex_driver0 (fps[3:0], HEX0[6:0]);
assign HEX0[7] = 1'b1;
//fill in the hundreds digit as well as the negative sign
//assign HEX5 = {1'b1, ~signs[1], 3'b111, ~hundreds[1], ~hundreds[1], 1'b1};
//assign HEX2 = {1'b1, ~signs[0], 3'b111, ~hundreds[0], ~hundreds[0], 1'b1};
assign {Reset_h}=~ (KEY[0]);
//assign signs = 2'b00;
assign hex_num_5 = 4'h8;
assign hex_num_4 = 4'h8;
assign hex_num_3 = 4'h8;
assign hex_num_2 = 4'h8;
assign hex_num_1 = 4'h8;
assign hex_num_0 = 4'h8;
logic [7:0] fps, clock_reset;
timer clock_timer(.clock_reset(clock_reset), .clk(MAX10_CLK1_50), .fps(fps));
//remember to rename the SOC as necessary
lab7_2 u0 ( //for week 7.1
.clk_clk (MAX10_CLK1_50), //clk.clk
.reset_reset_n (1'b1), //reset.reset_n
.altpll_0_locked_conduit_export (), //altpll_0_locked_conduit.export
.altpll_0_phasedone_conduit_export (), //altpll_0_phasedone_conduit.export
.altpll_0_areset_conduit_export (), //altpll_0_areset_conduit.export
.key_external_connection_export (KEY), //key_external_connection.export
//SDRAM
.clk_sdram_clk(DRAM_CLK), //clk_sdram.clk
.sdram_wire_addr(DRAM_ADDR), //sdram_wire.addr
.sdram_wire_ba(DRAM_BA), //.ba
.sdram_wire_cas_n(DRAM_CAS_N), //.cas_n
.sdram_wire_cke(DRAM_CKE), //.cke
.sdram_wire_cs_n(DRAM_CS_N), //.cs_n
.sdram_wire_dq(DRAM_DQ), //.dq
.sdram_wire_dqm({DRAM_UDQM,DRAM_LDQM}), //.dqm
.sdram_wire_ras_n(DRAM_RAS_N), //.ras_n
.sdram_wire_we_n(DRAM_WE_N), //.we_n
//USB SPI
.spi0_SS_n(SPI0_CS_N),
.spi0_MOSI(SPI0_MOSI),
.spi0_MISO(SPI0_MISO),
.spi0_SCLK(SPI0_SCLK),
//USB GPIO
.usb_rst_export(USB_RST),
.usb_irq_export(USB_IRQ),
.usb_gpx_export(USB_GPX),
//LEDs and HEX
.hex_digits_export(),
.leds_export(),
.key_code_export(keycode),
//VGA
.vga_port_red (VGA_R),
.vga_port_green (VGA_G),
.vga_port_blue (VGA_B),
.vga_port_hs (VGA_HS),
.vga_port_vs (VGA_VS),
//timer
.fps_export(fps),
.timer_reset_export(clock_reset)
);
endmodule