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

Subversion Repositories zx_ula

[/] [zx_ula/] [branches/] [xilinx/] [spectrum_48k_for_digilent_spartan3_starter_kit/] [spectrum48k_tld.v] - Blame information for rev 9

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 8 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 9 mcleod_ide
    input clk50,
23
         input reset,
24
    output r,
25
    output g,
26
    output b,
27
    output i,
28 8 mcleod_ide
    output csync,
29 9 mcleod_ide
        // ULA I/O 
30
         input ear,
31 8 mcleod_ide
         output audio_out,
32
         output [7:0] kbd_rows,
33 9 mcleod_ide
         input [4:0] kbd_columns,
34
        // diagnostics
35
         output [7:0] leds,
36
        // SRAM memory
37
         output [17:0] sa,
38
         inout [7:0] sd1,
39
         output sramce1,
40
         output sramub1,
41
         output sramlb1,
42
         output sramoe,
43
         output sramwe
44
    );
45 8 mcleod_ide
 
46
        // CPU signals
47
        wire [15:0] a;
48
        wire [7:0] cpudout;
49 9 mcleod_ide
        wire [7:0] cpudin;
50
        wire clkcpu;
51 8 mcleod_ide
        wire mreq_n;
52
        wire iorq_n;
53
        wire wr_n;
54
        wire rd_n;
55
        wire rfsh_n;
56
        wire int_n;
57
 
58
        // VRAM signals
59 9 mcleod_ide
        wire [13:0] va;
60 8 mcleod_ide
        wire [7:0] vramdin;
61 9 mcleod_ide
        wire [7:0] vramdout;
62
        wire vramoe;
63
        wire vramcs;
64
        wire vramwe;
65 8 mcleod_ide
 
66
        // I/O
67 9 mcleod_ide
        wire mic;
68 8 mcleod_ide
        wire spk;
69 9 mcleod_ide
        assign audio_out = spk;
70 8 mcleod_ide
 
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;
84
        wire vram_cs = !a[15] & a[14] & !mreq_n;
85
        wire port255_cs = !iorq_n && a[7:0]==8'hFF && !rd_n;
86
        wire rom_cs = !a[15] & !a[14] & !mreq_n & !rd_n;
87
 
88
        /////////////////////////////////////
89
        // Master clock (14MHz) generation
90
        /////////////////////////////////////
91
        wire clk28mhz;
92
   master_clock clock28mhz (
93
    .CLKIN_IN(clk50),
94
    .CLKFX_OUT(clk28mhz),
95
    .CLKIN_IBUFG_OUT(),
96
    .CLK0_OUT()
97
    );
98
        reg clk14 = 0;
99
        always @(posedge clk28mhz) begin
100
                clk14 = !clk14;
101
        end
102
        wire clkula = clk14;
103
        wire clkmem = clk28mhz;
104
 
105
   /////////////////////////////////////
106
   // ROM
107
   /////////////////////////////////////        
108
        rom the_rom (
109
                .clka(clkmem),
110
                .ena(rom_cs),
111
                .addra(a[13:0]),
112
                .douta(romdout)
113
        );
114
 
115
   /////////////////////////////////////
116
   // VRAM and upper RAM banks
117
   /////////////////////////////////////        
118
   ram_controller vram_and_upper_ram (
119 9 mcleod_ide
                .clk(clkmem),
120
                // Bank 1 (VRAM)
121
                .a1({2'b00,va}),
122
                .cs1_n(!vramcs),
123
                .oe1_n(!vramoe),
124
                .we1_n(!vramwe),
125
                .din1(vramdin),
126
                .dout1(vramdout),
127
                // Bank 2 (upper RAM)
128
                .a2({1'b0,a[14:0]}),
129
                .cs2_n(!sram_cs),
130
                .oe2_n(rd_n),
131
                .we2_n(wr_n),
132
                .din2(sramdin),
133 8 mcleod_ide
                .dout2(sramdout),
134 9 mcleod_ide
                // Outputs to actual SRAM on board
135
                .sa(sa),
136
                .sd(sd1),
137
                .sramce(sramce1),
138
                .sramub(sramub1),
139
                .sramlb(sramlb1),
140
                .sramoe(sramoe),
141
                .sramwe(sramwe)
142
        );
143 8 mcleod_ide
 
144
   /////////////////////////////////////
145
   // The ULA
146
   /////////////////////////////////////        
147 9 mcleod_ide
        ula the_ula (
148
                .clk14(clkula),
149
                .a(a),
150
                .din(uladin),
151
                .dout(uladout),
152
                .mreq_n(mreq_n),
153
                .iorq_n(iorq_n),
154
                .rd_n(rd_n),
155
                .wr_n(wr_n),
156
                .rfsh_n(rfsh_n),
157
                .clkcpu(clkcpu),
158
                .msk_int_n(int_n),
159
                .va(va),
160
                .vramdout(vramdout),
161
                .vramdin(vramdin),
162
                .vramoe(vramoe),
163
                .vramcs(vramcs),
164
                .vramwe(vramwe),
165
                .ear(ear),
166
                .mic(mic),
167
                .spk(spk),
168
                .kbrows(kbd_rows),
169
                .kbcolumns(kbd_columns),
170
                .r(r),
171
                .g(g),
172
                .b(b),
173
                .i(i),
174
                .csync(csync)
175
        );
176 8 mcleod_ide
 
177
   /////////////////////////////////////
178
   // The CPU Z80A
179
   /////////////////////////////////////        
180 9 mcleod_ide
   tv80n cpu (
181
                // Outputs
182
                .m1_n(),
183
                .mreq_n(mreq_n),
184
                .iorq_n(iorq_n),
185
                .rd_n(rd_n),
186
                .wr_n(wr_n),
187
                .rfsh_n(rfsh_n),
188
                .halt_n(),
189
                .busak_n(),
190
                .A(a),
191
                .dout(cpudout),
192
                // Inputs
193
                .reset_n(!reset),
194
                .clk(clkcpu),
195
                .wait_n(1'b1),
196
                .int_n(int_n),
197
                .nmi_n(1'b1),
198
                .busrq_n(1'b1),
199
                .di(cpudin)
200
   );
201 8 mcleod_ide
 
202
   /////////////////////////////////////
203
   // Connecting all togther
204
   /////////////////////////////////////        
205
        assign sramdin = cpudout;
206
        assign uladin = cpudout;
207
        assign cpudin = (rom_cs)? romdout :
208
                        (ula_cs | vram_cs | port255_cs)? uladout :
209
                                                 (sram_cs)? sramdout :
210 9 mcleod_ide
                                                            8'hFF;
211 8 mcleod_ide
 
212
   /////////////////////////////////////
213
   // Diagnostics
214
   /////////////////////////////////////        
215
        reg [7:0] rLeds = 8'b10000000;
216
        assign leds = rLeds;
217
        reg [1:0] cntleds = 2'b00;
218
        always @(posedge int_n) begin
219
                cntleds <= cntleds + 1;
220
                if (cntleds == 2'b11) begin
221
                        rLeds <= { rLeds[0], rLeds[7:1] };
222
                end
223
        end
224
 
225
endmodule

powered by: WebSVN 2.1.0

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