Skip to content

Commit

Permalink
Fix #181
Browse files Browse the repository at this point in the history
  • Loading branch information
james-ball-qualcomm committed Oct 24, 2024
1 parent 98126d8 commit 8c611b1
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 20 deletions.
3 changes: 3 additions & 0 deletions arch/crd/MC-1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ MC-1:
name: MC-1
long_name: LONG NAME
family: Microcontroller

mandatory_priv_modes:
- M

# semantic version within the CRD family
version: "1.0"
Expand Down
3 changes: 3 additions & 0 deletions arch/crd/MockCRD-1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ MockCRD-1:
long_name: Mock CRD Long Name

family: MockCRDFamily

mandatory_priv_modes:
- M,U

# XLEN used by rakefile
base: 64
Expand Down
5 changes: 1 addition & 4 deletions arch/crd_family/Microcontroller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,4 @@ Microcontroller:
** A <patch> release only provides specification clarifications and doesn’t change requirements. The initial minor release has an implicit patch release value of “.0” so the first update to a minor release has a patch release of “.1”.
** For example, the first release of MC is MC-1 (can omit the implicit “.0” minor release), its first minor release is MC-1.1, a patch release of this minor release is MC-1.1.1 and the next major release is MC-2.
* \<-MODE> is -Unpriv, -Priv, or -Debug. If \<-MODE> is omitted, the reference applies equally to all modes.
* \<-XLEN> is -32 for 32-bit microcontrollers and -64 for 64-bit microcontrollers. If \<-XLEN> is omitted, the reference applies equally to 32-bit and 64-bit microcontrollers. The term MXLEN used in the Priv ISA Manual is always equal to XLEN for MC.
mandatory_priv_modes:
- M
* \<-XLEN> is -32 for 32-bit microcontrollers and -64 for 64-bit microcontrollers. If \<-XLEN> is omitted, the reference applies equally to 32-bit and 64-bit microcontrollers. The term MXLEN used in the Priv ISA Manual is always equal to XLEN for MC.
5 changes: 1 addition & 4 deletions arch/crd_family/MockCRDFamily.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,4 @@ MockCRDFamily:
Here's the Mock CRD Family's introduction.
naming_scheme: |
Here's the Mock CRD Family's naming scheme.
mandatory_priv_modes:
- M
Here's the Mock CRD Family's naming scheme.
22 changes: 12 additions & 10 deletions backends/crd_doc/templates/crd.adoc.erb
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,15 @@ a| <% rev.changes.each do |change| %>

CSR field colors::

* Grey fields are reserved (WPRI)
* Green fields are present
* Red fields are defined by the RISC-V ISA but not present
* [green]#Green fields# are present in the associated CRD.
* [red]#Red fields# are defined by the RISC-V ISA but not required in the associated CRD.
* [silver]#Grey fields# are reserved for future use by RISC-V (AKA WPRI). Software should ignore the values read from
these fields and should preserve the values held in these fields when writing values to other fields.
For forward compatibility, implementations that do not furnish these fields must make them read-only zero.

CSR field types::

[%autowidth]
[cols="1,6"]
|===
| Abbreviation | Description

Expand Down Expand Up @@ -83,16 +85,16 @@ CSR field types::
| <%= crd.debug_manual_revision %>
|===

=== Privileged Modes
=== <%= crd.name %> Privileged Modes

|===
| M | S | U | VS | VU

| <% if crd.family.mandatory_priv_modes.include?('M') -%> MANDATORY <% else -%> OUT-OF-SCOPE <% end -%>
| <% if crd.family.mandatory_priv_modes.include?('S') -%> MANDATORY <% else -%> OUT-OF-SCOPE <% end -%>
| <% if crd.family.mandatory_priv_modes.include?('U') -%> MANDATORY <% else -%> OUT-OF-SCOPE <% end -%>
| <% if crd.family.mandatory_priv_modes.include?('VS') -%> MANDATORY <% else -%> OUT-OF-SCOPE <% end -%>
| <% if crd.family.mandatory_priv_modes.include?('VU') -%> MANDATORY <% else -%> OUT-OF-SCOPE <% end -%>
| <% if crd.m_mode? -%> MANDATORY <% else -%> OUT-OF-SCOPE <% end -%>
| <% if crd.s_mode? -%> MANDATORY <% else -%> OUT-OF-SCOPE <% end -%>
| <% if crd.u_mode? -%> MANDATORY <% else -%> OUT-OF-SCOPE <% end -%>
| <% if crd.vs_mode? -%> MANDATORY <% else -%> OUT-OF-SCOPE <% end -%>
| <% if crd.vu_mode? -%> MANDATORY <% else -%> OUT-OF-SCOPE <% end -%>

|===

Expand Down
29 changes: 27 additions & 2 deletions lib/arch_obj_models/crd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ def initialize(data, arch_def)
@arch_def = arch_def
end

def mandatory_priv_modes = @data["mandatory_priv_modes"]

def revisions
return @revisions unless @revisions.nil?

Expand Down Expand Up @@ -118,6 +116,33 @@ def family
@family = fam
end

def mandatory_priv_modes = @data["mandatory_priv_modes"]

# @return [true/false]
def m_mode?
mandatory_priv_modes.include?('M')
end

# @return [true/false]
def s_mode?
mandatory_priv_modes.include?('S')
end

# @return [true/false]
def u_mode?
mandatory_priv_modes.include?('U')
end

# @return [true/false]
def vs_mode?
mandatory_priv_modes.include?('VS')
end

# @return [true/false]
def vu_mode?
mandatory_priv_modes.include?('VU')
end

def tsc_profile
return nil if @data["tsc_profile"].nil?

Expand Down

0 comments on commit 8c611b1

Please sign in to comment.