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

Rebase #30

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
c72b5b1
Assembly for hint instructions needs spaces after mnemonics
ThinkOpenly Oct 25, 2023
532cfca
Add `json` target
ThinkOpenly Aug 10, 2023
383846e
Start tagging extensions uniformly
ThinkOpenly Sep 29, 2023
f11e46f
Add more uniform extension tags
ThinkOpenly Oct 25, 2023
dc4f28f
support most remaining extensions via extension()
ThinkOpenly Oct 26, 2023
e21590f
hints again
ThinkOpenly Oct 30, 2023
3389eca
tag extensions "V" and "Zbkb"
ThinkOpenly Oct 31, 2023
cc680e5
Add C extension conditionals
Sanket-0510 Jan 20, 2024
edb07a9
Use extension discriminator for "A" and "M" extensions
Bakugo90 Mar 7, 2024
78ba6a6
Added names and descriptions for some instructions in riscv_insts_bas…
jriyyya Mar 8, 2024
afc175f
Fix up some whitespace and capitalization
ThinkOpenly Mar 8, 2024
5500f38
[JSON] Suppress command echo to stdout
snapdgn Mar 20, 2024
5afa30e
Utilize function extension instead of haveZdinx()
jriyyya Apr 9, 2024
a85b7fc
Utilize extension function instead of haveZhinx()
jriyyya Apr 9, 2024
3b03fc7
Utilize extension function instead of haveZfinx()
jriyyya Apr 9, 2024
7335c61
Add names for some instructions within groups
ThinkOpenly Apr 9, 2024
11a2af8
Make use of extension() instead of have*()
jriyyya Apr 18, 2024
8291be5
Add compilation steps to README.md
joydeep049 May 8, 2024
aed0935
Add names for SHA2-256 instructions
Linda-Njau Jun 10, 2024
b021578
Add newline at end of JSON.md
ThinkOpenly Jun 12, 2024
5f41034
Add names for SHA2-512 instructions
Linda-Njau Jun 11, 2024
acef250
Add Makefile target to validate JSON
ThinkOpenly Jun 12, 2024
9e0a892
Sail rebase now requires quoted strings in annotations
ThinkOpenly Jun 17, 2024
a67bf16
tweaks after rebase
ThinkOpenly Jun 18, 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
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,19 @@ RISCV_EXTRAS_LEM = $(addprefix handwritten_support/,$(RISCV_EXTRAS_LEM_FILES))
all: ocaml_emulator/riscv_ocaml_sim_$(ARCH) c_emulator/riscv_sim_$(ARCH)
.PHONY: all

json: $(SAIL_SRCS) model/main.sail Makefile
@sail -json $(SAIL_FLAGS) $(SAIL_SRCS)

.PHONY: check-json
check-json:
sail -json $(SAIL_FLAGS) $(SAIL_SRCS) | python3 -c "import json; import sys; j=json.load(sys.stdin)"

output: $(SAIL_SRCS) model/main.sail Makefile
sail -output-sail $(SAIL_FLAGS) $(SAIL_SRCS)

decode: $(SAIL_SRCS) model/main.sail Makefile
sail -plugin $(HOME)/projects/Sail/riscvdecode/riscv_decode.cmxs -riscv_decode $(SAIL_FLAGS) $(SAIL_SRCS)

# the following ensures empty sail-generated .c files don't hang around and
# break future builds if sail exits badly
.DELETE_ON_ERROR: generated_definitions/c/%.c
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,10 @@ There is also (as yet unmerged) support for [integration with riscv-config](http
For booting operating system images, see the information under the
[os-boot/](os-boot/) subdirectory.

### How to use the out-of-tree JSON backend to generate JSON from Sail

For details, see [JSON.md](doc/JSON.md).

### Using development versions of Sail

Rarely, the version of Sail packaged in opam may not meet your needs. This could happen if you need a bug fix or new feature not yet in the released Sail version, or you are actively working on Sail. In this case you can tell the `sail-riscv` `Makefile` to use a local copy of Sail by setting `SAIL_DIR` to the root of a checkout of the Sail repo when you invoke `make`. Alternatively, you can use `opam pin` to install Sail from a local checkout of the Sail repo as described in the Sail installation instructions.
Expand Down
18 changes: 18 additions & 0 deletions doc/JSON.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
STEPS TO BUILD AND COMPILE THE PROJECT
=======================================

After Installing the prerequisites

1. We first need to build the sail parser.
1. Find a directory to clone this repository, and make that directory your current working directory.
2. `git clone https://github.com/ThinkOpenly/sail`
3. `cd sail`
4. `make`

2. Then, set up the environment for building in the RISC-V Sail repository:
1. `eval $(opam env)`
2. `export PATH=<path-to-sail-repository>:$PATH`

3. Clone this sail-riscv repository.

4. Within that clone : `make json`
6 changes: 3 additions & 3 deletions model/riscv_fdext_control.sail
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

/* val clause ext_is_CSR_defined : (csreg, Privilege) -> bool */

function clause ext_is_CSR_defined (0x001, _) = haveFExt() | haveZfinx()
function clause ext_is_CSR_defined (0x002, _) = haveFExt() | haveZfinx()
function clause ext_is_CSR_defined (0x003, _) = haveFExt() | haveZfinx()
function clause ext_is_CSR_defined (0x001, _) = extension("F") | extension("Zfinx")
function clause ext_is_CSR_defined (0x002, _) = extension("F") | extension("Zfinx")
function clause ext_is_CSR_defined (0x003, _) = extension("F") | extension("Zfinx")

function clause ext_read_CSR (0x001) = Some(zero_extend(fcsr[FFLAGS]))
function clause ext_read_CSR (0x002) = Some(zero_extend(fcsr[FRM]))
Expand Down
2 changes: 1 addition & 1 deletion model/riscv_fetch.sail
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function fetch() -> FetchResult =
match ext_fetch_check_pc(PC, PC) {
Ext_FetchAddr_Error(e) => F_Ext_Error(e),
Ext_FetchAddr_OK(use_pc) => {
if (use_pc[0] != bitzero | (use_pc[1] != bitzero & not(haveRVC())))
if (use_pc[0] != bitzero | (use_pc[1] != bitzero & not(extension("C"))))
then F_Error(E_Fetch_Addr_Align(), PC)
else match translateAddr(use_pc, Execute()) {
TR_Failure(e, _) => F_Error(e, PC),
Expand Down
2 changes: 1 addition & 1 deletion model/riscv_fetch_rvfi.sail
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function fetch() -> FetchResult = {
Ext_FetchAddr_Error(e) => F_Ext_Error(e),
Ext_FetchAddr_OK(use_pc) => {
/* then check PC alignment */
if (use_pc[0] != bitzero | (use_pc[1] != bitzero & not(haveRVC())))
if (use_pc[0] != bitzero | (use_pc[1] != bitzero & not(extension("C"))))
then F_Error(E_Fetch_Addr_Align(), PC)
else match translateAddr(use_pc, Execute()) {
TR_Failure(e, _) => F_Error(e, PC),
Expand Down
12 changes: 6 additions & 6 deletions model/riscv_insts_aext.sail
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ function amo_width_valid(size : word_width) -> bool = {
/* ****************************************************************** */
union clause ast = LOADRES : (bool, bool, regidx, word_width, regidx)

mapping clause encdec = LOADRES(aq, rl, rs1, size, rd) if haveZalrsc() & amo_width_valid(size)
<-> 0b00010 @ bool_bits(aq) @ bool_bits(rl) @ 0b00000 @ rs1 @ 0b0 @ size_enc(size) @ rd @ 0b0101111 if haveZalrsc() & amo_width_valid(size)
mapping clause encdec = LOADRES(aq, rl, rs1, size, rd) if extension("Zalrsc") & amo_width_valid(size)
<-> 0b00010 @ bool_bits(aq) @ bool_bits(rl) @ 0b00000 @ rs1 @ 0b0 @ size_enc(size) @ rd @ 0b0101111 if extension("Zalrsc") & amo_width_valid(size)


/* We could set load-reservations on physical or virtual addresses.
Expand Down Expand Up @@ -88,8 +88,8 @@ mapping clause assembly = LOADRES(aq, rl, rs1, size, rd)
/* ****************************************************************** */
union clause ast = STORECON : (bool, bool, regidx, regidx, word_width, regidx)

mapping clause encdec = STORECON(aq, rl, rs2, rs1, size, rd) if haveZalrsc() & amo_width_valid(size)
<-> 0b00011 @ bool_bits(aq) @ bool_bits(rl) @ rs2 @ rs1 @ 0b0 @ size_enc(size) @ rd @ 0b0101111 if haveZalrsc() & amo_width_valid(size)
mapping clause encdec = STORECON(aq, rl, rs2, rs1, size, rd) if extension("Zalrsc") & amo_width_valid(size)
<-> 0b00011 @ bool_bits(aq) @ bool_bits(rl) @ rs2 @ rs1 @ 0b0 @ size_enc(size) @ rd @ 0b0101111 if extension("Zalrsc") & amo_width_valid(size)

/* NOTE: Currently, we only EA if address translation is successful. This may need revisiting. */
function clause execute (STORECON(aq, rl, rs2, rs1, width, rd)) = {
Expand Down Expand Up @@ -163,8 +163,8 @@ mapping encdec_amoop : amoop <-> bits(5) = {
AMOMAXU <-> 0b11100
}

mapping clause encdec = AMO(op, aq, rl, rs2, rs1, size, rd) if haveZaamo() & amo_width_valid(size)
<-> encdec_amoop(op) @ bool_bits(aq) @ bool_bits(rl) @ rs2 @ rs1 @ 0b0 @ size_enc(size) @ rd @ 0b0101111 if haveZaamo() & amo_width_valid(size)
mapping clause encdec = AMO(op, aq, rl, rs2, rs1, size, rd) if extension("Zaamo") & amo_width_valid(size)
<-> encdec_amoop(op) @ bool_bits(aq) @ bool_bits(rl) @ rs2 @ rs1 @ 0b0 @ size_enc(size) @ rd @ 0b0101111 if extension("Zaamo") & amo_width_valid(size)

/* NOTE: Currently, we only EA if address translation is successful.
This may need revisiting. */
Expand Down
Loading