@@ -17,47 +17,47 @@ function fetch() -> FetchResult = {
1717 * but any exceptions use the untransformed PC.
1818 */
1919 // TODO: Add a parameter to try_step() to allow forcing the fetch result and use that instead.
20+
2021 if get_config_rvfi ()
2122 then return rvfi_fetch ();
23+
2224 match ext_fetch_check_pc (PC , PC ) {
23- Ext_FetchAddr_Error (e ) => F_Ext_Error (e ),
24- Ext_FetchAddr_OK ( use_pc ) => {
25- let use_pc_bits = bits_of ( use_pc ) ;
26- if ( use_pc_bits [ 0 ] ! = bitzero | ( use_pc_bits [ 1 ] ! = bitzero & not ( currentlyEnabled ( Ext_Zca ))))
27- then F_Error ( E_Fetch_Addr_Align () , PC )
28- else match translateAddr ( use_pc , InstructionFetch ()) {
29- Err ( e , _ ) => F_Error ( e , PC ) ,
30- Ok ( ppclo , _ ) => {
31- /* split instruction fetch into 16-bit granules to handle RVC, as
32- * well as to generate precise fault addresses in any fetch
33- * exceptions.
34- */
35- match mem_read ( InstructionFetch () , ppclo , 2 , false , false , false ) {
36- Err ( e ) => F_Error ( e , PC ) ,
37- Ok ( ilo ) => {
38- if isRVC ( ilo )
39- then F_RVC (ilo )
40- else {
41- /* fetch PC check for the next instruction granule */
42- let PC_hi = PC + 2 ;
43- match ext_fetch_check_pc ( PC , PC_hi ) {
44- Ext_FetchAddr_Error ( e ) => F_Ext_Error ( e ) ,
45- Ext_FetchAddr_OK ( use_pc_hi ) => {
46- match translateAddr ( use_pc_hi , InstructionFetch ()) {
47- Err ( e , _ ) => F_Error ( e , PC_hi ),
48- Ok ( ppchi , _ ) => {
49- match mem_read ( InstructionFetch () , ppchi , 2 , false , false , false ) {
50- Err ( e ) => F_Error ( e , PC_hi ),
51- Ok ( ihi ) => F_Base ( append ( ihi , ilo ))
52- }
53- }
54- }
55- }
25+ Some (e ) => return F_Ext_Error (e ),
26+ None () => () ,
27+ } ;
28+
29+ if ( PC [ 0 ] ! = bitzero | ( PC [ 1 ] ! = bitzero & not ( currentlyEnabled ( Ext_Zca ))) )
30+ then return F_Error ( E_Fetch_Addr_Align () , PC );
31+
32+ match translateAddr ( Virtaddr ( PC ) , InstructionFetch ()) {
33+ Err ( e , _ ) => F_Error ( e , PC ) ,
34+ Ok ( ppclo , _ ) => {
35+ /* split instruction fetch into 16-bit granules to handle RVC, as
36+ * well as to generate precise fault addresses in any fetch
37+ * exceptions.
38+ */
39+ match mem_read ( InstructionFetch () , ppclo , 2 , false , false , false ) {
40+ Err ( e ) => F_Error ( e , PC ) ,
41+ Ok (ilo ) =>
42+ if isRVC ( ilo )
43+ then F_RVC ( ilo )
44+ else {
45+ /* fetch PC check for the next instruction granule */
46+ let PC_hi = PC + 2 ;
47+ match ext_fetch_check_pc ( PC , PC_hi ) {
48+ Some ( e ) => return F_Ext_Error ( e ) ,
49+ None ( ) => ( ),
50+ };
51+
52+ match translateAddr ( Virtaddr ( PC_hi ), InstructionFetch ()) {
53+ Err ( e , _ ) => F_Error ( e , PC_hi ) ,
54+ Ok ( ppchi , _ ) =>
55+ match mem_read ( InstructionFetch () , ppchi , 2 , false , false , false ) {
56+ Err ( e ) => F_Error ( e , PC_hi ) ,
57+ Ok ( ihi ) => F_Base ( append ( ihi , ilo ))
5658 }
57- }
5859 }
5960 }
60- }
6161 }
6262 }
6363 }
0 commit comments