From bdf98a7f7de7aa88a427397a2a0a0deead920468 Mon Sep 17 00:00:00 2001 From: Elyan Date: Sat, 26 Oct 2024 15:43:41 +0200 Subject: [PATCH] Added psr and esr special registers --- src/central-execution-engine-spec.adoc | 1 + ...rogram-and-exception-status-registers.adoc | 39 +++++++++ src/execution-engine-spec/registers.adoc | 80 ++++++++++++------- 3 files changed, 92 insertions(+), 28 deletions(-) create mode 100644 src/execution-engine-spec/program-and-exception-status-registers.adoc diff --git a/src/central-execution-engine-spec.adoc b/src/central-execution-engine-spec.adoc index 38289cd..dc42f33 100644 --- a/src/central-execution-engine-spec.adoc +++ b/src/central-execution-engine-spec.adoc @@ -8,5 +8,6 @@ This means that the amount of information pertaining to the internals of an _Exe include::execution-engine-spec/glossary.adoc[] include::execution-engine-spec/intro.adoc[] +include::execution-engine-spec/program-and-exception-status-registers.adoc[] include::execution-engine-spec/channel-io-overview.adoc[] include::execution-engine-spec/instructions.adoc[] \ No newline at end of file diff --git a/src/execution-engine-spec/program-and-exception-status-registers.adoc b/src/execution-engine-spec/program-and-exception-status-registers.adoc new file mode 100644 index 0000000..d6f3aee --- /dev/null +++ b/src/execution-engine-spec/program-and-exception-status-registers.adoc @@ -0,0 +1,39 @@ +[id=psr-and-esr] +== Program & Exception Status Registers +=== Program Status Register + +[wavedrom, ,svg] +.... +{reg: [ + {bits: 1, name: 'C', type: 2, attr: ['R', 'W']}, + {bits: 1, name: 'Z', type: 2, attr: ['R', 'W']}, + {bits: 1, name: 'N', type: 2, attr: ['R', 'W']}, + {bits: 1, name: 'V', type: 2, attr: ['R', 'W']}, + {bits: 4, name: 0x0, attr: 'unused'}, + {bits: 1, name: 'U', type: 6, attr: 'R'}, + {bits: 1, name: 'S', type: 6, attr: 'R'}, + {bits: 1, name: 'F', type: 6, attr: 'R'}, + {bits: 21, name: 0x0, attr: 'unused'}, +], config: {label: {right: 'psr'}}} +.... + +Only the ALU flags (C, Z, N, V) can be written to. Writing a 32-bits value into *psr* thus ignores the 28 upper bits. + +=== Exception Status Registers + +[wavedrom, ,svg] +.... +{reg: [ + {bits: 24, name: 'arg', type: 5}, + {bits: 8, name: 'exc', type: 8}, +], config: {label: {right: 'esr_svc'}}} +.... + +[wavedrom, ,svg] +.... +{reg: [ + {bits: 24, name: 'arg', type: 5}, + {bits: 8, name: 'exc', type: 8}, +], config: {label: {right: 'esr_fault'}}} +.... + diff --git a/src/execution-engine-spec/registers.adoc b/src/execution-engine-spec/registers.adoc index f78c6d0..dd93386 100644 --- a/src/execution-engine-spec/registers.adoc +++ b/src/execution-engine-spec/registers.adoc @@ -5,66 +5,90 @@ There are 8 GPRs in an _Execution Engine_. These registers are named *_r0_* thro ==== Special Purpose Registers -.Special purpose registers +.Registers accessible via common instructions [cols="1,1,1,1,3"] |=== |Name |User-mode |Supervisor-mode |Fault-mode |Description |lr -|X -|X -|X +|R/W +|R/W +|R/W |Link register. Store the return address from a Branch-with-Link. |pc -|X -|X -|X +|R/W +|R/W +|R/W |Program counter alias register. It is used as an alias to the current processor mode program counter register. |sp -|X -|X -|X +|R/W +|R/W +|R/W |Stack pointer alias register. It is used as an alias to the current processor mode stack pointer register. |pc_user -|X -|X -|X +|R/W +|R/W +|R/W |User-mode program counter. |sp_user -|X -|X -|X +|R/W +|R/W +|R/W |User-mode stack pointer. -|pc_sys +|pc_svc | -|X -|X +|R/W +|R/W |Supervisor-mode program counter. -|sp_sys +|sp_svc | -|X -|X +|R/W +|R/W |Supervisor-mode stack pointer. |pc_fault | -|X -|X +|R/W +|R/W |Fault-mode program counter. |sp_fault | -|X -|X +|R/W +|R/W |Fault-mode stack pointer. |=== -Other notable registers are accessible through <>. + -#TODO: Add the Program Status Register (ALU flags C, Z, N, V and processor modes U, S, F), Exception Status Register and the Channel Status Register in the Execution Engine State Subsystem.# +.Registers accessible via special instructions: `srr` & `srw` +[cols="1,1,1,1,3"] +|=== +|Name |User-mode |Supervisor-mode |Fault-mode |Description + +|psr +|R +|R/W +|R/W +|Program state register. Contains the ALU flags (C, Z, N, V) and the system mode flags (U, S, F). Writes by non privileged software are ignored. More details in <>. + +|esr_svc +| +|R +|R +|Supervisor-mode exception status register. Contains the identifier of the current exception being handled and a value passed along the exception. Read-only, writes are ignored. More details in <>. + +|esr_fault +| +|R +|R +|Fault-mode exception status register. Same as the *esr_svc* register. Read-only, writes are ignored. More details in <>. +|=== + +Other notable registers are accessible through <>. + +#TODO: Add the Channel Status Register in the Execution Engine State Subsystem.#