📄 proc_rtl.vhd
字号:
-------------------------------------------------------------------------------
-- CPU86 - VHDL CPU8088 IP core --
-- Copyright (C) 2005-2008 HT-LAB --
-- --
-- Contact/bugs : http://www.ht-lab.com/misc/feedback.html --
-- Web : http://www.ht-lab.com --
-- --
-- CPU86 is released as open-source under the Aladdin Free Public License. --
-- Contact HT-Lab for commercial applications and/or support contracts. --
-- --
-- Full details of the license can be found in the file "cpu86_license.txt" --
-- which is included in the distribution zip file. --
-------------------------------------------------------------------------------
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.std_logic_unsigned.ALL;
USE ieee.std_logic_arith.ALL;
USE work.cpu86pack.ALL;
USE work.cpu86instr.ALL;
ENTITY proc IS
PORT(
clk : IN std_logic;
flush_ack : IN std_logic;
instr : IN instruction_type;
inta1 : IN std_logic;
irq_req : IN std_logic;
latcho : IN std_logic;
reset : IN std_logic;
rw_ack : IN std_logic;
status : IN status_out_type;
clrop : OUT std_logic;
decode_state : OUT std_logic;
flush_coming : OUT std_logic;
flush_req : OUT std_logic;
intack : OUT std_logic;
iomem : OUT std_logic;
irq_blocked : OUT std_logic;
opc_req : OUT std_logic;
path : OUT path_in_type;
proc_error : OUT std_logic;
read_req : OUT std_logic;
word : OUT std_logic;
write_req : OUT std_logic;
wrpath : OUT write_in_type
);
-- Declarations
END proc ;
architecture rtl of proc is
type state_type is (
Sopcode,Sdecode,
Sreadmem,Swritemem,
Sexecute,Sflush,Shalt);
-- State vector declaration
attribute state_vector : string;
attribute state_vector of rtl : architecture is "current_state" ;
-- Declare current and next state signals
signal current_state: state_type ;
signal next_state : state_type ;
signal second_pass : std_logic; -- if 1 go round the loop again
signal second_pass_s: std_logic; -- Comb version
signal rep_set_s : std_logic; -- Start of REP Instruction, check CX when set
signal rep_clear_s : std_logic; -- Signal end of REP Instruction
signal rep_flag : std_logic; -- REPEAT Flag
signal rep_z_s : std_logic; -- Z value of REP instruction
signal rep_zl_s : std_logic; -- Latched Z value of REP
signal flush_coming_s : std_logic; -- Signal that a flush is imminent (don't bother filling the queue)
signal irq_blocked_s: std_logic; -- Indicate that IRQ will be blocked during the next instruction
-- This is required for pop segment etc instructions.
signal intack_s : std_logic; -- Signal asserted during 8 bits vector read, this occurs during
-- the second INTA cycle
signal passcnt_s : std_logic_vector(4 downto 0); -- Copy of CL register
signal passcnt : std_logic_vector(4 downto 0);
signal wrpath_s : write_in_type; -- combinatorial
signal wrpathl_s : write_in_type; -- Latched version of wrpath_s
signal path_s : path_in_type; -- combinatorial
signal proc_error_s : std_logic; -- Processor decode error
signal proc_err_s : std_logic; -- Processor decode error latch signal
signal iomem_s : std_logic; -- IO/~M cycle
-- alias ZFLAG : std_logic is status.flag(6); -- doesn't work, why not??
signal flush_req_s : std_logic; -- Flush Prefetch queue request
signal flush_reql_s : std_logic; -- Latched version of Flush request
begin
proc_error <= proc_err_s; -- connect to outside world
flush_req <= flush_req_s;
----------------------------------------------------------------------------
clocked : process(clk,reset)
----------------------------------------------------------------------------
begin
if (reset = '1') then
current_state <= Sopcode;
path <= ((others =>'0'),(others =>'0'),(others =>'0'),(others =>'0'),
(others =>'0'));
wrpathl_s <= ('0','0','0','0','0','0','0');
word <= '0'; -- default to 8 bits
proc_err_s <= '0'; -- Processor decode error
iomem <= '0'; -- default to memory access
second_pass <= '0'; -- default 1 pass
flush_reql_s<= '0'; -- flush prefetch queue
passcnt <= "00001"; -- Copy of CL register used in rot/shft
rep_flag <= '0'; -- REP instruction running flag
rep_zl_s <= '0'; -- REP latched z bit
flush_coming<= '0'; -- flush approaching
irq_blocked <= '1'; -- IRQ blocking for next instruction
intack <= '0'; -- Second INTA cycle signal
elsif rising_edge(clk) then
current_state<= next_state;
proc_err_s <= proc_error_s or proc_err_s; -- Latch Processor error, cleared by reset only
flush_reql_s <= flush_req_s; -- Latch Flush_request signal
if current_state=Sdecode then -- Latch write pulse and path settings
second_pass <= second_pass_s; -- latch pass signal
word <= path_s.datareg_input(3); -- word <= w bit
path <= path_s;
wrpathl_s <= wrpath_s;
passcnt <= passcnt_s;
irq_blocked <=irq_blocked_s; -- Signal to block IRQ during next instruction
intack <= intack_s; -- Second INTA cycle signal
end if;
if ((current_state=Sdecode) or (current_state=Sexecute)) then--Latch IOMEM signal
iomem <= iomem_s; -- Latch IOM signal
flush_coming<=flush_coming_s; -- flush approaching
end if;
--rep_flag <= (rep_flag or rep_set_s) and (not rep_clear_s);
if rep_set_s='1' then -- Set/Reset REP flag
rep_flag <= '1';
elsif rep_clear_s='1' then
rep_flag <= '0';
end if;
if rep_set_s='1' then
rep_zl_s <= rep_z_s; -- Latch Z value of REP instruction
end if;
end if;
end process clocked;
----------------------------------------------------------------------------
nextstate : process (current_state, latcho, rw_ack, flush_ack, instr, status,wrpathl_s, second_pass,irq_req,
passcnt, flush_reql_s, rep_flag, rep_zl_s, inta1)
----------------------------------------------------------------------------
begin
-- Default Assignment
opc_req <= '0';
read_req <= '0';
write_req <= '0';
wrpath_s <= ('0','0','0','0','0','0','0'); -- Default all writes disabled
wrpath <= ('0','0','0','0','0','0','0'); -- Combinatorial
path_s <= ((others =>'0'),(others =>'0'),(others =>'0'),(others =>'0'),
(others =>'0'));
proc_error_s<= '0';
iomem_s <= '0'; -- IO/~M default to memory access
flush_req_s <= '0'; -- Flush Prefetch queue request
passcnt_s <= "00001"; -- init to 1
rep_set_s <= '0'; -- default no repeat
rep_clear_s <= '0'; -- default no clear
rep_z_s <= '0'; -- REP instruction Z bit
flush_coming_s<='0'; -- don't fill the instruction queue
irq_blocked_s<='0'; -- default, no block IRQ
clrop <= '0'; -- Clear Segment override flag
second_pass_s<='0'; -- HT0912,
intack_s <= '0'; -- Signal asserted during INT second INTA cycle
decode_state <= '0'; -- Decode stage for signal spy only
case current_state is
----------------------------------------------------------------------------
-- Get Opcode from BIU
----------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -