CDL Modules
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;
39  bit[32] write_data;
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";
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;
103  bit flush;
104  // will_take?
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;
115  bit error;
118 
119 /*t t_riscv_config
120  */
121 typedef struct {
122  bit i32c;
123  bit e32;
124  bit i32m;
127  bit unaligned_mem; // if clear, trap on unaligned memory loads/stores
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)",
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";
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";
172 
173 /*t t_riscv_pipeline_debug_control
174  */
175 typedef struct {
176  bit valid;
180  t_riscv_word data "Data from a completed transaction; 0 otherwise";
182 
183 /*t t_riscv_pipeline_debug_response
184  */
185 typedef struct {
190 
Definition: riscv.h:98
bit[32] t_riscv_word
Definition: riscv.h:73
bit coproc_disable
Definition: riscv.h:126
Definition: riscv.h:185
bit i32c
Definition: riscv.h:122
t_riscv_mode mode
Definition: riscv.h:102
Definition: riscv.h:149
bit exec_halting
Definition: riscv.h:187
bit valid
Definition: riscv.h:176
t_riscv_mode mode
Definition: riscv.h:114
constant integer RISCV_DATA_ADDR_WIDTH
Definition: riscv.h:27
Definition: riscv.h:66
bit valid
Definition: riscv.h:99
t_riscv_mode
Definition: riscv.h:89
bit e32
Definition: riscv.h:123
bit[4] byte_enable
Definition: riscv.h:36
bit[32] address
Definition: riscv.h:35
bit ueip
Definition: riscv.h:81
bit msip
Definition: riscv.h:83
bit read_enable
Definition: riscv.h:38
Definition: riscv.h:138
constant integer RISCV_INSTR_ADDR_WIDTH
Definition: riscv.h:28
bit fetch_dret
Definition: riscv.h:179
Definition: riscv.h:110
Definition: riscv.h:92
bit kill_fetch
Definition: riscv.h:177
bit i32m
Definition: riscv.h:124
bit halt_request
Definition: riscv.h:178
Definition: riscv.h:135
bit meip
Definition: riscv.h:79
bit seip
Definition: riscv.h:80
bit write_enable
Definition: riscv.h:37
Definition: riscv.h:134
bit sequential
Definition: riscv.h:101
Definition: riscv.h:160
Definition: riscv.h:93
t_riscv_debug_op
Definition: riscv.h:132
Definition: riscv.h:34
bit error
Definition: riscv.h:115
bit nmi
Definition: riscv.h:78
Definition: riscv.h:137
bit unaligned_mem
Definition: riscv.h:127
Definition: riscv.h:175
bit t_riscv_debug_resp
Definition: riscv.h:141
Definition: riscv.h:133
bit[32] data
Definition: riscv.h:113
Definition: riscv.h:77
bit flush
Definition: riscv.h:103
t_riscv_fetch_tag tag
Definition: riscv.h:116
bit exec_valid
Definition: riscv.h:186
Definition: riscv.h:136
bit valid
Definition: riscv.h:111
Definition: riscv.h:90
bit mtip
Definition: riscv.h:82
bit i32m_fuse
Definition: riscv.h:125
bit[32] write_data
Definition: riscv.h:39
bit[2] t_riscv_fetch_tag
Definition: riscv.h:109
Definition: riscv.h:121
Definition: riscv.h:91
bit exec_dret
Definition: riscv.h:188
bit[32] address
Definition: riscv.h:100