Skip to content

Commit

Permalink
Merge pull request #7 from quic/xqci
Browse files Browse the repository at this point in the history
Xqci v0.4
  • Loading branch information
dhower-qc authored Nov 21, 2024
2 parents cd83543 + b5925d2 commit a0829f4
Show file tree
Hide file tree
Showing 172 changed files with 1,053 additions and 163 deletions.
17 changes: 17 additions & 0 deletions arch/ext/Zca.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# yaml-language-server: $schema=../../schemas/ext_schema.json

Zca:
long_name: Common compressed instructions
description: |
TODO
type: unprivileged
company:
name: RISC-V International
url: https://riscv.org
versions:
- version: "1.0.0"
state: ratified
ratification_date: 2021-06
repositories:
- url: https://github.com/riscv/riscv-bitmanip
branch: main
4 changes: 2 additions & 2 deletions backends/arch_gen/lib/arch_gen.rb
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ def maybe_add_csr(csr_name, extra_env = {})
arch_def_mock.define_singleton_method(:possible_xlens) do
pos_xlen_local
end
impl_ext = @cfg_impl_ext.map { |e| ExtensionVersion.new(e[0], e[1]) }
impl_ext = @cfg_impl_ext.map { |e| ExtensionVersion.new(e[0], e[1], nil) }
arch_def_mock.define_singleton_method(:implemented_extensions) do
impl_ext
end
Expand Down Expand Up @@ -1001,7 +1001,7 @@ def maybe_add_inst(inst_name, extra_env = {})
arch_def_mock = Object.new
arch_def_mock.define_singleton_method(:fully_configured?) { true }
arch_def_mock.define_singleton_method(:possible_xlens) { possible_xlens }
impl_ext = @cfg_impl_ext.map { |e| ExtensionVersion.new(e[0], e[1]) }
impl_ext = @cfg_impl_ext.map { |e| ExtensionVersion.new(e[0], e[1], nil) }
arch_def_mock.define_singleton_method(:implemented_extensions) do
impl_ext
end
Expand Down
25 changes: 14 additions & 11 deletions backends/cfg_html_doc/templates/ext.adoc.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,26 @@ Implemented Version:: <%= ext_version.version %>
== Versions

<%- ext.versions.each do |v| -%>
<%- implemented = arch_def.implemented_extensions.include?(ExtensionVersion.new(ext.name, v["version"])) -%>
<%= v["version"] %>::
<%- implemented = arch_def.implemented_extensions.include?(v) -%>
<%= v.version %>::
Ratification date:::
<%= v["ratification_date"] %>
<%- if v.key?("changes") -%>
<%= v.ratification_date %>
<%- unless v.changes.empty? -%>
Changes:::
<%= v["changes"] %>

<% v.changes.each do |c| -%>
* <%= c %>
<% end -%>

<%- end -%>
<%- if v.key?("url") -%>
<%- unless v.url.nil? -%>
Ratification document:::
<%= v["url"] %>
<%= v.url %>
<%- end -%>
<%- if v.key?("implies") -%>
<%- unless v.implications.empty? -%>
Implies:::
<%- implications = v["implies"][0].is_a?(Array) ? v["implies"] : [v["implies"]] -%>
<%- implications.each do |i| -%>
* `<%= i[0] %>` version <%= i[1] %>
<%- v.implications.each do |i| -%>
* `<%= i.name %>` version <%= i.version %>
<%- end -%>
<%- end -%>
<%- end -%>
Expand Down
23 changes: 11 additions & 12 deletions backends/crd_doc/templates/crd.adoc.erb
Original file line number Diff line number Diff line change
Expand Up @@ -277,30 +277,29 @@ Requirement <%= req.name %> only apply when <%= req.when_pretty %>.
*Version Requirement*: <%= ext_req.version_requirement %> +
<% ext_db.versions.each do |v| -%>
<%= v["version"] %>::
<%= v.version %>::
State:::
<%= v["state"] %>
<% if v["state"] == "ratified" -%>
<%= v.state %>
<% if v.state == "ratified" -%>
Ratification date:::
<%= v["ratification_date"] %>
<%= v.ratification_date %>
<% end # if %>
<% if v.key?("changes") -%>
<% if v.changes.size > 0 -%>
Changes:::
<% v["changes"].each do |c| -%>
<% v.changes.each do |c| -%>
* <%= c %>
<% end -%>
<% end -%>
<% if v.key?("url") -%>
<% unless v.url.nil? -%>
Ratification document:::
<%= v["url"] %>
<%= v.url %>
<% end -%>
<% if v.key?("implies") -%>
<% if v.implications.size > 0 -%>
Implies:::
<% implications = v["implies"][0].is_a?(Array) ? v["implies"] : [v["implies"]] -%>
<% implications.each do |i| -%>
* `<%= i[0] %>` version <%= i[1] %>
<% v.implications.each do |i| -%>
* `<%= i.name %>` version <%= i.version %>
<% end -%>
<% end -%>
<% end -%>
Expand Down
4 changes: 2 additions & 2 deletions backends/ext_pdf_doc/tasks.rake
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ rule %r{#{$root}/gen/ext_pdf_doc/.*/adoc/.*_extension\.adoc} => proc { |tname|
if ENV.key?("EXT_VERSION")
ENV["EXT_VERSION"]
else
ext.versions.max { |a, b| Gem::Version.new(a["version"]) <=> Gem::Version.new(b["version"]) }["version"]
ext.versions.max { |a, b| a.version <=> b.version }.version
end
ext_version = ext.versions.find { |v| v["version"] == version_num }
ext_version = ext.versions.find { |v| v.version == version_num }
FileUtils.mkdir_p File.dirname(t.name)
File.write t.name, AsciidocUtils.resolve_links(arch_def.find_replace_links(erb.result(binding)))
end
Expand Down
83 changes: 50 additions & 33 deletions backends/ext_pdf_doc/templates/ext_pdf.adoc.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[[header]]
:description: <%= ext.long_name %> (<%= ext.name %>)
:revdate: <%= ext_version.key?("ratification_date") ? ext_version["ratification_date"] : Date.today %>
:revnumber: <%= ext_version["version"] %>
:revdate: <%= ext_version.ratification_date.nil? ? Date.today : ext_version.ratification_date %>
:revnumber: <%= ext_version.version %>
:revmark: <%=
case ext_version["state"]
case ext_version.state
when "ratified"
<<~STATE
This document is in the http://riscv.org/spec-state[Ratified state] + \\
Expand All @@ -14,12 +14,12 @@
STATE
when "frozen"
<<~FROZEN_STATE
This document is in the http://riscv.org/spec-state[Frozen state].

Change is extremely unlikely.
A high threshold will be used, and a change will only occur because of some truly
critical issue being identified during the public review cycle.
Any other desired or needed changes can be the subject of a follow-on new extension.
This document is in the http://riscv.org/spec-state[Frozen state]. + \\
+ \\
Change is extremely unlikely. + \\
A high threshold will be used, and a change will only occur because of some truly + \\
critical issue being identified during the public review cycle. + \\
Any other desired or needed changes can be the subject of a follow-on new extension. + \\
FROZEN_STATE
when "development"
<<~DEV_STATE
Expand All @@ -28,7 +28,7 @@
Change should be expected + \\
DEV_STATE
else
raise "TODO: #{ext_version["state"]} description"
raise "TODO: #{ext_version.state} description"
end
%>
:company: <%= ext.company.nil? ? "unknown" : ext.company["name"] %>
Expand All @@ -41,7 +41,7 @@
:title-logo-image: image:risc-v_logo.png["RISC-V International Logo",pdfwidth=3.25in,align=center]
:back-cover-image: image:riscv-horizontal-color.svg[opacity=25%]
<%- end -%>
<%- unless ext_version["state"] == "ratified" -%>
<%- if ext_version.state == "development" -%>
:page-background-image: image:draft.png[opacity=20%]
<%- end -%>
// Settings
Expand Down Expand Up @@ -85,7 +85,7 @@ endif::[]

// Preamble
<%=
case ext_version["state"]
case ext_version.state
when "ratified"
<<~RATIFIED_STATE
[WARNING]
Expand Down Expand Up @@ -115,25 +115,25 @@ endif::[]
====
DEV_STATE
else
raise "TODO: #{ext_version["state"]} description"
raise "TODO: #{ext_version.state} description"
end
%>

[preface]
== Copyright and license information
This document is released under the <%= ext.doc_license.nil? ? "unknown" : ext.doc_license["url"] %>[<%= ext.doc_license.nil? ? "unknown" : ext.doc_license["name"] %>].

Copyright <%= ext_version["ratification_date"].nil? ? Date.today.year : ext_version["ratification_date"].split("-")[0] %> by <%= ext.company.nil? ? "unknown" : ext.company["name"] %>.
Copyright <%= ext_version.ratification_date.nil? ? Date.today.year : ext_version.ratification_date.split("-")[0] %> by <%= ext.company.nil? ? "unknown" : ext.company["name"] %>.

[preface]
== Acknowledgements

<%- ext.versions.each do |version| -%>
Contributors to version <%= version["version"] %> of the specification (in alphabetical order) include: +
Contributors to version <%= version.version %> of the specification (in alphabetical order) include: +

<%- unless version["contributors"].nil? -%>
<%- version["contributors"].sort { |a, b| a["name"].split(" ").last <=> b["name"].split(" ").last }.each do |c| -%>
* <%= c["name"] %> <<%= c["email"] %>> (<%= c["company"] %>)
<%- unless version.contributors.empty? -%>
<%- version.contributors.sort { |a, b| a.name.split(" ").last <=> b.name.split(" ").last }.each do |c| -%>
* <%= c.name %> <<%= c.email %>> (<%= c.company %>)

<%- end -%>
<%- end -%>
Expand All @@ -149,21 +149,29 @@ The following versions have been defined:

<%- ext.versions.each do |version| -%>
--
Version:: <%= version["version"] %>
State:: <%= version["state"] %>
<%- if version.key?("ratification_date") && !version["ratification_date"].nil? -%>
Ratification Date:: <%= version["ratification_date"] %>
Version:: <%= version.version %>
State:: <%= version.state %>
<%- unless version.ratification_date.nil? -%>
Ratification Date:: <%= version.ratification_date %>
<%- end -%>
<%- if version.key?("url") -%>
Design document:: <%= version["url"] %>
<%- unless version.url.nil? -%>
Design document:: <%= version.url %>
<%- end -%>
<%- if version.key?("changes") -%>
<%- unless version.changes.empty? -%>
Changes::
<%= version["changes"] %>

<% version.changes.each do |c| -%>
* <%= c %>
<% end -%>

<%- end -%>
<%- unless version["implies"].nil? || version["implies"].empty? -%>
<%- unless version.implications.empty? -%>
Implies::
* <%= version["implies"].map { |name, version| "#{name} (#{version})" }.join("\n* ") %>
* <%= version.implications.map { |i| "#{i.name} (#{i.version})" }.join("\n* ") %>
<%- unless version.requirements.empty? -%>
Requires::
<%= version.requirements.to_asciidoc %>
<%- end -%>
<%- end -%>
--
<%- end -%>
Expand All @@ -176,13 +184,22 @@ Implies::

<%- unless ext.implies.nil? -%>
=== Sub-extensions
The following sub-extensions are defined:
<%- if ext.implies.size > 1 -%>
<%= ext.name %> defines the following #{ext.implies.size} sub-extensions:
<%- else -%>
<%= ext.name %> defines a single sub-extension:
<%- end -%>

<%- ext.implies.each do |sub_ext| -%>
==== <%= sub_ext.name %>

<%= arch_def.extension(sub_ext.name).description %>

<%- unless sub_ext.requirements.empty? -%>
<%= sub_ext.name %> requires:
<%= sub_ext.requirements.to_asciidoc %>
<%- end -%>

<%- end -%>
<%- end -%>

Expand All @@ -194,14 +211,14 @@ The following <%= ext.instructions.size %> instructions are added by this extens

[%autowidth]
|===
| RV32 | RV64 | Mnemonic | Instruction | <%= ext.versions.map { |v| "v#{v["version"]}" }.join(" | ") %>
| RV32 | RV64 | Mnemonic | Instruction | <%= ext.versions.map { |v| "v#{v.version}" }.join(" | ") %>

<%- ext.instructions.each do |i| -%>
| <%= i.rv32? ? "&#x2713;" : "" %>
| <%= i.rv64? ? "&#x2713;" : "" %>
| `<%= i.name %> <%= i.assembly.gsub("x", "r").strip %>`
| xref:insns-<%= i.name.gsub('.', '_') %>[<%= i.long_name %>]
| <%= ext.versions.map { |v| i.defined_by?(ext.name, v["version"]) ? "&#x2713;" : "" }.join(" | ") %>
| <%= ext.versions.map { |v| i.defined_by?(ext.name, v.version) ? "&#x2713;" : "" }.join(" | ") %>
<%- end -%>
|===

Expand Down Expand Up @@ -230,14 +247,14 @@ The following <%= ext.csrs.size %> are added by this extension.

[%autowidth]
|===
| RV32 | RV64 | CSR | Name | <%= ext.versions.map { |v| "v#{v["version"]}" }.join(" | ") %>
| RV32 | RV64 | CSR | Name | <%= ext.versions.map { |v| "v#{v.version}" }.join(" | ") %>

<%- ext.csrs.each do |csr| -%>
| <%= csr.defined_in_base32? ? "&#x2713;" : "" %>
| <%= csr.defined_in_base64? ? "&#x2713;" : "" %>
| xref:csrs-<%= csr.name.gsub('.', '_') %>[<%= csr.name %>]
| <%= csr.long_name %>
| <%= ext.versions.map { |v| csr.defined_by?(ext.name, v["version"]) ? "&#x2713;" : "" }.join(" | ") %>
| <%= ext.versions.map { |v| csr.defined_by?(ext.name, v.version) ? "&#x2713;" : "" }.join(" | ") %>
<%- end -%>

|===
Expand Down
27 changes: 14 additions & 13 deletions backends/manual/templates/ext.adoc.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,29 @@
== Versions

<%- ext.versions.each do |v| -%>
<%= v["version"] %>::
<%= v.version %>::
State:::
<%= v["state"] %>
<%- if v["state"] == "ratified" -%>
<%= v.state %>
<%- if v.state == "ratified" -%>
Ratification date:::
<%= v["ratification_date"] %>
<%= v.ratification_date %>
<%- end -%>
<%- if v.key?("changes") -%>
<%- unless v.changes.empty? -%>
Changes:::
<%- v["changes"].each do |change| %>

<%- v.changes.each do |change| %>
* <%= change %>
<%- end -%>

<%- end -%>
<%- if v.key?("url") -%>
<%- unless v.url.nil? -%>
Ratification document:::
<%= v["url"] %>
<%= v.url %>
<%- end -%>
<%- if v.key?("implies") -%>
<%- unless v.implications -%>
Implies:::
<%- implications = v["implies"][0].is_a?(Array) ? v["implies"] : [v["implies"]] -%>
<%- implications.each do |i| -%>
* `<%= i[0] %>` version <%= i[1] %>
<%- v.implications.each do |i| -%>
* `<%= i.name %>` version <%= i.version %>
<%- end -%>
<%- end -%>
<%- end -%>
Expand All @@ -35,7 +36,7 @@

<%= ext.description %>

<%- insts = arch_def.instructions.select { |i| ext.versions.any? { |v| i.defined_by?(ext.name, v["version"]) } } -%>
<%- insts = arch_def.instructions.select { |i| ext.versions.any? { |v| i.defined_by?(ext.name, v.version) } } -%>
<%- unless insts.empty? -%>
== Instructions

Expand Down
2 changes: 1 addition & 1 deletion backends/manual/templates/param_list.adoc.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
= Architectural Parameters

<%-
params = manual_version.extensions.map{ |e| e.params(arch_def) }.flatten.uniq(&:name).sort_by!(&:name)
params = manual_version.extensions.map{ |e| e.params }.flatten.uniq(&:name).sort_by!(&:name)
-%>

The following <%= params.size %> parameters are defined in this manual:
Expand Down
Loading

0 comments on commit a0829f4

Please sign in to comment.