Line 1... |
Line 1... |
//============================================================================
|
//============================================================================
|
// The implementation of the Sinclair ZX Spectrum ULA
|
// Sinclair ZX Spectrum ULA
|
//
|
//
|
// Copyright (C) 2014-2016 Goran Devic
|
// Copyright (C) 2014-2016 Goran Devic
|
//
|
//
|
// This program is free software; you can redistribute it and/or modify it
|
// This program is free software; you can redistribute it and/or modify it
|
// under the terms of the GNU General Public License as published by the Free
|
// under the terms of the GNU General Public License as published by the Free
|
Line 22... |
Line 22... |
//-------- Clocks and reset -----------------
|
//-------- Clocks and reset -----------------
|
input wire CLOCK_27, // Input clock 27 MHz
|
input wire CLOCK_27, // Input clock 27 MHz
|
input wire CLOCK_24, // Input clock 24 MHz
|
input wire CLOCK_24, // Input clock 24 MHz
|
input wire turbo, // Turbo speed (3.5 MHz x 2 = 7.0 MHz)
|
input wire turbo, // Turbo speed (3.5 MHz x 2 = 7.0 MHz)
|
output wire clk_vram,
|
output wire clk_vram,
|
input wire reset, // KEY0 is reset
|
input wire nreset, // Active low reset
|
output wire locked, // PLL is locked signal
|
output wire locked, // PLL is locked signal
|
|
|
//-------- CPU control ----------------------
|
//-------- CPU control ----------------------
|
output wire clk_cpu, // Generates CPU clock of 3.5 MHz
|
output wire clk_cpu, // Generates CPU clock of 3.5 MHz
|
output wire vs_nintr, // Generates a vertical retrace interrupt
|
output wire vs_nintr, // Generates a vertical retrace interrupt
|
Line 102... |
Line 102... |
// Instantiate audio interface
|
// Instantiate audio interface
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
wire audio_done;
|
wire audio_done;
|
wire audio_error;
|
wire audio_error;
|
|
|
i2c_loader i2c_loader_( .CLK(CLOCK_24), .nRESET(reset), .I2C_SCL(I2C_SCLK), .I2C_SDA(I2C_SDAT), .IS_DONE(audio_done), .IS_ERROR(audio_error) );
|
i2c_loader i2c_loader_( .CLK(CLOCK_24), .nRESET(nreset), .I2C_SCL(I2C_SCLK), .I2C_SDA(I2C_SDAT), .IS_DONE(audio_done), .IS_ERROR(audio_error) );
|
|
|
assign AUD_DACLRCK = AUD_ADCLRCK;
|
assign AUD_DACLRCK = AUD_ADCLRCK;
|
wire [15:0] pcm_inl;
|
wire [15:0] pcm_inl;
|
wire [15:0] pcm_inr;
|
wire [15:0] pcm_inr;
|
reg [15:0] pcm_outl;
|
reg [15:0] pcm_outl;
|
reg [15:0] pcm_outr;
|
reg [15:0] pcm_outr;
|
|
|
i2s_intf i2s_intf_( .CLK(CLOCK_24), .nRESET(reset),
|
i2s_intf i2s_intf_( .CLK(CLOCK_24), .nRESET(nreset),
|
.PCM_INL(pcm_inl[15:0]), .PCM_INR(pcm_inr[15:0]), .PCM_OUTL(pcm_outl[15:0]), .PCM_OUTR(pcm_outr[15:0]),
|
.PCM_INL(pcm_inl[15:0]), .PCM_INR(pcm_inr[15:0]), .PCM_OUTL(pcm_outl[15:0]), .PCM_OUTR(pcm_outr[15:0]),
|
.I2S_MCLK(AUD_XCK), .I2S_LRCLK(AUD_ADCLRCK), .I2S_BCLK(AUD_BCLK), .I2S_DOUT(AUD_DACDAT), .I2S_DIN(AUD_ADCDAT) );
|
.I2S_MCLK(AUD_XCK), .I2S_LRCLK(AUD_ADCLRCK), .I2S_BCLK(AUD_BCLK), .I2S_DOUT(AUD_DACDAT), .I2S_DIN(AUD_ADCDAT) );
|
|
|
// Show the beeper visually by dividing the frequency with some factor to generate blinks
|
// Show the beeper visually by dividing the frequency with some factor to generate LED blinks
|
reg beep; // Beeper latch
|
reg beep; // Beeper latch
|
reg [6:0] beepcnt; // Beeper counter
|
reg [6:0] beepcnt; // Beeper counter
|
always @(posedge beep)
|
always @(posedge beep)
|
begin
|
begin
|
beepcnt <= beepcnt - '1;
|
beepcnt <= beepcnt - '1;
|
Line 140... |
Line 140... |
ps2_keyboard ps2_keyboard_( .*, .clk(clk_cpu) );
|
ps2_keyboard ps2_keyboard_( .*, .clk(clk_cpu) );
|
|
|
wire [4:0] key_row;
|
wire [4:0] key_row;
|
zx_keyboard zx_keyboard_( .*, .clk(clk_cpu) );
|
zx_keyboard zx_keyboard_( .*, .clk(clk_cpu) );
|
|
|
always @(*) // always_comb
|
always_comb
|
begin
|
begin
|
ula_data = 8'hFF;
|
ula_data = 8'hFF;
|
// Regular IO at every odd address: line-in and keyboard
|
// Regular IO at every odd address: line-in and keyboard
|
if (A[0]==0) begin
|
if (A[0]==0) begin
|
ula_data = { 1'b0, pcm_inl[14] | pcm_inr[14], 1'b0, key_row[4:0] };
|
ula_data = { 1'b0, pcm_inl[14] | pcm_inr[14], 1'b0, key_row[4:0] };
|