Skip to content

Commit

Permalink
Use 28MHz clock for CPU
Browse files Browse the repository at this point in the history
  • Loading branch information
lawrie committed Apr 22, 2020
1 parent fca223a commit 90db1e0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
33 changes: 14 additions & 19 deletions src/spectrum.v
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ module Spectrum (
wire n_ramCS;
wire n_kbdCS;

reg [5:0] cpuClkCount = 0;
reg cpuClock;
reg [2:0] cpuClockCount;
wire cpuClock;
wire cpuClockEnable;

assign interrupt = !n_INT;

Expand All @@ -53,7 +54,8 @@ module Spectrum (
pll pll_i (
.clkin(clk25_mhz),
.clkout0(clk125),
.clkout1(clk)
.clkout1(clk),
.clkout2(cpuClock)
);

// ===============================================================
Expand All @@ -76,14 +78,13 @@ module Spectrum (

tv80n cpu1 (
.reset_n(n_hard_reset),
.clk(cpuClock),
.clk(cpuClockEnable),
.wait_n(1'b1),
.int_n(n_INT),
.nmi_n(1'b1),
.busrq_n(1'b1),
.mreq_n(n_MREQ),
.iorq_n(n_IORQ),
.rd_n(n_RD),
.wr_n(n_WR),
.A(cpuAddress),
.di(cpuDataIn),
Expand All @@ -110,7 +111,7 @@ module Spectrum (
wire [12:0] vga_addr;

dpram ram48 (
.clk_a(clk),
.clk_a(cpuClock),
.we_a(!n_ramCS & !n_memWR),
.addr_a(cpuAddress - 16'h4000),
.din_a(cpuDataOut),
Expand Down Expand Up @@ -210,23 +211,17 @@ module Spectrum (
n_romCS == 1'b0 ? romOut :
n_ramCS == 1'b0 ? ramOut :
8'hff;

// ===============================================================
// CPU clock generation
// CPU clock enable
// ===============================================================
always @(posedge clk) begin
if(cpuClkCount < 4) begin
cpuClkCount <= cpuClkCount + 1;
end else begin
cpuClkCount <= 0;
end
if(cpuClkCount < 2) begin
cpuClock <= 1'b0;
end else begin
cpuClock <= 1'b1;
end

always @(posedge cpuClock) begin
cpuClockCount <= cpuClockCount + 1;
end

assign cpuClockEnable = cpuClockCount[2]; // 3.5Mhz

// ===============================================================
// Leds
// ===============================================================
Expand Down
7 changes: 7 additions & 0 deletions ulx3s/pll.v
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ module pll
input clkin, // 25 MHz, 0 deg
output clkout0, // 125 MHz, 0 deg
output clkout1, // 25 MHz, 0 deg
output clkout2, // 28.4091 MHz, 0 deg
output locked
);
(* FREQUENCY_PIN_CLKI="25" *)
(* FREQUENCY_PIN_CLKOP="125" *)
(* FREQUENCY_PIN_CLKOS="25" *)
(* FREQUENCY_PIN_CLKOS2="28.4091" *)
(* ICP_CURRENT="12" *) (* LPF_RESISTOR="8" *) (* MFG_ENABLE_FILTEROPAMP="1" *) (* MFG_GMCREF_SEL="2" *)
EHXPLLL #(
.PLLRST_ENA("DISABLED"),
Expand All @@ -31,6 +33,10 @@ EHXPLLL #(
.CLKOS_DIV(25),
.CLKOS_CPHASE(2),
.CLKOS_FPHASE(0),
.CLKOS2_ENABLE("ENABLED"),
.CLKOS2_DIV(22),
.CLKOS2_CPHASE(2),
.CLKOS2_FPHASE(0),
.FEEDBK_PATH("CLKOP"),
.CLKFB_DIV(5)
) pll_i (
Expand All @@ -39,6 +45,7 @@ EHXPLLL #(
.CLKI(clkin),
.CLKOP(clkout0),
.CLKOS(clkout1),
.CLKOS2(clkout2),
.CLKFB(clkout0),
.CLKINTFB(),
.PHASESEL0(1'b0),
Expand Down

0 comments on commit 90db1e0

Please sign in to comment.