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

Subversion Repositories a-z80

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 8 gdevic
//============================================================================
2
// Implementation of the Sinclair ZX Spectrum ULA
3
//
4
// This module contains the clocks section.
5
//
6
// TODO: Video RAM contention would cause a clock gating which would be
7
// implemented in this module. RAM contention is not implemented since we are
8
// using FPGA RAM cells configured in dual-port mode.
9
//
10
//  Copyright (C) 2014-2016  Goran Devic
11
//
12
//  This program is free software; you can redistribute it and/or modify it
13
//  under the terms of the GNU General Public License as published by the Free
14
//  Software Foundation; either version 2 of the License, or (at your option)
15
//  any later version.
16
//
17
//  This program is distributed in the hope that it will be useful, but WITHOUT
18
//  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19
//  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
20
//  more details.
21
//
22
//  You should have received a copy of the GNU General Public License along
23
//  with this program; if not, write to the Free Software Foundation, Inc.,
24
//  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25
//============================================================================
26
module clocks
27
(
28
    input wire clk_ula,         // Input ULA clock of 14 MHz
29
    input wire turbo,           // Turbo speed (3.5 MHz x 2 = 7.0 MHz)
30
    output reg clk_cpu          // Output 3.5 MHz CPU clock
31
);
32
 
33
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
34
// Generate 3.5 MHz Z80 CPU clock by dividing input clock of 14 MHz by 4
35
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
36
reg [0:0] counter;
37
 
38
// Note: In order to get to 3.5 MHz, the PLL needs to be set to generate 14 MHz
39
// and then this divider-by-4 brings the effective clock down to 3.5 MHz
40
// 1. always block at positive edge of clk_ula divides by 2
41
// 2. counter flop further divides it by 2 unless the turbo mode is set
42
always @(posedge clk_ula)
43
begin
44
    if (counter=='0 | turbo)
45
        clk_cpu <= ~clk_cpu;
46
    counter <= counter - 1'b1;
47
end
48
 
49
endmodule

powered by: WebSVN 2.1.0

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