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

Subversion Repositories rv01_riscv_core

[/] [rv01_riscv_core/] [trunk/] [VHDL/] [RV01_cpu_init.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) 2015 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 CPU initialization control
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_FUNCS_PKG.all;
40
use work.RV01_CSR_PKG.all;
41
 
42
entity RV01_CPU_INIT is
43
  port(
44
    CLK_i : in std_logic;
45
    RST_i : in std_logic;
46
    STRT_i : in std_logic;
47
    RSM_i : in std_logic;
48
    BHT_INIT_END_i : in std_logic;
49
 
50
    INIT_STRT_o : out std_logic;
51
    STRT_o : out std_logic
52
  );
53
end RV01_CPU_INIT;
54
 
55
architecture ARC of RV01_CPU_INIT is
56
 
57
  signal INIT_q : std_logic;
58
  signal INITD_q : std_logic;
59
  signal INIT_END : std_logic;
60
 
61
begin
62
 
63
  ----------------------------------------------
64
 
65
  -- This module insures that instruction 
66
  -- execution starts only after BPU initialization
67
  -- is complete, to this purpose a start execution
68
  -- request coming on STRT_i can be delayed until
69
  -- BPU notifies initialization is over.
70
 
71
  -- When BPU is not present, this module is
72
  -- omitted from the core and start execution
73
  -- requests are always processed immediately.
74
 
75
  ----------------------------------------------
76
 
77
  -- Initialization Done flag register,
78
  -- this register is cleared at reset 
79
  -- and asserted when BPU initialization
80
  -- completes.
81
 
82
  process(CLK_i)
83
  begin
84
    if(CLK_i = '1' and CLK_i'event) then
85
      if(RST_i = '1') then
86
        INITD_q <= '0';
87
      elsif(INIT_END = '1') then
88
        INITD_q <= '1';
89
      end if;
90
    end if;
91
  end process;
92
 
93
  -- Initialization Done flag, asserted 
94
  -- by BPU when it completes initialization.
95
 
96
  INIT_END <= BHT_INIT_END_i;
97
 
98
  -- Initialization start flag, BPU 
99
  -- initialization is started whenever START_i
100
  -- is asserted, if initialization has not
101
  -- already been completed and there no
102
  -- pending start request.
103
 
104
  INIT_STRT_o <= STRT_i and not(INITD_q) and not(INIT_q);
105
 
106
  -- (Pending) start flag register, this
107
  -- register is needed because a start execution
108
  -- request coming during initialization must be
109
  -- held until initialization is complete.
110
 
111
  process(CLK_i)
112
  begin
113
    if(CLK_i = '1' and CLK_i'event) then
114
      if(RST_i = '1') then
115
        INIT_q <= '0';
116
      elsif(STRT_i = '1' and INITD_q = '0') then
117
        INIT_q <= '1';
118
      elsif(INIT_END = '1') then
119
        INIT_q <= '0';
120
      end if;
121
    end if;
122
  end process;
123
 
124
  -- Start execution flag, this flag is asserted when
125
  -- 1) there's a pending start request when
126
  -- initialization complete, OR
127
  -- 2) there's a start request and initialization is
128
  -- already complete.
129
 
130
  STRT_o <= (INIT_q and INIT_END) or (STRT_i and INITD_q);
131
 
132
end ARC;

powered by: WebSVN 2.1.0

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