Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sdtrig support #486

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
7d36342
Sdtrig Draft
Mudassir10X May 14, 2024
37e993a
added tcontrol and tinfo CSR
Mudassir10X May 21, 2024
a24b0fd
Merge branch 'riscv:master' into sdtrig_support
Mudassir10X May 22, 2024
3b2f17f
enabled trigger registers and legalized tselect only
Mudassir10X May 23, 2024
80794b9
added TODO tags for the things that need to be done as a reminder
Mudassir10X May 23, 2024
0735323
This commit fixes #487
Mudassir10X May 23, 2024
debc43e
Merge branch 'riscv:master' into Solving-LTO-wrapper-warning-(Issue#487)
Mudassir10X May 23, 2024
b6440dd
Merge branch 'riscv:master' into sdtrig_support
Mudassir10X May 23, 2024
c3c9019
Merge branch 'riscv:master' into Solving-LTO-wrapper-warning-(Issue#487)
Mudassir10X May 23, 2024
08ffb78
Merge branch 'riscv:master' into sdtrig_support
Mudassir10X May 23, 2024
c2998f1
Merge pull request #1 from Mudassir10X/Solving-LTO-wrapper-warning-(I…
Mudassir10X May 23, 2024
8ffe477
removing trailing whitespaces
Mudassir10X May 24, 2024
d865d0f
Declared all the bitfields
Mudassir10X May 24, 2024
a728fa5
draft
Mudassir10X Jun 4, 2024
4fbb701
Merge branch 'riscv:master' into sdtrig_support
Mudassir10X Jun 7, 2024
8738225
extra
Mudassir10X Jun 11, 2024
cfce8c8
Merge remote-tracking branch 'refs/remotes/origin/sdtrig_support' int…
Mudassir10X Jun 11, 2024
c544edb
trimming
Mudassir10X Jun 11, 2024
8813620
Defined Privilege permissions for sdtrig registers
Mudassir10X Jun 12, 2024
ed4c073
Merge branch 'riscv:master' into sdtrig_support
Mudassir10X Jun 12, 2024
c98efb8
Merge branch 'riscv:master' into sdtrig_support
Mudassir10X Jun 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@ _sbuild/
*.o
*.a
/z3_problems
c_emulator/riscv_sim_RV32
c_emulator/riscv_sim_RV64
c_emulator/riscv_rvfi_RV64
ocaml_emulator/riscv_ocaml_sim_RV64
ocaml_emulator/riscv_ocaml_sim_RV32
5 changes: 5 additions & 0 deletions c_emulator/riscv_platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ bool sys_enable_zfinx(unit u)
return rv_enable_zfinx;
}

bool sys_enable_sdtrig(unit u)
{
return rv_enable_sdtrig;
}

bool sys_enable_writable_fiom(unit u)
{
return rv_enable_writable_fiom;
Expand Down
1 change: 1 addition & 0 deletions c_emulator/riscv_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
bool sys_enable_rvc(unit);
bool sys_enable_next(unit);
bool sys_enable_fdext(unit);
bool sys_enable_sdtrig(unit);
bool sys_enable_svinval(unit);
bool sys_enable_zcb(unit);
bool sys_enable_zfinx(unit);
Expand Down
1 change: 1 addition & 0 deletions c_emulator/riscv_platform_impl.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ uint64_t rv_pmp_grain = 0;
bool rv_enable_svinval = false;
bool rv_enable_zcb = false;
bool rv_enable_zfinx = false;
bool rv_enable_sdtrig = false;
bool rv_enable_rvc = true;
bool rv_enable_next = false;
bool rv_enable_writable_misa = true;
Expand Down
1 change: 1 addition & 0 deletions c_emulator/riscv_platform_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ extern bool rv_enable_zfinx;
extern bool rv_enable_rvc;
extern bool rv_enable_next;
extern bool rv_enable_fdext;
extern bool rv_enable_sdtrig;
extern bool rv_enable_vext;
extern bool rv_enable_writable_misa;
extern bool rv_enable_dirty_update;
Expand Down
6 changes: 6 additions & 0 deletions c_emulator/riscv_sim.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const char *RV32ISA = "RV32IMAC";
#define OPT_PMP_COUNT 1002
#define OPT_PMP_GRAIN 1003
#define OPT_ENABLE_SVINVAL 1004
#define OPT_ENABLE_SDTRIG 1005
#define OPT_ENABLE_ZCB 10014

static bool do_dump_dts = false;
Expand Down Expand Up @@ -149,6 +150,7 @@ static struct option options[] = {
{"enable-writable-fiom", no_argument, 0, OPT_ENABLE_WRITABLE_FIOM},
{"enable-svinval", no_argument, 0, OPT_ENABLE_SVINVAL },
{"enable-zcb", no_argument, 0, OPT_ENABLE_ZCB },
{"enable-sdtrig", no_argument, 0, OPT_ENABLE_SDTRIG },
#ifdef SAILCOV
{"sailcov-file", required_argument, 0, 'c' },
#endif
Expand Down Expand Up @@ -394,6 +396,10 @@ static int process_args(int argc, char **argv)
fprintf(stderr, "enabling Zcb extension.\n");
rv_enable_zcb = true;
break;
case OPT_ENABLE_SDTRIG:
fprintf(stderr, "enabling sdtrig extension.\n");
rv_enable_sdtrig = true;
break;
case 'x':
fprintf(stderr, "enabling Zfinx support.\n");
rv_enable_zfinx = true;
Expand Down
1 change: 0 additions & 1 deletion generated_definitions/ast/riscv-ast-raw.txt

This file was deleted.

4 changes: 4 additions & 0 deletions handwritten_support/riscv_extras.lem
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ val sys_enable_zfinx : unit -> bool
let sys_enable_zfinx () = false
declare ocaml target_rep function sys_enable_zfinx = `Platform.enable_zfinx`

val sys_enable_sdtrig : unit -> bool
let sys_enable_sdtrig () = false
declare ocaml target_rep function sys_enable_sdtrig = `Platform.enable_sdtrig`

val sys_enable_vext : unit -> bool
let sys_enable_vext () = true
declare ocaml target_rep function sys_enable_vext = `Platform.enable_vext`
Expand Down
1 change: 1 addition & 0 deletions handwritten_support/riscv_extras.v
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ Axiom sys_enable_rvc : unit -> bool.
Axiom sys_enable_fdext : unit -> bool.
Axiom sys_enable_next : unit -> bool.
Axiom sys_enable_zfinx : unit -> bool.
Axiom sys_enable_sdtrig : unit -> bool.
Axiom sys_enable_writable_fiom : unit -> bool.

(* The constraint solver can do this itself, but a Coq bug puts
Expand Down
4 changes: 4 additions & 0 deletions handwritten_support/riscv_extras_sequential.lem
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ val sys_enable_zfinx : unit -> bool
let sys_enable_zfinx () = false
declare ocaml target_rep function sys_enable_zfinx = `Platform.enable_zfinx`

val sys_enable_sdtrig : unit -> bool
let sys_enable_sdtrig () = false
declare ocaml target_rep function sys_enable_sdtrig = `Platform.enable_sdtrig`

val sys_enable_next : unit -> bool
let sys_enable_next () = true
declare ocaml target_rep function sys_enable_next = `Platform.enable_next`
Expand Down
2 changes: 2 additions & 0 deletions model/riscv_csr_map.sail
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ mapping clause csr_name_map = 0x7a0 <-> "tselect"
mapping clause csr_name_map = 0x7a1 <-> "tdata1"
mapping clause csr_name_map = 0x7a2 <-> "tdata2"
mapping clause csr_name_map = 0x7a3 <-> "tdata3"
mapping clause csr_name_map = 0x7a4 <-> "tinfo"
mapping clause csr_name_map = 0x7a5 <-> "tcontrol"
/* vector csrs */
mapping clause csr_name_map = 0x008 <-> "vstart"
mapping clause csr_name_map = 0x009 <-> "vxsat"
Expand Down
14 changes: 12 additions & 2 deletions model/riscv_insts_zicsr.sail
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,12 @@ function readCSR csr : csreg -> xlenbits = {
(0xC22, _) => vlenb,

/* trigger/debug */
(0x7a0, _) => ~(tselect), /* this indicates we don't have any trigger support */
(0x7a0, _) => tselect.bits,
Mudassir10X marked this conversation as resolved.
Show resolved Hide resolved
(0x7a1, _) => tdata1.bits,
(0x7a2, _) => tdata2,
(0x7a3, _) => tdata3,
(0x7a4, _) => legalize_tinfo(tinfo),
(0x7a5, _) => tcontrol.bits,

/* supervisor mode */
(0x100, _) => lower_mstatus(mstatus).bits,
Expand Down Expand Up @@ -153,7 +158,12 @@ function writeCSR (csr : csreg, value : xlenbits) -> unit = {
(0xB82, 32) => { minstret[63 .. 32] = value; minstret_increment = false; Some(value) },

/* trigger/debug */
(0x7a0, _) => { tselect = value; Some(tselect) },
(0x7a0, _) => { tselect = legalize_tselect(tselect, value); Some(tselect.bits) },
(0x7a1, _) => { tdata1 = legalize_tdata1(tdata1, value); Some(tdata1.bits) },
// (0x7a2, _) => { tdata2[(sizeof(xlen) - 1) .. 0] = value; Some(value) },
// (0x7a3, _) => { tdata3[(sizeof(xlen) - 1) .. 0] = value; Some(value) },
(0x7a4, _) => { Some(tinfo.bits) }, // ignoring Writes to Tinfo
(0x7a5, _) => { tcontrol = legalize_tcontrol(tcontrol, value); Some(tcontrol.bits) },

/* supervisor mode */
(0x100, _) => { mstatus = legalize_sstatus(mstatus, value); Some(mstatus.bits) },
Expand Down
5 changes: 5 additions & 0 deletions model/riscv_sys_control.sail
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ function is_CSR_defined (csr : csreg, p : Privilege) -> bool =

/* disabled trigger/debug module */
0x7a0 => p == Machine,
0x7a1 => p == Machine,
0x7a2 => p == Machine,
0x7a3 => p == Machine,
0x7a4 => p == Machine,
0x7a5 => p == Machine,

/* supervisor mode: trap setup */
0x100 => haveSupMode() & (p == Machine | p == Supervisor), // sstatus
Expand Down
Loading
Loading