temporary undoing of renaming
[riscv-isa-sim.git] / riscv / riscv-isa-run.cc
1 #include <stdio.h>
2 #include "sim.h"
3 #include "htif.h"
4
5 static void help()
6 {
7 fprintf(stderr, "usage: riscv-isa-run -f <fd> -t <fd> [additional options]\n");
8 fprintf(stderr, "Options:\n");
9 fprintf(stderr, " -f <fd> From-host pipe file descriptor\n");
10 fprintf(stderr, " -t <fd> To-host pipe file descriptor\n");
11 fprintf(stderr, " -p <n> Simulate <n> processors\n");
12 fprintf(stderr, " -d Interactive debug mode\n");
13 exit(1);
14 }
15
16 int main(int argc, char** argv)
17 {
18 bool debug = false;
19 int nprocs = 1;
20 int fromhost_fd = -1, tohost_fd = -1;
21
22 // parse command-line arguments
23 for(int c; (c = getopt(argc,argv,"hdp:f:t:")) != -1; )
24 {
25 switch(c)
26 {
27 case 'd':
28 debug = true;
29 break;
30 case 'p':
31 nprocs = atoi(optarg);
32 break;
33 case 'f':
34 fromhost_fd = atoi(optarg);
35 break;
36 case 't':
37 tohost_fd = atoi(optarg);
38 break;
39 default:
40 fprintf(stderr, "unknown option: -%c", optopt);
41 case 'h':
42 help();
43 }
44 }
45
46 // we require -f and -t to be specified so we can communicate with the host
47 if(fromhost_fd == -1 || tohost_fd == -1)
48 help();
49
50 // initialize host-target interface
51 htif_t htif(tohost_fd, fromhost_fd);
52
53 // initalize simulator and run to completion
54 sim_t s(nprocs, &htif);
55 s.run(debug);
56 }