@@ -19,14 +19,31 @@ scattered mapping extensionName
1919val hartSupports : extension -> bool
2020scattered function hartSupports
2121
22+ function hartSupports_measure (ext : extension ) -> int =
23+ match ext {
24+ Ext_D => 1 , // > F
25+ Ext_Sstvecd => 1 , // > S
26+ Ext_Ssu64xl => 1 , // > S
27+ Ext_Zvkn => 1 , // > Zvkned
28+ Ext_Zvks => 1 , // > Zvksed
29+
30+ Ext_C => 2 , // > D
31+ Ext_Zvknc => 2 , // > Zvkn
32+ Ext_Zvkng => 2 , // > Zvkn
33+ Ext_Zvksc => 2 , // > Zvks
34+ Ext_Zvksg => 2 , // > Zvks
35+
36+ _ => 0 ,
37+ }
38+
39+ termination_measure hartSupports (ext ) = hartSupports_measure (ext )
40+
2241// Function used to determine if an extension is currently enabled in the model.
2342// This means an extension is supported, *and* any necessary bits are set in the
2443// relevant CSRs (misa, mstatus, etc.) to enable its use. It is possible for some
2544// extensions to be supported in hardware, but temporarily disabled via a CSR, in
2645// which case this function should return false.
27- // Note: when adding a new extension, adjust the associated termination measure
28- // in the file termination.sail, as explained in the comment in
29- // that file.
46+ // Note: when adding a new extension, adjust the `currentlyEnabled_measure` below.
3047val currentlyEnabled : extension -> bool
3148scattered function currentlyEnabled
3249
@@ -474,6 +491,66 @@ enum clause extension = Ext_Smcntrpmf
474491mapping clause extensionName = Ext_Smcntrpmf <-> "smcntrpmf"
475492function clause hartSupports (Ext_Smcntrpmf ) = config extensions . Smcntrpmf . supported
476493
494+ // When adding a new extension X, we need to make sure that if X being enabled
495+ // depends on Y being enabled, then the value associated to X is _greater_ than
496+ // the value associated to Y. The default value is 2, so that if it does not
497+ // depend on anything or only on extensions A, B, C, D, F, M, S, Zve32x, Zvl* or Zicsr,
498+ // nothing needs to be done.
499+
500+ function currentlyEnabled_measure (ext : extension ) -> int =
501+ match ext {
502+ Ext_A => 0 ,
503+ Ext_B => 0 ,
504+ Ext_C => 0 ,
505+ Ext_M => 0 ,
506+ Ext_Zicsr => 0 ,
507+ Ext_Zvl128b => 0 ,
508+ Ext_Zvl32b => 0 ,
509+ Ext_Zvl64b => 0 ,
510+
511+ Ext_D => 1 , // > Zicsr
512+ Ext_F => 1 , // > Zicsr
513+ Ext_S => 1 , // > Zicsr
514+ Ext_Zaamo => 1 , // > A
515+ Ext_Zalrsc => 1 , // > A
516+ Ext_Zca => 1 , // > C
517+ Ext_Zfinx => 1 , // > Zicsr
518+ Ext_Zicntr => 1 , // > Zicsr
519+ Ext_Zihpm => 1 , // > Zicsr
520+ Ext_Zve32x => 1 , // > Zvl32b
521+
522+ // Note: even though these match the default case, making them explicit to
523+ // annotate the chain of dependencies
524+ Ext_Sv39 => 2 , // > S
525+ Ext_Zfh => 2 , // > F
526+ Ext_Zhinx => 2 , // > Zfinx
527+ Ext_Zvbb => 2 , // > Zve32x
528+ Ext_Zve32f => 2 , // > Zve32x
529+ Ext_Zve64x => 2 , // > Zve32x
530+
531+ Ext_Svrsw60t59b => 3 , // > Sv39
532+ Ext_Zfhmin => 3 , // > Zfh
533+ Ext_Zhinxmin => 3 , // > Zhinx
534+ Ext_Zicfilp => 3 , // > get_xLPE
535+ Ext_Zvbc => 3 , // > Zve64x
536+ Ext_Zve64f => 3 , // > Zve64x
537+ Ext_Zvfbfmin => 3 , // > Zve32f
538+ Ext_Zvkb => 3 , // > Zvbb
539+ Ext_Zvknhb => 3 , // > Zve64x
540+
541+ Ext_H => 4 , // > virtual_mem_supported
542+ Ext_Zve64d => 4 , // > Zve64f
543+ Ext_Zvfbfwma => 4 , // > Zvfbfmin
544+ Ext_Zvfh => 4 , // > Zfhmin
545+
546+ Ext_V => 5 , // > Zve64d
547+ Ext_Zvfhmin => 5 , // > Zvfh
548+
549+ _ => 2
550+ }
551+
552+ termination_measure currentlyEnabled (ext ) = currentlyEnabled_measure (ext )
553+
477554let extensions_ordered_for_isa_string = [
478555 // Single letter extensions.
479556 Ext_M ,
0 commit comments