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

Subversion Repositories rv01_riscv_core

[/] [rv01_riscv_core/] [trunk/] [VHDL/] [RV01_top_nohost.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) 2017 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 top-level module (without host interface)
30
---------------------------------------------------------------
31
 
32
library IEEE;
33
use IEEE.std_logic_1164.all;
34
use IEEE.numeric_std.all;
35
use STD.textio.all;
36
 
37
library WORK;
38
use work.RV01_CONSTS_PKG.all;
39
use work.RV01_TYPES_PKG.all;
40
use work.RV01_FUNCS_PKG.all;
41
use work.RV01_PLIC_PKG.all;
42
 
43
entity RV01_TOP_NOHOST is
44
  generic(
45
    -- synthesis translate_off
46
    ST_FILE : string := "NONE";
47
    WB_FILE : string := "NONE";
48
    -- synthesis translate_on
49
    IMEM_SIZE : natural := 1024*32; -- 128Kb
50
    DMEM_SIZE : natural := 1024*16; -- 64Kb
51
    IOMEM_SIZE : natural := 1024; -- 4Kb
52
    IMEM_SIZE_PO2 : std_logic := '1';
53
    DMEM_SIZE_PO2 : std_logic := '1';
54
    IMEM_LOWM : std_logic := '1';
55
    BHT_SIZE : natural := 256;
56
    EI_SRC_CNT : natural := 8;
57
    EI_TRIG_TYPE : PLIC_TRIG_TYPE := LEVEL;
58
    EI_REQ_MAXCNT : natural := 16;
59
    CFG_FLAGS : std_logic_vector(16-1 downto 0) := "00000000"&"01100111";
60
    SIMULATION_ONLY : std_logic := '0'
61
  );
62
  port(
63
    CLK_i : in std_logic; -- clock
64
    RST_i : in std_logic; -- reset
65
    -- External Interrupt Request
66
    EI_REQ_i : std_logic_vector(EI_SRC_CNT-1 downto 0);
67
    -- DP Port
68
    DP_WE_i : in std_logic; -- DP write-enable
69
    DP_ADR_i : in std_logic_vector(ALEN-1 downto 0); -- DP address
70
    DP_DAT_i : in std_logic_vector(SDLEN-1 downto 0); -- DP data-in
71
    -- Control Port
72
    CP_RE_i : in std_logic; -- CP read-enable
73
    CP_WE_i : in std_logic; -- CP write enable
74
    CP_ADR_i : in std_logic_vector(17-1 downto 0); -- CP address
75
    CP_DAT_i : in std_logic_vector(SDLEN-1 downto 0);  -- CP data-in
76
 
77
    -- DP interface
78
    DP_DAT_o : out std_logic_vector(SDLEN-1 downto 0); -- DP data-out
79
    -- CP interface
80
    CP_DAT_o : out std_logic_vector(SDLEN-1 downto 0) -- CP data-out
81
  );
82
end RV01_TOP_NOHOST;
83
 
84
architecture ARC of RV01_TOP_NOHOST is
85
 
86
  component RV01_TOP is
87
    generic(
88
      -- synthesis translate_off
89
      ST_FILE : string := "NONE";
90
      WB_FILE : string := "NONE";
91
      -- synthesis translate_on
92
      IMEM_SIZE : natural := 1024*32; -- 128Kb
93
      DMEM_SIZE : natural := 1024*16; -- 64Kb
94
      IOMEM_SIZE : natural := 1024; -- 4Kb
95
      IMEM_SIZE_PO2 : std_logic := '1';
96
      DMEM_SIZE_PO2 : std_logic := '1';
97
      IMEM_LOWM : std_logic := '1';
98
      BHT_SIZE : natural := 256;
99
      EI_SRC_CNT : natural := 8;
100
      EI_TRIG_TYPE : PLIC_TRIG_TYPE := LEVEL;
101
      EI_REQ_MAXCNT : natural := 16;
102
      CFG_FLAGS : std_logic_vector(16-1 downto 0) := "00000000"&"01100111";
103
      SIMULATION_ONLY : std_logic := '0'
104
    );
105
    port(
106
      CLK_i : in std_logic; -- clock
107
      RST_i : in std_logic; -- reset
108
      CHK_ENB_i : in std_logic; -- check-enable
109
      -- External Interrupt Request
110
      EI_REQ_i : std_logic_vector(EI_SRC_CNT-1 downto 0);
111
      -- Host interface
112
      MFROMHOST_WE_i : in std_logic;
113
      MFROMHOST_i : in std_logic_vector(SDLEN-1 downto 0);
114
      -- DP interface
115
      DP_WE_i : in std_logic; -- DP write-enable
116
      DP_ADR_i : in std_logic_vector(ALEN-1 downto 0);
117
      DP_DAT_i : in std_logic_vector(SDLEN-1 downto 0); -- DP data-in
118
      -- CP interface
119
      CP_RE_i : in std_logic;
120
      CP_WE_i : in std_logic;
121
      CP_ADR_i : in std_logic_vector(17-1 downto 0);
122
      CP_DAT_i : in std_logic_vector(SDLEN-1 downto 0);
123
 
124
      -- Host interface
125
      MTOHOST_OE_o : out std_logic;
126
      MTOHOST_o : out std_logic_vector(SDLEN-1 downto 0);
127
      -- DP interface
128
      DP_DAT_o : out std_logic_vector(SDLEN-1 downto 0); -- DP data-out
129
      -- CP interface
130
      CP_DAT_o : out std_logic_vector(SDLEN-1 downto 0)
131
    );
132
  end component ;
133
 
134
  constant PLIC_PRESENT : std_logic := CFG_FLAGS(6);
135
 
136
  signal CHK_ENB : std_logic := '1';
137
  signal EI_REQ : std_logic_vector(EI_SRC_CNT-1 downto 0);
138
 
139
  signal MFROMHOST_WE : std_logic;
140
  signal MFROMHOST : std_logic_vector(SDLEN-1 downto 0) := (others => '0');
141
  signal MTOHOST_OE : std_logic;
142
  signal MTOHOST : std_logic_vector(SDLEN-1 downto 0);
143
  signal MHOST_V_q : std_logic;
144
  signal MHOST_q : std_logic_vector(SDLEN-1 downto 0);
145
 
146
begin
147
 
148
  ----------------------------------------------
149
 
150
  -- This module exists mainly as a debugging
151
  -- and simulation aid, it consists of an
152
  -- instance of the top-level module RV01_TOP
153
  -- with the MTOHOST_o output looping back to
154
  -- the MFROMHOST_i and EI_REQ_i inputs.
155
  -- This arrangement allows to simulate the 
156
  -- host interface and, to some degree, PLIC 
157
  -- module operations without additional logic.
158
 
159
  ----------------------------------------------
160
 
161
  U_RVTOP : RV01_TOP
162
    generic map(
163
      -- synthesis translate_off
164
      ST_FILE => ST_FILE, --"NONE",
165
      WB_FILE => WB_FILE, --"NONE",
166
      -- synthesis translate_on
167
      IMEM_SIZE => IMEM_SIZE,
168
      DMEM_SIZE => DMEM_SIZE,
169
      IOMEM_SIZE => IOMEM_SIZE,
170
      IMEM_SIZE_PO2 => IMEM_SIZE_PO2,
171
      DMEM_SIZE_PO2 => DMEM_SIZE_PO2,
172
      IMEM_LOWM => IMEM_LOWM,
173
      BHT_SIZE => BHT_SIZE,
174
      EI_SRC_CNT => EI_SRC_CNT,
175
      EI_TRIG_TYPE => EI_TRIG_TYPE,
176
      EI_REQ_MAXCNT => EI_REQ_MAXCNT,
177
      CFG_FLAGS => CFG_FLAGS,
178
      SIMULATION_ONLY => SIMULATION_ONLY
179
    )
180
    port map(
181
      CLK_i => CLK_i,
182
      RST_i => RST_i,
183
      CHK_ENB_i => CHK_ENB,
184
      --
185
      EI_REQ_i => EI_REQ,
186
      --
187
      MFROMHOST_WE_i => MFROMHOST_WE,
188
      MFROMHOST_i => MFROMHOST,
189
      --
190
      DP_WE_i => DP_WE_i,
191
      DP_ADR_i => DP_ADR_i,
192
      DP_DAT_i => DP_DAT_i,
193
      --
194
      CP_RE_i => CP_RE_i,
195
      CP_WE_i => CP_WE_i,
196
      CP_ADR_i => CP_ADR_i,
197
      CP_DAT_i => CP_DAT_i,
198
 
199
      MTOHOST_OE_o => MTOHOST_OE,
200
      MTOHOST_o => MTOHOST,
201
      --
202
      DP_DAT_o => DP_DAT_o,
203
      --
204
      CP_DAT_o => CP_DAT_o
205
    );
206
 
207
  -- Looping-back MTOHOST into MFROMHOST: this
208
  -- provides a simple way of checking host
209
  -- insterface.
210
 
211
  process(CLK_i)
212
  begin
213
    if(CLK_i = '1' and CLK_i'event) then
214
      if(RST_i = '1') then
215
        MHOST_V_q <= '0';
216
      else
217
        MHOST_V_q <= MTOHOST_OE;
218
      end if;
219
      MHOST_q <= MTOHOST;
220
    end if;
221
  end process;
222
 
223
 MFROMHOST_WE <= MHOST_V_q;
224
 MFROMHOST <= MHOST_q;
225
 
226
 -- Drive EI_REQ through MTOHOST: this
227
 -- provides a simple way of generating
228
 -- external interrupt requests. 
229
 
230
 GPLIC_1: if(PLIC_PRESENT = '1') generate
231
 EI_REQ <= MTOHOST(EI_SRC_CNT-1 downto 0) or EI_REQ_i;
232
 end generate;
233
 
234
 GPLIC_0: if(PLIC_PRESENT = '0') generate
235
 EI_REQ <= (others => '0');
236
 end generate;
237
 
238
end ARC;

powered by: WebSVN 2.1.0

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