Skip to content

Commit

Permalink
Added instructions type to the Json schema. Added test types for I ex…
Browse files Browse the repository at this point in the history
…tensions.

Signed-off-by: Afonso Oliveira <[email protected]>
  • Loading branch information
AFOliveira committed Feb 4, 2025
1 parent 6938420 commit 3a5c55a
Show file tree
Hide file tree
Showing 55 changed files with 112 additions and 38 deletions.
1 change: 1 addition & 0 deletions arch/inst/I/add.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ $schema: "inst_schema.json#"
kind: instruction
name: add
long_name: Integer add
type: R-Type
description: |
Add the value in rs1 to rs2, and store the result in rd.
Any overflow is thrown away.
Expand Down
3 changes: 2 additions & 1 deletion arch/inst/I/addi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ $schema: "inst_schema.json#"
kind: instruction
name: addi
long_name: Add immediate
type: I-Type
description: Add an immediate to the value in rs1, and store the result in rd
definedBy: I
assembly: xd, xs1, imm
encoding:
match: -----------------000-----0010011
match: "-----------------000-----0010011"
variables:
- name: imm
location: 31-20
Expand Down
7 changes: 5 additions & 2 deletions arch/inst/I/addiw.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ $schema: "inst_schema.json#"
kind: instruction
name: addiw
long_name: Add immediate word
description: Add an immediate to the 32-bit value in rs1, and store the sign extended result in rd
type: I-Type
description:
Add an immediate to the 32-bit value in rs1, and store the sign extended
result in rd
definedBy: I
base: 64
assembly: xd, xs1, imm
encoding:
match: -----------------000-----0011011
match: "-----------------000-----0011011"
variables:
- name: imm
location: 31-20
Expand Down
1 change: 1 addition & 0 deletions arch/inst/I/addw.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ $schema: "inst_schema.json#"
kind: instruction
name: addw
long_name: Add word
type: R-Type
description: |
Add the 32-bit values in rs1 to rs2, and store the sign-extended result in rd.
Any overflow is thrown away.
Expand Down
1 change: 1 addition & 0 deletions arch/inst/I/and.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ $schema: "inst_schema.json#"
kind: instruction
name: and
long_name: And
type: R-Type
description: And rs1 with rs2, and store the result in rd
definedBy: I
assembly: xd, xs1, xs2
Expand Down
3 changes: 2 additions & 1 deletion arch/inst/I/andi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ $schema: "inst_schema.json#"
kind: instruction
name: andi
long_name: And immediate
type: I-Type
description: And an immediate to the value in rs1, and store the result in rd
definedBy: I
assembly: xd, xs1, imm
encoding:
match: -----------------111-----0010011
match: "-----------------111-----0010011"
variables:
- name: imm
location: 31-20
Expand Down
3 changes: 2 additions & 1 deletion arch/inst/I/auipc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ $schema: "inst_schema.json#"
kind: instruction
name: auipc
long_name: Add upper immediate to pc
type: U-Type
description: Add an immediate to the current PC.
definedBy: I
assembly: xd, imm
encoding:
match: -------------------------0010111
match: "-------------------------0010111"
variables:
- name: imm
location: 31-12
Expand Down
3 changes: 2 additions & 1 deletion arch/inst/I/beq.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ $schema: "inst_schema.json#"
kind: instruction
name: beq
long_name: Branch if equal
type: B-Type
description: |
Branch to PC + imm if
the value in register rs1 is equal to the value in register rs2.
Expand All @@ -12,7 +13,7 @@ description: |
definedBy: I
assembly: xs1, xs2, imm
encoding:
match: -----------------000-----1100011
match: "-----------------000-----1100011"
variables:
- name: imm
location: 31|7|30-25|11-8
Expand Down
3 changes: 2 additions & 1 deletion arch/inst/I/bge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ $schema: "inst_schema.json#"
kind: instruction
name: bge
long_name: Branch if greater than or equal
type: B-Type
description: |
Branch to PC + imm if
the signed value in register rs1 is greater than or equal to the signed value in register rs2.
Expand All @@ -12,7 +13,7 @@ description: |
definedBy: I
assembly: xs1, xs2, imm
encoding:
match: -----------------101-----1100011
match: "-----------------101-----1100011"
variables:
- name: imm
location: 31|7|30-25|11-8
Expand Down
3 changes: 2 additions & 1 deletion arch/inst/I/bgeu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ $schema: "inst_schema.json#"
kind: instruction
name: bgeu
long_name: Branch if greater than or equal unsigned
type: B-Type
description: |
Branch to PC + imm if
the unsigned value in register rs1 is greater than or equal to the unsigned value in register rs2.
Expand All @@ -12,7 +13,7 @@ description: |
definedBy: I
assembly: xs1, xs2, imm
encoding:
match: -----------------111-----1100011
match: "-----------------111-----1100011"
variables:
- name: imm
location: 31|7|30-25|11-8
Expand Down
3 changes: 2 additions & 1 deletion arch/inst/I/blt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ $schema: "inst_schema.json#"
kind: instruction
name: blt
long_name: Branch if less than
type: B-Type
description: |
Branch to PC + imm if
the signed value in register rs1 is less than the signed value in register rs2.
Expand All @@ -12,7 +13,7 @@ description: |
definedBy: I
assembly: xs1, xs2, imm
encoding:
match: -----------------100-----1100011
match: "-----------------100-----1100011"
variables:
- name: imm
location: 31|7|30-25|11-8
Expand Down
3 changes: 2 additions & 1 deletion arch/inst/I/bltu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ $schema: "inst_schema.json#"
kind: instruction
name: bltu
long_name: Branch if less than unsigned
type: B-Type
description: |
Branch to PC + imm if
the unsigned value in register rs1 is less than the unsigned value in register rs2.
Expand All @@ -12,7 +13,7 @@ description: |
definedBy: I
assembly: xs1, xs2, imm
encoding:
match: -----------------110-----1100011
match: "-----------------110-----1100011"
variables:
- name: imm
location: 31|7|30-25|11-8
Expand Down
3 changes: 2 additions & 1 deletion arch/inst/I/bne.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ $schema: "inst_schema.json#"
kind: instruction
name: bne
long_name: Branch if not equal
type: B-Type
description: |
Branch to PC + imm if
the value in register rs1 is not equal to the value in register rs2.
Expand All @@ -12,7 +13,7 @@ description: |
definedBy: I
assembly: xs1, xs2, imm
encoding:
match: -----------------001-----1100011
match: "-----------------001-----1100011"
variables:
- name: imm
location: 31|7|30-25|11-8
Expand Down
1 change: 1 addition & 0 deletions arch/inst/I/ebreak.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ $schema: "inst_schema.json#"
kind: instruction
name: ebreak
long_name: Breakpoint exception
type: Unknown
description: |
The EBREAK instruction is used by debuggers to cause control to be transferred back to
a debugging environment. Unless overridden by an external debug environment,
Expand Down
1 change: 1 addition & 0 deletions arch/inst/I/ecall.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ $schema: "inst_schema.json#"
kind: instruction
name: ecall
long_name: Environment call
type: Unknown
description: |
The ECALL instruction is used to make a request to the supporting execution environment.
When executed in U-mode, S-mode, or M-mode, it generates an environment-call-from-U-mode
Expand Down
3 changes: 2 additions & 1 deletion arch/inst/I/fence.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ $schema: "inst_schema.json#"
kind: instruction
name: fence
long_name: Memory ordering fence
type: Unknown
description: |
Orders memory operations.
Expand Down Expand Up @@ -123,7 +124,7 @@ description: |
definedBy: I
assembly: "TODO"
encoding:
match: -----------------000-----0001111
match: "-----------------000-----0001111"
variables:
- name: fm
location: 31-28
Expand Down
3 changes: 2 additions & 1 deletion arch/inst/I/jal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ $schema: "inst_schema.json#"
kind: instruction
name: jal
long_name: Jump and link
type: J-Type
description: |
Jump to a PC-relative offset and store the return
address in rd.
definedBy: I
assembly: xd, imm
encoding:
match: -------------------------1101111
match: "-------------------------1101111"
variables:
- name: imm
location: 31|19-12|20|30-21
Expand Down
3 changes: 2 additions & 1 deletion arch/inst/I/jalr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ $schema: "inst_schema.json#"
kind: instruction
name: jalr
long_name: Jump and link register
type: I-Type
description: |
Jump to an address formed by adding rs1
to a signed offset then clearing the least
Expand All @@ -12,7 +13,7 @@ description: |
definedBy: I
assembly: xd, imm(rs1)
encoding:
match: -----------------000-----1100111
match: "-----------------000-----1100111"
variables:
- name: imm
location: 31-20
Expand Down
3 changes: 2 additions & 1 deletion arch/inst/I/lb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ $schema: "inst_schema.json#"
kind: instruction
name: lb
long_name: Load byte
type: I-Type
description: |
Load 8 bits of data into register `rd` from an
address formed by adding `rs1` to a signed offset.
Sign extend the result.
definedBy: I
assembly: xd, imm(rs1)
encoding:
match: -----------------000-----0000011
match: "-----------------000-----0000011"
variables:
- name: imm
location: 31-20
Expand Down
3 changes: 2 additions & 1 deletion arch/inst/I/lbu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ $schema: "inst_schema.json#"
kind: instruction
name: lbu
long_name: Load byte unsigned
type: I-Type
description: |
Load 8 bits of data into register `rd` from an
address formed by adding `rs1` to a signed offset.
Zero extend the result.
definedBy: I
assembly: xd, imm(rs1)
encoding:
match: -----------------100-----0000011
match: "-----------------100-----0000011"
variables:
- name: imm
location: 31-20
Expand Down
3 changes: 2 additions & 1 deletion arch/inst/I/ld.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ $schema: "inst_schema.json#"
kind: instruction
name: ld
long_name: Load doubleword
type: I-Type
description: |
Load 64 bits of data into register `rd` from an
address formed by adding `rs1` to a signed offset.
definedBy: I
base: 64
assembly: xd, imm(rs1)
encoding:
match: -----------------011-----0000011
match: "-----------------011-----0000011"
variables:
- name: imm
location: 31-20
Expand Down
3 changes: 2 additions & 1 deletion arch/inst/I/lh.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ $schema: "inst_schema.json#"
kind: instruction
name: lh
long_name: Load halfword
type: I-Type
description: |
Load 16 bits of data into register `rd` from an
address formed by adding `rs1` to a signed offset.
Sign extend the result.
definedBy: I
assembly: xd, imm(rs1)
encoding:
match: -----------------001-----0000011
match: "-----------------001-----0000011"
variables:
- name: imm
location: 31-20
Expand Down
3 changes: 2 additions & 1 deletion arch/inst/I/lhu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ $schema: "inst_schema.json#"
kind: instruction
name: lhu
long_name: Load halfword unsigned
type: I-Type
description: |
Load 16 bits of data into register `rd` from an
address formed by adding `rs1` to a signed offset.
Zero extend the result.
definedBy: I
assembly: xd, imm(rs1)
encoding:
match: -----------------101-----0000011
match: "-----------------101-----0000011"
variables:
- name: imm
location: 31-20
Expand Down
3 changes: 2 additions & 1 deletion arch/inst/I/lui.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ $schema: "inst_schema.json#"
kind: instruction
name: lui
long_name: Load upper immediate
type: U-Type
description: Load the zero-extended imm into rd.
definedBy: I
assembly: xd, imm
encoding:
match: -------------------------0110111
match: "-------------------------0110111"
variables:
- name: imm
location: 31-12
Expand Down
3 changes: 2 additions & 1 deletion arch/inst/I/lw.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ $schema: "inst_schema.json#"
kind: instruction
name: lw
long_name: Load word
type: I-Type
description: |
Load 32 bits of data into register `rd` from an
address formed by adding `rs1` to a signed offset.
Sign extend the result.
definedBy: I
assembly: xd, imm(rs1)
encoding:
match: -----------------010-----0000011
match: "-----------------010-----0000011"
variables:
- name: imm
location: 31-20
Expand Down
3 changes: 2 additions & 1 deletion arch/inst/I/lwu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ $schema: "inst_schema.json#"
kind: instruction
name: lwu
long_name: Load word unsigned
type: I-Type
description: |
Load 64 bits of data into register `rd` from an
address formed by adding `rs1` to a signed offset.
Expand All @@ -12,7 +13,7 @@ definedBy: I
base: 64
assembly: xd, imm(rs1)
encoding:
match: -----------------110-----0000011
match: "-----------------110-----0000011"
variables:
- name: imm
location: 31-20
Expand Down
1 change: 1 addition & 0 deletions arch/inst/I/mret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ $schema: "inst_schema.json#"
kind: instruction
name: mret
long_name: Machine Exception Return
type: Unknown
description: |
Returns from an exception in M-mode.
assembly: ""
Expand Down
Loading

0 comments on commit 3a5c55a

Please sign in to comment.