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

Subversion Repositories rv01_riscv_core

[/] [rv01_riscv_core/] [trunk/] [VHDL/] [RV01_hltlog_ix2.vhd] - Rev 2

Compare with Previous | Blame | View Log

-----------------------------------------------------------------
--                                                             --
-----------------------------------------------------------------
--                                                             --
-- Copyright (C) 2015 Stefano Tonello                          --
--                                                             --
-- This source file may be used and distributed without        --
-- restriction provided that this copyright statement is not   --
-- removed from the file and that any derivative work contains --
-- the original copyright notice and the associated disclaimer.--
--                                                             --
-- THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY         --
-- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   --
-- TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS   --
-- FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR      --
-- OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,         --
-- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    --
-- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE   --
-- GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        --
-- BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  --
-- LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT  --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  --
-- OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         --
-- POSSIBILITY OF SUCH DAMAGE.                                 --
--                                                             --
-----------------------------------------------------------------
 
---------------------------------------------------------------
-- RV01 halt logic (IX2 stage)
---------------------------------------------------------------
 
library IEEE;
use IEEE.std_logic_1164.all; 
use IEEE.numeric_std.all;
 
library work;
use work.RV01_CONSTS_PKG.all;
use work.RV01_TYPES_PKG.all;
use work.RV01_IDEC_PKG.all;
 
entity RV01_HLTLOG_IX2 is
  generic(
    NW : natural := 2
  );
  port(
    V_i : in std_logic_vector(NW-1 downto 0);
    IMNMC0_i : in INST_MNEMONIC_T;
    PC0_i : in unsigned(ALEN-1 downto 0);
    PC1_i : in unsigned(ALEN-1 downto 0);
    HOBRK_i : in std_logic;
    HOADR_i : in std_logic_vector(NW-1 downto 0);
    HADR_i : in unsigned(ALEN-1 downto 0);
    HRQ_i : in std_logic;
 
    HALT_o : out std_logic_vector(NW-1 downto 0);
    HIS_o : out std_logic
  );
end RV01_HLTLOG_IX2;
 
architecture ARC of RV01_HLTLOG_IX2 is
 
  signal BRK0,HOBRK0 : std_logic;
  signal HOADR : std_logic_vector(NW-1 downto 0);
 
begin
 
  -- Halt via HLT_i/HOBRK_i/HOADR_i/HADR_i interface.
 
  -- Instruction execution is halted on the first valid
  -- instruction which:
  -- 1) is a sbreak (if HOBRK_i = '1'), OR
  -- 2) fetch address matches HADR_i (if HOADR_i = '1'), OR
  -- 3) reaches IX3 when HRQ_i = '1'.
 
  -- Halting may occurs with some delay with respect to HLT_i
  -- assertion because it's "triggered" by a valid instruction.
 
  -- Instruction execution restarts when RSM_q and STRT_q are both '1'.
  -- Restarting is immediate.
 
  -- sbreak instruction flag
  BRK0 <= '1' when (IMNMC0_i = IM_SBREAK) else '0';
 
  -- halt-on-break flag
  HOBRK0 <= HOBRK_i and BRK0;
 
  -- halt-on-address flags
  HOADR(0) <= HOADR_i(0) when (PC0_i = HADR_i) else '0';
  HOADR(1) <= HOADR_i(1) when (PC1_i = HADR_i) else '0';
 
  -- final halt flags
  HALT_o(0) <= V_i(0) and (HOBRK0 or HOADR(0) or HRQ_i);
  HALT_o(1) <= V_i(1) and (HOADR(1) or HRQ_i);
 
  -- halt instruction selector
  HIS_o <= '0' when (
    HOBRK0 = '1' or
    HOADR(0) = '1' or 
    (V_i(0) = '1' and HRQ_i = '1')
  ) else '1';
 
end ARC;
 

Compare with Previous | Blame | View Log

powered by: WebSVN 2.1.0

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