bd3b102a2dbb263c06011cbc81c175a78d10c020
[riscv-isa-sim.git] / riscv / riscv-isa-run.cc
1 #include <unistd.h>
2 #include <fcntl.h>
3 #include "common.h"
4 #include "sim.h"
5 #include "applink.h"
6
7 int main(int argc, char** argv)
8 {
9 bool debug = false;
10 int nprocs = 1;
11 int fromhost_fd = -1, tohost_fd = -1;
12 size_t icsim_sets = 1024, icsim_linesz = 32, icsim_ways = 1;
13
14 for(int c; (c = getopt(argc,argv,"dp:f:t:i:")) != -1; )
15 {
16 switch(c)
17 {
18 case 'd':
19 debug = true;
20 break;
21 case 'p':
22 nprocs = atoi(optarg);
23 break;
24 case 'f':
25 fromhost_fd = atoi(optarg);
26 break;
27 case 't':
28 tohost_fd = atoi(optarg);
29 break;
30 case 'i':
31 switch(optarg[0])
32 {
33 case 's':
34 icsim_sets = atoi(optarg+1);
35 break;
36 case 'l':
37 icsim_linesz = atoi(optarg+1);
38 break;
39 case 'a':
40 icsim_ways = atoi(optarg+1);
41 break;
42 }
43 break;
44 }
45 }
46
47 demand(fcntl(fromhost_fd,F_GETFD) >= 0, "fromhost file not open");
48 demand(fcntl(tohost_fd,F_GETFD) >= 0, "tohost file not open");
49
50 icsim_t icache(icsim_sets, icsim_ways, icsim_linesz, "I$");
51 icsim_t dcache(512, 2, 32, "D$");
52
53 appserver_link_t applink(tohost_fd, fromhost_fd);
54
55 sim_t s(nprocs, &applink, &icache, &dcache);
56 try
57 {
58 s.run(debug);
59 }
60 catch(quit_sim&)
61 {
62 }
63 }