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 15

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
        // Master clock (14MHz) generation
99
        /////////////////////////////////////
100
        wire clk28mhz;
101
   master_clock clock28mhz (
102
    .CLKIN_IN(clk50),
103
    .CLKFX_OUT(clk28mhz),
104
    .CLKIN_IBUFG_OUT(),
105
    .CLK0_OUT()
106
    );
107
        reg clk14 = 0;
108
        always @(posedge clk28mhz) begin
109
                clk14 = !clk14;
110
        end
111
        wire clkula = clk14;
112
        wire clkmem = clk28mhz;
113
        wire clkaudio = clk14;
114
        wire clkkbd = clk14;
115
 
116
   /////////////////////////////////////
117
   // ROM
118
   /////////////////////////////////////        
119
        rom the_rom (
120
                .clka(clkmem),
121
                .ena(rom_cs),
122
                .addra(a[13:0]),
123
                .douta(romdout)
124
        );
125
 
126
   /////////////////////////////////////
127
   // VRAM and upper RAM banks
128
   /////////////////////////////////////        
129
   ram_controller vram_and_upper_ram (
130
                .clk(clkmem),
131
                // Bank 1 (VRAM)
132
                .a1({2'b00,va}),
133
                .cs1_n(!vramcs),
134
                .oe1_n(!vramoe),
135
                .we1_n(!vramwe),
136
                .din1(vramdin),
137
                .dout1(vramdout),
138
                // Bank 2 (upper RAM)
139
                .a2({1'b0,a[14:0]}),
140
                .cs2_n(!sram_cs),
141
                .oe2_n(rd_n),
142
                .we2_n(wr_n),
143
                .din2(sramdin),
144
                .dout2(sramdout),
145
                // Outputs to actual SRAM on board
146
                .sa(sa),
147
                .sd(sd1),
148
                .sramce(sramce1),
149
                .sramub(sramub1),
150
                .sramlb(sramlb1),
151
                .sramoe(sramoe),
152
                .sramwe(sramwe)
153
        );
154
 
155
   /////////////////////////////////////
156
   // The ULA
157
   /////////////////////////////////////        
158
        ula the_ula (
159
                .clk14(clkula),
160
                .reset(reset),
161
                .a(a),
162
                .din(uladin),
163
                .dout(uladout),
164
                .mreq_n(mreq_n),
165
                .iorq_n(iorq_n),
166
                .rd_n(rd_n),
167
                .wr_n(wr_n),
168
                .rfsh_n(rfsh_n),
169
                .clkcpu(clkcpu),
170
                .msk_int_n(int_n),
171
                .va(va),
172
                .vramdout(vramdout),
173
                .vramdin(vramdin),
174
                .vramoe(vramoe),
175
                .vramcs(vramcs),
176
                .vramwe(vramwe),
177
                .ear(ear),
178
                .mic(mic),
179
                .spk(spk),
180
                .kbrows(),
181
                .kbcolumns(kbd_columns),
182
                .r(r),
183
                .g(g),
184
                .b(b),
185
                .i(i),
186
                .csync(csync)
187
        );
188
 
189
   /////////////////////////////////////
190
   // The CPU Z80A
191
   /////////////////////////////////////        
192
   tv80n cpu (
193
                // Outputs
194
                .m1_n(),
195
                .mreq_n(mreq_n),
196
                .iorq_n(iorq_n),
197
                .rd_n(rd_n),
198
                .wr_n(wr_n),
199
                .rfsh_n(rfsh_n),
200
                .halt_n(),
201
                .busak_n(),
202
                .A(a),
203
                .dout(cpudout),
204
                // Inputs
205
                .reset_n(!reset),
206
                .clk(clkcpu),
207
                .wait_n(1'b1),
208
                .int_n(int_n),
209
                .nmi_n(1'b1),
210
                .busrq_n(1'b1),
211
                .di(cpudin)
212
   );
213
 
214
   /////////////////////////////////////
215
   // CPU data bus
216
   /////////////////////////////////////        
217
        assign sramdin = cpudout;
218
        assign uladin = cpudout;
219
        assign cpudin = (rom_cs)? romdout :
220
                        (ula_cs | vram_cs | port255_cs | ulaplusaddr_cs | ulaplusdata_cs)? uladout :
221
                                                 (sram_cs)? sramdout :
222
                                                            8'hFF;
223
 
224
   /////////////////////////////////////
225
   // Audio mixer
226
   /////////////////////////////////////        
227
        mixer audio_mix (
228
                .clkdac(clkaudio),
229
                .reset(reset),
230
                .ear(ear),
231
                .mic(mic),
232
                .spk(spk),
233
                .audio(audio_out)
234
        );
235
 
236
   /////////////////////////////////////
237
   // PS2 Keyboard
238
   /////////////////////////////////////        
239
        wire [7:0] kbdscancode;
240
 
241
        ps2kbd keyboard (
242
                .clk(clkkbd),
243
                .reset(reset),
244
                .clkps2(clkps2),
245
                .dataps2(dataps2),
246
                .ledextended(ledextended),
247
                .ledreleased(ledreleased),
248
                .ledmayus(ledshift),
249
                .scancode(kbdscancode),
250
                .semifila(a[15:8]),
251
                .columna(kbd_columns)
252
    );
253
 
254
   /////////////////////////////////////
255
   // Diagnostics
256
   /////////////////////////////////////        
257
        display numeric_display (
258
    .clk(clkkbd),
259
    .load(int_n),
260
    .valor({8'h00,kbdscancode}),
261
    .an(dispanodes),
262
    .seg(dispcathodes)
263
    );
264
 
265
        reg [19:0] divclkcpu = 0;
266
        assign ledclk = divclkcpu[19]; // a simple "hearbeat" blink to let us know that the CPU is running.
267
        always @(posedge clkcpu)
268
                divclkcpu <= divclkcpu + 1;
269
        assign ledaux = 4'b0000;
270
 
271
endmodule

powered by: WebSVN 2.1.0

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