Line 200... |
Line 200... |
-- potentially block higher priority interrupts
|
-- potentially block higher priority interrupts
|
-- until the lower priority ISR returns or clears
|
-- until the lower priority ISR returns or clears
|
-- the I bit.
|
-- the I bit.
|
-- Also added the I bit to the exported flags for
|
-- Also added the I bit to the exported flags for
|
-- use in memory protection schemes.
|
-- use in memory protection schemes.
|
|
-- Seth Henry 04/16/20 Modified to use new Open8 bus record. Also added
|
|
-- reset and usec_tick logic to drive utility signals
|
|
|
library ieee;
|
library ieee;
|
use ieee.std_logic_1164.all;
|
use ieee.std_logic_1164.all;
|
use ieee.std_logic_unsigned.all;
|
use ieee.std_logic_unsigned.all;
|
use ieee.std_logic_arith.all;
|
use ieee.std_logic_arith.all;
|
Line 221... |
Line 223... |
Stack_Xfer_Flag : integer := PSR_GP4; -- GP4 modifies RSP
|
Stack_Xfer_Flag : integer := PSR_GP4; -- GP4 modifies RSP
|
Enable_Auto_Increment : boolean := false; -- Modify indexed instr
|
Enable_Auto_Increment : boolean := false; -- Modify indexed instr
|
BRK_Implements_WAI : boolean := false; -- BRK -> Wait for Int
|
BRK_Implements_WAI : boolean := false; -- BRK -> Wait for Int
|
Enable_NMI : boolean := true; -- Force INTR0 enabled
|
Enable_NMI : boolean := true; -- Force INTR0 enabled
|
Sequential_Interrupts : boolean := false; -- Interruptable ISRs
|
Sequential_Interrupts : boolean := false; -- Interruptable ISRs
|
RTI_Ignores_GP_Flags : boolean := false; -- RTI restores all flags
|
RTI_Ignores_GP_Flags : boolean := false; -- RTI sets all flags
|
Default_Interrupt_Mask : DATA_TYPE := x"FF"; -- Enable all Ints
|
Default_Interrupt_Mask : DATA_TYPE := x"FF"; -- Enable all Ints
|
Reset_Level : std_logic := '0' ); -- Active reset level
|
Clock_Frequency : real -- Clock Frequency
|
|
);
|
port(
|
port(
|
Clock : in std_logic;
|
Clock : in std_logic;
|
Reset : in std_logic;
|
PLL_Locked : in std_logic;
|
CPU_Halt : in std_logic := '0';
|
CPU_Halt : in std_logic := '0';
|
GP_Flags : out EXT_GP_FLAGS;
|
|
--
|
--
|
Open8_Bus : out OPEN8_BUS_TYPE;
|
Open8_Bus : out OPEN8_BUS_TYPE;
|
Rd_Data : in DATA_TYPE;
|
Rd_Data : in DATA_TYPE;
|
Interrupts : in INTERRUPT_BUNDLE := x"00"
|
Interrupts : in INTERRUPT_BUNDLE := x"00"
|
);
|
);
|
end entity;
|
end entity;
|
|
|
architecture behave of o8_cpu is
|
architecture behave of o8_cpu is
|
|
|
|
signal Reset_q : std_logic := Reset_Level;
|
|
signal Reset : std_logic := Reset_Level;
|
|
|
|
constant USEC_VAL : integer := integer(Clock_Frequency / 1000000.0);
|
|
constant USEC_WDT : integer := ceil_log2(USEC_VAL - 1);
|
|
constant USEC_DLY : std_logic_vector :=
|
|
conv_std_logic_vector(USEC_VAL - 1, USEC_WDT);
|
|
signal uSec_Cntr : std_logic_vector( USEC_WDT - 1 downto 0 );
|
|
signal uSec_Tick : std_logic;
|
|
|
constant INT_VECTOR_0 : ADDRESS_TYPE := ISR_Start_Addr;
|
constant INT_VECTOR_0 : ADDRESS_TYPE := ISR_Start_Addr;
|
constant INT_VECTOR_1 : ADDRESS_TYPE := ISR_Start_Addr+2;
|
constant INT_VECTOR_1 : ADDRESS_TYPE := ISR_Start_Addr+2;
|
constant INT_VECTOR_2 : ADDRESS_TYPE := ISR_Start_Addr+4;
|
constant INT_VECTOR_2 : ADDRESS_TYPE := ISR_Start_Addr+4;
|
constant INT_VECTOR_3 : ADDRESS_TYPE := ISR_Start_Addr+6;
|
constant INT_VECTOR_3 : ADDRESS_TYPE := ISR_Start_Addr+6;
|
constant INT_VECTOR_4 : ADDRESS_TYPE := ISR_Start_Addr+8;
|
constant INT_VECTOR_4 : ADDRESS_TYPE := ISR_Start_Addr+8;
|
Line 287... |
Line 299... |
signal Wait_for_FSM : std_logic := '0';
|
signal Wait_for_FSM : std_logic := '0';
|
signal Wait_for_ISR : std_logic := '0';
|
signal Wait_for_ISR : std_logic := '0';
|
|
|
begin
|
begin
|
|
|
|
-------------------------------------------------------------------------------
|
|
-- Reset & uSec Tick
|
|
-------------------------------------------------------------------------------
|
|
|
|
CPU_Reset_Sync: process( Clock, PLL_Locked )
|
|
begin
|
|
if( PLL_Locked = '0' )then
|
|
Reset_q <= Reset_Level;
|
|
Reset <= Reset_Level;
|
|
elsif( rising_edge(Clock) )then
|
|
Reset_q <= not Reset_Level;
|
|
Reset <= Reset_q;
|
|
end if;
|
|
end process;
|
|
|
|
uSec_Tick_proc: process( Clock, Reset )
|
|
begin
|
|
if( Reset = Reset_Level )then
|
|
uSec_Cntr <= USEC_DLY;
|
|
uSec_Tick <= '0';
|
|
elsif( rising_edge( Clock ) )then
|
|
uSec_Cntr <= uSec_Cntr - 1;
|
|
if( or_reduce(uSec_Cntr) = '0' )then
|
|
uSec_Cntr <= USEC_DLY;
|
|
end if;
|
|
uSec_Tick <= nor_reduce(uSec_Cntr);
|
|
end if;
|
|
end process;
|
|
|
|
Open8_Bus.Clock <= Clock;
|
|
Open8_Bus.Reset <= Reset;
|
|
Open8_Bus.uSec_Tick <= uSec_Tick;
|
|
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
-- Address bus selection/generation logic
|
-- Address bus selection/generation logic
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
|
|
Line 914... |
Line 958... |
for i in 0 to 7 loop
|
for i in 0 to 7 loop
|
Regfile(i) <= x"00";
|
Regfile(i) <= x"00";
|
end loop;
|
end loop;
|
Flags <= x"00";
|
Flags <= x"00";
|
|
|
GP_Flags <= (others => '0');
|
Open8_Bus.GP_Flags <= (others => '0');
|
|
|
elsif( rising_edge(Clock) )then
|
elsif( rising_edge(Clock) )then
|
|
|
CPU_Halt_Req <= CPU_Halt;
|
CPU_Halt_Req <= CPU_Halt;
|
|
|
Line 1251... |
Line 1295... |
|
|
when others =>
|
when others =>
|
null;
|
null;
|
end case;
|
end case;
|
|
|
GP_Flags <= Flags(7 downto 3);
|
Open8_Bus.GP_Flags <= Flags(7 downto 3);
|
|
|
end if;
|
end if;
|
end process;
|
end process;
|
|
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|