-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_sdd.v
339 lines (320 loc) · 9.49 KB
/
test_sdd.v
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
/*
*/
`default_nettype none
`timescale 1ns/1ps
module test_sdd(
input wire clk_25mhz,
inout wire [GPIO_NR -1:0] gpio,
output wire [24:21] gn,
output wire [24:21] gp
);
//localparam SYSTEM_CLK = 110_000_000;
localparam SYSTEM_CLK = 80_000_000;
localparam GPIO_NR = 8;
/* gpio */
reg [GPIO_NR -1:0] gpio_output_en;
wire [GPIO_NR -1:0] gpio_in;
reg [GPIO_NR -1:0] gpio_output_val;
wire [31:0] mem_din;
wire gpio_output_wr;
wire gpio_output_val_wr;
wire gpio_output_en_wr;
/* input */
assign gpio_in = gpio;
/* output */
genvar i;
generate
for (i = 0; i < GPIO_NR; i = i +1) begin
assign gpio[i] = gpio_output_en[i] ? gpio_output_val[i] : 1'bz;
end
endgenerate
always @(posedge clk) begin
if (!resetn) begin
gpio_output_en <= 0; // default all is input pin
gpio_output_val <= 0; // digilent led 0: off 1:0
end else begin
gpio_output_val <= gpio_output_val_wr ? mem_din[GPIO_NR -1:0] : gpio_output_val;
gpio_output_en <= gpio_output_en_wr ? mem_din[GPIO_NR -1:0] : gpio_output_en;
end
end
// reset
reg [15:0] reset_cnt = 0;
wire resetn = 0;
always @(posedge clk) begin
if (reset_cnt == 0) begin
resetn <= 1;
end else begin
resetn <= 0;
end
reset_cnt <= reset_cnt + {14'b0, !resetn};
end
//wire clk = clk_25mhz;
wire clk;
pll #(SYSTEM_CLK/1_000_000) pll_i(clk_25mhz, clk);
wire oled_cs;
wire oled_mosi;
wire oled_sck;
wire oled_dc;
wire oled_rst;
wire oled_vccen;
wire oled_pmoden;
reg [7:0] oled_x_dc;
reg [7:0] oled_y_data;
reg [15:0] oled_rgb;
reg oled_strobe;
reg oled_setpixel_raw8tx;
wire oled_ready;
wire oled_valid;
assign gn[24] = oled_cs;
assign gn[23] = oled_mosi;
assign gn[21] = oled_sck;
assign gp[24] = oled_dc;
assign gp[23] = oled_rst;
assign gp[22] = oled_vccen;
assign gp[21] = oled_pmoden;
sdd1331_gen_pattern ssd_clk(
.clk(clk),
.out_hcnt(oled_x_dc),
.out_vcnt(oled_y_data),
.rgb(oled_rgb),
.rst(~resetn)
);
oled_ssd1331 #(.SYSTEM_CLK(SYSTEM_CLK))
oled_ssd1331_i(
.clk(clk),
.resetn(resetn),
.oled_rst(oled_rst),
.strobe(oled_strobe),
.setpixel_raw8tx(oled_setpixel_raw8tx),
.x_dc(oled_x_dc),
.y_data(oled_y_data),
.rgb(oled_rgb),
.ready(oled_ready),
.valid(oled_valid),
.spi_cs(oled_cs),
.spi_dc(oled_dc),
.spi_mosi(oled_mosi),
.spi_sck(oled_sck),
.vccen(oled_vccen),
.pmoden(oled_pmoden)
);
endmodule
/*
* Do not edit this file, it was generated by gen_pll.sh
*
* FPGA kind : ECP5
* Input frequency: 25 MHz
*/
module pll #(
parameter freq = 40
) (
input wire pclk,
output wire clk
);
(* ICP_CURRENT="12" *) (* LPF_RESISTOR="8" *) (* MFG_ENABLE_FILTEROPAMP="1" *) (* MFG_GMCREF_SEL="2" *)
EHXPLLL pll_i (
.RST(1'b0),
.STDBY(1'b0),
.CLKI(pclk),
.CLKOP(clk),
.CLKFB(clk),
.CLKINTFB(),
.PHASESEL0(1'b0),
.PHASESEL1(1'b0),
.PHASEDIR(1'b1),
.PHASESTEP(1'b1),
.PHASELOADREG(1'b1),
.PLLWAKESYNC(1'b0),
.ENCLKOP(1'b0)
);
defparam pll_i.PLLRST_ENA = "DISABLED";
defparam pll_i.INTFB_WAKE = "DISABLED";
defparam pll_i.STDBY_ENABLE = "DISABLED";
defparam pll_i.DPHASE_SOURCE = "DISABLED";
defparam pll_i.OUTDIVIDER_MUXA = "DIVA";
defparam pll_i.OUTDIVIDER_MUXB = "DIVB";
defparam pll_i.OUTDIVIDER_MUXC = "DIVC";
defparam pll_i.OUTDIVIDER_MUXD = "DIVD";
defparam pll_i.CLKOP_ENABLE = "ENABLED";
defparam pll_i.CLKOP_FPHASE = 0;
defparam pll_i.FEEDBK_PATH = "CLKOP";
generate
case(freq)
16: begin
defparam pll_i.CLKI_DIV=8;
defparam pll_i.CLKOP_DIV=38;
defparam pll_i.CLKOP_CPHASE=18;
defparam pll_i.CLKFB_DIV=5;
end
20: begin
defparam pll_i.CLKI_DIV=5;
defparam pll_i.CLKOP_DIV=30;
defparam pll_i.CLKOP_CPHASE=15;
defparam pll_i.CLKFB_DIV=4;
end
24: begin
defparam pll_i.CLKI_DIV=1;
defparam pll_i.CLKOP_DIV=24;
defparam pll_i.CLKOP_CPHASE=11;
defparam pll_i.CLKFB_DIV=1;
end
25: begin
defparam pll_i.CLKI_DIV=1;
defparam pll_i.CLKOP_DIV=24;
defparam pll_i.CLKOP_CPHASE=11;
defparam pll_i.CLKFB_DIV=1;
end
30: begin
defparam pll_i.CLKI_DIV=5;
defparam pll_i.CLKOP_DIV=20;
defparam pll_i.CLKOP_CPHASE=9;
defparam pll_i.CLKFB_DIV=6;
end
35: begin
defparam pll_i.CLKI_DIV=5;
defparam pll_i.CLKOP_DIV=17;
defparam pll_i.CLKOP_CPHASE=8;
defparam pll_i.CLKFB_DIV=7;
end
40: begin
defparam pll_i.CLKI_DIV=5;
defparam pll_i.CLKOP_DIV=15;
defparam pll_i.CLKOP_CPHASE=7;
defparam pll_i.CLKFB_DIV=8;
end
45: begin
defparam pll_i.CLKI_DIV=5;
defparam pll_i.CLKOP_DIV=13;
defparam pll_i.CLKOP_CPHASE=6;
defparam pll_i.CLKFB_DIV=9;
end
48: begin
defparam pll_i.CLKI_DIV=8;
defparam pll_i.CLKOP_DIV=13;
defparam pll_i.CLKOP_CPHASE=6;
defparam pll_i.CLKFB_DIV=15;
end
50: begin
defparam pll_i.CLKI_DIV=1;
defparam pll_i.CLKOP_DIV=12;
defparam pll_i.CLKOP_CPHASE=5;
defparam pll_i.CLKFB_DIV=2;
end
55: begin
defparam pll_i.CLKI_DIV=5;
defparam pll_i.CLKOP_DIV=11;
defparam pll_i.CLKOP_CPHASE=5;
defparam pll_i.CLKFB_DIV=11;
end
60: begin
defparam pll_i.CLKI_DIV=5;
defparam pll_i.CLKOP_DIV=10;
defparam pll_i.CLKOP_CPHASE=4;
defparam pll_i.CLKFB_DIV=12;
end
65: begin
defparam pll_i.CLKI_DIV=5;
defparam pll_i.CLKOP_DIV=9;
defparam pll_i.CLKOP_CPHASE=4;
defparam pll_i.CLKFB_DIV=13;
end
66: begin
defparam pll_i.CLKI_DIV=8;
defparam pll_i.CLKOP_DIV=9;
defparam pll_i.CLKOP_CPHASE=4;
defparam pll_i.CLKFB_DIV=21;
end
70: begin
defparam pll_i.CLKI_DIV=5;
defparam pll_i.CLKOP_DIV=9;
defparam pll_i.CLKOP_CPHASE=4;
defparam pll_i.CLKFB_DIV=14;
end
75: begin
defparam pll_i.CLKI_DIV=1;
defparam pll_i.CLKOP_DIV=8;
defparam pll_i.CLKOP_CPHASE=4;
defparam pll_i.CLKFB_DIV=3;
end
80: begin
defparam pll_i.CLKI_DIV=5;
defparam pll_i.CLKOP_DIV=7;
defparam pll_i.CLKOP_CPHASE=3;
defparam pll_i.CLKFB_DIV=16;
end
85: begin
defparam pll_i.CLKI_DIV=5;
defparam pll_i.CLKOP_DIV=7;
defparam pll_i.CLKOP_CPHASE=3;
defparam pll_i.CLKFB_DIV=17;
end
90: begin
defparam pll_i.CLKI_DIV=5;
defparam pll_i.CLKOP_DIV=7;
defparam pll_i.CLKOP_CPHASE=3;
defparam pll_i.CLKFB_DIV=18;
end
95: begin
defparam pll_i.CLKI_DIV=5;
defparam pll_i.CLKOP_DIV=6;
defparam pll_i.CLKOP_CPHASE=3;
defparam pll_i.CLKFB_DIV=19;
end
100: begin
defparam pll_i.CLKI_DIV=1;
defparam pll_i.CLKOP_DIV=6;
defparam pll_i.CLKOP_CPHASE=2;
defparam pll_i.CLKFB_DIV=4;
end
105: begin
defparam pll_i.CLKI_DIV=5;
defparam pll_i.CLKOP_DIV=6;
defparam pll_i.CLKOP_CPHASE=2;
defparam pll_i.CLKFB_DIV=21;
end
110: begin
defparam pll_i.CLKI_DIV=5;
defparam pll_i.CLKOP_DIV=5;
defparam pll_i.CLKOP_CPHASE=2;
defparam pll_i.CLKFB_DIV=22;
end
115: begin
defparam pll_i.CLKI_DIV=5;
defparam pll_i.CLKOP_DIV=5;
defparam pll_i.CLKOP_CPHASE=2;
defparam pll_i.CLKFB_DIV=23;
end
120: begin
defparam pll_i.CLKI_DIV=5;
defparam pll_i.CLKOP_DIV=5;
defparam pll_i.CLKOP_CPHASE=2;
defparam pll_i.CLKFB_DIV=24;
end
125: begin
defparam pll_i.CLKI_DIV=1;
defparam pll_i.CLKOP_DIV=5;
defparam pll_i.CLKOP_CPHASE=2;
defparam pll_i.CLKFB_DIV=5;
end
130: begin
defparam pll_i.CLKI_DIV=5;
defparam pll_i.CLKOP_DIV=5;
defparam pll_i.CLKOP_CPHASE=2;
defparam pll_i.CLKFB_DIV=26;
end
135: begin
defparam pll_i.CLKI_DIV=5;
defparam pll_i.CLKOP_DIV=4;
defparam pll_i.CLKOP_CPHASE=2;
defparam pll_i.CLKFB_DIV=27;
end
140: begin
defparam pll_i.CLKI_DIV=5;
defparam pll_i.CLKOP_DIV=4;
defparam pll_i.CLKOP_CPHASE=1;
defparam pll_i.CLKFB_DIV=28;
end
default: UNKNOWN_FREQUENCY unknown_frequency();
endcase
endgenerate
endmodule