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 18

Go to most recent revision | 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
 
65
        // VRAM signals
66
        wire [13:0] va;
67
        wire [7:0] vramdin;
68
        wire [7:0] vramdout;
69
        wire vramoe;
70
        wire vramcs;
71
        wire vramwe;
72
 
73
        // I/O
74
        wire mic;
75
        wire spk;
76
        wire [4:0] kbd_columns;
77
 
78
        // ULA data bus
79
        wire [7:0] uladout;
80
        wire [7:0] uladin;
81
 
82
        // SRAM data bus
83
        wire [7:0] sramdout;
84
        wire [7:0] sramdin;
85
 
86
        // ROM data bus
87
        wire [7:0] romdout;
88
 
89
        wire sram_cs = a[15] & !mreq_n;
90
        wire ula_cs = !a[0] & !iorq_n;
91
        wire vram_cs = !a[15] & a[14] & !mreq_n;
92
        wire port255_cs = !iorq_n && a[7:0]==8'hFF && !rd_n;
93
        wire ulaplusaddr_cs = !iorq_n & a[0] & !a[2] & a[7:6]==2'b00 & (a[15:14]==2'b10); // port BF3Bh
94
        wire ulaplusdata_cs = !iorq_n & a[0] & !a[2] & a[7:6]==2'b00 & (a[15:14]==2'b11);  // port FF3Bh
95
        wire rom_cs = !a[15] & !a[14] & !mreq_n & !rd_n;
96
 
97
        /////////////////////////////////////
98 18 mcleod_ide
        // Clock generation
99 15 mcleod_ide
        /////////////////////////////////////
100 18 mcleod_ide
        wire clk56mhz;
101
   master_clock clock56mhz (
102 15 mcleod_ide
    .CLKIN_IN(clk50),
103 18 mcleod_ide
    .CLKFX_OUT(clk56mhz),
104 15 mcleod_ide
    .CLKIN_IBUFG_OUT(),
105
    .CLK0_OUT()
106
    );
107 18 mcleod_ide
        reg [1:0] cnt56;
108
        always @(posedge clk56mhz) begin
109
                cnt56 = cnt56 + 1;
110 15 mcleod_ide
        end
111 18 mcleod_ide
        wire clk28 = cnt56[0];
112
        wire clk14 = cnt56[1];
113 15 mcleod_ide
        wire clkula = clk14;
114 18 mcleod_ide
        wire clkdacvideo = clk56mhz;
115
        wire clkmem = clk28;
116
        wire clkdacaudio = clk14;
117 15 mcleod_ide
        wire clkkbd = clk14;
118
 
119
   /////////////////////////////////////
120
   // ROM
121
   /////////////////////////////////////        
122
        rom the_rom (
123
                .clka(clkmem),
124
                .ena(rom_cs),
125
                .addra(a[13:0]),
126
                .douta(romdout)
127
        );
128
 
129
   /////////////////////////////////////
130
   // VRAM and upper RAM banks
131
   /////////////////////////////////////        
132
   ram_controller vram_and_upper_ram (
133
                .clk(clkmem),
134
                // Bank 1 (VRAM)
135
                .a1({2'b00,va}),
136
                .cs1_n(!vramcs),
137
                .oe1_n(!vramoe),
138
                .we1_n(!vramwe),
139
                .din1(vramdin),
140
                .dout1(vramdout),
141
                // Bank 2 (upper RAM)
142
                .a2({1'b0,a[14:0]}),
143
                .cs2_n(!sram_cs),
144
                .oe2_n(rd_n),
145
                .we2_n(wr_n),
146
                .din2(sramdin),
147
                .dout2(sramdout),
148
                // Outputs to actual SRAM on board
149
                .sa(sa),
150
                .sd(sd1),
151
                .sramce(sramce1),
152
                .sramub(sramub1),
153
                .sramlb(sramlb1),
154
                .sramoe(sramoe),
155
                .sramwe(sramwe)
156
        );
157
 
158
   /////////////////////////////////////
159
   // The ULA
160
   /////////////////////////////////////        
161 18 mcleod_ide
        wire ula_r,ula_g,ula_b,ula_i,ulaplus_enabled;
162
        wire [7:0] rgbulaplus;
163 15 mcleod_ide
        ula the_ula (
164
                .clk14(clkula),
165
                .reset(reset),
166
                .a(a),
167
                .din(uladin),
168
                .dout(uladout),
169
                .mreq_n(mreq_n),
170
                .iorq_n(iorq_n),
171
                .rd_n(rd_n),
172
                .wr_n(wr_n),
173
                .rfsh_n(rfsh_n),
174
                .clkcpu(clkcpu),
175
                .msk_int_n(int_n),
176
                .va(va),
177
                .vramdout(vramdout),
178
                .vramdin(vramdin),
179
                .vramoe(vramoe),
180
                .vramcs(vramcs),
181
                .vramwe(vramwe),
182
                .ear(ear),
183
                .mic(mic),
184
                .spk(spk),
185
                .kbrows(),
186
                .kbcolumns(kbd_columns),
187 18 mcleod_ide
                .r(ula_r),
188
                .g(ula_g),
189
                .b(ula_b),
190
                .i(ula_i),
191
                .rgbulaplus(rgbulaplus),
192
                .ulaplus_enabled(ulaplus_enabled),
193 15 mcleod_ide
                .csync(csync)
194
        );
195
 
196
   /////////////////////////////////////
197 18 mcleod_ide
   // ULA/ULA+ video selector and enconding
198
   /////////////////////////////////////        
199
        assign i = 1;
200
   rgbdtoa video_final_stage (
201
                .clk(clkdacvideo),
202
                .reset(reset),
203
                .select(ulaplus_enabled),
204
                .ri(ula_r),
205
                .gi(ula_g),
206
                .bi(ula_b),
207
                .hi(ula_i),
208
                .rgbulap(rgbulaplus),
209
                .r(r),
210
                .g(g),
211
                .b(b)
212
    );
213
 
214
   /////////////////////////////////////
215 15 mcleod_ide
   // The CPU Z80A
216
   /////////////////////////////////////        
217
   tv80n cpu (
218
                // Outputs
219
                .m1_n(),
220
                .mreq_n(mreq_n),
221
                .iorq_n(iorq_n),
222
                .rd_n(rd_n),
223
                .wr_n(wr_n),
224
                .rfsh_n(rfsh_n),
225
                .halt_n(),
226
                .busak_n(),
227
                .A(a),
228
                .dout(cpudout),
229
                // Inputs
230
                .reset_n(!reset),
231
                .clk(clkcpu),
232
                .wait_n(1'b1),
233
                .int_n(int_n),
234
                .nmi_n(1'b1),
235
                .busrq_n(1'b1),
236
                .di(cpudin)
237
   );
238
 
239
   /////////////////////////////////////
240
   // CPU data bus
241
   /////////////////////////////////////        
242
        assign sramdin = cpudout;
243
        assign uladin = cpudout;
244
        assign cpudin = (rom_cs)? romdout :
245
                        (ula_cs | vram_cs | port255_cs | ulaplusaddr_cs | ulaplusdata_cs)? uladout :
246
                                                 (sram_cs)? sramdout :
247
                                                            8'hFF;
248
 
249
   /////////////////////////////////////
250
   // Audio mixer
251
   /////////////////////////////////////        
252
        mixer audio_mix (
253 18 mcleod_ide
                .clkdac(clkdacaudio),
254 15 mcleod_ide
                .reset(reset),
255
                .ear(ear),
256
                .mic(mic),
257
                .spk(spk),
258
                .audio(audio_out)
259
        );
260
 
261
   /////////////////////////////////////
262
   // PS2 Keyboard
263
   /////////////////////////////////////        
264
        wire [7:0] kbdscancode;
265
 
266
        ps2kbd keyboard (
267
                .clk(clkkbd),
268
                .reset(reset),
269
                .clkps2(clkps2),
270
                .dataps2(dataps2),
271
                .ledextended(ledextended),
272
                .ledreleased(ledreleased),
273
                .ledmayus(ledshift),
274
                .scancode(kbdscancode),
275
                .semifila(a[15:8]),
276
                .columna(kbd_columns)
277
    );
278
 
279
   /////////////////////////////////////
280
   // Diagnostics
281
   /////////////////////////////////////        
282
        display numeric_display (
283
    .clk(clkkbd),
284
    .load(int_n),
285
    .valor({8'h00,kbdscancode}),
286
    .an(dispanodes),
287
    .seg(dispcathodes)
288
    );
289
 
290
        reg [19:0] divclkcpu = 0;
291
        assign ledclk = divclkcpu[19]; // a simple "hearbeat" blink to let us know that the CPU is running.
292
        always @(posedge clkcpu)
293
                divclkcpu <= divclkcpu + 1;
294
        assign ledaux = 4'b0000;
295
 
296
endmodule

powered by: WebSVN 2.1.0

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