Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
bb6a2f8
test(idl): test:idl task takes config from enviornment
dhower-qc Apr 4, 2025
f8a7b59
idl: add indirect csr access; do direct csr access with functions
dhower-qc Apr 4, 2025
54b5f3a
schema(csr): add writeable field
dhower-qc Apr 4, 2025
bffee3f
fix(ruby): corrects adoc generation for CSR read expressions
dhower-qc Apr 4, 2025
60addff
test(idl): test:idl task takes config from enviornment
dhower-qc Apr 4, 2025
716b515
idl: add indirect csr access; do direct csr access with functions
dhower-qc Apr 4, 2025
fe3dc19
schema(csr): add writeable field
dhower-qc Apr 4, 2025
7222654
fix(ruby): corrects adoc generation for CSR read expressions
dhower-qc Apr 4, 2025
ca1cdd5
correct(csr): Fixes the layout file for hpmcounterXh
dhower-qc Apr 8, 2025
9d10541
Merge remote-tracking branch 'origin/indirect-csr' into indirect-csr
dhower-qc Apr 8, 2025
4095177
fix: buggy last commit
dhower-qc Apr 8, 2025
f13a222
refactor: small comment cleanup
dhower-qc Apr 8, 2025
a2a49a9
fix: make csr address at most MXLEN bits
dhower-qc Apr 15, 2025
e98d4b2
Merge remote-tracking branch 'origin/main' into indirect-csr
dhower-qc Apr 15, 2025
6340f6a
fix: XLEN -> MXLEN in builtin_functions
dhower-qc Apr 15, 2025
b9e1407
feat: add window slot for indirect csrs
dhower-qc Apr 29, 2025
fc4cc5e
Merge remote-tracking branch 'origin/main' into indirect-csr
dhower-qc Apr 29, 2025
9959661
fix: add indirect_address/slot to Csr model
dhower-qc Apr 29, 2025
03e86af
Merge branch 'main' into indirect-csr
dhower-qc Apr 30, 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
20 changes: 11 additions & 9 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -238,18 +238,15 @@ namespace :test do
puts "All files validate against their schema"
end

task idl: ["#{$root}/.stamps/resolve-rv32.stamp", "#{$root}/.stamps/resolve-rv64.stamp"] do
print "Parsing IDL code for RV32..."
cfg_arch32 = cfg_arch_for("rv32")
puts "done"

cfg_arch32.type_check
task :idl do
cfg = ENV["CFG"]
raise "Missing CFG enviornment variable" if cfg.nil?

print "Parsing IDL code for RV64..."
cfg_arch64 = cfg_arch_for("rv64")
print "Parsing IDL code for #{cfg}..."
cfg_arch = cfg_arch_for(cfg)
puts "done"

cfg_arch64.type_check
cfg_arch.type_check

puts "All IDL passed type checking"
end
Expand Down Expand Up @@ -410,6 +407,11 @@ namespace :test do
Rake::Task["test:idl_compiler"].invoke
Rake::Task["test:lib"].invoke
Rake::Task["test:schema"].invoke
ENV["CFG"] = "rv32"
Rake::Task["test:idl"].invoke
ENV["CFG"] = "rv64"
Rake::Task["test:idl"].invoke
ENV["CFG"] = "qc_iu"
Rake::Task["test:idl"].invoke
Rake::Task["test:inst_encodings"].invoke
end
Expand Down
1 change: 0 additions & 1 deletion arch/csr/Zihpm/hpmcounter10h.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ kind: csr
name: hpmcounter10h
long_name: User-mode Hardware Performance Counter 7, high half
address: 0xC8A
base: 32
description: |
Alias for M-mode CSR `mhpmcounter10h`.

Expand Down
1 change: 0 additions & 1 deletion arch/csr/Zihpm/hpmcounter11h.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ kind: csr
name: hpmcounter11h
long_name: User-mode Hardware Performance Counter 8, high half
address: 0xC8B
base: 32
description: |
Alias for M-mode CSR `mhpmcounter11h`.

Expand Down
1 change: 0 additions & 1 deletion arch/csr/Zihpm/hpmcounter12h.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ kind: csr
name: hpmcounter12h
long_name: User-mode Hardware Performance Counter 9, high half
address: 0xC8C
base: 32
description: |
Alias for M-mode CSR `mhpmcounter12h`.

Expand Down
1 change: 0 additions & 1 deletion arch/csr/Zihpm/hpmcounter13h.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ kind: csr
name: hpmcounter13h
long_name: User-mode Hardware Performance Counter 10, high half
address: 0xC8D
base: 32
description: |
Alias for M-mode CSR `mhpmcounter13h`.

Expand Down
1 change: 0 additions & 1 deletion arch/csr/Zihpm/hpmcounter14h.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ kind: csr
name: hpmcounter14h
long_name: User-mode Hardware Performance Counter 11, high half
address: 0xC8E
base: 32
description: |
Alias for M-mode CSR `mhpmcounter14h`.

Expand Down
1 change: 0 additions & 1 deletion arch/csr/Zihpm/hpmcounter15h.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ kind: csr
name: hpmcounter15h
long_name: User-mode Hardware Performance Counter 12, high half
address: 0xC8F
base: 32
description: |
Alias for M-mode CSR `mhpmcounter15h`.

Expand Down
1 change: 0 additions & 1 deletion arch/csr/Zihpm/hpmcounter16h.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ kind: csr
name: hpmcounter16h
long_name: User-mode Hardware Performance Counter 13, high half
address: 0xC90
base: 32
description: |
Alias for M-mode CSR `mhpmcounter16h`.

Expand Down
1 change: 0 additions & 1 deletion arch/csr/Zihpm/hpmcounter17h.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ kind: csr
name: hpmcounter17h
long_name: User-mode Hardware Performance Counter 14, high half
address: 0xC91
base: 32
description: |
Alias for M-mode CSR `mhpmcounter17h`.

Expand Down
1 change: 0 additions & 1 deletion arch/csr/Zihpm/hpmcounter18h.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ kind: csr
name: hpmcounter18h
long_name: User-mode Hardware Performance Counter 15, high half
address: 0xC92
base: 32
description: |
Alias for M-mode CSR `mhpmcounter18h`.

Expand Down
1 change: 0 additions & 1 deletion arch/csr/Zihpm/hpmcounter19h.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ kind: csr
name: hpmcounter19h
long_name: User-mode Hardware Performance Counter 16, high half
address: 0xC93
base: 32
description: |
Alias for M-mode CSR `mhpmcounter19h`.

Expand Down
1 change: 0 additions & 1 deletion arch/csr/Zihpm/hpmcounter20h.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ kind: csr
name: hpmcounter20h
long_name: User-mode Hardware Performance Counter 17, high half
address: 0xC94
base: 32
description: |
Alias for M-mode CSR `mhpmcounter20h`.

Expand Down
1 change: 0 additions & 1 deletion arch/csr/Zihpm/hpmcounter21h.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ kind: csr
name: hpmcounter21h
long_name: User-mode Hardware Performance Counter 18, high half
address: 0xC95
base: 32
description: |
Alias for M-mode CSR `mhpmcounter21h`.

Expand Down
1 change: 0 additions & 1 deletion arch/csr/Zihpm/hpmcounter22h.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ kind: csr
name: hpmcounter22h
long_name: User-mode Hardware Performance Counter 19, high half
address: 0xC96
base: 32
description: |
Alias for M-mode CSR `mhpmcounter22h`.

Expand Down
1 change: 0 additions & 1 deletion arch/csr/Zihpm/hpmcounter23h.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ kind: csr
name: hpmcounter23h
long_name: User-mode Hardware Performance Counter 20, high half
address: 0xC97
base: 32
description: |
Alias for M-mode CSR `mhpmcounter23h`.

Expand Down
1 change: 0 additions & 1 deletion arch/csr/Zihpm/hpmcounter24h.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ kind: csr
name: hpmcounter24h
long_name: User-mode Hardware Performance Counter 21, high half
address: 0xC98
base: 32
description: |
Alias for M-mode CSR `mhpmcounter24h`.

Expand Down
1 change: 0 additions & 1 deletion arch/csr/Zihpm/hpmcounter25h.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ kind: csr
name: hpmcounter25h
long_name: User-mode Hardware Performance Counter 22, high half
address: 0xC99
base: 32
description: |
Alias for M-mode CSR `mhpmcounter25h`.

Expand Down
1 change: 0 additions & 1 deletion arch/csr/Zihpm/hpmcounter26h.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ kind: csr
name: hpmcounter26h
long_name: User-mode Hardware Performance Counter 23, high half
address: 0xC9A
base: 32
description: |
Alias for M-mode CSR `mhpmcounter26h`.

Expand Down
1 change: 0 additions & 1 deletion arch/csr/Zihpm/hpmcounter27h.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ kind: csr
name: hpmcounter27h
long_name: User-mode Hardware Performance Counter 24, high half
address: 0xC9B
base: 32
description: |
Alias for M-mode CSR `mhpmcounter27h`.

Expand Down
1 change: 0 additions & 1 deletion arch/csr/Zihpm/hpmcounter28h.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ kind: csr
name: hpmcounter28h
long_name: User-mode Hardware Performance Counter 25, high half
address: 0xC9C
base: 32
description: |
Alias for M-mode CSR `mhpmcounter28h`.

Expand Down
1 change: 0 additions & 1 deletion arch/csr/Zihpm/hpmcounter29h.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ kind: csr
name: hpmcounter29h
long_name: User-mode Hardware Performance Counter 26, high half
address: 0xC9D
base: 32
description: |
Alias for M-mode CSR `mhpmcounter29h`.

Expand Down
1 change: 0 additions & 1 deletion arch/csr/Zihpm/hpmcounter30h.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ kind: csr
name: hpmcounter30h
long_name: User-mode Hardware Performance Counter 27, high half
address: 0xC9E
base: 32
description: |
Alias for M-mode CSR `mhpmcounter30h`.

Expand Down
1 change: 0 additions & 1 deletion arch/csr/Zihpm/hpmcounter31h.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ kind: csr
name: hpmcounter31h
long_name: User-mode Hardware Performance Counter 28, high half
address: 0xC9F
base: 32
description: |
Alias for M-mode CSR `mhpmcounter31h`.

Expand Down
1 change: 0 additions & 1 deletion arch/csr/Zihpm/hpmcounter3h.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ kind: csr
name: hpmcounter3h
long_name: User-mode Hardware Performance Counter 0, high half
address: 0xC83
base: 32
description: |
Alias for M-mode CSR `mhpmcounter3h`.

Expand Down
1 change: 0 additions & 1 deletion arch/csr/Zihpm/hpmcounter4h.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ kind: csr
name: hpmcounter4h
long_name: User-mode Hardware Performance Counter 1, high half
address: 0xC84
base: 32
description: |
Alias for M-mode CSR `mhpmcounter4h`.

Expand Down
1 change: 0 additions & 1 deletion arch/csr/Zihpm/hpmcounter5h.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ kind: csr
name: hpmcounter5h
long_name: User-mode Hardware Performance Counter 2, high half
address: 0xC85
base: 32
description: |
Alias for M-mode CSR `mhpmcounter5h`.

Expand Down
1 change: 0 additions & 1 deletion arch/csr/Zihpm/hpmcounter6h.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ kind: csr
name: hpmcounter6h
long_name: User-mode Hardware Performance Counter 3, high half
address: 0xC86
base: 32
description: |
Alias for M-mode CSR `mhpmcounter6h`.

Expand Down
1 change: 0 additions & 1 deletion arch/csr/Zihpm/hpmcounter7h.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ kind: csr
name: hpmcounter7h
long_name: User-mode Hardware Performance Counter 4, high half
address: 0xC87
base: 32
description: |
Alias for M-mode CSR `mhpmcounter7h`.

Expand Down
1 change: 0 additions & 1 deletion arch/csr/Zihpm/hpmcounter8h.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ kind: csr
name: hpmcounter8h
long_name: User-mode Hardware Performance Counter 5, high half
address: 0xC88
base: 32
description: |
Alias for M-mode CSR `mhpmcounter8h`.

Expand Down
1 change: 0 additions & 1 deletion arch/csr/Zihpm/hpmcounter9h.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ kind: csr
name: hpmcounter9h
long_name: User-mode Hardware Performance Counter 6, high half
address: 0xC89
base: 32
description: |
Alias for M-mode CSR `mhpmcounter9h`.

Expand Down
16 changes: 13 additions & 3 deletions arch/inst/Zicsr/csrrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,26 @@ access:
vu: always
data_independent_timing: false
operation(): |
Csr csr_handle = direct_csr_lookup(csr);

Boolean will_write = xs1 != 0;
check_csr(csr, will_write, $encoding);

XReg initial_csr_value = CSR[csr].sw_read();
# permission checks
if (csr_handle.valid == false) {
unimplemented_csr($encoding);
} else if (!compatible_mode?(csr_handle.mode, mode())) {
raise (ExceptionCode::IllegalInstruction, mode(), $encoding);
} else if (will_write && csr_handle.writable == false) {
raise (ExceptionCode::IllegalInstruction, mode(), $encoding);
}

XReg initial_csr_value = csr_sw_read(csr_handle);

if (xs1 != 0) {
# clear bits using the mask
# performing any WARL transformations first
XReg mask = X[xs1];
CSR[csr].sw_write(initial_csr_value & ~mask);
csr_sw_write(csr_handle, initial_csr_value & ~mask);
}

X[xd] = initial_csr_value;
18 changes: 14 additions & 4 deletions arch/inst/Zicsr/csrrci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,25 @@ access:
data_independent_timing: false
operation(): |
Boolean will_write = uimm != 0;
check_csr(csr, will_write, $encoding);

XReg initial_csr_value = CSR[csr].sw_read();
Csr csr_handle = direct_csr_lookup(csr);

if (uimm != 0) {
# permission checks
if (csr_handle.valid == false) {
unimplemented_csr($encoding);
} else if (!compatible_mode?(csr_handle.mode, mode())) {
raise (ExceptionCode::IllegalInstruction, mode(), $encoding);
} else if (will_write && csr_handle.writable == false) {
raise (ExceptionCode::IllegalInstruction, mode(), $encoding);
}

XReg initial_csr_value = csr_sw_read(csr_handle);

if (will_write) {
# set bits using the mask
# performing any WARL transformations first
XReg mask = uimm;
CSR[csr].sw_write(initial_csr_value & ~mask);
csr_sw_write(csr_handle, initial_csr_value & ~mask);
}

X[xd] = initial_csr_value;
16 changes: 13 additions & 3 deletions arch/inst/Zicsr/csrrs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,25 @@ access:
vu: always
operation(): |
Boolean will_write = rs1 != 0;
check_csr(csr, will_write, $encoding);

XReg initial_csr_value = CSR[csr].sw_read();
Csr csr_handle = direct_csr_lookup(csr);

# permission checks
if (csr_handle.valid == false) {
unimplemented_csr($encoding);
} else if (!compatible_mode?(csr_handle.mode, mode())) {
raise (ExceptionCode::IllegalInstruction, mode(), $encoding);
} else if (will_write && csr_handle.writable == false) {
raise (ExceptionCode::IllegalInstruction, mode(), $encoding);
}

XReg initial_csr_value = csr_sw_read(csr_handle);

if (will_write) {
# set bits using the mask
# performing any WARL transformations first
XReg mask = X[rs1];
CSR[csr].sw_write(initial_csr_value | mask);
csr_sw_write(csr_handle, initial_csr_value | mask);
}

X[rd] = initial_csr_value;
Expand Down
16 changes: 13 additions & 3 deletions arch/inst/Zicsr/csrrsi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,25 @@ access:
data_independent_timing: false
operation(): |
Boolean will_write = uimm != 0;
check_csr(csr, will_write, $encoding);

XReg initial_csr_value = CSR[csr].sw_read();
Csr csr_handle = direct_csr_lookup(csr);

# permission checks
if (csr_handle.valid == false) {
unimplemented_csr($encoding);
} else if (!compatible_mode?(csr_handle.mode, mode())) {
raise (ExceptionCode::IllegalInstruction, mode(), $encoding);
} else if (will_write && csr_handle.writable == false) {
raise (ExceptionCode::IllegalInstruction, mode(), $encoding);
}

XReg initial_csr_value = csr_sw_read(csr_handle);

if (will_write) {
# set bits using the mask
# performing any WARL transformations first
XReg mask = uimm;
CSR[csr].sw_write(initial_csr_value | mask);
csr_sw_write(csr_handle, initial_csr_value | mask);
}

X[xd] = initial_csr_value;
Loading