OpenCores
URL https://opencores.org/ocsvn/a-z80/a-z80/trunk

Subversion Repositories a-z80

[/] [a-z80/] [trunk/] [host/] [zxspectrum_de1/] [ula/] [test_ula.sv] - Blame information for rev 8

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 8 gdevic
//============================================================================
2
// Test the implementation of the Sinclair ZX Spectrum ULA
3
//
4
//  Copyright (C) 2014-2016  Goran Devic
5
//
6
//  This program is free software; you can redistribute it and/or modify it
7
//  under the terms of the GNU General Public License as published by the Free
8
//  Software Foundation; either version 2 of the License, or (at your option)
9
//  any later version.
10
//
11
//  This program is distributed in the hope that it will be useful, but WITHOUT
12
//  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
//  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
14
//  more details.
15
//
16
//  You should have received a copy of the GNU General Public License along
17
//  with this program; if not, write to the Free Software Foundation, Inc.,
18
//  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
//============================================================================
20
module test_ula
21
(
22
    input wire CLOCK_50,        // Input clock 50 MHz
23
    input wire CLOCK_27,        // Input clock 27 MHz
24
    input wire KEY0,            // Button 0 is reset
25
 
26
    output wire [3:0] VGA_R,
27
    output wire [3:0] VGA_G,
28
    output wire [3:0] VGA_B,
29
    output reg VGA_HS,
30
    output reg VGA_VS,
31
 
32
    output wire [21:0] FL_ADDR,
33
    input wire [7:0] FL_DQ,
34
    output wire FL_CE_N,
35
    output wire FL_OE_N,
36
    output wire FL_RST_N,
37
    output wire FL_WE_N,
38
 
39
    input wire PS2_CLK,
40
    input wire PS2_DAT,
41
    output wire UART_TXD,
42
 
43
    output wire [6:0] GPIO_0,   // Scope test points
44
    input wire SW0,
45
    input wire SW1,
46
    input wire SW2
47
);
48
`default_nettype none
49
 
50
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
51
// Instantiate PLL and clocks block
52
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
53
wire clk_pix;                   // VGA pixel clock (25.175 MHz)
54
wire clk_ula;                   // ULA master clock (14 MHz)
55
pll pll_( .inclk0(CLOCK_27), .c0(clk_pix), .c1(clk_ula) );
56
 
57
wire clk_cpu;                   // Clocks generates CPU clocks of 3.5 MHz
58
clocks clocks_( .* );
59
 
60
// Various scope test points, connect as needed:
61
//assign GPIO_0[0] = CLOCK_27;
62
//assign GPIO_0[1] = clk_pix;
63
//assign GPIO_0[2] = clk_ula;
64
//assign GPIO_0[3] = clk_cpu;
65
assign GPIO_0[4] = VGA_VS;
66
assign GPIO_0[5] = VGA_HS;
67
assign GPIO_0[6] = VGA_B[0];
68
 
69
assign GPIO_0[0] = PS2_CLK;
70
assign GPIO_0[1] = PS2_DAT;
71
assign GPIO_0[2] = UART_TXD;
72
assign GPIO_0[3] = vs_nintr;
73
 
74
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
75
// Instantiate RAM that contains a sample screen image
76
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
77
reg [12:0] vram_address;
78
reg [7:0] vram_data;
79
ram8 ram8_( .address(vram_address), .clock(clk_pix), .data(0), .wren(0), .q(vram_data));
80
 
81
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
82
// State register containing the border color index
83
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
84
reg [7:0] state;
85
 
86
// Testing: assign the border color index based on the board switches
87
wire [2:0] border;              // Border color index value
88
assign border = { SW2, SW1, SW0 };
89
 
90
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
91
// Instantiate ULA's video subsystem
92
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
93
wire vs_nintr;                  // Vertical retrace interrupt
94
 
95
video video_( .*, .vram_address(vram_address), .vram_data(vram_data) );
96
 
97
// Use flash interface instead of the internal RAM
98
assign FL_CE_N = 0;
99
assign FL_OE_N = 0;
100
assign FL_RST_N = KEY0;
101
assign FL_WE_N = 1;
102
assign FL_ADDR[21:13] = 'b10;
103
//video video_( .*, .vram_address(FL_ADDR[12:0]), .vram_data(FL_DQ) );
104
 
105
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
106
// Instantiate keyboard support
107
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
108
wire [7:0] scan_code;
109
wire scan_code_ready;
110
wire scan_code_error;
111
 
112
ps2_keyboard ps2_keyboard_( .*, .clk(CLOCK_50), .reset(KEY0) );
113
 
114
reg [15:0] A = 16'hFEFE;
115
wire [4:0] key_row;
116
zx_keyboard zx_keyboard_( .*, .clk(CLOCK_50), .reset(KEY0)  );
117
 
118
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
119
// Add UART so we can echo keyboard through the serial port out
120
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
121
wire busy_tx;
122
uart_core uart_core_( .*, .reset(!KEY0), .clk(CLOCK_50), .uart_tx(UART_TXD), .data_in(scan_code), .data_in_wr(scan_code_ready) );
123
 
124
endmodule

powered by: WebSVN 2.1.0

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