Skip to content

Commit 00dbb73

Browse files
authored
Add FFLAGS and FRM CSRs (#657)
The PR addresses Issue #559 and adds the remaining F CSRs. - `FFLAGS` - `FRM` Most of the information for the two CSRs is also included in `fcsr.yaml` since `fcsr` is `frm` + `fflags`.
1 parent 2f061df commit 00dbb73

File tree

2 files changed

+153
-0
lines changed

2 files changed

+153
-0
lines changed

arch/csr/F/fflags.yaml

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# yaml-language-server: $schema=../../../schemas/csr_schema.json
2+
3+
$schema: "csr_schema.json#"
4+
kind: csr
5+
name: fflags
6+
long_name: Floating-Point Accrued Exceptions
7+
address: 0x001
8+
description:
9+
- id: csr-fflags-purpose
10+
normative: true
11+
text: |
12+
The accrued exception flags indicate the exception conditions that have arisen on any floating-point arithmetic
13+
instruction since the field was last reset by software.
14+
- id: csr-fflags-fptrap
15+
normative: false
16+
text: The base RISC-V ISA does not support generating a trap on the setting of a floating-point exception flag.
17+
- id: csr-fflags-reasoning
18+
normative: false
19+
text: |
20+
As allowed by the standard, we do not support traps on floating-point exceptions in the F
21+
extension, but instead require explicit checks of the flags in software. We considered
22+
adding branches controlled directly by the contents of the floating-point accrued
23+
exception flags, but ultimately chose to omit these instructions to keep the ISA simple.
24+
25+
priv_mode: U
26+
length: 32
27+
definedBy: F
28+
fields:
29+
NV:
30+
alias: fcsr.NV
31+
long_name: Invalid Operation
32+
location: 4
33+
description: |
34+
Set by hardware when a floating point operation is invalid and stays set until explicitly
35+
cleared by software.
36+
type: RW-H
37+
reset_value: UNDEFINED_LEGAL
38+
sw_write(csr_value): |
39+
CSR[fcsr].NV = csr_value.NV;
40+
return csr_value.NV;
41+
DZ:
42+
alias: fcsr.DZ
43+
long_name: Divide by Zero
44+
location: 3
45+
description: |
46+
Set by hardware when a floating point divide attempts to divide by zero and stays set until explicitly
47+
cleared by software.
48+
type: RW-H
49+
reset_value: UNDEFINED_LEGAL
50+
sw_write(csr_value): |
51+
CSR[fcsr].DZ = csr_value.DZ;
52+
return csr_value.DZ;
53+
OF:
54+
alias: fcsr.OF
55+
long_name: Overflow
56+
location: 2
57+
description: |
58+
Set by hardware when a floating point operation overflows and stays set until explicitly
59+
cleared by software.
60+
type: RW-H
61+
reset_value: UNDEFINED_LEGAL
62+
sw_write(csr_value): |
63+
CSR[fcsr].OF = csr_value.OF;
64+
return csr_value.OF;
65+
UF:
66+
alias: fcsr.UF
67+
long_name: Underflow
68+
location: 1
69+
description: |
70+
Set by hardware when a floating point operation underflows and stays set until explicitly
71+
cleared by software.
72+
type: RW-H
73+
reset_value: UNDEFINED_LEGAL
74+
sw_write(csr_value): |
75+
CSR[fcsr].UF = csr_value.UF;
76+
return csr_value.UF;
77+
NX:
78+
alias: fcsr.NX
79+
long_name: Inexact
80+
location: 0
81+
description: |
82+
Set by hardware when a floating point operation is inexact and stays set until explicitly
83+
cleared by software.
84+
type: RW-H
85+
reset_value: UNDEFINED_LEGAL
86+
sw_write(csr_value): |
87+
CSR[fcsr].NX = csr_value.NX;
88+
return csr_value.NX;
89+
sw_read(): |
90+
return
91+
(CSR[fcsr].NV `<< 4) |
92+
(CSR[fcsr].DZ `<< 3) |
93+
(CSR[fcsr].OF `<< 2) |
94+
(CSR[fcsr].UF `<< 1) |
95+
CSR[fcsr].NX;

arch/csr/F/frm.yaml

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# yaml-language-server: $schema=../../../schemas/csr_schema.json
2+
3+
$schema: "csr_schema.json#"
4+
kind: csr
5+
name: frm
6+
long_name: Floating-Point Dynamic Rounding Mode
7+
address: 0x002
8+
description:
9+
- id: csr-frm-encodings
10+
normative: false
11+
text: |
12+
Rounding modes are encoded as follows:
13+
14+
[[rm]]
15+
.Rounding mode encoding.
16+
[%autowidth,float="center",align="center",cols="^,^,<",options="header"]
17+
!===
18+
!Rounding Mode |Mnemonic |Meaning
19+
!000 !RNE !Round to Nearest, ties to Even
20+
!001 !RTZ !Round towards Zero
21+
!010 !RDN !Round Down (towards latexmath:[$-\infty$])
22+
!011 !RUP !Round Up (towards latexmath:[$+\infty$])
23+
!100 !RMM !Round to Nearest, ties to Max Magnitude
24+
!101 ! !_Reserved for future use._
25+
!110 ! !_Reserved for future use._
26+
!111 !DYN !In instruction's _rm_ field, selects dynamic rounding mode; In Rounding Mode register, _reserved_.
27+
!===
28+
- id: csr-frm-reserved
29+
normative: false
30+
text: |
31+
The behavior of floating-point instructions that depend on rounding mode when
32+
executed with a reserved rounding mode is _reserved_, including both static
33+
reserved rounding modes (101-110) and dynamic reserved rounding modes (101-111).
34+
- id: csr-frm-rmfield
35+
normative: false
36+
text: |
37+
Some instructions, including widening conversions, have the _rm_ field but are
38+
nevertheless mathematically unaffected by the rounding mode; software should set
39+
their _rm_ field to RNE (000) but implementations must treat the _rm_ field as
40+
usual (in particular, with regard to decoding legal vs. reserved encodings).
41+
42+
priv_mode: U
43+
length: 32
44+
definedBy: F
45+
fields:
46+
ROUNDINGMODE:
47+
alias: fcsr.FRM
48+
location: 2-0
49+
description: |
50+
Rounding mode data.
51+
type: RW-H
52+
reset_value: UNDEFINED_LEGAL
53+
sw_write(csr_value): |
54+
CSR[fcsr].FRM = csr_value.ROUNDINGMODE;
55+
return csr_value.ROUNDINGMODE;
56+
sw_read(): |
57+
return
58+
CSR[fcsr].FRM;

0 commit comments

Comments
 (0)