diff options
-rw-r--r-- | c_emulator/riscv_sim.c | 18 | ||||
-rw-r--r-- | ocaml_emulator/riscv_ocaml_sim.ml | 7 |
2 files changed, 21 insertions, 4 deletions
diff --git a/c_emulator/riscv_sim.c b/c_emulator/riscv_sim.c index 9cca587..ebcfdc9 100644 --- a/c_emulator/riscv_sim.c +++ b/c_emulator/riscv_sim.c @@ -79,6 +79,7 @@ static struct option options[] = { {"device-tree-blob", required_argument, 0, 'b'}, {"terminal-log", required_argument, 0, 't'}, {"show-times", required_argument, 0, 'p'}, + {"report-arch", no_argument, 0, 'a'}, #ifdef RVFI_DII {"rvfi-dii", required_argument, 0, 'r'}, #endif @@ -101,6 +102,12 @@ static void print_usage(const char *argv0, int ec) exit(ec); } +static void report_arch(void) +{ + fprintf(stdout, "RV%lu\n", zxlen_val); + exit(0); +} + static void dump_dts(void) { #ifdef ENABLE_SPIKE @@ -154,9 +161,12 @@ char *process_args(int argc, char **argv) int c, idx = 1; uint64_t ram_size = 0; while(true) { - c = getopt_long(argc, argv, "dmCspz:b:t:v:hr:", options, &idx); + c = getopt_long(argc, argv, "admCspz:b:t:v:hr:", options, &idx); if (c == -1) break; switch (c) { + case 'a': + report_arch(); + break; case 'd': fprintf(stderr, "enabling dirty update.\n"); rv_enable_dirty_update = true; @@ -663,12 +673,12 @@ void init_logs() int main(int argc, char **argv) { + // Initialize model so that we can check or report its architecture. + preinit_sail(); + char *file = process_args(argc, argv); init_logs(); - // Initialize model so that we can check its architecture. - preinit_sail(); - if (gettimeofday(&init_start, NULL) < 0) { fprintf(stderr, "Cannot gettimeofday: %s\n", strerror(errno)); exit(1); diff --git a/ocaml_emulator/riscv_ocaml_sim.ml b/ocaml_emulator/riscv_ocaml_sim.ml index e1acc08..05912f5 100644 --- a/ocaml_emulator/riscv_ocaml_sim.ml +++ b/ocaml_emulator/riscv_ocaml_sim.ml @@ -61,6 +61,10 @@ let opt_file_arguments = ref ([] : string list) let opt_dump_dts = ref false let opt_dump_dtb = ref false +let report_arch () = + Printf.printf "RV%d\n" (Big_int.to_int Riscv.zxlen_val); + exit 0 + let options = Arg.align ([("-dump-dts", Arg.Set opt_dump_dts, " dump the platform device-tree source to stdout"); @@ -79,6 +83,9 @@ let options = Arg.align ([("-dump-dts", ("-ram-size", Arg.Int PI.set_dram_size, " size of physical ram memory to use (in MB)"); + ("-report-arch", + Arg.Unit report_arch, + " report model architecture (RV32 or RV64)"); ("-with-dtc", Arg.String PI.set_dtc, " full path to dtc to use") |