Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
3f860c6
Draft riscv-opcodes generator
BrianAnakPintar Nov 29, 2024
4bfc6b6
Integrate Brian branch with UDB in ext/ folder. Merge the output of t…
AFOliveira Jan 30, 2025
9c0fadc
Add README.md with instruction on how to use this tool.
AFOliveira Jan 30, 2025
ca6ee60
Enhance error handling and support for non-default extensions, such a…
AFOliveira Jan 30, 2025
6fe6eb1
Switch directory folder and remove duplicated content
AFOliveira Feb 3, 2025
17a9e78
Add all riscv-opcodes functionality to the Makefile
AFOliveira Feb 3, 2025
603584a
Merge branch 'main' into BrianOpcodes
AFOliveira Feb 3, 2025
9aa1c85
Update riscv-opcodes submodule to latest master
AFOliveira Feb 3, 2025
6dbadd9
Update Rakefile to add gen:opcode_outputs. Usage ./do gen:opcode_out…
AFOliveira Feb 3, 2025
6d069c9
Add opcode generation to github actions; specifically, to the regress…
AFOliveira Feb 4, 2025
769b5b1
Add opcode generation to regress on Rakefile
AFOliveira Feb 4, 2025
1843f80
Add riscv-opcodes to GHA and cache it
AFOliveira Feb 4, 2025
714b95f
Merge branch 'main' into BrianOpcodes
AFOliveira Feb 14, 2025
5296964
Add fieldo.js created by Aliaksei Chapyzhenka, @drom
AFOliveira Feb 14, 2025
426ae24
Update script to use fieldo.js to find immediates
AFOliveira Feb 14, 2025
0cd3b11
Change fieldo.js to fieldo.json
AFOliveira Feb 24, 2025
990a726
Properly order .json output to compare with riscv-opcodes output
AFOliveira Feb 24, 2025
98f4c4d
Nicer error message for common error with unupdated subomdule
AFOliveira Feb 24, 2025
1506dcd
Change names on several functions and variables
AFOliveira Feb 25, 2025
bb4b765
Add kind: verification to all files && fix one small variable name
AFOliveira Feb 25, 2025
38b6893
Remove unnecessary or duplicate packages
AFOliveira Feb 25, 2025
1250f56
Add fix for branch instructions
AFOliveira Mar 7, 2025
b9e1bc6
Add sorter to Makefile so we can compare easily
AFOliveira Mar 7, 2025
3ced442
add Pytest to ensure we are matching with risc-v opcodes and test in …
AFOliveira Mar 7, 2025
c216ca2
Enhance parsing and sorting
AFOliveira Mar 7, 2025
19610a6
Add JAL corner case
AFOliveira Mar 12, 2025
6bc6ec4
Fix V extension instructions.
AFOliveira Mar 12, 2025
4a2085e
Enahnce pairs on immediates
AFOliveira Mar 12, 2025
e69e2ed
Final approach to script.
AFOliveira Mar 13, 2025
a9f13e0
Fix C extension rd/rs1.
AFOliveira Mar 13, 2025
6424ed4
Fix file mode on YAML files
AFOliveira Mar 13, 2025
c9e0703
Remove checked out outputs.
AFOliveira Mar 13, 2025
7213ad0
Bump RISC-V opcodes to latest head. I did a couple changes that impac…
AFOliveira Mar 19, 2025
a844ac0
Substitute immediate names from zimm to zimm5, due to update in risc…
AFOliveira Mar 19, 2025
72c7a7f
Enhance testing method to split differences. Added warnings instead o…
AFOliveira Mar 19, 2025
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
39 changes: 39 additions & 0 deletions .github/workflows/regress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,42 @@ jobs:
run: ./bin/build_container
- name: Generate extension PDF
run: ./do gen:profile[MockProfileRelease]
regress-gen-opcode:
runs-on: ubuntu-latest
env:
SINGULARITY: 1
steps:
- name: Clone Github Repo Action
uses: actions/checkout@v4
- name: Cache riscv-opcodes submodule
id: cache-opcodes
uses: actions/cache@v4
with:
path: ext/riscv-opcodes
key: ${{ runner.os }}-submodule-riscv-opcodes-${{ hashFiles('.gitmodules') }}
- if: steps.cache-opcodes.outputs.cache-hit != 'true'
name: Checkout riscv-opcodes submodule
run: |
git submodule init ext/riscv-opcodes
git submodule update ext/riscv-opcodes
- name: Setup apptainer
uses: eWaterCycle/[email protected]
- name: Get container from cache
id: cache-sif
uses: actions/cache@v4
with:
path: .singularity/image.sif
key: ${{ hashFiles('container.def', 'bin/.container-tag') }}
- name: Get gems and node files from cache
id: cache-bundle-npm
uses: actions/cache@v4
with:
path: |
.home/.gems
node_modules
key: ${{ hashFiles('Gemfile.lock') }}-${{ hashFiles('package-lock.json') }}
- if: ${{ steps.cache-sif.outputs.cache-hit != 'true' }}
name: Build container
run: ./bin/build_container
- name: Generate opcode outputs
run: ./do gen:opcode_outputs
Empty file modified .pre-commit-config.yaml
100644 → 100755
Empty file.
25 changes: 25 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ require "yard"
require "minitest/test_task"

require_relative $root / "lib" / "architecture"
$opcode_outputs = $root / "gen" / "opcodes_outputs"

directory "#{$root}/.stamps"

Expand Down Expand Up @@ -39,6 +40,28 @@ file "#{$root}/.stamps/dev_gems" => ["#{$root}/.stamps"] do |t|
FileUtils.touch t.name
end

namespace :gen do
desc "Generate opcode outputs, optionally specify YAML_DIR=path/to/yaml"
task :opcode_outputs do
yaml_dir = ENV['YAML_DIR'] || "#{$root}/arch/inst"
mkdir_p $opcode_outputs
sh "#{$root}/.home/.venv/bin/python3 #{$root}/backends/opcodes_maker/yaml_to_json.py #{yaml_dir} #{$opcode_outputs}"
sh "#{$root}/.home/.venv/bin/python3 #{$root}/backends/opcodes_maker/generator.py #{$opcode_outputs}/instr_dict.json -c -chisel -spinalhdl -sverilog -rust -go -latex"

# Move generated files to output dir
Dir.chdir("#{$root}") do
mv "encoding.out.h", "#{$opcode_outputs}/", force: true
mv "inst.chisel", "#{$opcode_outputs}/", force: true
mv "inst.spinalhdl", "#{$opcode_outputs}/", force: true
mv "inst.sverilog", "#{$opcode_outputs}/", force: true
mv "inst.rs", "#{$opcode_outputs}/", force: true
mv "inst.go", "#{$opcode_outputs}/", force: true
mv "instr-table.tex", "#{$opcode_outputs}/", force: true
mv "priv-instr-table.tex", "#{$opcode_outputs}/", force: true
end
end
end

namespace :gen do
desc "Generate documentation for the ruby tooling"
task tool_doc: "#{$root}/.stamps/dev_gems" do
Expand Down Expand Up @@ -319,6 +342,8 @@ namespace :test do

Rake::Task["gen:html"].invoke("generic_rv64")

Rake::Task["gen:opcode_outputs"].invoke

Rake::Task["#{$root}/gen/certificate_doc/pdf/MockCertificateModel.pdf"].invoke
Rake::Task["#{$root}/gen/profile_doc/pdf/MockProfileRelease.pdf"].invoke

Expand Down
3 changes: 2 additions & 1 deletion arch/inst/C/c.add.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ encoding:
variables:
- name: rs2
location: 6-2
- name: rd
- name: rd/rs1
location: 11-7
not: 0
access:
s: always
u: always
Expand Down
2 changes: 1 addition & 1 deletion arch/inst/C/c.addi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ encoding:
- name: imm
location: 12|6-2
not: 0
- name: rd
- name: rd/rs1
location: 11-7
not: 0
access:
Expand Down
2 changes: 1 addition & 1 deletion arch/inst/C/c.addiw.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ encoding:
variables:
- name: imm
location: 12|6-2
- name: rd
- name: rd/rs1
location: 11-7
not: 0
access:
Expand Down
2 changes: 1 addition & 1 deletion arch/inst/C/c.addw.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ encoding:
variables:
- name: rs2
location: 4-2
- name: rd
- name: rd/rs1
location: 9-7
access:
s: always
Expand Down
2 changes: 1 addition & 1 deletion arch/inst/C/c.and.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ encoding:
variables:
- name: rs2
location: 4-2
- name: rd
- name: rd/rs1
location: 9-7
access:
s: always
Expand Down
2 changes: 1 addition & 1 deletion arch/inst/C/c.andi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ encoding:
variables:
- name: imm
location: 12|6-2
- name: rd
- name: rd/rs1
location: 9-7
access:
s: always
Expand Down
2 changes: 1 addition & 1 deletion arch/inst/C/c.or.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ encoding:
variables:
- name: rs2
location: 4-2
- name: rd
- name: rd/rs1
location: 9-7
access:
s: always
Expand Down
2 changes: 1 addition & 1 deletion arch/inst/C/c.slli.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ encoding:
variables:
- name: shamt
location: 12|6-2
- name: rd
- name: rd/rs1
location: 11-7
not: 0
access:
Expand Down
2 changes: 1 addition & 1 deletion arch/inst/C/c.srai.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ encoding:
variables:
- name: shamt
location: 12|6-2
- name: rd
- name: rd/rs1
location: 9-7
access:
s: always
Expand Down
2 changes: 1 addition & 1 deletion arch/inst/C/c.srli.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ encoding:
variables:
- name: shamt
location: 12|6-2
- name: rd
- name: rd/rs1
location: 9-7
access:
s: always
Expand Down
2 changes: 1 addition & 1 deletion arch/inst/C/c.sub.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ encoding:
variables:
- name: rs2
location: 4-2
- name: rd
- name: rd/rs1
location: 9-7
access:
s: always
Expand Down
2 changes: 1 addition & 1 deletion arch/inst/C/c.subw.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ encoding:
variables:
- name: rs2
location: 4-2
- name: rd
- name: rd/rs1
location: 9-7
access:
s: always
Expand Down
2 changes: 1 addition & 1 deletion arch/inst/C/c.xor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ encoding:
variables:
- name: rs2
location: 4-2
- name: rd
- name: rd/rs1
location: 9-7
access:
s: always
Expand Down
4 changes: 2 additions & 2 deletions arch/inst/V/vsetivli.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ assembly: xd, imm
encoding:
match: 11---------------111-----1010111
variables:
- name: zimm10
- name: imm
location: 29-20
- name: uimm
- name: imm
location: 19-15
- name: rd
location: 11-7
Expand Down
2 changes: 1 addition & 1 deletion arch/inst/V/vsetvli.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ assembly: xs1, xd, imm
encoding:
match: 0----------------111-----1010111
variables:
- name: zimm11
- name: imm
location: 30-20
- name: rs1
location: 19-15
Expand Down
2 changes: 1 addition & 1 deletion arch/inst/Zicsr/csrrwi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ description: |
If `rd=x0`, then the instruction shall not read the CSR and shall not
cause any of the side effects that might occur on a CSR read.
definedBy: Zicsr
assembly: xd, zimm, csr
assembly: xd, imm, csr
encoding:
match: -----------------101-----1110011
variables:
Expand Down
2 changes: 1 addition & 1 deletion arch/inst/Zvbb/vwsll.vi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ encoding:
location: 25-25
- name: vs2
location: 24-20
- name: zimm5
- name: imm
location: 19-15
- name: vd
location: 11-7
Expand Down
2 changes: 1 addition & 1 deletion arch/inst/Zvkn/vaeskf1.vi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ encoding:
variables:
- name: vs2
location: 24-20
- name: zimm5
- name: imm
location: 19-15
- name: vd
location: 11-7
Expand Down
2 changes: 1 addition & 1 deletion arch/inst/Zvkn/vaeskf2.vi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ encoding:
variables:
- name: vs2
location: 24-20
- name: zimm5
- name: imm
location: 19-15
- name: vd
location: 11-7
Expand Down
2 changes: 1 addition & 1 deletion arch/inst/Zvks/vsm3c.vi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ encoding:
variables:
- name: vs2
location: 24-20
- name: zimm5
- name: imm
location: 19-15
- name: vd
location: 11-7
Expand Down
2 changes: 1 addition & 1 deletion arch/inst/Zvks/vsm4k.vi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ encoding:
variables:
- name: vs2
location: 24-20
- name: zimm5
- name: imm
location: 19-15
- name: vd
location: 11-7
Expand Down
35 changes: 35 additions & 0 deletions backends/instr_isa_manual/tasks.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# tasks.rake

# Define the manual generation directory constant
ISA_INDEX_GEN_DIR = $root / "gen" / "instr_isa_manual/index"

# Rule to create the instructions index page (all instructions with details)
rule %r{#{ISA_INDEX_GEN_DIR}/.*/antora/modules/insts/pages/instructions_index\.adoc} => [
__FILE__,
($root / "backends" / "instr_isa_manual" / "templates" / "instr_index.adoc.erb").to_s
] do |t|
cfg_arch = cfg_arch_for("_")
# Collect all instructions sorted by name
instructions = cfg_arch.instructions.sort_by(&:name)
template_path = $root / "backends" / "instr_isa_manual" / "templates" / "instr_index.adoc.erb"
erb = ERB.new(template_path.read, trim_mode: "-")
erb.filename = template_path.to_s

FileUtils.mkdir_p(File.dirname(t.name))
File.write(t.name, AsciidocUtils.resolve_links(cfg_arch.find_replace_links(erb.result(binding))))
end

# Rake task to generate the instructions index page.
namespace :gen do
desc "Generate the instructions index page (with index and full instruction details)"
task :instructions_index do
# Use provided version or default to "latest"
version = ENV["VERSION"] || "latest"
target = ISA_INDEX_GEN_DIR / version / "antora/modules/insts/pages/instructions_index.adoc"

# Invoke the rule to generate the file
Rake::Task[target.to_s].invoke

puts "SUCCESS: Instructions index generated at '#{target}'"
end
end
Loading
Loading