OpenCores
URL https://opencores.org/ocsvn/aoocs/aoocs/trunk

Subversion Repositories aoocs

[/] [aoocs/] [trunk/] [rtl/] [terasic_de2_70/] [drv_debug.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 alfik
/*
2
 * Copyright 2010, Aleksander Osman, alfik@poczta.fm. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without modification, are
5
 * permitted provided that the following conditions are met:
6
 *
7
 *  1. Redistributions of source code must retain the above copyright notice, this list of
8
 *     conditions and the following disclaimer.
9
 *
10
 *  2. Redistributions in binary form must reproduce the above copyright notice, this list
11
 *     of conditions and the following disclaimer in the documentation and/or other materials
12
 *     provided with the distribution.
13
 *
14
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
15
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16
 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
17
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20
 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
 */
24
 
25
/*! \file
26
 * \brief Switches and hex leds driver for debug purposes.
27
 */
28
 
29
/*! \brief \copybrief drv_debug.v
30
*/
31
module drv_debug(
32
    //% \name Clock and reset
33
    //% @{
34
    input           CLK_I,
35
    input           reset_n,
36
    //% @}
37
 
38
    //% \name Internal debug signals
39
    //% @{
40
    input [31:2]    master_adr_o,
41
    input [31:0]    debug_pc,
42
    input [7:0]     debug_syscon,
43
    input [7:0]     debug_track,
44
    //% @}
45
 
46
    //% \name Switches and hex leds hardware interface
47
    //% @{
48
    // hex output
49
    output [7:0]    hex0,
50
    output [7:0]    hex1,
51
    output [7:0]    hex2,
52
    output [7:0]    hex3,
53
    output [7:0]    hex4,
54
    output [7:0]    hex5,
55
    output [7:0]    hex6,
56
    output [7:0]    hex7,
57
    // switches input
58
    input           debug_sw_pc,
59
    input           debug_sw_adr
60
    //% @}
61
);
62
 
63
assign hex0 =
64
    (display[3:0] == 4'd0) ?    ~8'b00111111 :
65
    (display[3:0] == 4'd1) ?    ~8'b00000110 :
66
    (display[3:0] == 4'd2) ?    ~8'b01011011 :
67
    (display[3:0] == 4'd3) ?    ~8'b01001111 :
68
    (display[3:0] == 4'd4) ?    ~8'b01100110 :
69
    (display[3:0] == 4'd5) ?    ~8'b01101101 :
70
    (display[3:0] == 4'd6) ?    ~8'b01111101 :
71
    (display[3:0] == 4'd7) ?    ~8'b00000111 :
72
    (display[3:0] == 4'd8) ?    ~8'b01111111 :
73
    (display[3:0] == 4'd9) ?    ~8'b01101111 :
74
    (display[3:0] == 4'd10) ?   ~8'b01110111 :
75
    (display[3:0] == 4'd11) ?   ~8'b01111100 :
76
    (display[3:0] == 4'd12) ?   ~8'b00111001 :
77
    (display[3:0] == 4'd13) ?   ~8'b01011110 :
78
    (display[3:0] == 4'd14) ?   ~8'b01111001 :
79
                                ~8'b01110001;
80
assign hex1 =
81
    (display[7:4] == 4'd0) ?    ~8'b00111111 :
82
    (display[7:4] == 4'd1) ?    ~8'b00000110 :
83
    (display[7:4] == 4'd2) ?    ~8'b01011011 :
84
    (display[7:4] == 4'd3) ?    ~8'b01001111 :
85
    (display[7:4] == 4'd4) ?    ~8'b01100110 :
86
    (display[7:4] == 4'd5) ?    ~8'b01101101 :
87
    (display[7:4] == 4'd6) ?    ~8'b01111101 :
88
    (display[7:4] == 4'd7) ?    ~8'b00000111 :
89
    (display[7:4] == 4'd8) ?    ~8'b01111111 :
90
    (display[7:4] == 4'd9) ?    ~8'b01101111 :
91
    (display[7:4] == 4'd10) ?   ~8'b01110111 :
92
    (display[7:4] == 4'd11) ?   ~8'b01111100 :
93
    (display[7:4] == 4'd12) ?   ~8'b00111001 :
94
    (display[7:4] == 4'd13) ?   ~8'b01011110 :
95
    (display[7:4] == 4'd14) ?   ~8'b01111001 :
96
                                ~8'b01110001;
97
assign hex2 =
98
    (display[11:8] == 4'd0) ?   ~8'b00111111 :
99
    (display[11:8] == 4'd1) ?   ~8'b00000110 :
100
    (display[11:8] == 4'd2) ?   ~8'b01011011 :
101
    (display[11:8] == 4'd3) ?   ~8'b01001111 :
102
    (display[11:8] == 4'd4) ?   ~8'b01100110 :
103
    (display[11:8] == 4'd5) ?   ~8'b01101101 :
104
    (display[11:8] == 4'd6) ?   ~8'b01111101 :
105
    (display[11:8] == 4'd7) ?   ~8'b00000111 :
106
    (display[11:8] == 4'd8) ?   ~8'b01111111 :
107
    (display[11:8] == 4'd9) ?   ~8'b01101111 :
108
    (display[11:8] == 4'd10) ?  ~8'b01110111 :
109
    (display[11:8] == 4'd11) ?  ~8'b01111100 :
110
    (display[11:8] == 4'd12) ?  ~8'b00111001 :
111
    (display[11:8] == 4'd13) ?  ~8'b01011110 :
112
    (display[11:8] == 4'd14) ?  ~8'b01111001 :
113
                                ~8'b01110001;
114
assign hex3 =
115
    (display[15:12] == 4'd0) ?  ~8'b00111111 :
116
    (display[15:12] == 4'd1) ?  ~8'b00000110 :
117
    (display[15:12] == 4'd2) ?  ~8'b01011011 :
118
    (display[15:12] == 4'd3) ?  ~8'b01001111 :
119
    (display[15:12] == 4'd4) ?  ~8'b01100110 :
120
    (display[15:12] == 4'd5) ?  ~8'b01101101 :
121
    (display[15:12] == 4'd6) ?  ~8'b01111101 :
122
    (display[15:12] == 4'd7) ?  ~8'b00000111 :
123
    (display[15:12] == 4'd8) ?  ~8'b01111111 :
124
    (display[15:12] == 4'd9) ?  ~8'b01101111 :
125
    (display[15:12] == 4'd10) ? ~8'b01110111 :
126
    (display[15:12] == 4'd11) ? ~8'b01111100 :
127
    (display[15:12] == 4'd12) ? ~8'b00111001 :
128
    (display[15:12] == 4'd13) ? ~8'b01011110 :
129
    (display[15:12] == 4'd14) ? ~8'b01111001 :
130
                                ~8'b01110001;
131
assign hex4 =
132
    (display[19:16] == 4'd0) ?  ~8'b00111111 :
133
    (display[19:16] == 4'd1) ?  ~8'b00000110 :
134
    (display[19:16] == 4'd2) ?  ~8'b01011011 :
135
    (display[19:16] == 4'd3) ?  ~8'b01001111 :
136
    (display[19:16] == 4'd4) ?  ~8'b01100110 :
137
    (display[19:16] == 4'd5) ?  ~8'b01101101 :
138
    (display[19:16] == 4'd6) ?  ~8'b01111101 :
139
    (display[19:16] == 4'd7) ?  ~8'b00000111 :
140
    (display[19:16] == 4'd8) ?  ~8'b01111111 :
141
    (display[19:16] == 4'd9) ?  ~8'b01101111 :
142
    (display[19:16] == 4'd10) ? ~8'b01110111 :
143
    (display[19:16] == 4'd11) ? ~8'b01111100 :
144
    (display[19:16] == 4'd12) ? ~8'b00111001 :
145
    (display[19:16] == 4'd13) ? ~8'b01011110 :
146
    (display[19:16] == 4'd14) ? ~8'b01111001 :
147
                                ~8'b01110001;
148
assign hex5 =
149
    (display[23:20] == 4'd0) ?  ~8'b00111111 :
150
    (display[23:20] == 4'd1) ?  ~8'b00000110 :
151
    (display[23:20] == 4'd2) ?  ~8'b01011011 :
152
    (display[23:20] == 4'd3) ?  ~8'b01001111 :
153
    (display[23:20] == 4'd4) ?  ~8'b01100110 :
154
    (display[23:20] == 4'd5) ?  ~8'b01101101 :
155
    (display[23:20] == 4'd6) ?  ~8'b01111101 :
156
    (display[23:20] == 4'd7) ?  ~8'b00000111 :
157
    (display[23:20] == 4'd8) ?  ~8'b01111111 :
158
    (display[23:20] == 4'd9) ?  ~8'b01101111 :
159
    (display[23:20] == 4'd10) ? ~8'b01110111 :
160
    (display[23:20] == 4'd11) ? ~8'b01111100 :
161
    (display[23:20] == 4'd12) ? ~8'b00111001 :
162
    (display[23:20] == 4'd13) ? ~8'b01011110 :
163
    (display[23:20] == 4'd14) ? ~8'b01111001 :
164
                                ~8'b01110001;
165
assign hex6 =
166
    (display[27:24] == 4'd0) ?  ~8'b00111111 :
167
    (display[27:24] == 4'd1) ?  ~8'b00000110 :
168
    (display[27:24] == 4'd2) ?  ~8'b01011011 :
169
    (display[27:24] == 4'd3) ?  ~8'b01001111 :
170
    (display[27:24] == 4'd4) ?  ~8'b01100110 :
171
    (display[27:24] == 4'd5) ?  ~8'b01101101 :
172
    (display[27:24] == 4'd6) ?  ~8'b01111101 :
173
    (display[27:24] == 4'd7) ?  ~8'b00000111 :
174
    (display[27:24] == 4'd8) ?  ~8'b01111111 :
175
    (display[27:24] == 4'd9) ?  ~8'b01101111 :
176
    (display[27:24] == 4'd10) ? ~8'b01110111 :
177
    (display[27:24] == 4'd11) ? ~8'b01111100 :
178
    (display[27:24] == 4'd12) ? ~8'b00111001 :
179
    (display[27:24] == 4'd13) ? ~8'b01011110 :
180
    (display[27:24] == 4'd14) ? ~8'b01111001 :
181
                                ~8'b01110001;
182
assign hex7 =
183
    (display[31:28] == 4'd0) ?  ~8'b00111111 :
184
    (display[31:28] == 4'd1) ?  ~8'b00000110 :
185
    (display[31:28] == 4'd2) ?  ~8'b01011011 :
186
    (display[31:28] == 4'd3) ?  ~8'b01001111 :
187
    (display[31:28] == 4'd4) ?  ~8'b01100110 :
188
    (display[31:28] == 4'd5) ?  ~8'b01101101 :
189
    (display[31:28] == 4'd6) ?  ~8'b01111101 :
190
    (display[31:28] == 4'd7) ?  ~8'b00000111 :
191
    (display[31:28] == 4'd8) ?  ~8'b01111111 :
192
    (display[31:28] == 4'd9) ?  ~8'b01101111 :
193
    (display[31:28] == 4'd10) ? ~8'b01110111 :
194
    (display[31:28] == 4'd11) ? ~8'b01111100 :
195
    (display[31:28] == 4'd12) ? ~8'b00111001 :
196
    (display[31:28] == 4'd13) ? ~8'b01011110 :
197
    (display[31:28] == 4'd14) ? ~8'b01111001 :
198
                                ~8'b01110001;
199
reg [31:0] display;
200
 
201
always @(posedge CLK_I or negedge reset_n) begin
202
    if(reset_n == 1'b0) begin
203
        display <= 32'd0;
204
    end
205
    else begin
206
        if(debug_sw_pc == 1'b1)         display <= debug_pc;
207
        else if(debug_sw_adr == 1'b1)   display <= {master_adr_o[31:2], 2'b00 };
208
        else                            display <= { debug_track, 16'd0, debug_syscon };
209
    end
210
end
211
endmodule
212
 
213
// ---------------- general DEBUG
214
/*
215
wire debug_write;
216
assign debug_write =    master1_cyc_o == 1'b1 && master1_stb_o == 1'b1 && master1_we_o == 1'b0 && master1_adr_o != last_addr &&
217
                        ({master1_adr_o[31:2], 2'b00} >= 32'h00DFF000) && ({master1_adr_o[31:2], 2'b00} <= 32'h00DFF01C);
218
 
219
reg [11:0] debug_addr;
220
reg [31:2] last_addr;
221
always @(posedge clk_30 or negedge reset_n) begin
222
    if(reset_n == 1'b0)                                         last_addr <= 30'd0;
223
    else                                                        last_addr <= master1_adr_o;
224
end
225
 
226
always @(posedge clk_30 or negedge reset_n) begin
227
    if(reset_n == 1'b0)                                       debug_addr <= 12'd0;
228
    else if(debug_write == 1'b1 //&& debug_addr < 12'd4095//) debug_addr <= debug_addr + 12'd1;
229
end
230
 
231
altsyncram debug_ram_inst(
232
    .clock0(clk_30),
233
 
234
    .address_a(debug_addr),
235
    .wren_a(debug_write == 1'b1),
236
    .data_a( { 3'b0, master1_adr_o[8:2], 2'b00} ),
237
    .q_a()
238
);
239
defparam
240
    debug_ram_inst.operation_mode = "SINGLE_PORT",
241
    debug_ram_inst.width_a = 12,
242
    debug_ram_inst.lpm_hint = "ENABLE_RUNTIME_MOD=YES,INSTANCE_NAME=mem",
243
    debug_ram_inst.widthad_a = 12;
244
*/
245
 
246
/*
247
// ----------------------------- copper DEBUG
248
wire debug_write;
249
assign debug_write = (state == S_SAVE && ACK_I == 1'b1);
250
 
251
reg [7:0] debug_addr;
252
always @(posedge CLK_I) begin
253
    if(line_start == 1'b1 && line_number == 9'd0)   debug_addr <= 8'd0;
254
    else if(debug_write == 1'b1 && debug_addr < 8'd255) debug_addr <= debug_addr + 8'd1;
255
end
256
 
257
altsyncram debug_ram_inst(
258
    .clock0(CLK_I),
259
 
260
    .address_a(debug_addr),
261
    .wren_a(debug_write == 1'b1),
262
    .data_a({3'b0, line_number, ir}),
263
    .q_a()
264
);
265
defparam
266
    debug_ram_inst.operation_mode = "SINGLE_PORT",
267
    debug_ram_inst.width_a = 60,
268
    debug_ram_inst.lpm_hint = "ENABLE_RUNTIME_MOD=YES,INSTANCE_NAME=cop",
269
    debug_ram_inst.widthad_a = 8;
270
*/
271
 
272
//------------------------- video DEBUG
273
/*
274
altsyncram debug_ram_inst(
275
    .clock0(CLK_I),
276
 
277
    .address_a(bitplain_ram_addr),
278
    .wren_a(burst_read_ready == 1'b1 && burst_read_request == 1'b1 && line_number == 9'hF4),
279
    .data_a({dma_address_full, (dma_address_full[1] == 1'b0) ? burst_read_data : {even_data, burst_read_data[31:16]}, 3'b0, burst_read_enabled }),
280
    .q_a()
281
);
282
defparam
283
    debug_ram_inst.operation_mode = "SINGLE_PORT",
284
    debug_ram_inst.width_a = 68,
285
    debug_ram_inst.lpm_hint = "ENABLE_RUNTIME_MOD=YES,INSTANCE_NAME=bpl",
286
    debug_ram_inst.widthad_a = 5;
287
*/
288
/*
289
wire debug_write;
290
assign debug_write = (line_number >= 9'd64 && write_ena == 1'b1 && write_address == 1'b0);
291
 
292
reg [7:0] debug_addr;
293
always @(posedge CLK_I or negedge reset_n) begin
294
    if(reset_n == 1'b0)             debug_addr <= 8'd0;
295
    else if(debug_write == 1'b1)    debug_addr <= debug_addr + 8'd1;
296
end
297
 
298
altsyncram debug_ram_inst(
299
    .clock0(CLK_I),
300
 
301
    .address_a(debug_addr),
302
    .wren_a(debug_write == 1'b1),
303
    .data_a( { 3'b0, line_number, 3'b0, column_number, 2'b0, dma_state, write_sel, write_data, dma_address_full } ),
304
    .q_a()
305
);
306
defparam
307
    debug_ram_inst.operation_mode = "SINGLE_PORT",
308
    debug_ram_inst.width_a = 96,
309
    debug_ram_inst.lpm_hint = "ENABLE_RUNTIME_MOD=YES,INSTANCE_NAME=mem",
310
    debug_ram_inst.widthad_a = 8;
311
*/
312
 
313
// ---------------- floppy DEBUG
314
/*
315
wire debug_write;
316
assign debug_write = (buffer_read_cycle == 1'b1 && state != S_WRITE_TO_SD);
317
 
318
reg [7:0] debug_addr;
319
always @(posedge clk_30 or negedge reset_n) begin
320
    if(reset_n == 1'b0)                                         debug_addr <= 8'd0;
321
    else if(debug_write == 1'b1 && debug_addr < 8'd255)         debug_addr <= debug_addr + 8'd1;
322
end
323
 
324
altsyncram debug_ram_inst(
325
    .clock0(clk_30),
326
 
327
    .address_a(debug_addr),
328
    .wren_a(debug_write == 1'b1),
329
    .data_a( { mfm_decoder[11:8], dsklen, dskptr, 4'b1111 } ),
330
    .q_a()
331
);
332
defparam
333
    debug_ram_inst.operation_mode = "SINGLE_PORT",
334
    debug_ram_inst.width_a = 56,
335
    debug_ram_inst.lpm_hint = "ENABLE_RUNTIME_MOD=YES,INSTANCE_NAME=flop",
336
    debug_ram_inst.widthad_a = 8;
337
*/
338
 
339
//------------------------------------------------- video_priority DEBUG
340
/*
341
altsyncram debug_ram_inst(
342
    .clock0(CLK_I),
343
 
344
    .address_a(line_ram_addr),
345
    .wren_a(line_ena == 1'b1 && line_number == 9'd150 && column_number >= 9'h81 &&
346
        ((column_number == 9'h1C1 && line_ram_counter == 3'd1) || (column_number < 9'h1C1 && line_ram_counter == 3'd3))),
347
    .data_a((column_number == 9'h1C1 && line_ram_counter == 3'd1)? { final_color_value, 24'd0 } : { line_ram_data[23:0], final_color_value }),
348
    .q_a()
349
);
350
defparam
351
    debug_ram_inst.operation_mode = "SINGLE_PORT",
352
    debug_ram_inst.width_a = 36,
353
    debug_ram_inst.lpm_hint = "ENABLE_RUNTIME_MOD=YES,INSTANCE_NAME=mem",
354
    debug_ram_inst.widthad_a = 8;
355
*/
356
 
357
// ----------------------------- cia8520 DEBUG
358
/*
359
wire debug_write;
360
assign debug_write =    (last_irq_n == 1'b1 && irq_n == 1'b0);
361
 
362
reg last_irq_n;
363
always @(posedge CLK_I or negedge reset_n) begin
364
    if(reset_n == 1'b0) last_irq_n <= 1'b1;
365
    else                last_irq_n <= irq_n;
366
end
367
 
368
reg [7:0] debug_addr;
369
always @(posedge CLK_I) begin
370
    if(debug_write == 1'b1 && debug_addr < 8'd255) debug_addr <= debug_addr + 8'd1;
371
end
372
 
373
altsyncram debug_ram_inst(
374
    .clock0(CLK_I),
375
 
376
    .address_a(debug_addr),
377
    .wren_a(debug_write == 1'b1),
378
    .data_a( {2'b0, icr_mask, 2'b0, icr_data, last_cnt_i, cnt_i, cra, serial_latch } ),
379
    .q_a()
380
);
381
defparam
382
    debug_ram_inst.operation_mode = "SINGLE_PORT",
383
    debug_ram_inst.width_a = 32,
384
    debug_ram_inst.lpm_hint = "ENABLE_RUNTIME_MOD=YES,INSTANCE_NAME=cia",
385
    debug_ram_inst.widthad_a = 8;
386
*/

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.