Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
43 changes: 43 additions & 0 deletions arch/csr/Smrnmi/mncause.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# yaml-language-server: $schema=../../../schemas/csr_schema.json

$schema: csr_schema.json#
kind: csr
name: mncause
long_name: Resumable NMI cause
address: 0x742
priv_mode: M
length: MXLEN
definedBy: Smrnmi
description: |
The mncause CSR holds the reason for the NMI.
If the reason is an interrupt, bit MXLEN-1 is set to 1, and the NMI cause is encoded in
the least-significant bits.
If the reason is an interrupt and NMI causes are not supported,
bit MXLEN-1 is set to 1, and zero is written to the least-significant bits.
If the reason is an exception within M-mode that results in a double trap as
specified in the Smdbltrp extension, bit MXLEN-1 is set to 0 and the least-significant
bits are set to the cause code corresponding to the exception that precipitated the
double trap.
fields:
INT:
location_rv32: 31
location_rv64: 63
description: |
Written by hardware when a resumable NMI is taken into M-mode.

When set, the last non-maskable exception was caused by an asynchronous Interrupt.

[when,"TRAP_ON_ILLEGAL_WLRL == true"]
If `mcause` is written with an undefined cause (combination of `mcause.INT` and `mcause.CODE`), an `Illegal Instruction` exception occurs.

[when,"TRAP_ON_ILLEGAL_WLRL == false"]
If `mcause` is written with an undefined cause (combination of `mcause.INT` and `mcause.CODE`), neither `mcause.INT` nor `mcause.CODE` are modified.
type: RW-H
reset_value: UNDEFINED_LEGAL
CODE:
location_rv32: 30-0
location_rv64: 62-0
description: |
TODO
type: RW-H
reset_value: UNDEFINED_LEGAL
2 changes: 1 addition & 1 deletion backends/common_templates/adoc/csr.adoc.erb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ This CSR has no fields. However, it must still exist (not cause an `Illegal Inst

<%- csr.fields.each do |field| -%>
[[<%=csr.name%>-<%=field.name%>-def]]
===== `<%= field.name %>`
=== `<%= field.name %>`

[example]
****
Expand Down
22 changes: 16 additions & 6 deletions backends/ext_pdf_doc/tasks.rake
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ rule %r{#{$root}/gen/ext_pdf_doc/.*/pdf/.*_extension\.pdf} => proc { |tname|
config_name = Pathname.new(tname).relative_path_from("#{$root}/gen/ext_pdf_doc").to_s.split("/")[0]
ext_name = Pathname.new(tname).basename(".pdf").to_s.split("_")[0..-2].join("_")
[
ENV["THEME"],
"#{$root}/ext/docs-resources/themes/riscv-pdf.yml",
"#{$root}/gen/ext_pdf_doc/#{config_name}/adoc/#{ext_name}_extension.adoc"
]
Expand All @@ -70,7 +71,7 @@ rule %r{#{$root}/gen/ext_pdf_doc/.*/pdf/.*_extension\.pdf} => proc { |tname|
"-v",
"-a toc",
"-a compress",
"-a pdf-theme=#{$root}/ext/docs-resources/themes/riscv-pdf.yml",
"-a pdf-theme=#{ENV['THEME']}",
"-a pdf-fontsdir=#{$root}/ext/docs-resources/fonts",
"-a imagesdir=#{$root}/ext/docs-resources/images",
"-r asciidoctor-diagram",
Expand Down Expand Up @@ -128,7 +129,7 @@ rule %r{#{$root}/gen/ext_pdf_doc/.*/adoc/.*_extension\.adoc} => proc { |tname|
} do |t|
config_name = Pathname.new(t.name).relative_path_from("#{$root}/gen/ext_pdf_doc").to_s.split("/")[0]

cfg_arch = cfg_arch_for("_")
cfg_arch = cfg_arch_for(config_name)

ext_name = Pathname.new(t.name).basename(".adoc").to_s.split("_")[0..-2].join("_")

Expand All @@ -143,11 +144,13 @@ rule %r{#{$root}/gen/ext_pdf_doc/.*/adoc/.*_extension\.adoc} => proc { |tname|
ext.versions
else
vs = ext.versions.select do |ext_ver|
version_strs.include?(ext_ver.version_spec.to_s)
version_strs.any? { |v| v != "latest" && ext_ver.version_spec == VersionSpec.new(v) }
end
vs << ext.max_version if version_strs.include?("latest")
vs.uniq
end
raise "No version matches #{ENV['VERSION']}" if versions.empty?

max_version = versions.max { |a, b| a.version <=> b.version }
FileUtils.mkdir_p File.dirname(t.name)
File.write t.name, AsciidocUtils.resolve_links(cfg_arch.find_replace_links(erb.result(binding)))
Expand All @@ -164,29 +167,36 @@ namespace :gen do
* EXT - The extension name
* CFG - The config name, required only when an overlay is required
* VERSION - A list of versions to include. May also be "all" or "latest".
* THEME - path to an AsciidocPDF theme file. If not set, will use default RVI theme.

Examples:

./do gen:ext_pdf EXT=Xqci CFG=qc_iu VERSION=latest
./do gen:ext_pdf EXT=Xqci CFG=qc_iu VERSION=latest THEME=cfgs/qc_iu/qc_theme.yaml
./do gen:ext_pdf EXT=B VERSION=all
./do gen:ext_pdf EXT=B VERSION=1.0.0
./do gen:ext_pdf EXT=B VERSION=1.0.0,1.1.0

DESC
task :ext_pdf, [:extension] do |_t, args|
task :ext_pdf do
raise ArgumentError, "Missing required argument EXT" if ENV["EXT"].nil?

extension = ENV["EXT"]
cfg = ENV["CFG"]
version = ENV["VERSION"]
ENV["THEME"] =
if ENV["THEME"].nil?
"#{$root}/ext/docs-resources/themes/riscv-pdf.yml"
else
Pathname.new(ENV["THEME"]).realpath.to_s
end

versions = version.split(",")
raise ArgumentError, "Nothing else should be specified with 'all'" if versions.include?("all") && versions.size > 1

if cfg.nil?
Rake::Task[$root / "gen" / "ext_pdf_doc" / "_" / "pdf" / "#{extension}_extension.pdf"].invoke
else
Rake::Task[$root / "gen" / "ext_pdf_doc" / cfg / "pdf" / "#{extension}_extension.pdf"].invoke(args)
Rake::Task[$root / "gen" / "ext_pdf_doc" / cfg / "pdf" / "#{extension}_extension.pdf"].invoke
end
end

Expand Down
58 changes: 58 additions & 0 deletions cfgs/qc_iu/arch_overlay/csr/Xqci/gen_mcliciX.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@

require 'erb'

pend_template = <<~YAML
# yaml-language-server: $schema=../../../../../schemas/csr_schema.json

qc_mclicip<%= num %>:
long_name: IRQ Pending <%= num %>
address: 0x<%= (0x7f0 + num).to_s(16) %>
length: 32
priv_mode: M
base: 32
definedBy: Xqci
description: |
Pending bits for IRQs <%= num*32 %>-<%= (num + 1)*32 - 1 %>
fields:
<%- 32.times do |i| -%>
IRQ<%= num*32 + i %>:
type: RW
reset_value: 0
location: <%= i %>
description: IRQ<%= num*32 + i %> pending
<%- end -%>
YAML

en_template = <<~YAML
# yaml-language-server: $schema=../../../../../schemas/csr_schema.json

qc_mclicie<%= num %>:
long_name: IRQ Enable <%= num %>
address: 0x<%= (0x7f0 + num).to_s(16) %>
length: 32
base: 32
priv_mode: M
definedBy: Xqci
description: |
Enable bits for IRQs <%= num*32 %>-<%= (num + 1)*32 - 1 %>
fields:
<%- 32.times do |i| -%>
IRQ<%= num*32 + i %>:
type: RW
reset_value: 0
location: <%= i %>
description: IRQ<%= num*32 + i %> enabled
<%- end -%>
YAML

root = File.dirname(__FILE__)

erb = ERB.new(pend_template, trim_mode: '-')
8.times do |num|
File.write("#{root}/qc_mclicip#{num}.yaml", erb.result(binding))
end

erb = ERB.new(en_template, trim_mode: '-')
8.times do |num|
File.write("#{root}/qc_mclicie#{num}.yaml", erb.result(binding))
end
78 changes: 78 additions & 0 deletions cfgs/qc_iu/arch_overlay/csr/Xqci/qc_flags.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
$schema: csr_schema.json#
kind: csr
name: qc_flags
long_name: Flags register (Condition Code Register + co-processor flags)
address: 0x803
priv_mode: M
base: 32
length: 32
description: |
Condition Code Register with condition codes, plus a co-processor flags (_e.g._, to support floating point)
definedBy: Xqci
fields:
CPFLAGS:
location: 31-16
description: |
Co-Processor FLAGS: comprocessor-dependednt context (used to support floating point, for example)
type: RW-H
reset_value: 0
LTU:
location: 9
description: |
Less Then (Unsigned) flag
type: RW-H
reset_value: 0
GEU:
location: 8
description: |
Greater or Equal (Unsigned) flag
type: RW-H
reset_value: 0
LEU:
location: 7
description: |
Less or Equal (Unsigned) flag
type: RW-H
reset_value: 0
GTU:
location: 6
description: |
Greater Then (Unsigned) flag
type: RW-H
reset_value: 0
LT:
location: 5
description: |
Less Then flag
type: RW-H
reset_value: 0
GE:
location: 4
description: |
Greater or Equal flag
type: RW-H
reset_value: 0
LE:
location: 3
description: |
Less or Equal flag
type: RW-H
reset_value: 0
GT:
location: 2
description: |
Greater Than flag
type: RW-H
reset_value: 0
NE:
location: 1
description: |
Not Equal flag
type: RW-H
reset_value: 0
EQ:
location: 0
description: |
EQual flag
type: RW-H
reset_value: 0
Loading