cavatools: initialize repository
[cavatools.git] / caveat / core.h
1 /*
2 Copyright (c) 2020 Peter Hsu. All Rights Reserved. See LICENCE file for details.
3 */
4
5
6 #define sex(rd) IR(rd).l = IR(rd).l << 32 >> 32
7 #define zex(rd) IR(rd).ul = IR(rd).ul << 32 >> 32
8 #define box(rd)
9
10 extern unsigned long lrsc_set; // globally shared location for atomic lock
11 extern long regval[];
12
13 struct core_t {
14 struct fifo_t* tb;
15 struct reg_t reg[64]; // Register files, IR[0-31], FR[32-63]
16 #define IR(rn) cpu->reg[rn]
17 #define FR(rn) cpu->reg[rn]
18 Addr_t pc; // Next instruction to be executed
19 Addr_t holding_pc; // For verification tracing
20
21 struct {
22 long coreid;
23 long ustatus;
24 long mcause;
25 Addr_t mepc;
26 long mtval;
27 union {
28 struct {
29 unsigned flags : 5;
30 unsigned rmode : 3;
31 } fcsr;
32 unsigned long fcsr_v;
33 };
34 } state;
35
36 struct {
37 long insn_executed;
38 long start_tick;
39 struct timeval start_timeval;
40 } counter;
41
42 struct {
43 Addr_t breakpoint; /* entrypoint of traced function */
44 long after; /* countdown, negative=start tracing */
45 long every; /* but only trace once per n-1 calls */
46 long skip; /* skip until negative, reset to every */
47 long report;
48 long flags;
49 long quiet;
50 } params;
51 };
52
53
54 extern struct fifo_t verify;
55
56 void init_core(struct core_t* cpu, long start_tick, const struct timeval* start_timeval);
57 int run_program(struct core_t* cpu);
58 int outer_loop(struct core_t* cpu);
59 void fast_sim(struct core_t*, long max_count);
60 void slow_sim(struct core_t*, long max_count);
61 int proxy_ecall( struct core_t* cpu );
62 void proxy_csr( struct core_t* cpu, const struct insn_t* p, int which );
63 void status_report(struct core_t* cpu, FILE*);
64