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

Subversion Repositories rv01_riscv_core

[/] [rv01_riscv_core/] [trunk/] [VHDL/] [RV01_csr_pkg.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 constants package
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
 
40
package RV01_CSR_PKG is
41
 
42
  -- CSR address width
43
  constant CSR_ADR_WIDTH : natural := 12;
44
 
45
  -- CSR address type
46
  subtype CSR_ADR_T is unsigned(CSR_ADR_WIDTH-1 downto 0);
47
 
48
  -- Debug port address width
49
  constant DBG_ADR_WIDTH : natural := 16;
50
 
51
  -- Debug port address type
52
  subtype DBG_ADR_T is unsigned(DBG_ADR_WIDTH-1 downto 0);
53
 
54
 
55
  -- User-level CSR addresses
56
  constant UFFLAGS_ADR : CSR_ADR_T := X"001";
57
  constant UFRM_ADR : CSR_ADR_T := X"002";
58
  constant UFCSR_ADR : CSR_ADR_T := X"003";
59
  constant UCYCLE_ADR : CSR_ADR_T := X"C00";
60
  constant UCYCLEH_ADR : CSR_ADR_T := X"C80";
61
  constant UTIME_ADR : CSR_ADR_T := X"C01";
62
  constant UTIMEH_ADR : CSR_ADR_T := X"C81";
63
  constant UINSTRET_ADR : CSR_ADR_T := X"C02";
64
  constant UINSTRETH_ADR : CSR_ADR_T := X"C82";
65
  -- this CSR is added only for compatibility
66
  -- with sodor core.
67
  constant USTATS_ADR : CSR_ADR_T := X"0C0";
68
 
69
  -- Machine-level CSR addresses
70
  constant MCPUID_ADR : CSR_ADR_T := X"F00";
71
  constant MIMPID_ADR : CSR_ADR_T := X"F01";
72
  constant MHARTID_ADR : CSR_ADR_T := X"F10";
73
  constant MSTATUS_ADR : CSR_ADR_T := X"300";
74
  constant MTVEC_ADR : CSR_ADR_T := X"301";
75
  constant MTDELEG_ADR : CSR_ADR_T := X"302";
76
  constant MIE_ADR : CSR_ADR_T := X"304";
77
  constant MTIMECMP_ADR : CSR_ADR_T := X"321";
78
  constant MTIME_ADR : CSR_ADR_T := X"701";
79
  constant MTIMEH_ADR : CSR_ADR_T := X"741";
80
  constant MSCRATCH_ADR : CSR_ADR_T := X"340";
81
  constant MEPC_ADR : CSR_ADR_T := X"341";
82
  constant MCAUSE_ADR : CSR_ADR_T := X"342";
83
  constant MBADADDR_ADR : CSR_ADR_T := X"343";
84
  constant MIP_ADR : CSR_ADR_T := X"344";
85
  constant MBASE_ADR : CSR_ADR_T := X"380";
86
  constant MBOUND_ADR : CSR_ADR_T := X"381";
87
  constant MIBASE_ADR : CSR_ADR_T := X"382";
88
  constant MIBOUND_ADR : CSR_ADR_T := X"383";
89
  constant MDBASE_ADR : CSR_ADR_T := X"384";
90
  constant MDBOUND_ADR : CSR_ADR_T := X"385";
91
  constant HTIMEW_ADR : CSR_ADR_T := X"B01";
92
  constant HTIMEHW_ADR : CSR_ADR_T := X"B81";
93
  -- Non standard Machine-level CSR addresses
94
  -- Host interface
95
  constant MTOHOST_ADR : CSR_ADR_T := X"780";
96
  constant MFROMHOST_ADR : CSR_ADR_T := X"781";
97
  -- RV01 core control
98
  constant MRV01CC_ADR : CSR_ADR_T := X"782";
99
  -- RV01 halt control
100
  constant MRV01HC_ADR : CSR_ADR_T := X"784";
101
  -- RV01 halt address
102
  constant MRV01HA_ADR : CSR_ADR_T := X"785";
103
  -- RV01 halt address
104
  constant MRV01RA_ADR : CSR_ADR_T := X"786";
105
 
106
  -- Debug Module CSR addresses
107
  --constant DCCS_ADR : CSR_ADR_T := X"770"; 
108
  --constant DDTMMA_ADR : CSR_ADR_T := X"771"; 
109
  --constant DDCS_ADR : CSR_ADR_T := X"772"; 
110
  --constant DDPC_ADR : CSR_ADR_T := X"773"; 
111
  --constant DDMBX0_ADR : CSR_ADR_T := X"774"; 
112
  --constant DDMBX1_ADR : CSR_ADR_T := X"775"; 
113
  --constant DDS_ADR : CSR_ADR_T := X"776"; 
114
  --constant DPCS_ADR : CSR_ADR_T := X"777"; 
115
 
116
  constant CCS_ADR : DBG_ADR_T := X"0000";
117
  constant DTMIA_ADR : DBG_ADR_T := X"0010";
118
  constant DCS_ADR : DBG_ADR_T := X"0020";
119
  constant PCS_ADR : DBG_ADR_T := X"0030";
120
  constant SI_ADR : DBG_ADR_T := X"0100";
121
  constant DJ_ADR : DBG_ADR_T := X"0110";
122
  constant PC_ADR : DBG_ADR_T := X"0120";
123
 
124
  -- CSR write masks
125
  constant UFCSR_WMSK : SDWORD_T := X"000000ff";
126
  constant UFFLAGS_WMSK : SDWORD_T := X"0000001f";
127
  constant UFRM_WMSK : SDWORD_T := X"00000007";
128
  constant MSTATUS_WMSK : SDWORD_T := X"001f0fff";
129
  constant MTVEC_WMSK : SDWORD_T := X"fffffffc";
130
  constant MIE_WMSK : SDWORD_T := X"00000088";
131
  constant MEPC_WMSK : SDWORD_T := X"fffffffc";
132
  constant MCAUSE_WMSK : SDWORD_T := X"8000000f";
133
  constant MIP_WMSK : SDWORD_T := X"00000008";
134
  constant MRV01CC_WMSK : SDWORD_T := X"00000001";
135
  constant MRV01HC_WMSK : SDWORD_T := X"00000030";
136
  constant CCS_WMSK : SDWORD_T := X"0f0200ff";
137
  constant DCS_WMSK : SDWORD_T := X"0000000f";
138
 
139
  -- CSR's read-only content
140
 
141
  -- mcpuid is read-only (value: RV32I with "M" extension)
142
  constant MCPUID_RO : SDWORD_T := X"00001000";
143
 
144
  -- mimpid is read-only (value: anonymous source)
145
  constant MIMPID_RO : SDWORD_T := X"00008000";
146
 
147
  -- mihartid is read-only (value: all-0)
148
  constant MHARTID_RO : SDWORD_T := X"00000000";
149
 
150
  -- mtdeleg is read-only (value: all-0)
151
  constant MTDELEG_RO : SDWORD_T := X"00000000";
152
 
153
  -- CSR's reset content
154
 
155
  -- mstatus (
156
  -- SD = 0,
157
  -- VM = 0, 
158
  -- MPRV = 0,
159
  -- FS = 0,
160
  -- XS = 0,
161
  -- PRV1/3 = 00,
162
  -- IE1/3 = 1
163
  -- PRV = 11,
164
  -- IE = 0
165
  --)   
166
  constant MSTATUS_RST : SDWORD_T := X"0000024e";
167
 
168
  -- mtvec (low trap vector location) 
169
  constant MTVEC_RST : SDWORD_T := X"00000100";
170
 
171
  -- mie (no enabled timer interrupts)
172
  constant MIE_RST : SDWORD_T := X"00000000";
173
 
174
  -- mip (no pending timer interrupts) 
175
  constant MIP_RST : SDWORD_T := X"00000000";
176
 
177
  -- mrv01cc (
178
  -- pxe=1
179
  --) 
180
  constant MRV01CC_RST : SDWORD_T := X"00000001";
181
 
182
  -- mrv01hc (
183
  -- haltstate=1
184
  --) 
185
  constant MRV01HC_RST : SDWORD_T := X"00000001";
186
 
187
  -- CCS (
188
  -- 31 - authenticated = 1
189
  -- 30 - authbusy = 0
190
  -- 27 - ndreset = 0
191
  -- 26 - fullreset = 0
192
  -- 25 - stopcycle = 1
193
  -- 24 - stoptime = 1
194
  -- 23 - frozen = 0
195
  -- 22 - freezesup = 0
196
  -- 21 - freezeresume = 0
197
  -- 20 - freezeresume = 0
198
  -- 19 - halted = 1
199
  -- 18 - haltsup = 1
200
  -- 17 - halt = 0
201
  -- 16 - resume = 0
202
  -- 7:0 - interrupt = 0x0000
203
  --) 
204
  constant CCS_RST : SDWORD_T := X"830c0000";
205
 
206
  -- DCS (
207
  -- 31 - pcsample = 1
208
  -- 30 - haltinterrupt = 0
209
  -- 29:28 - xdebugver = 01
210
  -- 27:16 - hwbpcount = 0x000
211
  -- 7 - debug = 1
212
  -- 6:4 - cause = 011
213
  -- 3 - ebreakm = 0
214
  -- 2 - ebreakh = 0
215
  -- 1 - ebreaks = 0
216
  -- 0 - ebreaku = 0
217
  --) 
218
  constant DCS_RST : SDWORD_T := X"900000b0";
219
 
220
  -- mcause patterns
221
  constant IADRMIS : std_logic_vector(5-1 downto 0) := "00000";
222
  constant IACCFLT : std_logic_vector(5-1 downto 0) := "00001";
223
  constant ILLGINS : std_logic_vector(5-1 downto 0) := "00010";
224
  constant BRKPNT : std_logic_vector(5-1 downto 0) := "00011";
225
  constant LADRMIS : std_logic_vector(5-1 downto 0) := "00100";
226
  constant LACCFLT : std_logic_vector(5-1 downto 0) := "00101";
227
  constant SADRMIS : std_logic_vector(5-1 downto 0) := "00110";
228
  constant SACCFLT : std_logic_vector(5-1 downto 0) := "00111";
229
  constant UMCALL : std_logic_vector(5-1 downto 0) := "01000";
230
  constant SMCALL : std_logic_vector(5-1 downto 0) := "01001";
231
  constant HMCALL : std_logic_vector(5-1 downto 0) := "01010";
232
  constant MMCALL : std_logic_vector(5-1 downto 0) := "01011";
233
  constant SOFTINT : std_logic_vector(5-1 downto 0) := "10000";
234
  constant TIMRINT : std_logic_vector(5-1 downto 0) := "10001";
235
  constant EXTINT : std_logic_vector(5-1 downto 0) := "10010";
236
 
237
  -- address enviroments
238
  constant MBARE : std_logic_vector(4-1 downto 0) := "0000";
239
  constant MBB : std_logic_vector(4-1 downto 0) := "0001";
240
  constant MBBID : std_logic_vector(4-1 downto 0) := "0010";
241
 
242
  -- mtvec allowed values
243
  constant MTVEC_LO : unsigned(SDLEN-1 downto 0) := X"00000100";
244
  constant MTVEC_HI : unsigned(SDLEN-1 downto 0) := X"fffffe00";
245
 
246
  -- trap/interrupt vector address (low address version)
247
  constant UTRAP_VA_LO : unsigned(SDLEN-1 downto 0) := X"00000100";
248
  constant STRAP_VA_LO : unsigned(SDLEN-1 downto 0) := X"00000140";
249
  constant HTRAP_VA_LO : unsigned(SDLEN-1 downto 0) := X"00000180";
250
  constant MTRAP_VA_LO : unsigned(SDLEN-1 downto 0) := X"000001C0";
251
  constant NMINT_VA_LO : unsigned(SDLEN-1 downto 0) := X"000001FC";
252
  constant RESET_VA_LO : unsigned(SDLEN-1 downto 0) := X"00000200";
253
 
254
  -- trap/interrupt vector address (high address version)
255
  constant UTRAP_VA_HI : unsigned(SDLEN-1 downto 0) := X"fffffe00";
256
  constant STRAP_VA_HI : unsigned(SDLEN-1 downto 0) := X"fffffe40";
257
  constant HTRAP_VA_HI : unsigned(SDLEN-1 downto 0) := X"fffffe80";
258
  constant MTRAP_VA_HI : unsigned(SDLEN-1 downto 0) := X"fffffeC0";
259
  constant NMINT_VA_HI : unsigned(SDLEN-1 downto 0) := X"fffffeFC";
260
  constant RESET_VA_HI : unsigned(SDLEN-1 downto 0) := X"ffffff00";
261
 
262
end package;
263
 
264
package body RV01_CSR_PKG is
265
end package body;

powered by: WebSVN 2.1.0

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