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

Subversion Repositories zx_ula

[/] [zx_ula/] [branches/] [xilinx/] [spectrum_48k_spartan3_starter_kit_timex_hicolor_ulaplus/] [spectrum48k_tld.v] - Blame information for rev 23

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 15 mcleod_ide
`timescale 1ns / 1ps
2
//////////////////////////////////////////////////////////////////////////////////
3
// Company:        Dept. Architecture and Computing Technology. University of Seville
4
// Engineer:       Miguel Angel Rodriguez Jodar. rodriguj@atc.us.es
5
// 
6
// Create Date:    19:13:39 4-Apr-2012 
7
// Design Name:    ZX Spectrum
8
// Module Name:    tld_spartan3_sp48k
9
// Project Name: 
10
// Target Devices: 
11
// Tool versions: 
12
// Description: 
13
//
14
// Dependencies: 
15
//
16
// Revision: 
17
// Revision 1.00 - File Created
18
// Additional Comments: GPL License policies apply to the contents of this file.
19
//
20
//////////////////////////////////////////////////////////////////////////////////
21
module tld_spartan3_sp48k (
22
    input clk50,
23
         input reset,
24
    output r,
25
    output g,
26
    output b,
27
    output i,
28
    output csync,
29
        // ULA I/O 
30
         input ear,
31
         output audio_out,
32
        // PS/2 keyboard
33
         input clkps2,
34
         input dataps2,
35
        // diagnostics
36
         output [6:0] dispcathodes,
37
         output [3:0] dispanodes,
38
         output ledreleased,
39
         output ledextended,
40
         output ledshift,
41
         output ledclk,
42
         output [3:0] ledaux,
43
        // SRAM memory
44
         output [17:0] sa,
45
         inout [7:0] sd1,
46
         output sramce1,
47
         output sramub1,
48
         output sramlb1,
49
         output sramoe,
50
         output sramwe
51
    );
52
 
53
        // CPU signals
54
        wire [15:0] a;
55
        wire [7:0] cpudout;
56
        wire [7:0] cpudin;
57
        wire clkcpu;
58
        wire mreq_n;
59
        wire iorq_n;
60
        wire wr_n;
61
        wire rd_n;
62
        wire rfsh_n;
63
        wire int_n;
64 22 mcleod_ide
        wire m1_n;
65 15 mcleod_ide
 
66
        // VRAM signals
67
        wire [13:0] va;
68
        wire [7:0] vramdin;
69
        wire [7:0] vramdout;
70
        wire vramoe;
71
        wire vramcs;
72
        wire vramwe;
73
 
74
        // I/O
75
        wire mic;
76
        wire spk;
77
        wire [4:0] kbd_columns;
78
 
79
        // ULA data bus
80
        wire [7:0] uladout;
81
        wire [7:0] uladin;
82
 
83
        // SRAM data bus
84
        wire [7:0] sramdout;
85
        wire [7:0] sramdin;
86
 
87
        // ROM data bus
88
        wire [7:0] romdout;
89
 
90
        wire sram_cs = a[15] & !mreq_n;
91 22 mcleod_ide
        wire ula_cs = !a[0] & !iorq_n & m1_n;
92 15 mcleod_ide
        wire vram_cs = !a[15] & a[14] & !mreq_n;
93 22 mcleod_ide
        wire port255_cs = !iorq_n && m1_n && a[7:0]==8'hFF && !rd_n;
94
        wire ulaplusaddr_cs = !iorq_n & m1_n & a[0] & !a[2] & a[7:6]==2'b00 & (a[15:14]==2'b10); // port BF3Bh
95
        wire ulaplusdata_cs = !iorq_n & m1_n & a[0] & !a[2] & a[7:6]==2'b00 & (a[15:14]==2'b11);  // port FF3Bh
96 15 mcleod_ide
        wire rom_cs = !a[15] & !a[14] & !mreq_n & !rd_n;
97
 
98
        /////////////////////////////////////
99 18 mcleod_ide
        // Clock generation
100 15 mcleod_ide
        /////////////////////////////////////
101 18 mcleod_ide
        wire clk56mhz;
102
   master_clock clock56mhz (
103 15 mcleod_ide
    .CLKIN_IN(clk50),
104 18 mcleod_ide
    .CLKFX_OUT(clk56mhz),
105 15 mcleod_ide
    .CLKIN_IBUFG_OUT(),
106
    .CLK0_OUT()
107
    );
108 18 mcleod_ide
        reg [1:0] cnt56;
109
        always @(posedge clk56mhz) begin
110
                cnt56 = cnt56 + 1;
111 15 mcleod_ide
        end
112 18 mcleod_ide
        wire clk28 = cnt56[0];
113
        wire clk14 = cnt56[1];
114 15 mcleod_ide
        wire clkula = clk14;
115 18 mcleod_ide
        wire clkdacvideo = clk56mhz;
116
        wire clkmem = clk28;
117
        wire clkdacaudio = clk14;
118 15 mcleod_ide
        wire clkkbd = clk14;
119
 
120
   /////////////////////////////////////
121
   // ROM
122
   /////////////////////////////////////        
123
        rom the_rom (
124
                .clka(clkmem),
125
                .ena(rom_cs),
126
                .addra(a[13:0]),
127
                .douta(romdout)
128
        );
129
 
130
   /////////////////////////////////////
131
   // VRAM and upper RAM banks
132
   /////////////////////////////////////        
133
   ram_controller vram_and_upper_ram (
134
                .clk(clkmem),
135
                // Bank 1 (VRAM)
136
                .a1({2'b00,va}),
137
                .cs1_n(!vramcs),
138
                .oe1_n(!vramoe),
139
                .we1_n(!vramwe),
140
                .din1(vramdin),
141
                .dout1(vramdout),
142
                // Bank 2 (upper RAM)
143
                .a2({1'b0,a[14:0]}),
144
                .cs2_n(!sram_cs),
145
                .oe2_n(rd_n),
146
                .we2_n(wr_n),
147
                .din2(sramdin),
148
                .dout2(sramdout),
149
                // Outputs to actual SRAM on board
150
                .sa(sa),
151
                .sd(sd1),
152
                .sramce(sramce1),
153
                .sramub(sramub1),
154
                .sramlb(sramlb1),
155
                .sramoe(sramoe),
156
                .sramwe(sramwe)
157
        );
158
 
159
   /////////////////////////////////////
160
   // The ULA
161
   /////////////////////////////////////        
162 18 mcleod_ide
        wire ula_r,ula_g,ula_b,ula_i,ulaplus_enabled;
163
        wire [7:0] rgbulaplus;
164 15 mcleod_ide
        ula the_ula (
165
                .clk14(clkula),
166
                .reset(reset),
167
                .a(a),
168
                .din(uladin),
169
                .dout(uladout),
170
                .mreq_n(mreq_n),
171
                .iorq_n(iorq_n),
172
                .rd_n(rd_n),
173
                .wr_n(wr_n),
174
                .rfsh_n(rfsh_n),
175
                .clkcpu(clkcpu),
176
                .msk_int_n(int_n),
177
                .va(va),
178
                .vramdout(vramdout),
179
                .vramdin(vramdin),
180
                .vramoe(vramoe),
181
                .vramcs(vramcs),
182
                .vramwe(vramwe),
183
                .ear(ear),
184
                .mic(mic),
185
                .spk(spk),
186
                .kbrows(),
187
                .kbcolumns(kbd_columns),
188 18 mcleod_ide
                .r(ula_r),
189
                .g(ula_g),
190
                .b(ula_b),
191
                .i(ula_i),
192
                .rgbulaplus(rgbulaplus),
193
                .ulaplus_enabled(ulaplus_enabled),
194 15 mcleod_ide
                .csync(csync)
195
        );
196
 
197
   /////////////////////////////////////
198 18 mcleod_ide
   // ULA/ULA+ video selector and enconding
199
   /////////////////////////////////////        
200
        assign i = 1;
201
   rgbdtoa video_final_stage (
202
                .clk(clkdacvideo),
203
                .reset(reset),
204
                .select(ulaplus_enabled),
205
                .ri(ula_r),
206
                .gi(ula_g),
207
                .bi(ula_b),
208
                .hi(ula_i),
209
                .rgbulap(rgbulaplus),
210
                .r(r),
211
                .g(g),
212
                .b(b)
213
    );
214
 
215
   /////////////////////////////////////
216 15 mcleod_ide
   // The CPU Z80A
217
   /////////////////////////////////////        
218 23 mcleod_ide
   tv80n_wrapper cpu (
219 15 mcleod_ide
                // Outputs
220 22 mcleod_ide
                .m1_n(m1_n),
221 15 mcleod_ide
                .mreq_n(mreq_n),
222
                .iorq_n(iorq_n),
223
                .rd_n(rd_n),
224
                .wr_n(wr_n),
225
                .rfsh_n(rfsh_n),
226
                .halt_n(),
227
                .busak_n(),
228
                .A(a),
229
                .dout(cpudout),
230
                // Inputs
231
                .reset_n(!reset),
232
                .clk(clkcpu),
233
                .wait_n(1'b1),
234
                .int_n(int_n),
235
                .nmi_n(1'b1),
236
                .busrq_n(1'b1),
237
                .di(cpudin)
238
   );
239
 
240
   /////////////////////////////////////
241
   // CPU data bus
242
   /////////////////////////////////////        
243
        assign sramdin = cpudout;
244
        assign uladin = cpudout;
245
        assign cpudin = (rom_cs)? romdout :
246
                        (ula_cs | vram_cs | port255_cs | ulaplusaddr_cs | ulaplusdata_cs)? uladout :
247
                                                 (sram_cs)? sramdout :
248
                                                            8'hFF;
249
 
250
   /////////////////////////////////////
251
   // Audio mixer
252
   /////////////////////////////////////        
253
        mixer audio_mix (
254 18 mcleod_ide
                .clkdac(clkdacaudio),
255 15 mcleod_ide
                .reset(reset),
256
                .ear(ear),
257
                .mic(mic),
258
                .spk(spk),
259
                .audio(audio_out)
260
        );
261
 
262
   /////////////////////////////////////
263
   // PS2 Keyboard
264
   /////////////////////////////////////        
265
        wire [7:0] kbdscancode;
266
 
267
        ps2kbd keyboard (
268
                .clk(clkkbd),
269
                .reset(reset),
270
                .clkps2(clkps2),
271
                .dataps2(dataps2),
272
                .ledextended(ledextended),
273
                .ledreleased(ledreleased),
274
                .ledmayus(ledshift),
275
                .scancode(kbdscancode),
276
                .semifila(a[15:8]),
277
                .columna(kbd_columns)
278
    );
279
 
280
   /////////////////////////////////////
281
   // Diagnostics
282
   /////////////////////////////////////        
283
        display numeric_display (
284
    .clk(clkkbd),
285
    .load(int_n),
286
    .valor({8'h00,kbdscancode}),
287
    .an(dispanodes),
288
    .seg(dispcathodes)
289
    );
290
 
291
        reg [19:0] divclkcpu = 0;
292
        assign ledclk = divclkcpu[19]; // a simple "hearbeat" blink to let us know that the CPU is running.
293
        always @(posedge clkcpu)
294
                divclkcpu <= divclkcpu + 1;
295
        assign ledaux = 4'b0000;
296
 
297
endmodule

powered by: WebSVN 2.1.0

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