OpenCores
URL https://opencores.org/ocsvn/open8_urisc/open8_urisc/trunk

Subversion Repositories open8_urisc

[/] [open8_urisc/] [trunk/] [VHDL/] [o8_cpu.vhd] - Diff between revs 227 and 244

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 227 Rev 244
Line 74... Line 74...
--            :   after an interrupt. By default, all of the flag bits are put
--            :   after an interrupt. By default, all of the flag bits are put
--            :   back to their original state. If this flag is set true, only
--            :   back to their original state. If this flag is set true, only
--            :   the lower four bits are restored, allowing ISR code to alter
--            :   the lower four bits are restored, allowing ISR code to alter
--            :   the GP flags persistently.
--            :   the GP flags persistently.
--            :
--            :
 
--            :  Supervisor_Mode, when set, disables the STP PSR_I instruction
 
--            :   preventing code from setting the I bit. When enabled, only
 
--            :   interrupts can set the I bit, allowing for more robust memory
 
--            :   protection by preventing errant code execution from
 
--            :   inadvertently entering an interrupt state.
 
--            :
 
--            :  Default_Int_Flag allows the initial state of the I bit to be
 
--            :   set at startup. If set, initialization code may be run in an
 
--            :   ISR context, disabling memory protection initially. Init code
 
--            :   should clear the I bit when done;
 
--            :
--            :  Default_Interrupt_Mask sets the intial/reset value of the
--            :  Default_Interrupt_Mask sets the intial/reset value of the
--            :   interrupt mask. To remain true to the original core, which
--            :   interrupt mask. To remain true to the original core, which
--            :   had no interrupt mask, this should be set to x"FF". Otherwise
--            :   had no interrupt mask, this should be set to x"FF". Otherwise
--            :   it can be initialized to any value. Note that Enable_NMI
--            :   it can be initialized to any value. Note that Enable_NMI
--            :   will logically force the LSB high.
--            :   will logically force the LSB high.
Line 203... Line 214...
--                          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
-- Seth Henry      04/16/20 Modified to use new Open8 bus record. Also added
--                           reset and usec_tick logic to drive utility
--                           reset and usec_tick logic to drive utility
--                           signals. Also added Halt_Ack output.
--                           signals. Also added Halt_Ack output.
 
-- Seth Henry      05/20/20 Added two new generics to alter the way the I bit
 
--                           is handled. The Supervisor_Mode setting disables
 
--                           STP PSR_I from being executed, preventing it
 
--                           from being set outside of an ISR. The
 
--                           Default_Int_Flag setting allows the I bit to
 
--                           start set so that initialization code can run,
 
--                           but not be hijacked later to corrupt any memory
 
--                           write protection later.
 
 
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 225... Line 244...
    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 sets all flags
    RTI_Ignores_GP_Flags     : boolean      := false;   -- RTI sets all flags
 
    Supervisor_Mode          : boolean      := false;   -- I bit is restricted
 
    Default_Int_Flag         : boolean      := false;   -- Start with I bit set
    Default_Interrupt_Mask   : DATA_TYPE    := x"FF";   -- Enable all Ints
    Default_Interrupt_Mask   : DATA_TYPE    := x"FF";   -- Enable all Ints
    Clock_Frequency          : real                     -- Clock Frequency
    Clock_Frequency          : real                     -- Clock Frequency
);
);
  port(
  port(
    Clock                    : in  std_logic;
    Clock                    : in  std_logic;
Line 595... Line 616...
            Cache_Ctrl       <= CACHE_PREFETCH;
            Cache_Ctrl       <= CACHE_PREFETCH;
            PC_Ctrl.Offset   <= PC_REV2;
            PC_Ctrl.Offset   <= PC_REV2;
            DP_Ctrl.Src      <= DATA_WR_REG;
            DP_Ctrl.Src      <= DATA_WR_REG;
            DP_Ctrl.Reg      <= ACCUM;
            DP_Ctrl.Reg      <= ACCUM;
 
 
 
          when OP_STP =>
 
            PC_Ctrl.Offset   <= PC_NEXT;
 
            if( Supervisor_Mode )then
 
              if( SubOp /= PSR_I )then
 
                ALU_Ctrl.Oper  <= Opcode;
 
                ALU_Ctrl.Reg   <= SubOp;
 
              end if;
 
            else
 
              ALU_Ctrl.Oper  <= Opcode;
 
              ALU_Ctrl.Reg   <= SubOp;
 
            end if;
 
 
          when others =>
          when others =>
            PC_Ctrl.Offset   <= PC_NEXT;
            PC_Ctrl.Offset   <= PC_NEXT;
            ALU_Ctrl.Oper    <= Opcode;
            ALU_Ctrl.Oper    <= Opcode;
            ALU_Ctrl.Reg     <= SubOp;
            ALU_Ctrl.Reg     <= SubOp;
 
 
Line 965... Line 998...
 
 
      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";
 
      if( Default_Int_Flag )then
 
        Flags(PSR_I)         <= '1';
 
      end if;
 
 
      Open8_Bus.GP_Flags     <= (others => '0');
      Open8_Bus.GP_Flags     <= (others => '0');
 
 
    elsif( rising_edge(Clock) )then
    elsif( rising_edge(Clock) )then
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.