CDL Modules
Main Page
Modules
Data Structures
Files
File List
Globals
cdl
inc
riscv.h
Go to the documentation of this file.
1
19
/*a Includes */
20
include
"jtag.h"
21
22
/*a Constants
23
*
24
* Constants for the RISC-V implementation; can be overridden in CDL
25
* builds with a dc: option in the model_list
26
*/
27
constant integer
RISCV_DATA_ADDR_WIDTH
= 14;
28
constant integer
RISCV_INSTR_ADDR_WIDTH
= 14;
29
30
/*a Basic types
31
*/
32
/*t t_riscv_mem_access_req
33
*/
34
typedef
struct
{
35
bit[32]
address
;
36
bit[4]
byte_enable
;
37
bit
write_enable
;
38
bit
read_enable
;
39
bit[32]
write_data
;
40
}
t_riscv_mem_access_req
;
41
42
/*t t_riscv_mem_access_resp
43
*
44
* Note that the response in some circumstances is defined to be valid in the same cycle as the request.
45
* In other circumstances it is defined to be valid in the cycle following a request.
46
*
47
* The signals do not change.
48
*
49
* For example, a very simple fetch/execute RISC-V implementation
50
* requires the read response in the same cycle as a data memory
51
* request, since execute (which includes the full memory access) is a
52
* single cycle.
53
*
54
* However, a deeper pipeline RISC-V implementation such as pipeline3
55
* issues a request in the ALU cycle and provides a whole cycle for an
56
* SRAM access to satisfy any data memory read. Here, then, the
57
* response is valid one cycle after the request.
58
*
59
* Note that the wait signal is valid with the data; but it also
60
* applies to a memory cycle that is a write; that is, a write memory
61
* cycle cannot complete if wait is asserted. The next request is
62
* already being presented when the wait is given in response to the
63
* previous request, though.
64
*
65
*/
66
typedef
struct
{
67
bit wait
"Valid in the same cycle as read_data"
;
68
bit[32] read_data
"Data returned from reading the requested address"
;
69
}
t_riscv_mem_access_resp
;
70
71
/*t t_riscv_word
72
*/
73
typedef
bit[32]
t_riscv_word
;
74
75
/*t t_riscv_irqs
76
*/
77
typedef
struct
{
78
bit
nmi
;
79
bit
meip
;
80
bit
seip
;
81
bit
ueip
;
82
bit
mtip
;
83
bit
msip
;
84
bit[64] time
"Global time concept; may be tied low if user time CSR is not required"
;
85
}
t_riscv_irqs
;
86
87
/*t t_riscv_mode
88
*/
89
typedef
enum
[3] {
90
rv_mode_user
= 3b000,
// matches the encoding in table 1.1 of v1.10 privilege spec
91
rv_mode_supervisor
= 3b001,
// matches the encoding in table 1.1 of v1.10 privilege spec
92
rv_mode_machine
= 3b011,
// matches the encoding in table 1.1 of v1.10 privilege spec
93
rv_mode_debug
= 3b111,
// all 1s so that it is a superset of machine mode
94
}
t_riscv_mode
;
95
96
/*t t_riscv_fetch_req
97
*/
98
typedef
struct
{
99
bit
valid
;
100
bit[32]
address
;
101
bit
sequential
;
102
t_riscv_mode
mode
;
103
bit
flush
;
104
// will_take?
105
}
t_riscv_fetch_req
;
106
107
/*t t_riscv_fetch_resp
108
*/
109
typedef
bit[2]
t_riscv_fetch_tag
;
110
typedef
struct
{
111
bit
valid
;
112
bit debug
"Needs to permit register read/write encoding, break after execution, break before execution, execution mode, breakpoint-in-hardware-not-software; force-debug-subroutine-trap-before-execution"
;
113
bit[32]
data
;
114
t_riscv_mode
mode
;
115
bit
error
;
116
t_riscv_fetch_tag
tag
;
117
}
t_riscv_fetch_resp
;
118
119
/*t t_riscv_config
120
*/
121
typedef
struct
{
122
bit
i32c
;
123
bit
e32
;
124
bit
i32m
;
125
bit
i32m_fuse
;
126
bit
coproc_disable
;
127
bit
unaligned_mem
;
// if clear, trap on unaligned memory loads/stores
128
}
t_riscv_config
;
129
130
/*t t_riscv_debug_op
131
*/
132
typedef
enum
[4] {
133
rv_debug_set_requests
"Set request bits for halt, resume, step (args[0..2])"
,
134
rv_debug_read
"Request read of a GPR/CSR"
,
135
rv_debug_write
"Request write of a GPR/CSR"
,
136
rv_debug_acknowledge
"Acknowledge halt, breakpoint hit, status; removes attention signal"
,
137
rv_debug_execute
"Execute instruction provided resumption of execution at dpc and in mode dcsr.prv"
,
138
rv_debug_execute_progbuf
"Execute instruction at 'progbuf' address X (if it is a jump and link it will return)"
,
139
}
t_riscv_debug_op
;
140
141
typedef
bit
t_riscv_debug_resp
;
142
/*t t_riscv_debug_mst
143
*
144
* Debug module (DM) communication to (many) pipeline debug modules (PDMs)
145
*
146
*
147
*
148
*/
149
typedef
struct
{
150
bit valid
"Asserted if op is valid; has no effect on mask and attention"
;
151
bit[6] select
"PDM to select"
;
152
bit[6] mask
"PDM attention mask (mask && id)==(mask&&select) -> drive attention on next cycle"
;
153
t_riscv_debug_op
op
"Operation for selected PDM to perform"
;
154
bit[16] arg
"Argument for debug op"
;
155
t_riscv_word
data
"Data for writing or instruction execution"
;
156
}
t_riscv_debug_mst
;
157
158
/*t t_riscv_debug_tgt
159
*/
160
typedef
struct
{
161
bit valid
"Asserted by a PDM if driving the bus"
;
162
bit[6] selected
"Number of the PDM driving, or 0 if not driving the bus"
;
163
bit halted
"Asserted by a PDM if it is selected and halted since last ack; 0 otherwise"
;
164
bit resumed
"Asserted by a PDM if it is selected and has resumed since last ack; 0 otherwise"
;
165
bit hit_breakpoint
"Asserted by a PDM if it is selected and has hit breakpoint since lask ack; 0 otherwise"
;
166
bit op_was_none
"Asserted if the response is not valid"
;
167
t_riscv_debug_resp
resp
"Response from a requested op - only one op should be requested for each response"
;
168
t_riscv_word
data
"Data from a completed transaction; 0 otherwise"
;
169
170
bit attention
"Asserted by a PDM if it has unacknowledged halt, breakpoint hit, resumption"
;
171
}
t_riscv_debug_tgt
;
172
173
/*t t_riscv_pipeline_debug_control
174
*/
175
typedef
struct
{
176
bit
valid
;
177
bit
kill_fetch
;
178
bit
halt_request
;
179
bit
fetch_dret
;
180
t_riscv_word
data
"Data from a completed transaction; 0 otherwise"
;
181
}
t_riscv_pipeline_debug_control
;
182
183
/*t t_riscv_pipeline_debug_response
184
*/
185
typedef
struct
{
186
bit
exec_valid
;
187
bit
exec_halting
;
188
bit
exec_dret
;
189
}
t_riscv_pipeline_debug_response
;
190
t_riscv_fetch_req
Definition:
riscv.h:98
t_riscv_word
bit[32] t_riscv_word
Definition:
riscv.h:73
t_riscv_config::coproc_disable
bit coproc_disable
Definition:
riscv.h:126
t_riscv_pipeline_debug_response
Definition:
riscv.h:185
t_riscv_config::i32c
bit i32c
Definition:
riscv.h:122
t_riscv_fetch_req::mode
t_riscv_mode mode
Definition:
riscv.h:102
t_riscv_debug_mst
Definition:
riscv.h:149
t_riscv_pipeline_debug_response::exec_halting
bit exec_halting
Definition:
riscv.h:187
t_riscv_pipeline_debug_control::valid
bit valid
Definition:
riscv.h:176
t_riscv_fetch_resp::mode
t_riscv_mode mode
Definition:
riscv.h:114
RISCV_DATA_ADDR_WIDTH
constant integer RISCV_DATA_ADDR_WIDTH
Definition:
riscv.h:27
t_riscv_mem_access_resp
Definition:
riscv.h:66
t_riscv_fetch_req::valid
bit valid
Definition:
riscv.h:99
t_riscv_mode
t_riscv_mode
Definition:
riscv.h:89
t_riscv_config::e32
bit e32
Definition:
riscv.h:123
t_riscv_mem_access_req::byte_enable
bit[4] byte_enable
Definition:
riscv.h:36
t_riscv_mem_access_req::address
bit[32] address
Definition:
riscv.h:35
t_riscv_irqs::ueip
bit ueip
Definition:
riscv.h:81
t_riscv_irqs::msip
bit msip
Definition:
riscv.h:83
t_riscv_mem_access_req::read_enable
bit read_enable
Definition:
riscv.h:38
rv_debug_execute_progbuf
Definition:
riscv.h:138
RISCV_INSTR_ADDR_WIDTH
constant integer RISCV_INSTR_ADDR_WIDTH
Definition:
riscv.h:28
t_riscv_pipeline_debug_control::fetch_dret
bit fetch_dret
Definition:
riscv.h:179
t_riscv_fetch_resp
Definition:
riscv.h:110
rv_mode_machine
Definition:
riscv.h:92
t_riscv_pipeline_debug_control::kill_fetch
bit kill_fetch
Definition:
riscv.h:177
t_riscv_config::i32m
bit i32m
Definition:
riscv.h:124
t_riscv_pipeline_debug_control::halt_request
bit halt_request
Definition:
riscv.h:178
rv_debug_write
Definition:
riscv.h:135
t_riscv_irqs::meip
bit meip
Definition:
riscv.h:79
t_riscv_irqs::seip
bit seip
Definition:
riscv.h:80
t_riscv_mem_access_req::write_enable
bit write_enable
Definition:
riscv.h:37
rv_debug_read
Definition:
riscv.h:134
t_riscv_fetch_req::sequential
bit sequential
Definition:
riscv.h:101
t_riscv_debug_tgt
Definition:
riscv.h:160
rv_mode_debug
Definition:
riscv.h:93
t_riscv_debug_op
t_riscv_debug_op
Definition:
riscv.h:132
t_riscv_mem_access_req
Definition:
riscv.h:34
t_riscv_fetch_resp::error
bit error
Definition:
riscv.h:115
t_riscv_irqs::nmi
bit nmi
Definition:
riscv.h:78
rv_debug_execute
Definition:
riscv.h:137
t_riscv_config::unaligned_mem
bit unaligned_mem
Definition:
riscv.h:127
t_riscv_pipeline_debug_control
Definition:
riscv.h:175
t_riscv_debug_resp
bit t_riscv_debug_resp
Definition:
riscv.h:141
rv_debug_set_requests
Definition:
riscv.h:133
t_riscv_fetch_resp::data
bit[32] data
Definition:
riscv.h:113
t_riscv_irqs
Definition:
riscv.h:77
t_riscv_fetch_req::flush
bit flush
Definition:
riscv.h:103
t_riscv_fetch_resp::tag
t_riscv_fetch_tag tag
Definition:
riscv.h:116
t_riscv_pipeline_debug_response::exec_valid
bit exec_valid
Definition:
riscv.h:186
rv_debug_acknowledge
Definition:
riscv.h:136
t_riscv_fetch_resp::valid
bit valid
Definition:
riscv.h:111
rv_mode_user
Definition:
riscv.h:90
t_riscv_irqs::mtip
bit mtip
Definition:
riscv.h:82
t_riscv_config::i32m_fuse
bit i32m_fuse
Definition:
riscv.h:125
t_riscv_mem_access_req::write_data
bit[32] write_data
Definition:
riscv.h:39
t_riscv_fetch_tag
bit[2] t_riscv_fetch_tag
Definition:
riscv.h:109
t_riscv_config
Definition:
riscv.h:121
rv_mode_supervisor
Definition:
riscv.h:91
t_riscv_pipeline_debug_response::exec_dret
bit exec_dret
Definition:
riscv.h:188
t_riscv_fetch_req::address
bit[32] address
Definition:
riscv.h:100
Generated on Sun Sep 30 2018 17:21:43 for CDL Modules by
1.8.11