@@ -124,13 +124,14 @@ def get_generator_cmd(simulator, simulator_yaml, cov, exp, debug_cmd):
124124 sys .exit (RET_FAIL )
125125
126126
127- def parse_iss_yaml (iss , iss_yaml , isa , setting_dir , debug_cmd ):
127+ def parse_iss_yaml (iss , iss_yaml , isa , priv , setting_dir , debug_cmd ):
128128 """Parse ISS YAML to get the simulation command
129129
130130 Args:
131131 iss : target ISS used to look up in ISS YAML
132132 iss_yaml : ISS configuration file in YAML format
133133 isa : ISA variant passed to the ISS
134+ priv: : privilege modes
134135 setting_dir : Generator setting directory
135136 debug_cmd : Produce the debug cmd log without running
136137
@@ -140,6 +141,9 @@ def parse_iss_yaml(iss, iss_yaml, isa, setting_dir, debug_cmd):
140141 logging .info ("Processing ISS setup file : {}" .format (iss_yaml ))
141142 yaml_data = read_yaml (iss_yaml )
142143
144+ # Path to the "yaml" subdirectory
145+ yaml_dir = os .path .dirname (iss_yaml )
146+
143147 # Path to the "scripts" subdirectory
144148 my_path = os .path .dirname (os .path .realpath (__file__ ))
145149 scripts_dir = os .path .join (my_path , "scripts" ) # Search for matched ISS
@@ -166,7 +170,9 @@ def parse_iss_yaml(iss, iss_yaml, isa, setting_dir, debug_cmd):
166170 cmd = re .sub ("\<variant\>" , variant , cmd )
167171 else :
168172 cmd = re .sub ("\<variant\>" , isa , cmd )
173+ cmd = re .sub ("\<priv\>" , priv , cmd )
169174 cmd = re .sub ("\<scripts_path\>" , scripts_dir , cmd )
175+ cmd = re .sub ("\<config_path\>" , yaml_dir , cmd )
170176 return cmd
171177 logging .error ("Cannot find ISS {}" .format (iss ))
172178 sys .exit (RET_FAIL )
@@ -442,7 +448,12 @@ def gcc_compile(test_list, output_dir, isa, mabi, opts, debug_cmd):
442448 if 'gen_opts' in test :
443449 # Disable compressed instruction
444450 if re .search ('disable_compressed_instr' , test ['gen_opts' ]):
445- test_isa = re .sub ("c" , "" , test_isa )
451+ # Note that this substitution assumes the cannonical order
452+ # of extensions, i.e. that extensions with preceding
453+ # underscores will be provided after all letter extensions.
454+ # This assumption should hold true, as this is a
455+ # requirement enforced by e.g. gcc
456+ test_isa = re .sub (r"(rv.+?)c" , r"\1" , test_isa )
446457 # If march/mabi is not defined in the test gcc_opts, use the default
447458 # setting from the command line.
448459 if not re .search ('march' , cmd ):
@@ -641,7 +652,7 @@ def run_c_from_dir(c_test_dir, iss_yaml, isa, mabi, gcc_opts, iss,
641652
642653
643654def iss_sim (test_list , output_dir , iss_list , iss_yaml , iss_opts ,
644- isa , setting_dir , timeout_s , debug_cmd ):
655+ isa , priv , setting_dir , timeout_s , debug_cmd ):
645656 """Run ISS simulation with the generated test program
646657
647658 Args:
@@ -651,13 +662,15 @@ def iss_sim(test_list, output_dir, iss_list, iss_yaml, iss_opts,
651662 iss_yaml : ISS configuration file in YAML format
652663 iss_opts : ISS command line options
653664 isa : ISA variant passed to the ISS
665+ priv : privilege modes
654666 setting_dir : Generator setting directory
655667 timeout_s : Timeout limit in seconds
656668 debug_cmd : Produce the debug cmd log without running
657669 """
658670 for iss in iss_list .split ("," ):
659671 log_dir = ("{}/{}_sim" .format (output_dir , iss ))
660- base_cmd = parse_iss_yaml (iss , iss_yaml , isa , setting_dir , debug_cmd )
672+ base_cmd = parse_iss_yaml (iss , iss_yaml , isa , priv , setting_dir , debug_cmd )
673+ base_cmd += iss_opts
661674 logging .info ("{} sim log dir: {}" .format (iss , log_dir ))
662675 run_cmd_output (["mkdir" , "-p" , log_dir ])
663676 for test in test_list :
@@ -814,6 +827,8 @@ def parse_args(cwd):
814827 command is not specified" )
815828 parser .add_argument ("--isa" , type = str , default = "" ,
816829 help = "RISC-V ISA subset" )
830+ parser .add_argument ("--priv" , type = str , default = "m" ,
831+ help = "RISC-V privilege modes enabled in simulation [su]" )
817832 parser .add_argument ("-m" , "--mabi" , type = str , default = "" ,
818833 help = "mabi used for compilation" , dest = "mabi" )
819834 parser .add_argument ("--gen_timeout" , type = int , default = 360 ,
@@ -936,40 +951,40 @@ def load_config(args, cwd):
936951 args .core_setting_dir = cwd + "/target/" + args .target
937952 if args .target == "rv32imc" :
938953 args .mabi = "ilp32"
939- args .isa = "rv32imc "
954+ args .isa = "rv32imc_zicsr_zifencei "
940955 elif args .target == "rv32imafdc" :
941956 args .mabi = "ilp32"
942- args .isa = "rv32imafdc "
957+ args .isa = "rv32imafdc_zicsr_zifencei "
943958 elif args .target == "rv32imc_sv32" :
944959 args .mabi = "ilp32"
945- args .isa = "rv32imc "
960+ args .isa = "rv32imc_zicsr_zifencei "
946961 elif args .target == "multi_harts" :
947962 args .mabi = "ilp32"
948- args .isa = "rv32gc "
963+ args .isa = "rv32gc_zicsr_zifencei "
949964 elif args .target == "rv32imcb" :
950965 args .mabi = "ilp32"
951- args .isa = "rv32imcb "
966+ args .isa = "rv32imcb_zicsr_zifencei "
952967 elif args .target == "rv32i" :
953968 args .mabi = "ilp32"
954- args .isa = "rv32i "
969+ args .isa = "rv32i_zicsr_zifencei "
955970 elif args .target == "rv64imc" :
956971 args .mabi = "lp64"
957- args .isa = "rv64imc "
972+ args .isa = "rv64imc_zicsr_zifencei "
958973 elif args .target == "rv64imcb" :
959974 args .mabi = "lp64"
960- args .isa = "rv64imcb "
975+ args .isa = "rv64imcb_zicsr_zifencei "
961976 elif args .target == "rv64gc" :
962977 args .mabi = "lp64"
963- args .isa = "rv64gc "
978+ args .isa = "rv64gc_zicsr_zifencei "
964979 elif args .target == "rv64gcv" :
965980 args .mabi = "lp64"
966- args .isa = "rv64gcv "
981+ args .isa = "rv64gcv_zicsr_zifencei "
967982 elif args .target == "ml" :
968983 args .mabi = "lp64"
969- args .isa = "rv64imc "
984+ args .isa = "rv64imc_zicsr_zifencei "
970985 elif args .target == "rv64imafdc" :
971986 args .mabi = "lp64"
972- args .isa = "rv64imafdc "
987+ args .isa = "rv64imafdc_zicsr_zifencei "
973988 else :
974989 sys .exit ("Unsupported pre-defined target: {}" .format (args .target ))
975990 else :
@@ -1147,7 +1162,7 @@ def main():
11471162 if args .steps == "all" or re .match (".*iss_sim.*" , args .steps ):
11481163 iss_sim (matched_list , output_dir , args .iss , args .iss_yaml ,
11491164 args .iss_opts ,
1150- args .isa , args .core_setting_dir , args .iss_timeout ,
1165+ args .isa , args .priv , args . core_setting_dir , args .iss_timeout ,
11511166 args .debug )
11521167
11531168 # Compare ISS simulation result
0 commit comments