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/] [spectrum48k_tld.v] - Blame information for rev 14

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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