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

Subversion Repositories zx_ula

[/] [zx_ula/] [branches/] [xilinx/] [spectrum_48k_spartan3a_for_gameduino_mod_vga_timex_hicolor_ulaplus/] [spectrum48k_tld.v] - Blame information for rev 29

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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