Skip to content

Commit 52eb36b

Browse files
authored
Merge pull request #355 from riscv-software-src/add_xqci
Add Xqci upstream
2 parents 55e2cf1 + 5107c8c commit 52eb36b

File tree

182 files changed

+9452
-10
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

182 files changed

+9452
-10
lines changed

arch/csr/Smrnmi/mncause.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# yaml-language-server: $schema=../../../schemas/csr_schema.json
2+
3+
$schema: csr_schema.json#
4+
kind: csr
5+
name: mncause
6+
long_name: Resumable NMI cause
7+
address: 0x742
8+
priv_mode: M
9+
length: MXLEN
10+
definedBy: Smrnmi
11+
description: |
12+
The mncause CSR holds the reason for the NMI.
13+
If the reason is an interrupt, bit MXLEN-1 is set to 1, and the NMI cause is encoded in
14+
the least-significant bits.
15+
If the reason is an interrupt and NMI causes are not supported,
16+
bit MXLEN-1 is set to 1, and zero is written to the least-significant bits.
17+
If the reason is an exception within M-mode that results in a double trap as
18+
specified in the Smdbltrp extension, bit MXLEN-1 is set to 0 and the least-significant
19+
bits are set to the cause code corresponding to the exception that precipitated the
20+
double trap.
21+
fields:
22+
INT:
23+
location_rv32: 31
24+
location_rv64: 63
25+
description: |
26+
Written by hardware when a resumable NMI is taken into M-mode.
27+
28+
When set, the last non-maskable exception was caused by an asynchronous Interrupt.
29+
30+
[when,"TRAP_ON_ILLEGAL_WLRL == true"]
31+
If `mcause` is written with an undefined cause (combination of `mcause.INT` and `mcause.CODE`), an `Illegal Instruction` exception occurs.
32+
33+
[when,"TRAP_ON_ILLEGAL_WLRL == false"]
34+
If `mcause` is written with an undefined cause (combination of `mcause.INT` and `mcause.CODE`), neither `mcause.INT` nor `mcause.CODE` are modified.
35+
type: RW-H
36+
reset_value: UNDEFINED_LEGAL
37+
CODE:
38+
location_rv32: 30-0
39+
location_rv64: 62-0
40+
description: |
41+
TODO
42+
type: RW-H
43+
reset_value: UNDEFINED_LEGAL

backends/common_templates/adoc/csr.adoc.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ This CSR has no fields. However, it must still exist (not cause an `Illegal Inst
6767

6868
<%- csr.fields.each do |field| -%>
6969
[[<%=csr.name%>-<%=field.name%>-def]]
70-
===== `<%= field.name %>`
70+
=== `<%= field.name %>`
7171

7272
[example]
7373
****

backends/ext_pdf_doc/tasks.rake

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ rule %r{#{$root}/gen/ext_pdf_doc/.*/pdf/.*_extension\.pdf} => proc { |tname|
5555
config_name = Pathname.new(tname).relative_path_from("#{$root}/gen/ext_pdf_doc").to_s.split("/")[0]
5656
ext_name = Pathname.new(tname).basename(".pdf").to_s.split("_")[0..-2].join("_")
5757
[
58+
ENV["THEME"],
5859
"#{$root}/ext/docs-resources/themes/riscv-pdf.yml",
5960
"#{$root}/gen/ext_pdf_doc/#{config_name}/adoc/#{ext_name}_extension.adoc"
6061
]
@@ -70,7 +71,7 @@ rule %r{#{$root}/gen/ext_pdf_doc/.*/pdf/.*_extension\.pdf} => proc { |tname|
7071
"-v",
7172
"-a toc",
7273
"-a compress",
73-
"-a pdf-theme=#{$root}/ext/docs-resources/themes/riscv-pdf.yml",
74+
"-a pdf-theme=#{ENV['THEME']}",
7475
"-a pdf-fontsdir=#{$root}/ext/docs-resources/fonts",
7576
"-a imagesdir=#{$root}/ext/docs-resources/images",
7677
"-r asciidoctor-diagram",
@@ -128,7 +129,7 @@ rule %r{#{$root}/gen/ext_pdf_doc/.*/adoc/.*_extension\.adoc} => proc { |tname|
128129
} do |t|
129130
config_name = Pathname.new(t.name).relative_path_from("#{$root}/gen/ext_pdf_doc").to_s.split("/")[0]
130131

131-
cfg_arch = cfg_arch_for("_")
132+
cfg_arch = cfg_arch_for(config_name)
132133

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

@@ -143,11 +144,13 @@ rule %r{#{$root}/gen/ext_pdf_doc/.*/adoc/.*_extension\.adoc} => proc { |tname|
143144
ext.versions
144145
else
145146
vs = ext.versions.select do |ext_ver|
146-
version_strs.include?(ext_ver.version_spec.to_s)
147+
version_strs.any? { |v| v != "latest" && ext_ver.version_spec == VersionSpec.new(v) }
147148
end
148149
vs << ext.max_version if version_strs.include?("latest")
149150
vs.uniq
150151
end
152+
raise "No version matches #{ENV['VERSION']}" if versions.empty?
153+
151154
max_version = versions.max { |a, b| a.version <=> b.version }
152155
FileUtils.mkdir_p File.dirname(t.name)
153156
File.write t.name, AsciidocUtils.resolve_links(cfg_arch.find_replace_links(erb.result(binding)))
@@ -164,29 +167,36 @@ namespace :gen do
164167
* EXT - The extension name
165168
* CFG - The config name, required only when an overlay is required
166169
* VERSION - A list of versions to include. May also be "all" or "latest".
170+
* THEME - path to an AsciidocPDF theme file. If not set, will use default RVI theme.
167171
168172
Examples:
169173
170-
./do gen:ext_pdf EXT=Xqci CFG=qc_iu VERSION=latest
174+
./do gen:ext_pdf EXT=Xqci CFG=qc_iu VERSION=latest THEME=cfgs/qc_iu/qc_theme.yaml
171175
./do gen:ext_pdf EXT=B VERSION=all
172176
./do gen:ext_pdf EXT=B VERSION=1.0.0
173177
./do gen:ext_pdf EXT=B VERSION=1.0.0,1.1.0
174178
175179
DESC
176-
task :ext_pdf, [:extension] do |_t, args|
180+
task :ext_pdf do
177181
raise ArgumentError, "Missing required argument EXT" if ENV["EXT"].nil?
178182

179183
extension = ENV["EXT"]
180184
cfg = ENV["CFG"]
181185
version = ENV["VERSION"]
186+
ENV["THEME"] =
187+
if ENV["THEME"].nil?
188+
"#{$root}/ext/docs-resources/themes/riscv-pdf.yml"
189+
else
190+
Pathname.new(ENV["THEME"]).realpath.to_s
191+
end
182192

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

186196
if cfg.nil?
187197
Rake::Task[$root / "gen" / "ext_pdf_doc" / "_" / "pdf" / "#{extension}_extension.pdf"].invoke
188198
else
189-
Rake::Task[$root / "gen" / "ext_pdf_doc" / cfg / "pdf" / "#{extension}_extension.pdf"].invoke(args)
199+
Rake::Task[$root / "gen" / "ext_pdf_doc" / cfg / "pdf" / "#{extension}_extension.pdf"].invoke
190200
end
191201
end
192202

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
2+
require 'erb'
3+
4+
pend_template = <<~YAML
5+
# yaml-language-server: $schema=../../../../../schemas/csr_schema.json
6+
7+
qc_mclicip<%= num %>:
8+
long_name: IRQ Pending <%= num %>
9+
address: 0x<%= (0x7f0 + num).to_s(16) %>
10+
length: 32
11+
priv_mode: M
12+
base: 32
13+
definedBy: Xqci
14+
description: |
15+
Pending bits for IRQs <%= num*32 %>-<%= (num + 1)*32 - 1 %>
16+
fields:
17+
<%- 32.times do |i| -%>
18+
IRQ<%= num*32 + i %>:
19+
type: RW
20+
reset_value: 0
21+
location: <%= i %>
22+
description: IRQ<%= num*32 + i %> pending
23+
<%- end -%>
24+
YAML
25+
26+
en_template = <<~YAML
27+
# yaml-language-server: $schema=../../../../../schemas/csr_schema.json
28+
29+
qc_mclicie<%= num %>:
30+
long_name: IRQ Enable <%= num %>
31+
address: 0x<%= (0x7f0 + num).to_s(16) %>
32+
length: 32
33+
base: 32
34+
priv_mode: M
35+
definedBy: Xqci
36+
description: |
37+
Enable bits for IRQs <%= num*32 %>-<%= (num + 1)*32 - 1 %>
38+
fields:
39+
<%- 32.times do |i| -%>
40+
IRQ<%= num*32 + i %>:
41+
type: RW
42+
reset_value: 0
43+
location: <%= i %>
44+
description: IRQ<%= num*32 + i %> enabled
45+
<%- end -%>
46+
YAML
47+
48+
root = File.dirname(__FILE__)
49+
50+
erb = ERB.new(pend_template, trim_mode: '-')
51+
8.times do |num|
52+
File.write("#{root}/qc_mclicip#{num}.yaml", erb.result(binding))
53+
end
54+
55+
erb = ERB.new(en_template, trim_mode: '-')
56+
8.times do |num|
57+
File.write("#{root}/qc_mclicie#{num}.yaml", erb.result(binding))
58+
end
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
$schema: csr_schema.json#
2+
kind: csr
3+
name: qc_flags
4+
long_name: Flags register (Condition Code Register + co-processor flags)
5+
address: 0x803
6+
priv_mode: M
7+
base: 32
8+
length: 32
9+
description: |
10+
Condition Code Register with condition codes, plus a co-processor flags (_e.g._, to support floating point)
11+
definedBy: Xqci
12+
fields:
13+
CPFLAGS:
14+
location: 31-16
15+
description: |
16+
Co-Processor FLAGS: comprocessor-dependednt context (used to support floating point, for example)
17+
type: RW-H
18+
reset_value: 0
19+
LTU:
20+
location: 9
21+
description: |
22+
Less Then (Unsigned) flag
23+
type: RW-H
24+
reset_value: 0
25+
GEU:
26+
location: 8
27+
description: |
28+
Greater or Equal (Unsigned) flag
29+
type: RW-H
30+
reset_value: 0
31+
LEU:
32+
location: 7
33+
description: |
34+
Less or Equal (Unsigned) flag
35+
type: RW-H
36+
reset_value: 0
37+
GTU:
38+
location: 6
39+
description: |
40+
Greater Then (Unsigned) flag
41+
type: RW-H
42+
reset_value: 0
43+
LT:
44+
location: 5
45+
description: |
46+
Less Then flag
47+
type: RW-H
48+
reset_value: 0
49+
GE:
50+
location: 4
51+
description: |
52+
Greater or Equal flag
53+
type: RW-H
54+
reset_value: 0
55+
LE:
56+
location: 3
57+
description: |
58+
Less or Equal flag
59+
type: RW-H
60+
reset_value: 0
61+
GT:
62+
location: 2
63+
description: |
64+
Greater Than flag
65+
type: RW-H
66+
reset_value: 0
67+
NE:
68+
location: 1
69+
description: |
70+
Not Equal flag
71+
type: RW-H
72+
reset_value: 0
73+
EQ:
74+
location: 0
75+
description: |
76+
EQual flag
77+
type: RW-H
78+
reset_value: 0

0 commit comments

Comments
 (0)