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

Subversion Repositories rv01_riscv_core

[/] [rv01_riscv_core/] [trunk/] [VHDL/] [RV01_dbglog_ix2.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 madsilicon
-----------------------------------------------------------------
2
--                                                             --
3
-----------------------------------------------------------------
4
--                                                             --
5
-- Copyright (C) 2016 Stefano Tonello                          --
6
--                                                             --
7
-- This source file may be used and distributed without        --
8
-- restriction provided that this copyright statement is not   --
9
-- removed from the file and that any derivative work contains --
10
-- the original copyright notice and the associated disclaimer.--
11
--                                                             --
12
-- THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY         --
13
-- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   --
14
-- TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS   --
15
-- FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR      --
16
-- OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,         --
17
-- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    --
18
-- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE   --
19
-- GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        --
20
-- BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  --
21
-- LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT  --
22
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  --
23
-- OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         --
24
-- POSSIBILITY OF SUCH DAMAGE.                                 --
25
--                                                             --
26
-----------------------------------------------------------------
27
 
28
---------------------------------------------------------------
29
-- RV01 debug logic (IX2 stage)
30
---------------------------------------------------------------
31
 
32
library IEEE;
33
use IEEE.std_logic_1164.all;
34
use IEEE.numeric_std.all;
35
 
36
library work;
37
use work.RV01_CONSTS_PKG.all;
38
use work.RV01_TYPES_PKG.all;
39
use work.RV01_IDEC_PKG.all;
40
 
41
entity RV01_DBGLOG_IX2 is
42
  generic(
43
    NW : natural := 2
44
  );
45
  port(
46
    CLK_i : in std_logic;
47
    RST_i : in std_logic;
48
    V_i : in std_logic_vector(NW-1 downto 0);
49
    IMNMC0_i : in INST_MNEMONIC_T;
50
    RFTCH0_i : in std_logic;
51
    STEP_i : in std_logic;
52
    HOBRK_i : in std_logic;
53
    HRQ_i : in std_logic;
54
 
55
    STEP_o : out std_logic;
56
    HALT_o : out std_logic_vector(NW-1 downto 0);
57
    HIS_o : out std_logic
58
  );
59
end RV01_DBGLOG_IX2;
60
 
61
architecture ARC of RV01_DBGLOG_IX2 is
62
 
63
  signal BRK0,STEP_q : std_logic;
64
 
65
begin
66
 
67
  -- sbreak instruction flag
68
  BRK0 <= '1' when (IMNMC0_i = IM_SBREAK) else '0';
69
 
70
  -- step flag register  
71
  process(CLK_i)
72
  begin
73
    if(CLK_i = '1' and CLK_i'event) then
74
      if(RST_i = '1') then
75
        STEP_q <= '0';
76
      elsif(STEP_i = '1') then
77
        STEP_q <= '1';
78
      elsif(V_i(0) = '1' and RFTCH0_i = '0') then -- or V_i(1) = '1') then
79
        STEP_q <= '0';
80
      end if;
81
    end if;
82
  end process;
83
 
84
  STEP_o <= STEP_q;
85
 
86
  -- Step flag is set by debug module (asserting STEP_i)
87
  -- when single-step execution is enabled and reset when
88
  -- the first valid instruction reaches IX3 stage.
89
  -- This flag allows first instruction to reach IX3 to 
90
  -- be executed normally, while second one triggers
91
  -- a halting condition.
92
 
93
  -- halt flags
94
 
95
  -- Halt flag is set for slot #0 instruction when
96
  -- instruction is valid and step flag is cleared, if:
97
  -- 1) there's a pending halt request, OR
98
  -- 2) instruction is a sbreak and halt-on-break is enabled.
99
 
100
  HALT_o(0) <= (V_i(0) and not(STEP_q)) when (
101
    (HRQ_i = '1')  or
102
    (HOBRK_i = '1' and BRK0 = '1')
103
  ) else '0';
104
 
105
  -- Halt flag is set for slot #0 instruction when
106
  -- instruction is valid and step flag is cleared or
107
  -- instruction #0 is valid, if there's a pending 
108
  --halt request.
109
 
110
  HALT_o(1) <= (V_i(1) and (not(STEP_q) or V_i(1))) and
111
    HRQ_i;
112
 
113
  -- halt instruction selector
114
  HIS_o <= not(V_i(0)) when (STEP_q = '0') else '1';
115
 
116
end ARC;

powered by: WebSVN 2.1.0

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