URL
https://opencores.org/ocsvn/System09/System09/trunk
Subversion Repositories System09
Compare Revisions
- This comparison shows the changes necessary to convert path
/System09/trunk/rtl/VHDL
- from Rev 100 to Rev 118
- ↔ Reverse comparison
Rev 100 → Rev 118
/ACIA_RX.vhd
File deleted
\ No newline at end of file
/ACIA_TX.vhd
File deleted
\ No newline at end of file
/vdu8_new.vhd
1,27 → 1,141
-- --------------------------------------------------- |
-- Video Display terminal |
-- --------------------------------------------------- |
-- John Kent |
-- 3th September 2004 |
-- Assumes a pixel clock input of 25 MHz |
--===========================================================================-- |
-- -- |
-- vdu8_new.vhd - Synthesizable Colour Video Display Unit for System09 -- |
-- -- |
--===========================================================================-- |
-- |
-- Display Format is: |
-- 80 characters across by 25 characters down. |
-- 8 horizontal pixels / character |
-- 16 vertical scan lines / character (2 scan lines/row) |
-- File name : vdu8_new.vhd |
-- |
-- Modified by Bert Cuzeau for compliance and code cleanliness |
-- The effort is not over. |
-- There are still signal initialized, which is BAD.\ |
-- Purpose : Implements a text based Colour Video Display Unit for System09 |
-- Supports 2KByte Text buffer and 2KByte Attribute memory |
-- Displays 80 characters across by 25 character rows |
-- Characters are 8 pixels across x 16 lines down. |
-- Character attribute bita for foreground and backgrond colour |
-- 1 bit for each Blue Green and Red signal |
-- Supports 2 x 8 chunky graphics character mode. |
-- Uses Generic arguments for setting the video synchronization timing. |
-- (I'm not sure what is "new" about this version.) |
-- |
-- Dependencies : ieee.Std_Logic_1164 |
-- ieee.std_logic_arith |
-- ieee.std_logic_unsigned |
-- ieee.numeric_std |
-- unisim.vcomponents |
-- |
-- 7th Februaury 2007 - John Kent |
-- Added generics for VGA Timing |
-- Uses : ram_2k (ram2k_b16.vhd) 2KByte Character & Attribute buffer |
-- char_rom (char_rom2k_b16.vhd) 2KByte Character Generator ROM |
-- |
-- Author : John E. Kent |
-- |
-- Email : dilbert57@opencores.org |
-- |
-- Web : http://opencores.org/project,system09 |
-- |
-- Description : Display Timing: |
-- 800 pixels / line |
-- 446 lines / frame |
-- None interlaced |
-- 25MHz pixel clock implies |
-- 31.25 KHz line rate |
-- 70.067 Hz frame rate |
-- Timing settable by generics. |
-- |
-- Display Size: |
-- 80 characters across |
-- 25 characters down. |
-- |
-- Character Size: |
-- 8 horizontal pixels across |
-- 16 vertical scan lines down (2 scan lines/row) |
-- |
-- Registers: |
-- Base + 0 ASCII character register |
-- Writing to this register writes an 8 bit byte |
-- into the text buffer at the specified cursor position |
-- Text Mode: ASCII Character (0 to 127) |
-- Chunky Graphics Mode: B0 B1 (0 to 255) |
-- B2 B3 |
-- B4 B5 |
-- B6 B7 |
-- Base + 1 Attibute bit (0 to 255) |
-- Writing to the register writes an 8 bit byte |
-- into the attribute buffer at the specified cursor position |
-- B7 - 0 => Text Mode / 1 => Chunky Graphics Mode |
-- B6 - 1 => Character Background Blue |
-- B5 - 1 => Character Background Green |
-- B4 - 1 => Character Background Red |
-- B3 - 1 => Character Background & Foreground Alternates |
-- B2 - 1 => Character Foreground Blue |
-- B1 - 1 => Character Foreground Green |
-- B0 - 1 => Character Foreground Red |
-- Base + 2 Cursor Horizontal Position (0 to 79) |
-- Base + 3 Cusror Vertical Position (0 to 24) |
-- Base + 4 Vertical Scroll Offset (0 to 24) |
-- Scrolls the display up by the specified number of character rows |
-- |
-- |
-- Video Timing : |
-- |
-- Horizontal 800 Pixels/ 25MHz Pixel Clock = 32usec Line period = 31.25 KHz Line Frequency |
-- /--------------------------\_____________/---------------\______________/ |
-- 640 Pixels Display 16 Pixel FP 96 Pixel HS 48 Pixel BP |
-- |
-- VGA_CLK_FREQ : integer := 25000000; -- HZ |
-- VGA_HOR_FRONT_PORCH : integer := 16; -- PIXELS 0.64us (0.94us) |
-- VGA_HOR_SYNC : integer := 96; -- PIXELS 3.84us (3.77us) |
-- VGA_HOR_BACK_PORCH : integer := 48; -- PIXELS 1.92us (1.89us) |
-- VGA_PIX_PER_CHAR : integer := 8; -- PIXELS 0.32us |
-- VGA_HOR_CHARS : integer := 80; -- CHARACTERS 25.6us |
-- |
-- Vertical 446 Lines * 32 usec Line rate = 14.272ms Frame Period = 70.07Hz Frame frequency |
-- /---------------------------\____________/---------------\______________/ |
-- 400 Line Display 10 Line FP 2 Line VS 34 Line BP |
-- |
-- VGA_VER_FRONT_PORCH : integer := 10; -- LINES 0.320ms |
-- VGA_VER_SYNC : integer := 2; -- LINES 0.064ms |
-- VGA_VER_BACK_PORCH : integer := 34; -- LINES 1.088ms |
-- VGA_LIN_PER_CHAR : integer := 16; -- LINES 0.512ms |
-- VGA_VER_CHARS : integer := 25; -- CHARACTERS 12.8ms |
-- |
-- Copyright (C) 2003 - 2010 John Kent |
-- |
-- 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 Software Foundation, either version 3 of the License, or |
-- (at your option) any later version. |
-- |
-- This program is distributed in the hope that it will be useful, |
-- but WITHOUT ANY WARRANTY; without even the implied warranty of |
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
-- GNU General Public License for more details. |
-- |
-- You should have received a copy of the GNU General Public License |
-- along with this program. If not, see <http://www.gnu.org/licenses/>. |
-- |
--===========================================================================-- |
-- -- |
-- Revision History -- |
-- -- |
--===========================================================================-- |
-- |
-- Version Author Date Changes |
-- |
-- 0.1 John Kent 2004-09-03 Initial release |
-- |
-- 0.2 Bert Cuzeau 2007-01-16 Modified by for compliance and code cleanliness |
-- The effort is not over. |
-- There are still signal initialized, which is BAD. |
-- |
-- 0.3 John Kent 2007-02-07 Added generics for VGA Timing |
-- |
-- 0.4 John Kent 2010-06-16 Added GPL notice. Updated description |
-- I'm not sure what is "new" about this version |
-- |
|
Library IEEE; |
use ieee.std_logic_1164.all; |
use IEEE.STD_LOGIC_ARITH.ALL; |
use IEEE.STD_LOGIC_UNSIGNED.ALL; |
use ieee.std_logic_arith.all; |
use ieee.std_logic_unsigned.all; |
use ieee.numeric_std.all; |
library unisim; |
use unisim.vcomponents.all; |
28,18 → 142,17
|
Entity vdu8 is |
generic( |
VDU_CLOCK_FREQUENCY : integer := 25000000; -- HZ |
VGA_CLOCK_FREQUENCY : integer := 25000000; -- HZ |
VGA_HOR_CHARS : integer := 80; -- CHARACTERS |
VGA_VER_CHARS : integer := 25; -- CHARACTERS |
VGA_PIXELS_PER_CHAR : integer := 8; -- PIXELS |
VGA_LINES_PER_CHAR : integer := 16; -- LINES |
VGA_HOR_BACK_PORCH : integer := 40; -- PIXELS |
VGA_HOR_SYNC : integer := 96; -- PIXELS |
VGA_HOR_FRONT_PORCH : integer := 24; -- PIXELS |
VGA_VER_BACK_PORCH : integer := 13; -- LINES |
VGA_VER_SYNC : integer := 2; -- LINES |
VGA_VER_FRONT_PORCH : integer := 36 -- LINES |
VGA_CLK_FREQ : integer := 25000000; -- HZ |
VGA_HOR_CHARS : integer := 80; -- CHARACTERS 25.6us |
VGA_HOR_CHAR_PIXELS : integer := 8; -- PIXELS 0.32us |
VGA_HOR_FRONT_PORCH : integer := 16; -- PIXELS 0.64us |
VGA_HOR_SYNC : integer := 96; -- PIXELS 3.84us |
VGA_HOR_BACK_PORCH : integer := 48; -- PIXELS 1.92us |
VGA_VER_CHARS : integer := 25; -- CHARACTERS 12.8ms |
VGA_VER_CHAR_LINES : integer := 16; -- LINES 0.512ms |
VGA_VER_FRONT_PORCH : integer := 10; -- LINES 0.320ms |
VGA_VER_SYNC : integer := 2; -- LINES 0.064ms |
VGA_VER_BACK_PORCH : integer := 34 -- LINES 1.088ms |
); |
port( |
-- control register interface |
68,30 → 181,26
-- Displayed Characters per row |
constant HOR_DISP_CHR : integer := VGA_HOR_CHARS; |
-- Last horizontal pixel displayed |
constant HOR_DISP_END : integer := HOR_DISP_CHR * VGA_PIXELS_PER_CHAR; |
constant HOR_DISP_END : integer := HOR_DISP_CHR * VGA_HOR_CHAR_PIXELS - 1; |
-- Start of horizontal synch pulse |
constant HOR_SYNC_BEG : integer := HOR_DISP_END + VGA_HOR_BACK_PORCH; |
constant HOR_SYNC_BEG : integer := HOR_DISP_END + VGA_HOR_FRONT_PORCH; |
-- End of Horizontal Synch pulse |
constant HOR_SYNC_END : integer := HOR_SYNC_BEG + VGA_HOR_SYNC; |
-- Last pixel in scan line |
constant HOR_SCAN_END : integer := HOR_SYNC_END + VGA_HOR_FRONT_PORCH; |
-- Total Characters across the screen |
constant HOR_TOTAL_CHAR : integer := HOR_SCAN_END/VGA_PIXELS_PER_CHAR; |
constant HOR_SCAN_END : integer := HOR_SYNC_END + VGA_HOR_BACK_PORCH; |
|
-- Displayed Characters per Column |
constant VER_DISP_CHR : integer := VGA_VER_CHARS; |
-- last row displayed |
constant VER_DISP_END : integer := VER_DISP_CHR * VGA_LINES_PER_CHAR; |
constant VER_DISP_END : integer := VER_DISP_CHR * VGA_VER_CHAR_LINES - 1; |
-- start of vertical synch pulse |
constant VER_SYNC_BEG : integer := VER_DISP_END + VGA_VER_BACK_PORCH; |
constant VER_SYNC_BEG : integer := VER_DISP_END + VGA_VER_FRONT_PORCH; |
-- end of vertical synch pulse |
constant VER_SYNC_END : integer := VER_SYNC_BEG + VGA_VER_SYNC; |
-- Last scan row in the frame |
constant VER_SCAN_END : integer := VER_SYNC_END + VGA_VER_FRONT_PORCH; |
-- Total Characters down the screen |
constant VER_TOTAL_CHAR : integer := VER_SCAN_END/VGA_LINES_PER_CHAR; |
|
constant BLINK_PERIOD : integer := 500; -- Blink Rate in msec |
constant VER_SCAN_END : integer := VER_SYNC_END + VGA_VER_BACK_PORCH; |
|
constant BLINK_PERIOD : integer := 500; -- Blink Rate in msec |
constant BLINK_RATE : integer := BLINK_PERIOD * (VGA_CLOCK_FREQUENCY/1000); |
|
signal vga_rst : std_logic; |
102,11 → 211,11
signal video_on_v : std_logic := '0'; |
signal video_on_h : std_logic := '0'; |
signal h_count : natural range 0 to HOR_SCAN_END := 0; |
signal v_count : natural range 0 to VER_SCAN_END := 0; |
signal v_count : natural range 0 to VER_SCAN_END := 0; |
signal p_count : natural range 0 to VGA_PIXELS_PER_CHAR-1 := 0; |
signal l_count : std_logic_vector(3 downto 0) := "0000"; |
signal c_count : std_logic_vector(6 downto 0) := "0000000"; |
signal r_count : std_logic_vector(5 downto 0) := "000000"; |
signal r_count : std_logic_vector(5 downto 0) := "000000"; |
signal blink_count : natural range 0 to BLINK_RATE := 0; |
-- |
-- Character generator ROM |
153,7 → 262,7
signal vga_addr : std_logic_vector(10 downto 0) := (others=>'0'); -- 2K byte character buffer |
signal vga_data_out : std_logic_vector(7 downto 0); |
signal attr_data_out : std_logic_vector(7 downto 0); |
|
|
-- |
-- Character write handshake signals |
-- |
330,13 → 439,13
vga0_rw <= '1'; |
col_addr <= c_count; |
row_addr <= r_count + ("0" & reg_voffset(4 downto 0)); |
end case; |
end case; |
|
-- |
-- on vga_clk + 1 round off row address |
-- |
vga1_cs <= vga0_cs; |
vga1_rw <= vga0_rw; |
vga1_rw <= vga0_rw; |
if row_addr < VER_DISP_CHR then |
row1_addr <= row_addr; |
else |
376,9 → 485,9
vga_blue_o <= '0'; |
-- Put all video signals through DFFs to elminate any delays that cause a blurry image |
|
elsif falling_edge(vga_clk) then |
elsif falling_edge(vga_clk) then |
-- |
-- p_count = 0 load pixel shift register |
-- p_count = 0 load pixel shift register |
-- |
if p_count = 0 then |
if (req_write = '1') and (ack_write = '0') then |
387,31 → 496,31
ack_write <= '0'; |
else |
ack_write <= ack_write; |
end if; |
|
end if; |
|
-- |
-- Pipeline video enable |
-- |
-- Pipeline video enable |
-- |
video_on2 <= video_on1; |
video_on <= video_on2; |
-- |
-- Blink Cursor |
-- |
video_on <= video_on2; |
-- |
-- Blink Cursor |
-- |
if blink_count > (BLINK_RATE/2) then |
cursor_on <= cursor_on1 or attr_data_out(3); |
else |
cursor_on <= '0'; |
end if; |
cursor_on <= cursor_on1 or attr_data_out(3); |
else |
cursor_on <= '0'; |
end if; |
-- |
-- Set forground and background colours |
-- |
-- Set forground and background colours |
-- |
vga_fg_colour <= attr_data_out(2 downto 0); |
vga_bg_colour <= attr_data_out(6 downto 4); |
-- |
-- Attribute bit 7 |
vga_bg_colour <= attr_data_out(6 downto 4); |
-- |
-- Attribute bit 7 |
-- 0 => text |
-- 1 => chunky graphics |
-- |
-- 1 => chunky graphics |
-- |
if attr_data_out(7) = '0' then |
vga_shift <= char_data_out; |
else |
430,10 → 539,10
vga_shift(3 downto 0) <= vga_data_out(7) & vga_data_out(7) & vga_data_out(7) & vga_data_out(7); |
end case; |
end if; |
else |
else |
-- |
-- p_count /= 0 shift out pixel shift register |
-- |
-- p_count /= 0 shift out pixel shift register |
-- |
vga_shift <= vga_shift(6 downto 0) & '0'; |
end if; |
|
460,13 → 569,13
-- Generate Horizontal and Vertical Timing Signals for Video Signal |
-- |
vga_sync : process(vga_clk, vga_rst) |
begin |
if vga_rst = '1' then |
h_count <= 0; |
c_count <= "0000000"; |
begin |
if vga_rst = '1' then |
h_count <= 0; |
c_count <= "0000000"; |
p_count <= 0; |
v_count <= 0; |
l_count <= "0000"; |
v_count <= 0; |
l_count <= "0000"; |
r_count <= "000000"; |
horiz_sync <= '0'; |
vert_sync <= '0'; |
474,7 → 583,7
video_on_v <= '0'; |
cursor_on_h <= '0'; |
cursor_on_v <= '0'; |
blink_count <= BLINK_RATE; |
blink_count <= BLINK_RATE; |
elsif falling_edge(vga_clk) then |
-- |
-- H_count counts pixels (640 + extra time for sync signals) |
483,17 → 592,17
-- H_count 0 640 659 755 799 |
-- |
if h_count = HOR_SCAN_END then |
h_count <= 0; |
c_count <= "0000000"; |
h_count <= 0; |
c_count <= "0000000"; |
p_count <= 0; |
else |
h_count <= h_count + 1; |
p_count <= p_count + 1; |
if p_count = VGA_PIXELS_PER_CHAR-1 then |
p_count <= 0; |
c_count <= c_count + "0000001"; |
h_count <= h_count + 1; |
p_count <= p_count + 1; |
if p_count = VGA_PIXELS_PER_CHAR-1 then |
p_count <= 0; |
c_count <= c_count + "0000001"; |
end if; |
end if; |
end if; |
|
-- |
-- V_count counts rows of pixels |
504,17 → 613,17
-- V_count 0 400 413 414 444 |
-- |
if (v_count = VER_SCAN_END) and (h_count = HOR_SCAN_END) then |
v_count <= 0; |
l_count <= "0000"; |
v_count <= 0; |
l_count <= "0000"; |
r_count <= "000000"; |
elsif h_count = HOR_SYNC_END then |
v_count <= v_count + 1; |
l_count <= l_count + "0001"; |
if l_count = VGA_LINES_PER_CHAR-1 then |
l_count <= "0000"; |
r_count <= r_count + "000001"; |
l_count <= l_count + "0001"; |
if l_count = VGA_LINES_PER_CHAR-1 then |
l_count <= "0000"; |
r_count <= r_count + "000001"; |
end if; |
end if; |
end if; |
|
-- |
-- Generate Horizontal Sync Signal |
524,7 → 633,7
elsif h_count = HOR_SYNC_END then |
horiz_sync <= '0'; |
end if; |
|
|
-- |
-- Generate Vertical Sync Signal |
-- |
532,10 → 641,10
vert_sync <= '1'; |
elsif v_count = VER_SYNC_END then |
vert_sync <= '0'; |
end if; |
end if; |
|
-- |
-- Horizontal display enable |
-- Horizontal display enable |
-- |
if h_count = 0 then |
video_on_h <= '1'; |
544,7 → 653,7
end if; |
|
-- |
-- Verical display enable |
-- Verical display enable |
-- |
if v_count = 0 then |
video_on_v <= '1'; |
552,18 → 661,18
video_on_v <= '0'; |
end if; |
|
-- |
-- Horizontal cursor on |
-- |
-- Horizontal cursor on |
-- |
if c_count = reg_hcursor(6 downto 0) then |
cursor_on_h <= '1'; |
else |
cursor_on_h <= '0'; |
end if; |
|
|
-- |
-- Vertical cursor on |
-- |
-- Vertical cursor on |
-- |
if r_count = ("0" & reg_vcursor(4 downto 0)) then |
cursor_on_v <= '1'; |
else |
570,30 → 679,30
cursor_on_v <= '0'; |
end if; |
|
-- cursor_on is only active when on selected character |
if blink_count = 0 then |
blink_count <= BLINK_RATE; |
-- cursor_on is only active when on selected character |
if blink_count = 0 then |
blink_count <= BLINK_RATE; |
else |
blink_count <= blink_count - 1; |
blink_count <= blink_count - 1; |
end if; |
end if; |
|
end process; |
-- |
-- VGA reset = VDU reset |
-- VGA = timing section |
-- VDU = CPU registers |
-- |
end process; |
-- |
-- VGA reset = VDU reset |
-- VGA = timing section |
-- VDU = CPU registers |
-- |
vga_rst <= vdu_rst; |
-- |
-- VGA Sync for 640 pixels x 400 lines |
-- negative horizonal sync |
-- positive verical sync |
-- |
-- |
-- VGA Sync for 640 pixels x 400 lines |
-- negative horizonal sync |
-- positive verical sync |
-- |
vga_hsync_o <= not horiz_sync; |
vga_vsync_o <= vert_sync; |
-- |
-- video_on is high only when RGB data is displayed |
-- video_on is high only when RGB data is displayed |
-- |
video_on1 <= video_on_H and video_on_V; |
cursor_on1 <= cursor_on_h and cursor_on_v; |
/vdu8_bert.vhd
1,19 → 1,133
-- --------------------------------------------------- |
-- Video Display terminal |
-- --------------------------------------------------- |
-- John Kent |
-- 3th September 2004 |
-- Assumes a pixel clock input of 50 MHz |
-- Generates a 12.5MHz CPU Clock output |
--===========================================================================-- |
-- -- |
-- vdu8_bert.vhd - Synthesizable Colour Video Display Unit for System09 -- |
-- -- |
--===========================================================================-- |
-- |
-- Display Format is: |
-- 80 characters across by 25 characters down. |
-- 8 horizontal pixels / character |
-- 16 vertical scan lines / character (2 scan lines/row) |
-- File name : vdu8_bert.vhd |
-- |
-- Modified by Bert Cuzeau for compliance and code cleanliness |
-- The effort is not over. |
-- There are still signal initialized, which is BAD. |
-- Purpose : Implements a text based Colour Video Display Unit for System09 |
-- Supports 2KByte Text buffer and 2KByte Attribute memory |
-- Displays 80 characters across by 25 character rows |
-- Characters are 8 pixels across x 16 lines down. |
-- Character attribute bita for foreground and backgrond colour |
-- 1 bit for each Blue Green and Red signal |
-- Supports 2 x 8 chunky graphics character mode. |
-- Assumes a pixel clock input of 50 MHz |
-- Generates a 12.5MHz CPU Clock output for old Spartan 2 boards. |
-- Partially cleaned up by Bertrand Cuzeau |
-- |
-- Dependencies : ieee.Std_Logic_1164 |
-- ieee.std_logic_unsigned |
-- ieee.std_logic_arith |
-- ieee.numeric_std |
-- |
-- Uses : ram_2k (ram2k_b16.vhd) 2KByte Character & Attribute buffer |
-- char_rom (char_rom2k_b16.vhd) 2KByte Character Generator ROM |
-- |
-- Author : John E. Kent |
-- |
-- Email : dilbert57@opencores.org |
-- |
-- Web : http://opencores.org/project,system09 |
-- |
-- Description : Display Timing: |
-- 800 pixels / line |
-- 446 lines / frame |
-- None interlaced |
-- 25MHz pixel clock implies |
-- 31.25 KHz line rate |
-- 70.067 Hz frame rate |
-- Timing settable by generics. |
-- |
-- Display Size: |
-- 80 characters across |
-- 25 characters down. |
-- |
-- Character Size: |
-- 8 horizontal pixels across |
-- 16 vertical scan lines down (2 scan lines/row) |
-- |
-- Registers: |
-- Base + 0 ASCII character register |
-- Writing to this register writes an 8 bit byte |
-- into the text buffer at the specified cursor position |
-- Text Mode: ASCII Character (0 to 127) |
-- Chunky Graphics Mode: B0 B1 (0 to 255) |
-- B2 B3 |
-- B4 B5 |
-- B6 B7 |
-- Base + 1 Attibute bit (0 to 255) |
-- Writing to the register writes an 8 bit byte |
-- into the attribute buffer at the specified cursor position |
-- B7 - 0 => Text Mode / 1 => Chunky Graphics Mode |
-- B6 - 1 => Character Background Blue |
-- B5 - 1 => Character Background Green |
-- B4 - 1 => Character Background Red |
-- B3 - 1 => Character Background & Foreground Alternates |
-- B2 - 1 => Character Foreground Blue |
-- B1 - 1 => Character Foreground Green |
-- B0 - 1 => Character Foreground Red |
-- Base + 2 Cursor Horizontal Position (0 to 79) |
-- Base + 3 Cusror Vertical Position (0 to 24) |
-- Base + 4 Vertical Scroll Offset (0 to 24) |
-- Scrolls the display up by the specified number of character rows |
-- |
-- Video Timing : |
-- |
-- Horizontal 800 Pixels/ 25MHz Pixel Clock = 32usec Line period = 31.25 KHz Line Frequency |
-- /--------------------------\_____________/---------------\______________/ |
-- 640 Pixels Display 16 Pixel FP 96 Pixel HS 48 Pixel BP |
-- |
-- VGA_CLK_FREQ : integer := 25000000; -- HZ |
-- VGA_HOR_FRONT_PORCH : integer := 16; -- PIXELS 0.64us (0.94us) |
-- VGA_HOR_SYNC : integer := 96; -- PIXELS 3.84us (3.77us) |
-- VGA_HOR_BACK_PORCH : integer := 48; -- PIXELS 1.92us (1.89us) |
-- VGA_PIX_PER_CHAR : integer := 8; -- PIXELS 0.32us |
-- VGA_HOR_CHARS : integer := 80; -- CHARACTERS 25.6us |
-- |
-- Vertical 446 Lines * 32 usec Line rate = 14.272ms Frame Period = 70.07Hz Frame frequency |
-- /---------------------------\____________/---------------\______________/ |
-- 400 Line Display 10 Line FP 2 Line VS 34 Line BP |
-- |
-- VGA_VER_FRONT_PORCH : integer := 10; -- LINES 0.320ms |
-- VGA_VER_SYNC : integer := 2; -- LINES 0.064ms |
-- VGA_VER_BACK_PORCH : integer := 34; -- LINES 1.088ms |
-- VGA_LIN_PER_CHAR : integer := 16; -- LINES 0.512ms |
-- VGA_VER_CHARS : integer := 25; -- CHARACTERS 12.8ms |
-- |
-- |
-- Copyright (C) 2003 - 2010 John Kent |
-- |
-- 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 Software Foundation, either version 3 of the License, or |
-- (at your option) any later version. |
-- |
-- This program is distributed in the hope that it will be useful, |
-- but WITHOUT ANY WARRANTY; without even the implied warranty of |
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
-- GNU General Public License for more details. |
-- |
-- You should have received a copy of the GNU General Public License |
-- along with this program. If not, see <http://www.gnu.org/licenses/>. |
-- |
--===========================================================================-- |
-- -- |
-- Revision History -- |
-- -- |
--===========================================================================-- |
-- |
-- Version Author Date Changes |
-- |
-- 0.1 John Kent 2004-09-03 Initial release |
-- |
-- 0.2 Bert Cuzeau 2007-01-16 Modified by for compliance and code cleanliness |
-- The effort is not over. |
-- There are still signal initialized, which is BAD. |
-- |
-- 0.3 John Kent 2010-06-16 Added GPL notice. Updated description |
-- |
|
Library IEEE; |
use IEEE.std_logic_1164.all; |
20,6 → 134,19
use IEEE.numeric_std.all; |
|
Entity vdu8 is |
generic( |
VGA_CLK_FREQ : integer := 25000000; -- HZ |
VGA_HOR_CHARS : integer := 80; -- CHARACTERS 25.6us |
VGA_HOR_CHAR_PIXELS : integer := 8; -- PIXELS 0.32us |
VGA_HOR_FRONT_PORCH : integer := 16; -- PIXELS 0.64us |
VGA_HOR_SYNC : integer := 96; -- PIXELS 3.84us |
VGA_HOR_BACK_PORCH : integer := 48; -- PIXELS 1.92us |
VGA_VER_CHARS : integer := 25; -- CHARACTERS 12.8ms |
VGA_VER_CHAR_LINES : integer := 16; -- LINES 0.512ms |
VGA_VER_FRONT_PORCH : integer := 10; -- LINES 0.320ms |
VGA_VER_SYNC : integer := 2; -- LINES 0.064ms |
VGA_VER_BACK_PORCH : integer := 34 -- LINES 1.088ms |
); |
port( |
-- control register interface |
vdu_clk_in : in std_logic; -- 50MHz System clock |
45,18 → 172,31
-- |
-- Synchronisation constants |
-- |
constant HOR_DISP_END : integer := 639; -- Last horizontal pixel displayed |
constant HOR_SYNC_BEG : integer := 679; -- Start of horizontal synch pulse |
constant HOR_SYNC_END : integer := 775; -- End of Horizontal Synch pulse |
constant HOR_SCAN_END : integer := 799; -- Last pixel in scan line |
constant HOR_DISP_CHR : integer := 80; -- Number of characters displayed per row |
-- |
-- Synchronisation constants |
-- |
-- Displayed Characters per row |
constant HOR_DISP_CHR : integer := VGA_HOR_CHARS; |
-- Last horizontal pixel displayed |
constant HOR_DISP_END : integer := (HOR_DISP_CHR * VGA_HOR_CHAR_PIXELS) - 1; |
-- Start of horizontal synch pulse |
constant HOR_SYNC_BEG : integer := HOR_DISP_END + VGA_HOR_FRONT_PORCH; |
-- End of Horizontal Synch pulse |
constant HOR_SYNC_END : integer := HOR_SYNC_BEG + VGA_HOR_SYNC; |
-- Last pixel in scan line |
constant HOR_SCAN_END : integer := HOR_SYNC_END + VGA_HOR_BACK_PORCH; |
|
-- Number of displayed characters rows |
constant VER_DISP_CHR : integer := VGA_VER_CHARS; |
-- last row displayed |
constant VER_DISP_END : integer := (VER_DISP_CHR * VGA_VER_CHAR_LINES) - 1; |
-- start of vertical synch pulse |
constant VER_SYNC_BEG : integer := VER_DISP_END + VGA_VER_FRONT_PORCH; |
-- end of vertical synch pulse |
constant VER_SYNC_END : integer := VER_SYNC_BEG + VGA_VER_SYNC; |
-- Last scan row in the frame |
constant VER_SCAN_END : integer := VER_SYNC_END + VGA_VER_BACK_PORCH; |
|
constant VER_DISP_END : integer := 399; -- last row displayed |
constant VER_SYNC_BEG : integer := 413; -- start of vertical synch pulse |
constant VER_SYNC_END : integer := 414; -- end of vertical synch pulse |
constant VER_SCAN_END : integer := 450; -- Last scan row in the frame |
constant VER_DISP_CHR : integer := 25; -- Number of character rows displayed |
|
signal horiz_sync : std_logic := '1'; |
signal vert_sync : std_logic := '1'; |
signal cursor_on_v : std_logic; |
/peripheral_bus.vhd
86,8 → 86,8
use ieee.std_logic_1164.all; |
use ieee.numeric_std.all; |
use ieee.std_logic_unsigned.all; |
library unisim; |
use unisim.vcomponents.all; |
--library unisim; |
-- use unisim.vcomponents.all; |
|
----------------------------------------------------------------------- |
-- Entity for peripheral bus -- |
/datram.vhd
87,8 → 87,8
library ieee; |
use ieee.std_logic_1164.all; |
use ieee.std_logic_unsigned.all; |
library unisim; |
use unisim.vcomponents.all; |
--library unisim; |
-- use unisim.vcomponents.all; |
|
entity dat_ram is |
port ( |
/ACIA_Clock.vhd
13,7 → 13,6
-- ieee.std_logic_arith |
-- ieee.std_logic_unsigned |
-- ieee.numeric_std |
-- unisim.vcomponents |
-- work.bit_funcs |
-- |
-- Author : John E. Kent |
55,8 → 54,8
use ieee.std_logic_arith.all; |
use ieee.std_logic_unsigned.all; |
use ieee.numeric_std.all; |
library unisim; |
use unisim.vcomponents.all; |
--library unisim; |
-- use unisim.vcomponents.all; |
library work; |
use work.bit_funcs.all; |
|
/spi-master.vhd
11,10 → 11,7
-- Purpose : Implements a SPI Master Controller |
-- |
-- Dependencies : ieee.std_logic_1164 |
-- ieee.std_logic_arith |
-- ieee.std_logic_unsigned |
-- ieee.numeric_std |
-- unisim.vcomponents |
-- |
-- Author : Hans Huebner |
-- |
/ps2_keyboard.vhd
12,7 → 12,6
-- ieee.std_logic_unsigned |
-- ieee.std_logic_arith |
-- ieee.numeric_std |
-- unisim.vcomponents |
-- |
-- Author : Original Verilog version by John Clayton |
-- Converted to VHDL by John E. Kent |
145,7 → 144,7
-- they correspond to 60usec for a 49.152MHz clock. |
-- |
-- Author: John Kent |
-- 2001-02-10 Converted to VHDL |
--2001-02-10 Converted to VHDL |
-- 2004-09-11 Added ctrl key |
-- Changed undefined key codes to x"ff" |
-- Reversed clock polarity |
154,9 → 153,9
-- 2007-02-06 Added Generic Clock parameter |
-- 2010-05-31 Revised header, added GPL |
-- 2010-06-17 Change some signal names for consistancy |
-- 2010-10-24 Rearranged code to prevent shift key outputting characters |
-- |
-- |
-- |
--------------------------------------------------------------------------------------- |
|
library ieee; |
164,8 → 163,8
use ieee.std_logic_arith.all; |
use ieee.std_logic_unsigned.all; |
use ieee.numeric_std.all; |
library unisim; |
use unisim.vcomponents.all; |
--library unisim; |
-- use unisim.vcomponents.all; |
|
entity ps2_keyboard is |
generic ( |
203,7 → 202,10
constant LEFT_SHIFT : integer := 16#12#; |
constant RIGHT_SHIFT : integer := 16#59#; |
constant CTRL_CODE : integer := 16#14#; |
constant CAPS_CODE : integer := 16#58#; |
constant LEFT_ALT : integer := 16#11#; |
constant CAPS_CODE : integer := 16#58#; |
constant SCROLL_LOCK : integer := 16#7E#; |
constant NUM_LOCK : integer := 16#77#; |
|
|
-- constants |
228,9 → 230,9
--constant TIMER_5USEC_BITS_PP : integer := 7; -- Number of bits needed for timer |
|
-- Values for generic Clock up to 50 MHz |
constant TIMER_60USEC_VALUE_PP : integer := CLK_FREQ_MHZ * 60; -- Number of sys_clks for 60usec. |
constant TIMER_60USEC_VALUE_PP : integer := CLK_FREQ_MHZ * 60; -- Number of clock cycles for 60usec. |
constant TIMER_60USEC_BITS_PP : integer := 12; -- Number of bits needed for timer |
constant TIMER_5USEC_VALUE_PP : integer := CLK_FREQ_MHZ * 5; -- Number of sys_clks for debounce |
constant TIMER_5USEC_VALUE_PP : integer := CLK_FREQ_MHZ * 5; -- Number of clock cycles for debounce |
constant TIMER_5USEC_BITS_PP : integer := 8; -- Number of bits needed for timer |
|
constant TRAP_SHIFT_KEYS_PP : integer := 1; -- Default: No shift key trap. |
374,66 → 376,72
|
m1_state_logic : process( m1_state, q, |
tx_shifting_done, tx_write, |
ps2_clk_s, ps2_data_s, |
timer_60usec_done, timer_5usec_done ) |
ps2_clk_s, ps2_data_s, |
timer_60usec_done, timer_5usec_done ) |
begin |
-- Output signals default to this value, unless changed in a state condition. |
ps2_clk_hi_z <= '1'; |
ps2_data_hi_z <= '1'; |
tx_error <= '0'; |
enable_timer_60usec <= '0'; |
enable_timer_5usec <= '0'; |
ps2_clk_hi_z <= '1'; |
ps2_data_hi_z <= '1'; |
tx_error <= '0'; |
enable_timer_60usec <= '0'; |
enable_timer_5usec <= '0'; |
|
case (m1_state) is |
when m1_rx_clk_h => |
enable_timer_60usec <= '1'; |
if (tx_write = '1') then |
m1_next_state <= m1_tx_reset_timer; |
elsif (ps2_clk_s = '0') then |
m1_next_state <= m1_rx_falling_edge_marker; |
else |
m1_next_state <= m1_rx_clk_h; |
case (m1_state) is |
-- |
-- receive clock transitions |
-- |
when m1_rx_clk_h => |
enable_timer_60usec <= '1'; |
if (tx_write = '1') then |
m1_next_state <= m1_tx_reset_timer; |
elsif (ps2_clk_s = '0') then |
m1_next_state <= m1_rx_falling_edge_marker; |
else |
m1_next_state <= m1_rx_clk_h; |
end if; |
|
when m1_rx_falling_edge_marker => |
enable_timer_60usec <= '0'; |
m1_next_state <= m1_rx_clk_l; |
when m1_rx_falling_edge_marker => |
enable_timer_60usec <= '0'; |
m1_next_state <= m1_rx_clk_l; |
|
when m1_rx_clk_l => |
enable_timer_60usec <= '1'; |
if (tx_write = '1') then |
m1_next_state <= m1_tx_reset_timer; |
elsif (ps2_clk_s = '1') then |
m1_next_state <= m1_rx_rising_edge_marker; |
else |
m1_next_state <= m1_rx_clk_l; |
end if; |
when m1_rx_clk_l => |
enable_timer_60usec <= '1'; |
if (tx_write = '1') then |
m1_next_state <= m1_tx_reset_timer; |
elsif (ps2_clk_s = '1') then |
m1_next_state <= m1_rx_rising_edge_marker; |
else |
m1_next_state <= m1_rx_clk_l; |
end if; |
|
when m1_rx_rising_edge_marker => |
enable_timer_60usec <= '0'; |
m1_next_state <= m1_rx_clk_h; |
|
-- |
-- write to keyboard (Tx) |
-- |
when m1_tx_reset_timer => |
enable_timer_60usec <= '0'; |
m1_next_state <= m1_tx_force_clk_l; |
|
when m1_rx_rising_edge_marker => |
enable_timer_60usec <= '0'; |
m1_next_state <= m1_rx_clk_h; |
when m1_tx_force_clk_l => |
enable_timer_60usec <= '1'; |
ps2_clk_hi_z <= '0'; -- Force the ps2_clk line low. |
if (timer_60usec_done = '1') then |
m1_next_state <= m1_tx_first_wait_clk_h; |
else |
m1_next_state <= m1_tx_force_clk_l; |
end if; |
|
when m1_tx_reset_timer => |
enable_timer_60usec <= '0'; |
m1_next_state <= m1_tx_force_clk_l; |
|
when m1_tx_force_clk_l => |
enable_timer_60usec <= '1'; |
ps2_clk_hi_z <= '0'; -- Force the ps2_clk line low. |
if (timer_60usec_done = '1') then |
m1_next_state <= m1_tx_first_wait_clk_h; |
else |
m1_next_state <= m1_tx_force_clk_l; |
end if; |
|
when m1_tx_first_wait_clk_h => |
enable_timer_5usec <= '1'; |
ps2_data_hi_z <= '0'; -- Start bit. |
if (ps2_clk_s = '0') and (timer_5usec_done = '1') then |
m1_next_state <= m1_tx_clk_l; |
else |
m1_next_state <= m1_tx_first_wait_clk_h; |
end if; |
when m1_tx_first_wait_clk_h => |
enable_timer_5usec <= '1'; |
ps2_data_hi_z <= '0'; -- Start bit. |
if (ps2_clk_s = '0') and (timer_5usec_done = '1') then |
m1_next_state <= m1_tx_clk_l; |
else |
m1_next_state <= m1_tx_first_wait_clk_h; |
end if; |
|
-- This state must be included because the device might possibly |
-- delay for up to 10 milliseconds before beginning its clock pulses. |
440,267 → 448,285
-- During that waiting time, we cannot drive the data (q[0]) because it |
-- is possibly 1, which would cause the keyboard to abort its receive |
-- and the expected clocks would then never be generated. |
when m1_tx_first_wait_clk_l => |
ps2_data_hi_z <= '0'; |
if (ps2_clk_s = '0') then |
m1_next_state <= m1_tx_clk_l; |
else |
m1_next_state <= m1_tx_first_wait_clk_l; |
end if; |
when m1_tx_first_wait_clk_l => |
ps2_data_hi_z <= '0'; |
if (ps2_clk_s = '0') then |
m1_next_state <= m1_tx_clk_l; |
else |
m1_next_state <= m1_tx_first_wait_clk_l; |
end if; |
|
when m1_tx_wait_clk_h => |
enable_timer_5usec <= '1'; |
ps2_data_hi_z <= q(0); |
if (ps2_clk_s = '1') and (timer_5usec_done = '1') then |
m1_next_state <= m1_tx_rising_edge_marker; |
else |
m1_next_state <= m1_tx_wait_clk_h; |
end if; |
when m1_tx_wait_clk_h => |
enable_timer_5usec <= '1'; |
ps2_data_hi_z <= q(0); |
if (ps2_clk_s = '1') and (timer_5usec_done = '1') then |
m1_next_state <= m1_tx_rising_edge_marker; |
else |
m1_next_state <= m1_tx_wait_clk_h; |
end if; |
|
when m1_tx_rising_edge_marker => |
ps2_data_hi_z <= q(0); |
m1_next_state <= m1_tx_clk_h; |
when m1_tx_rising_edge_marker => |
ps2_data_hi_z <= q(0); |
m1_next_state <= m1_tx_clk_h; |
|
when m1_tx_clk_h => |
ps2_data_hi_z <= q(0); |
if (tx_shifting_done = '1') then |
m1_next_state <= m1_tx_wait_keyboard_ack; |
elsif (ps2_clk_s = '0') then |
m1_next_state <= m1_tx_clk_l; |
else |
m1_next_state <= m1_tx_clk_h; |
end if; |
when m1_tx_clk_h => |
ps2_data_hi_z <= q(0); |
if (tx_shifting_done = '1') then |
m1_next_state <= m1_tx_wait_keyboard_ack; |
elsif (ps2_clk_s = '0') then |
m1_next_state <= m1_tx_clk_l; |
else |
m1_next_state <= m1_tx_clk_h; |
end if; |
|
when m1_tx_clk_l => |
ps2_data_hi_z <= q(0); |
if (ps2_clk_s = '1') then |
m1_next_state <= m1_tx_wait_clk_h; |
else |
m1_next_state <= m1_tx_clk_l; |
end if; |
when m1_tx_clk_l => |
ps2_data_hi_z <= q(0); |
if (ps2_clk_s = '1') then |
m1_next_state <= m1_tx_wait_clk_h; |
else |
m1_next_state <= m1_tx_clk_l; |
end if; |
|
when m1_tx_wait_keyboard_ack => |
if (ps2_clk_s = '0') and (ps2_data_s = '1') then |
m1_next_state <= m1_tx_error; |
elsif (ps2_clk_s = '0') and (ps2_data_s = '0') then |
m1_next_state <= m1_tx_done_recovery; |
else |
m1_next_state <= m1_tx_wait_keyboard_ack; |
end if; |
when m1_tx_wait_keyboard_ack => |
if (ps2_clk_s = '0') and (ps2_data_s = '1') then |
m1_next_state <= m1_tx_error; |
elsif (ps2_clk_s = '0') and (ps2_data_s = '0') then |
m1_next_state <= m1_tx_done_recovery; |
else |
m1_next_state <= m1_tx_wait_keyboard_ack; |
end if; |
|
when m1_tx_done_recovery => |
if (ps2_clk_s = '1') and (ps2_data_s = '1') then |
m1_next_state <= m1_rx_clk_h; |
else |
m1_next_state <= m1_tx_done_recovery; |
end if; |
when m1_tx_done_recovery => |
if (ps2_clk_s = '1') and (ps2_data_s = '1') then |
m1_next_state <= m1_rx_clk_h; |
else |
m1_next_state <= m1_tx_done_recovery; |
end if; |
|
when m1_tx_error => |
tx_error <= '1'; |
if (ps2_clk_s = '1') and (ps2_data_s ='1') then |
m1_next_state <= m1_rx_clk_h; |
else |
m1_next_state <= m1_tx_error; |
end if; |
when m1_tx_error => |
tx_error <= '1'; |
if (ps2_clk_s = '1') and (ps2_data_s ='1') then |
m1_next_state <= m1_rx_clk_h; |
else |
m1_next_state <= m1_tx_error; |
end if; |
|
when others => |
m1_next_state <= m1_rx_clk_h; |
end case; |
when others => |
m1_next_state <= m1_rx_clk_h; |
end case; |
end process; |
|
|
-- |
-- This is the bit counter |
-- |
bit_counter: process(clk, reset, m1_state, bit_count ) |
begin |
if clk'event and clk = '0' then |
if ( reset = '1' ) or |
( rx_shifting_done = '1' ) or |
(m1_state = m1_tx_wait_keyboard_ack) then -- After tx is done. |
bit_count <= "0000"; -- normal reset |
elsif (timer_60usec_done = '1' ) and |
(m1_state = m1_rx_clk_h) and |
(ps2_clk_s = '1') then |
bit_count <= "0000"; -- rx watchdog timer reset |
elsif (m1_state = m1_rx_falling_edge_marker) or -- increment for rx |
(m1_state = m1_tx_rising_edge_marker) then -- increment for tx |
bit_count <= bit_count + 1; |
end if; |
end if; |
if clk'event and clk = '0' then |
if ( reset = '1' ) or ( rx_shifting_done = '1' ) or |
(m1_state = m1_tx_wait_keyboard_ack) then -- After tx is done. |
bit_count <= "0000"; -- normal reset |
elsif (timer_60usec_done = '1' ) and |
( m1_state = m1_rx_clk_h ) and |
( ps2_clk_s = '1' ) then |
bit_count <= "0000"; -- rx watchdog timer reset |
elsif ( m1_state = m1_rx_falling_edge_marker ) or -- increment for rx |
(m1_state = m1_tx_rising_edge_marker) then -- increment for tx |
bit_count <= bit_count + 1; |
end if; |
end if; |
|
if (bit_count = TOTAL_BITS) then |
rx_shifting_done <= '1'; |
else |
rx_shifting_done <= '0'; |
end if; |
|
if (bit_count = (TOTAL_BITS-1)) then |
tx_shifting_done <= '1'; |
else |
tx_shifting_done <= '0'; |
end if; |
end process; |
|
assign: process( bit_count, tx_write, tx_data_empty_o, m1_state ) |
assign: process( bit_count, tx_write, m1_state, tx_data_empty_o, m1_state ) |
begin |
if (bit_count = TOTAL_BITS) then |
rx_shifting_done <= '1'; |
else |
rx_shifting_done <= '0'; |
end if; |
|
if (bit_count = (TOTAL_BITS-1)) then |
tx_shifting_done <= '1'; |
else |
tx_shifting_done <= '0'; |
end if; |
|
-- This is the signal which enables loading of the shift register. |
-- It also indicates "ack" to the device writing to the transmitter. |
if ((tx_write = '1') and (m1_state = m1_rx_clk_h)) or |
((tx_write = '1') and (m1_state = m1_rx_clk_l)) then |
tx_data_empty_o <= '1'; |
else |
tx_data_empty_o <= '0'; |
end if; |
tx_data_empty <= tx_data_empty_o; |
-- |
-- This is the signal which enables loading of the shift register. |
-- It also indicates "ack" to the device writing to the transmitter. |
-- |
if ((tx_write = '1') and (m1_state = m1_rx_clk_h)) or |
((tx_write = '1') and (m1_state = m1_rx_clk_l)) then |
tx_data_empty_o <= '1'; |
else |
tx_data_empty_o <= '0'; |
end if; |
tx_data_empty <= tx_data_empty_o; |
end process; |
|
-- This is the ODD parity bit for the transmitted word. |
-- assign tx_parity_bit = ~^tx_data; |
-- |
tx_parity_bit <= not( tx_data(7) xor tx_data(6) xor tx_data(5) xor tx_data(4) xor |
tx_data(3) xor tx_data(2) xor tx_data(1) xor tx_data(0) ); |
|
-- This is the shift register |
q_shift : process(clk, tx_data_empty_o, tx_parity_bit, tx_data, |
m1_state, q, ps2_data_s, rx_shifting_done ) |
begin |
if clk'event and clk='0' then |
if (reset = '1') then |
q <= "00000000000"; |
elsif (tx_data_empty_o = '1') then |
q <= "1" & tx_parity_bit & tx_data & "0"; |
elsif ( (m1_state = m1_rx_falling_edge_marker) or |
(m1_state = m1_tx_rising_edge_marker) ) then |
q <= ps2_data_s & q((TOTAL_BITS-1) downto 1); |
end if; |
end if; |
|
-- Create the signals which indicate special scan codes received. |
-- These are the "unlatched versions." |
if (q(8 downto 1) = EXTEND_CODE) and (rx_shifting_done = '1') then |
extended <= '1'; |
else |
extended <= '0'; |
end if; |
if (q(8 downto 1) = RELEASE_CODE) and (rx_shifting_done = '1') then |
released <= '1'; |
else |
released <= '0'; |
end if; |
-- |
-- This is the ODD parity bit for the transmitted word. |
-- assign tx_parity_bit = ~^tx_data; |
-- |
tx_parity_bit <= not( tx_data(7) xor tx_data(6) xor tx_data(5) xor tx_data(4) xor |
tx_data(3) xor tx_data(2) xor tx_data(1) xor tx_data(0) ); |
|
if clk'event and clk='0' then |
if (reset = '1') then |
q <= (others=>'0'); |
elsif (tx_data_empty_o = '1') then |
q <= "1" & tx_parity_bit & tx_data & "0"; |
elsif ( (m1_state = m1_rx_falling_edge_marker) or |
(m1_state = m1_tx_rising_edge_marker) ) then |
q <= ps2_data_s & q((TOTAL_BITS-1) downto 1); |
end if; |
end if; |
|
end process; |
|
|
-- |
-- This is the 60usec timer counter |
-- |
timer60usec: process(clk, enable_timer_60usec, timer_60usec_count) |
begin |
if clk'event and clk = '0' then |
if (enable_timer_60usec = '0') then |
timer_60usec_count <= (others => '0'); |
elsif (timer_60usec_done = '0') then |
timer_60usec_count <= timer_60usec_count + 1; |
end if; |
end if; |
if clk'event and clk = '0' then |
if (enable_timer_60usec = '0') then |
timer_60usec_count <= (others => '0'); |
elsif (timer_60usec_done = '0') then |
timer_60usec_count <= timer_60usec_count + 1; |
end if; |
end if; |
|
if (timer_60usec_count = (TIMER_60USEC_VALUE_PP - 1)) then |
timer_60usec_done <= '1'; |
else |
timer_60usec_done <= '0'; |
end if; |
if (timer_60usec_count = (TIMER_60USEC_VALUE_PP - 1)) then |
timer_60usec_done <= '1'; |
else |
timer_60usec_done <= '0'; |
end if; |
end process; |
|
|
-- |
-- This is the 5usec timer counter |
-- |
timer5usec : process(clk, enable_timer_5usec, timer_5usec_count ) |
begin |
if clk'event and clk = '0' then |
if (enable_timer_5usec = '0') then |
timer_5usec_count <= (others => '0'); |
elsif (timer_5usec_done = '0') then |
timer_5usec_count <= timer_5usec_count + 1; |
end if; |
end if; |
if clk'event and clk = '0' then |
if (enable_timer_5usec = '0') then |
timer_5usec_count <= (others => '0'); |
elsif (timer_5usec_done = '0') then |
timer_5usec_count <= timer_5usec_count + 1; |
end if; |
end if; |
|
if( timer_5usec_count = (TIMER_5USEC_VALUE_PP - 1)) then |
timer_5usec_done <= '1'; |
else |
timer_5usec_done <= '0'; |
end if; |
if( timer_5usec_count = (TIMER_5USEC_VALUE_PP - 1)) then |
timer_5usec_done <= '1'; |
else |
timer_5usec_done <= '0'; |
end if; |
end process; |
|
-- |
-- Create the signals which indicate special scan codes received. |
-- These are the "unlatched versions." |
-- |
extend_release_decode : process( q, rx_shifting_done, extended, released ) |
begin |
if (q(8 downto 1) = EXTEND_CODE) and (rx_shifting_done = '1') then |
extended <= '1'; |
else |
extended <= '0'; |
end if; |
|
if (q(8 downto 1) = RELEASE_CODE) and (rx_shifting_done = '1') then |
released <= '1'; |
else |
released <= '0'; |
end if; |
|
if (rx_shifting_done = '1') and (extended = '0') and (released = '0') then |
rx_output_event <= '1'; |
else |
rx_output_event <= '0'; |
end if; |
|
end process; |
|
|
-- |
-- Store the special scan code status bits |
-- Not the final output, but an intermediate storage place, |
-- until the entire set of output data can be assembled. |
-- |
special_scan : process(clk, reset, rx_output_event, rx_shifting_done, extended, released ) |
begin |
if clk'event and clk='0' then |
if (reset = '1') or (rx_output_event = '1') then |
hold_extended <= '0'; |
hold_released <= '0'; |
else |
if (rx_shifting_done = '1') and (extended = '1') then |
hold_extended <= '1'; |
end if; |
if (rx_shifting_done = '1') and (released = '1') then |
hold_released <= '1'; |
end if; |
end if; |
end if; |
if clk'event and clk='0' then |
if (reset = '1') or (rx_output_event = '1') then |
hold_extended <= '0'; |
hold_released <= '0'; |
else |
if (rx_shifting_done = '1') and (extended = '1') then |
hold_extended <= '1'; |
end if; |
if (rx_shifting_done = '1') and (released = '1') then |
hold_released <= '1'; |
end if; |
end if; |
end if; |
|
end process; |
|
|
-- |
-- convert scan code to ascii code |
-- |
scan_to_ascii : process( shift_key_on, caps_key_on, q ) |
begin |
shift_key_plus_code <= shift_key_on & caps_key_on & q(7 downto 1); |
end process; |
|
-- |
-- These bits contain the status of the two shift keys |
-- |
left_shift_proc : process(clk, reset, q, rx_shifting_done, hold_released ) |
begin |
if clk'event and clk = '0' then |
if (reset = '1') then |
left_shift_key <= '0'; |
elsif (q(8 downto 1) = LEFT_SHIFT) and |
(rx_shifting_done = '1') and |
(hold_released = '0') then |
left_shift_key <= '1'; |
elsif (q(8 downto 1) = LEFT_SHIFT) and |
(rx_shifting_done = '1') and |
(hold_released = '1') then |
left_shift_key <= '0'; |
end if; |
end if; |
if clk'event and clk = '0' then |
if (reset = '1') then |
left_shift_key <= '0'; |
elsif (q(8 downto 1) = LEFT_SHIFT) and (rx_shifting_done = '1') then |
left_shift_key <= not hold_released; |
end if; |
end if; |
end process; |
|
right_shift_proc : process(clk, reset, q, rx_shifting_done, hold_released ) |
begin |
if clk'event and clk = '0' then |
if (reset = '1') then |
right_shift_key <= '0'; |
elsif (q(8 downto 1) = RIGHT_SHIFT) and |
(rx_shifting_done = '1') and |
(hold_released = '0') then |
right_shift_key <= '1'; |
elsif (q(8 downto 1) = RIGHT_SHIFT) and |
(rx_shifting_done = '1') and |
(hold_released = '1') then |
right_shift_key <= '0'; |
end if; |
end if; |
if clk'event and clk = '0' then |
if (reset = '1') then |
right_shift_key <= '0'; |
elsif (q(8 downto 1) = RIGHT_SHIFT) and (rx_shifting_done = '1') then |
right_shift_key <= not hold_released; |
end if; |
end if; |
end process; |
|
shift_proc : process( left_shift_key, right_shift_key, shift_key_on, caps_key_on, q ) |
begin |
shift_key_on <= left_shift_key or right_shift_key; |
rx_shift_on <= shift_key_on; |
end process; |
|
shift_key_on <= left_shift_key or right_shift_key; |
rx_shift_on <= shift_key_on; |
|
-- |
-- Control keys |
-- |
ctrl_proc : process(clk, reset, q, rx_shifting_done, hold_released ) |
begin |
if clk'event and clk = '0' then |
if (reset = '1') then |
ctrl_key_on <= '0'; |
elsif (q(8 downto 1) = CTRL_CODE) and |
(rx_shifting_done = '1') and |
(hold_released = '0') then |
ctrl_key_on <= '1'; |
elsif (q(8 downto 1) = CTRL_CODE) and |
(rx_shifting_done = '1') and |
(hold_released = '1') then |
ctrl_key_on <= '0'; |
end if; |
end if; |
if clk'event and clk = '0' then |
if (reset = '1') then |
ctrl_key_on <= '0'; |
elsif (q(8 downto 1) = CTRL_CODE) and (rx_shifting_done = '1') then |
ctrl_key_on <= not hold_released; |
end if; |
end if; |
end process; |
|
-- |
708,85 → 734,79
-- |
caps_proc : process(clk, reset, q, rx_shifting_done, hold_released, caps_key_on ) |
begin |
if clk'event and clk = '0' then |
if (reset = '1') then |
caps_key_on <= '0'; |
elsif (q(8 downto 1) = CAPS_CODE) and |
(rx_shifting_done = '1') and |
(hold_released = '0') then |
caps_key_on <= not caps_key_on; |
end if; |
end if; |
if clk'event and clk = '0' then |
if (reset = '1') then |
caps_key_on <= '0'; |
elsif (q(8 downto 1) = CAPS_CODE) and (rx_shifting_done = '1') then |
if (hold_released = '0') then |
caps_key_on <= not caps_key_on; |
end if; |
end if; |
end if; |
end process; |
|
|
-- |
-- Output the special scan code flags, the scan code and the ascii |
special_scan_proc : process(clk, reset, |
hold_extended, hold_released, |
q, ascii, ctrl_key_on ) |
-- |
special_scan_proc : process(clk, reset, rx_output_strobe, |
hold_extended, hold_released, |
ascii, ctrl_key_on ) |
begin |
if clk'event and clk = '0' then |
if (reset = '1') then |
rx_extended <= '0'; |
rx_released <= '0'; |
-- rx_scan_code <= "00000000"; |
rx_data <= "00000000"; |
elsif (rx_output_strobe = '1') then |
rx_extended <= hold_extended; |
rx_released <= hold_released; |
-- rx_scan_code <= q(8 downto 1); |
elsif ctrl_key_on = '1' then |
rx_data <= ascii and x"1f"; |
else |
rx_data <= ascii; |
end if; |
end if; |
if clk'event and clk = '0' then |
if (reset = '1') then |
rx_extended <= '0'; |
rx_released <= '0'; |
rx_data <= (others=>'0'); |
elsif (rx_output_strobe = '1') then |
rx_extended <= hold_extended; |
rx_released <= hold_released; |
if ctrl_key_on = '1' then |
rx_data <= ascii and x"1f"; |
else |
rx_data <= ascii; |
end if; |
end if; |
end if; |
end process; |
|
|
-- |
-- Store the final rx output data only when all extend and release codes |
-- are received and the next (actual key) scan code is also ready. |
-- (the presence of rx_extended or rx_released refers to the |
-- the current latest scan code received, not the previously latched flags.) |
|
-- |
rx_output_proc : process( clk, reset, |
rx_shifting_done, rx_output_strobe, |
extended, released, |
q, ascii, rx_read ) |
begin |
if (rx_shifting_done = '1') and (extended = '0') and (released = '0') then |
rx_output_event <= '1'; |
else |
rx_output_event <= '0'; |
end if; |
|
if clk'event and clk = '0' then |
if reset = '1' then |
rx_output_strobe <= '0'; |
elsif (rx_shifting_done = '1') and |
(rx_output_strobe = '0') and |
(extended = '0') and |
(released = '0') and |
(hold_released = '0' ) and |
(ascii /= x"00" ) then |
-- ((TRAP_SHIFT_KEYS_PP = 0) or |
-- ( (q(8 downto 1) /= RIGHT_SHIFT) and |
-- (q(8 downto 1) /= LEFT_SHIFT) and |
-- (q(8 downto 1) /= CTRL_CODE) ) )then |
rx_output_strobe <= '1'; |
elsif rx_read = '1' then |
rx_output_strobe <= '0'; |
end if; |
end if; |
rx_data_ready <= rx_output_strobe; |
extended, released, |
hold_extended, hold_released, |
q, ascii, rx_read ) |
begin |
if clk'event and clk = '0' then |
if reset = '1' then |
rx_output_strobe <= '0'; |
elsif (rx_shifting_done = '1') and (rx_output_strobe = '0') and |
(extended = '0') and (released = '0') and |
(hold_released = '0' ) and |
(ascii /= "00000000" ) then |
-- ((TRAP_SHIFT_KEYS_PP = 0) or |
-- ( (q(8 downto 1) /= RIGHT_SHIFT) and |
-- (q(8 downto 1) /= LEFT_SHIFT) and |
-- (q(8 downto 1) /= CTRL_CODE) ) )then |
rx_output_strobe <= '1'; |
elsif rx_read = '1' then |
rx_output_strobe <= '0'; |
end if; |
end if; |
rx_data_ready <= rx_output_strobe; |
end process; |
|
|
-- This part translates the scan code into an ASCII value... |
-- Only the ASCII codes which I considered important have been included. |
-- if you want more, just add the appropriate case statement lines... |
-- (You will need to know the keyboard scan codes you wish to assign.) |
-- The entries are listed in ascending order of ASCII value. |
shift_key_plus_code <= shift_key_on & caps_key_on & q(7 downto 1); |
|
|
-- |
-- This part translates the scan code into an ASCII value... |
-- Only the ASCII codes which I considered important have been included. |
-- if you want more, just add the appropriate case statement lines... |
-- (You will need to know the keyboard scan codes you wish to assign.) |
-- The entries are listed in ascending order of ASCII value. |
-- |
--shift_map : process( shift_key_plus_code ) |
--begin |
-- case shift_key_plus_code is |
896,8 → 916,9
-- when x"10e" => ascii <= x"7e"; -- ~ |
-- when x"071" => ascii <= x"7f"; -- (Delete OR DEL on numeric keypad) |
-- when x"171" => ascii <= x"7f"; -- (Delete OR DEL on numeric keypad) |
-- when others => ascii <= x"ff"; -- 0xff used for unlisted characters. |
-- when others => ascii <= x"00"; -- 0xff used for unlisted characters. |
-- end case; |
--end process; |
|
|
end rtl; |
/clock_dll.vhd
1,103 → 1,125
--===========================================================================---- |
--===========================================================================-- |
-- -- |
-- clock_dll.vhd - Synthesible System Clock Divider for Xilinx Spartan 3 -- |
-- -- |
--===========================================================================-- |
-- |
-- S Y N T H E Z I A B L E Clock_dll for System09 - SOC. |
-- File name : clock_dll.vhd |
-- |
--===========================================================================---- |
-- |
-- This core adheres to the GNU public license |
-- No responsibility is taken for this design. |
-- Use at own risk. |
-- |
-- File name : Clock_dll.vhd |
-- |
-- Purpose : Generates Clocks for System09 |
-- For BurchED B3-Spartan2+ and B5-X300 |
-- Assumes a 12.5 MHz system clock input |
-- Generates a x1 (12.5 MHz) CPU clock |
-- Generates a x2 (25.0 MHz) VGA clock |
-- Generates a x4 (50.0 MHz) MEM clock |
-- |
-- Dependencies : ieee.Std_Logic_1164 |
-- Purpose : Implements a a system clock divider for System09. |
-- For Xilinx Spartan 3 and 3E FPGA boards |
-- Assumes a 12.5 MHz system clock input |
-- Generates a x1 (12.5 MHz) CPU clock |
-- Generates a x2 (25.0 MHz) VGA clock |
-- Generates a x4 (50.0 MHz) MEM clock |
-- |
-- Dependencies : ieee.std_logic_1164 |
-- ieee.std_logic_arith |
-- ieee.std_logic_unsigned |
-- ieee.std_logic_arith |
-- ieee.numeric_std |
-- |
-- |
-- Revision History : |
-- |
-- Rev : 0.1 |
-- Date : 7th September 2008 |
-- Description : Initial version. |
-- |
-- |
-- ieee.numeric_std |
-- unisim.vcomponents |
-- |
-- Author : John E. Kent |
-- |
-- Email : dilbert57@opencores.org |
-- |
-- Web : http://opencores.org/project,system09 |
-- |
-- clock_dll.vhd is a system clock divider for system09. |
-- |
-- Copyright (C) 2003 - 2010 John Kent |
-- |
-- 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 Software Foundation, either version 3 of the License, or |
-- (at your option) any later version. |
-- |
-- This program is distributed in the hope that it will be useful, |
-- but WITHOUT ANY WARRANTY; without even the implied warranty of |
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
-- GNU General Public License for more details. |
-- |
-- You should have received a copy of the GNU General Public License |
-- along with this program. If not, see <http://www.gnu.org/licenses/>. |
-- |
--===========================================================================-- |
-- -- |
-- Revision History -- |
-- -- |
--===========================================================================-- |
-- |
-- Revision Name Date Description |
-- 0.1 John E. Kent 7th September 2008 Initial version |
-- 1.0 John E. Kent 30th May 2010 Added GPL Header |
-- |
library ieee; |
use ieee.std_logic_1164.all; |
use IEEE.STD_LOGIC_ARITH.ALL; |
use IEEE.STD_LOGIC_UNSIGNED.ALL; |
use ieee.std_logic_arith.all; |
use ieee.std_logic_unsigned.all; |
use ieee.numeric_std.all; |
library unisim; |
use unisim.vcomponents.all; |
|
entity clock_dll is |
entity clock_dll is |
port( |
clk_in : in std_Logic; -- System Clock input |
clk_cpu : out std_logic; -- CPU Clock Out (x1) |
clk_vga : out std_logic; -- VGA Pixel Clock Out (x2) |
clk_mem : out std_logic; -- Memory Clock Out (x4) |
locked : out std_logic -- DLL in lock |
); |
end entity; |
|
clk_cpu : out std_logic; -- CPU Clock Out (x1) |
clk_vga : out std_logic; -- VGA Pixel Clock Out (x2) |
clk_mem : out std_logic; -- Memory Clock Out (x4) |
locked : out std_logic -- DLL in lock |
); |
end entity; |
|
architecture RTL of clock_dll is |
|
signal CPU_CLK0 : std_ulogic; |
signal CPU_CLK90 : std_ulogic; |
signal CPU_CLK180 : std_ulogic; |
signal CPU_CLK270 : std_ulogic; |
signal CPU_CLK2X : std_ulogic; |
signal CPU_CLKDV : std_ulogic; |
signal CPU_LOCKED : std_ulogic; |
signal CPU_CLKFB : std_ulogic; |
signal CPU_CLKIN : std_ulogic; |
signal CPU_RESET : std_ulogic; |
|
signal VGA_CLK0 : std_ulogic; |
signal VGA_CLK90 : std_ulogic; |
signal VGA_CLK180 : std_ulogic; |
signal VGA_CLK270 : std_ulogic; |
signal VGA_CLK2X : std_ulogic; |
signal VGA_CLKDV : std_ulogic; |
signal VGA_LOCKED : std_ulogic; |
|
signal CPU_CLK0 : std_ulogic; |
signal CPU_CLK90 : std_ulogic; |
signal CPU_CLK180 : std_ulogic; |
signal CPU_CLK270 : std_ulogic; |
signal CPU_CLK2X : std_ulogic; |
signal CPU_CLKDV : std_ulogic; |
signal CPU_LOCKED : std_ulogic; |
signal CPU_CLKFB : std_ulogic; |
signal CPU_CLKIN : std_ulogic; |
signal CPU_RESET : std_ulogic; |
|
signal VGA_CLK0 : std_ulogic; |
signal VGA_CLK90 : std_ulogic; |
signal VGA_CLK180 : std_ulogic; |
signal VGA_CLK270 : std_ulogic; |
signal VGA_CLK2X : std_ulogic; |
signal VGA_CLKDV : std_ulogic; |
signal VGA_LOCKED : std_ulogic; |
signal VGA_CLKFB : std_ulogic; |
signal VGA_CLKIN : std_ulogic; |
signal VGA_CLKIN : std_ulogic; |
signal VGA_RESET : std_ulogic; |
signal VGA_RESET_N : std_ulogic; |
|
-- Component Declaration for CLKDLL should be placed |
-- after architecture statement but before begin keyword |
|
component CLKDLL |
-- synthesis translate_off |
generic ( |
CLKDV_DIVIDE : real := 2.0; -- (1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 8.0, 16.0) |
DUTY_CYCLE_CORRECTION : Boolean := TRUE; -- (TRUE, FALSE) |
STARTUP_WAIT : boolean := FALSE -- (TRUE, FALSE) |
); |
-- synthesis translate_on |
port ( |
CLK0 : out STD_ULOGIC; |
CLK180 : out STD_ULOGIC; |
CLK270 : out STD_ULOGIC; |
CLK2X : out STD_ULOGIC; |
CLK90 : out STD_ULOGIC; |
CLKDV : out STD_ULOGIC; |
LOCKED : out STD_ULOGIC; |
CLKFB : in STD_ULOGIC; |
CLKIN : in STD_ULOGIC; |
RST : in STD_ULOGIC |
); |
end component; |
|
|
-- Component Declaration for CLKDLL should be placed |
-- after architecture statement but before begin keyword |
|
component CLKDLL |
-- synthesis translate_off |
generic ( |
CLKDV_DIVIDE : real := 2.0; -- (1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 8.0, 16.0) |
DUTY_CYCLE_CORRECTION : Boolean := TRUE; -- (TRUE, FALSE) |
STARTUP_WAIT : boolean := FALSE -- (TRUE, FALSE) |
); |
-- synthesis translate_on |
port ( |
CLK0 : out STD_ULOGIC; |
CLK180 : out STD_ULOGIC; |
CLK270 : out STD_ULOGIC; |
CLK2X : out STD_ULOGIC; |
CLK90 : out STD_ULOGIC; |
CLKDV : out STD_ULOGIC; |
LOCKED : out STD_ULOGIC; |
CLKFB : in STD_ULOGIC; |
CLKIN : in STD_ULOGIC; |
RST : in STD_ULOGIC |
); |
end component; |
|
component IBUFG |
port ( |
i: in std_logic; |
111,122 → 133,122
o: out std_logic |
); |
end component; |
|
component SRL16 |
port ( |
Q : out std_logic; |
D : in std_logic; |
CLK : in std_logic; |
A0 : in std_logic; |
A1 : in std_logic; |
A2 : in std_logic; |
A3 : in std_logic |
); |
end component; |
|
|
component SRL16 |
port ( |
Q : out std_logic; |
D : in std_logic; |
CLK : in std_logic; |
A0 : in std_logic; |
A1 : in std_logic; |
A2 : in std_logic; |
A3 : in std_logic |
); |
end component; |
|
-- |
-- Start instantiation |
-- |
begin |
|
-- |
-- Start instantiation |
-- |
begin |
|
-- |
-- 12.5MHz CPU clock input |
-- |
cpu_clkin_buffer : IBUFG |
cpu_clkin_buffer : IBUFG |
port map( |
i => clk_in, |
o => CPU_CLKIN |
); |
|
|
-- |
-- 12.5MHz CPU clock input |
-- |
cpu_clkout_buffer : BUFG |
cpu_clkout_buffer : BUFG |
port map( |
i => CPU_CLKIN, |
o => clk_cpu |
); |
|
|
-- |
-- 25 MHz VGA clock input |
-- |
cpu_clkfb_buffer : BUFG |
cpu_clkfb_buffer : BUFG |
port map( |
i => CPU_CLK2X, |
o => CPU_CLKFB |
); |
|
CLKDLL_CPU : CLKDLL |
-- synthesis translate_off |
generic map ( |
CLKDV_DIVIDE => 2.0, -- (1.5,2,2.5,3,4,5,8,16) |
DUTY_CYCLE_CORRECTION => TRUE, -- (TRUE, FALSE) |
STARTUP_WAIT => FALSE -- (TRUE, FALSE) |
); |
-- synthesis translate_on |
port map ( |
CLK0 => CPU_CLK0, |
CLK90 => CPU_CLK90, |
CLK180 => CPU_CLK180, |
CLK270 => CPU_CLK270, |
CLK2X => CPU_CLK2X, |
CLKDV => CPU_CLKDV, |
LOCKED => CPU_LOCKED, |
CLKFB => CPU_CLKFB, |
CLKIN => CPU_CLKIN, |
RST => CPU_RESET |
); |
|
|
CLKDLL_CPU : CLKDLL |
-- synthesis translate_off |
generic map ( |
CLKDV_DIVIDE => 2.0, -- (1.5,2,2.5,3,4,5,8,16) |
DUTY_CYCLE_CORRECTION => TRUE, -- (TRUE, FALSE) |
STARTUP_WAIT => FALSE -- (TRUE, FALSE) |
); |
-- synthesis translate_on |
port map ( |
CLK0 => CPU_CLK0, |
CLK90 => CPU_CLK90, |
CLK180 => CPU_CLK180, |
CLK270 => CPU_CLK270, |
CLK2X => CPU_CLK2X, |
CLKDV => CPU_CLKDV, |
LOCKED => CPU_LOCKED, |
CLKFB => CPU_CLKFB, |
CLKIN => CPU_CLKIN, |
RST => CPU_RESET |
); |
|
-- |
-- 25 MHz VGA clock output |
-- |
vga_clkfb_buffer : BUFG |
vga_clkfb_buffer : BUFG |
port map( |
i => VGA_CLK2X, |
o => VGA_CLKFB |
); |
|
CLKDLL_VGA : CLKDLL |
-- synthesis translate_off |
generic map ( |
CLKDV_DIVIDE => 2.0, -- (1.5,2,2.5,3,4,5,8,16) |
DUTY_CYCLE_CORRECTION => TRUE, -- (TRUE, FALSE) |
STARTUP_WAIT => FALSE -- (TRUE, FALSE) |
); |
-- synthesis translate_on |
port map ( |
CLK0 => VGA_CLK0, |
CLK90 => VGA_CLK90, |
CLK180 => VGA_CLK180, |
CLK270 => VGA_CLK270, |
CLK2X => VGA_CLK2X, |
CLKDV => VGA_CLKDV, |
LOCKED => VGA_LOCKED, |
CLKFB => VGA_CLKFB, |
CLKIN => VGA_CLKIN, |
RST => VGA_RESET |
); |
|
my_srl16 : SRL16 port map ( |
Q => VGA_RESET_N, |
D => CPU_LOCKED, |
CLK => CPU_CLKFB, |
A0 => '1', |
A1 => '1', |
A2 => '1', |
A3 => '1' |
); |
|
clock_dll_assign : process( VGA_RESET_N, VGA_LOCKED, |
clk_in, CPU_CLKFB, VGA_CLKFB ) |
begin |
VGA_RESET <= not VGA_RESET_N; |
VGA_CLKIN <= CPU_CLKFB; |
CPU_RESET <= '0'; |
clk_vga <= CPU_CLKFB; |
clk_mem <= VGA_CLKFB; |
locked <= VGA_LOCKED; |
end process; |
|
end architecture; |
|
CLKDLL_VGA : CLKDLL |
-- synthesis translate_off |
generic map ( |
CLKDV_DIVIDE => 2.0, -- (1.5,2,2.5,3,4,5,8,16) |
DUTY_CYCLE_CORRECTION => TRUE, -- (TRUE, FALSE) |
STARTUP_WAIT => FALSE -- (TRUE, FALSE) |
); |
-- synthesis translate_on |
port map ( |
CLK0 => VGA_CLK0, |
CLK90 => VGA_CLK90, |
CLK180 => VGA_CLK180, |
CLK270 => VGA_CLK270, |
CLK2X => VGA_CLK2X, |
CLKDV => VGA_CLKDV, |
LOCKED => VGA_LOCKED, |
CLKFB => VGA_CLKFB, |
CLKIN => VGA_CLKIN, |
RST => VGA_RESET |
); |
|
my_srl16 : SRL16 port map ( |
Q => VGA_RESET_N, |
D => CPU_LOCKED, |
CLK => CPU_CLKFB, |
A0 => '1', |
A1 => '1', |
A2 => '1', |
A3 => '1' |
); |
|
clock_dll_assign : process( VGA_RESET_N, VGA_LOCKED, |
clk_in, CPU_CLKFB, VGA_CLKFB ) |
begin |
VGA_RESET <= not VGA_RESET_N; |
VGA_CLKIN <= CPU_CLKFB; |
CPU_RESET <= '0'; |
clk_vga <= CPU_CLKFB; |
clk_mem <= VGA_CLKFB; |
locked <= VGA_LOCKED; |
end process; |
|
end architecture; |
|
/vdu8.vhd
15,9 → 15,7
-- Supports 2 x 8 chunky graphics character mode. |
-- Uses Generic arguments for setting the video synchronization timing. |
-- |
-- Dependencies : ieee.Std_Logic_1164 |
-- ieee.std_logic_unsigned |
-- ieee.std_logic_arith |
-- Dependencies : ieee.std_logic_1164 |
-- ieee.numeric_std |
-- |
-- Uses : ram_2k (ram2k_b16.vhd) 2KByte Character & Attribute buffer |
133,8 → 131,8
Library IEEE; |
use IEEE.std_logic_1164.all; |
use IEEE.numeric_std.all; |
Library unisim; |
use unisim.vcomponents.all; |
--Library unisim; |
-- use unisim.vcomponents.all; |
|
Entity vdu8 is |
generic( |
/pia6821.vhd
61,8 → 61,8
library ieee; |
use ieee.std_logic_1164.all; |
use ieee.std_logic_unsigned.all; |
library unisim; |
use unisim.vcomponents.all; |
--library unisim; |
-- use unisim.vcomponents.all; |
|
entity pia6821 is |
port ( |
/keyboard.vhd
14,7 → 14,6
-- ieee.std_logic_arith |
-- ieee.std_logic_unsigned |
-- ieee.numeric_std |
-- unisim.vcomponents |
-- |
-- Uses : ps2_keyboard_interface |
-- |
88,8 → 87,8
use ieee.std_logic_arith.all; |
use ieee.std_logic_unsigned.all; |
use ieee.numeric_std.all; |
library unisim; |
use unisim.vcomponents.all; |
--library unisim; |
-- use unisim.vcomponents.all; |
|
entity keyboard is |
generic ( |
249,7 → 248,7
-- |
keyboard_status : process( kbd_data_ready, kbd_data_empty, |
kbd_extended, kbd_released, kbd_shift_on, kbd_error, |
kbd_control) |
kbd_control, kbd_status ) |
begin |
kbd_status(0) <= kbd_data_ready; |
kbd_status(1) <= kbd_data_empty; |
/pia_timer.vhd
122,7 → 122,7
signal ca1_rise : std_logic; |
signal ca1_fall : std_logic; |
signal ca1_edge : std_logic; |
signal irqa1 : std_logic; |
signal irqa1 : std_logic := '0'; |
|
signal ca2 : std_logic; |
signal ca2_del : std_logic; |
129,7 → 129,7
signal ca2_rise : std_logic; |
signal ca2_fall : std_logic; |
signal ca2_edge : std_logic; |
signal irqa2 : std_logic; |
signal irqa2 : std_logic := '0'; |
signal ca2_out : std_logic; |
|
signal cb1 : std_logic; |
137,7 → 137,7
signal cb1_rise : std_logic; |
signal cb1_fall : std_logic; |
signal cb1_edge : std_logic; |
signal irqb1 : std_logic; |
signal irqb1 : std_logic := '0'; |
|
signal cb2 : std_logic; |
signal cb2_del : std_logic; |
144,7 → 144,7
signal cb2_rise : std_logic; |
signal cb2_fall : std_logic; |
signal cb2_edge : std_logic; |
signal irqb2 : std_logic; |
signal irqb2 : std_logic := '0'; |
signal cb2_out : std_logic; |
|
-- 74193 down counter |
166,55 → 166,57
pa, pb ) |
variable count : integer; |
begin |
case addr is |
when "00" => |
for count in 0 to 7 loop |
if porta_ctrl(2) = '0' then |
data_out(count) <= porta_ddr(count); |
porta_read <= '0'; |
data_out <= "00000000"; |
porta_read <= '0'; |
portb_read <= '0'; |
|
case addr is |
when "00" => |
for count in 0 to 7 loop |
if porta_ctrl(2) = '0' then |
data_out(count) <= porta_ddr(count); |
porta_read <= '0'; |
else |
if porta_ddr(count) = '1' then |
data_out(count) <= porta_data(count); |
else |
if porta_ddr(count) = '1' then |
data_out(count) <= porta_data(count); |
else |
data_out(count) <= pa(count); |
end if; |
porta_read <= cs; |
data_out(count) <= pa(count); |
end if; |
end loop; |
portb_read <= '0'; |
porta_read <= cs; |
end if; |
end loop; |
portb_read <= '0'; |
|
when "01" => |
data_out <= irqa1 & irqa2 & porta_ctrl; |
porta_read <= '0'; |
portb_read <= '0'; |
when "01" => |
data_out <= irqa1 & irqa2 & porta_ctrl; |
porta_read <= '0'; |
portb_read <= '0'; |
|
when "10" => |
for count in 0 to 7 loop |
if portb_ctrl(2) = '0' then |
data_out(count) <= portb_ddr(count); |
portb_read <= '0'; |
when "10" => |
for count in 0 to 7 loop |
if portb_ctrl(2) = '0' then |
data_out(count) <= portb_ddr(count); |
portb_read <= '0'; |
else |
if portb_ddr(count) = '1' then |
data_out(count) <= portb_data(count); |
else |
if portb_ddr(count) = '1' then |
data_out(count) <= portb_data(count); |
else |
data_out(count) <= pb(count); |
end if; |
portb_read <= cs; |
end if; |
end loop; |
porta_read <= '0'; |
end if; |
portb_read <= cs; |
end if; |
end loop; |
porta_read <= '0'; |
|
when "11" => |
data_out <= irqb1 & irqb2 & portb_ctrl; |
porta_read <= '0'; |
portb_read <= '0'; |
when "11" => |
data_out <= irqb1 & irqb2 & portb_ctrl; |
porta_read <= '0'; |
portb_read <= '0'; |
|
when others => |
data_out <= "00000000"; |
porta_read <= '0'; |
portb_read <= '0'; |
when others => |
null; |
end case; |
|
end case; |
end process; |
|
--------------------------------- |
/ioport.vhd
55,8 → 55,8
library ieee; |
use ieee.std_logic_1164.all; |
use ieee.std_logic_unsigned.all; |
library unisim; |
use unisim.vcomponents.all; |
--library unisim; |
-- use unisim.vcomponents.all; |
|
entity ioport is |
port ( |
/acia6850.vhd
12,8 → 12,8
-- Asynchronous Communications Interface Adapter (ACIA) |
-- |
-- Dependencies : ieee.std_logic_1164 |
-- ieee.numeric_std |
-- unisim.vcomponents |
-- ieee.numeric_std |
-- ieee.std_logic_unsigned |
-- |
-- Author : John E. Kent |
-- |
125,8 → 125,8
use ieee.std_logic_1164.all; |
use ieee.numeric_std.all; |
use ieee.std_logic_unsigned.all; |
library unisim; |
use unisim.vcomponents.all; |
--library unisim; |
-- use unisim.vcomponents.all; |
|
----------------------------------------------------------------------- |
-- Entity for ACIA_6850 -- |
340,11 → 340,12
-- Generate Read / Write strobes. |
----------------------------------------------------------------------------- |
|
ACIA_Read_Write : process(clk, ac_rst) |
acia_read_write : process(clk, ac_rst) |
begin |
if falling_edge(clk) then |
if ac_rst = '1' then |
CtrlReg <= (others => '0'); |
if rst = '1' then |
CtrlReg(1 downto 0) <= "11"; |
CtrlReg(7 downto 2) <= (others => '0'); |
TxReg <= (others => '0'); |
RxRd <= '0'; |
TxWr <= '0'; |
/Flasher.vhd
14,7 → 14,6
-- Dependencies : ieee.std_logic_1164 |
-- ieee.numeric_std |
-- ieee.std_logic_unsigned |
-- unisim.vcomponents |
-- |
-- Author : John E. Kent |
-- |
53,8 → 52,8
use ieee.std_logic_1164.all; |
use ieee.numeric_std.all; |
use ieee.std_logic_unsigned.all; |
library unisim; |
use unisim.vcomponents.all; |
--library unisim; |
-- use unisim.vcomponents.all; |
|
----------------------------------------------------------------------- |
-- Entity for B3_SRAM -- |
/clock_div.vhd
1,42 → 1,65
--===========================================================================---- |
--=========================================================================== |
-- |
-- S Y N T H E Z I A B L E Clock_dll for System09 - SOC. |
-- clock_div.vhd - Clock divider for System09 |
-- |
--===========================================================================---- |
--=========================================================================== |
-- |
-- File name : clock_div.vhd |
-- |
-- Entity name : clock_div |
-- |
-- This core adheres to the GNU public license |
-- No responsibility is taken for this design. |
-- Use at own risk. |
-- Purpose : Generates Clocks for System09 |
-- For BurchED B3-Spartan2+ and B5-X300 |
-- Divides the input clock which is normally 50MHz |
-- Generates a 1/1 (50.0 MHz) SYS clock |
-- Generates a 1/2 (25.0 MHz) VGA clock |
-- Generates a 1/4 (12.5 MHz) CPU clock |
-- |
-- File name : Clock_dll.vhd |
-- Dependencies : ieee.Std_Logic_1164 |
-- ieee.std_logic_unsigned |
-- ieee.std_logic_arith |
-- ieee.numeric_std |
-- |
-- Purpose : Generates Clocks for System09 |
-- For BurchED B3-Spartan2+ and B5-X300 |
-- Assumes a 12.5 MHz system clock input |
-- Generates a x1 (12.5 MHz) CPU clock |
-- Generates a x2 (25.0 MHz) VGA clock |
-- Generates a x4 (50.0 MHz) MEM clock |
-- Uses : IBUFG |
-- BUFG |
-- |
-- Dependencies : ieee.Std_Logic_1164 |
-- ieee.std_logic_unsigned |
-- ieee.std_logic_arith |
-- ieee.numeric_std |
-- Author : John E. Kent |
-- dilbert57@opencores.org |
-- |
-- Copyright (C) 2003 - 2010 John Kent |
-- |
-- 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 Software Foundation, either version 3 of the License, or |
-- (at your option) any later version. |
-- |
-- This program is distributed in the hope that it will be useful, |
-- but WITHOUT ANY WARRANTY; without even the implied warranty of |
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
-- GNU General Public License for more details. |
-- |
-- You should have received a copy of the GNU General Public License |
-- along with this program. If not, see <http://www.gnu.org/licenses/>. |
-- |
--=========================================================================== |
-- |
-- Revision History : |
-- Revision History: |
-- |
--=========================================================================== |
-- |
-- Rev : 0.1 |
-- Date : 7th September 2008 |
-- Description : Initial version. |
-- |
-- Rev: Date: Author: Description: |
-- |
-- 0.1 2008-09-07 John Kent Initial version |
-- 0.2 2010-09-14 John Kent Updated header |
-- |
-- |
library ieee; |
use ieee.std_logic_1164.all; |
use IEEE.STD_LOGIC_ARITH.ALL; |
use IEEE.STD_LOGIC_UNSIGNED.ALL; |
use ieee.numeric_std.all; |
library unisim; |
use unisim.vcomponents.all; |
--library unisim; |
-- use unisim.vcomponents.all; |
|
entity clock_div is |
port( |
49,16 → 72,8
|
architecture RTL of clock_div is |
|
signal div_clk : std_logic; |
signal div_count : std_logic_vector(1 downto 0); |
|
component IBUFG |
port ( |
i: in std_logic; |
o: out std_logic |
); |
end component; |
|
|
component BUFG |
port ( |
i: in std_logic; |
66,7 → 81,6
); |
end component; |
|
|
-- |
-- Start instantiation |
-- |
73,12 → 87,12
begin |
|
-- |
-- 50.0MHz system clock |
-- 50 MHz SYS clock output |
-- |
sys_clk_buffer : IBUFG |
sys_clk_buffer : BUFG |
port map( |
i => clk_in, |
o => div_clk |
o => sys_clk |
); |
|
-- |
102,12 → 116,11
-- |
-- Clock divider |
-- |
clock_div : process( div_clk ) |
clock_div : process( clk_in ) |
begin |
if rising_edge( div_clk) then |
if rising_edge( clk_in ) then |
div_count <= div_count + "01"; |
end if; |
sys_clk <= div_clk; |
end process; |
|
end architecture; |