From 94217bd15f7789a14298eb41947b20b93ea6661b Mon Sep 17 00:00:00 2001 From: Szymon Bieganski Date: Tue, 17 Oct 2023 11:20:40 +0200 Subject: [PATCH 1/4] Expose to the output ports whether the core is running in user or machine mode solves #8 Signed-off-by: Szymon Bieganski --- rtl/cve2_core.sv | 5 ++++- rtl/cve2_top.sv | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/rtl/cve2_core.sv b/rtl/cve2_core.sv index ea2693c856..2dff3b5b2a 100644 --- a/rtl/cve2_core.sv +++ b/rtl/cve2_core.sv @@ -103,7 +103,8 @@ module cve2_core import cve2_pkg::*; #( // CPU Control Signals input logic fetch_enable_i, - output logic core_busy_o + output logic core_busy_o, + output logic priv_mode_o ); localparam int unsigned PMP_NUM_CHAN = 3; @@ -280,6 +281,8 @@ module cve2_core import cve2_pkg::*; #( // interfaces to finish ongoing operations. assign core_busy_o = ctrl_busy | if_busy | lsu_busy; + assign priv_mode_o = ( priv_mode_id == PRIV_LVL_M ); + ////////////// // IF stage // ////////////// diff --git a/rtl/cve2_top.sv b/rtl/cve2_top.sv index be2ebc47aa..5553979d5a 100644 --- a/rtl/cve2_top.sv +++ b/rtl/cve2_top.sv @@ -95,7 +95,8 @@ module cve2_top import cve2_pkg::*; #( // CPU Control Signals input logic fetch_enable_i, - output logic core_sleep_o + output logic core_sleep_o, + output logic priv_mode_o ); // Scrambling Parameter @@ -228,7 +229,8 @@ module cve2_top import cve2_pkg::*; #( `endif .fetch_enable_i (fetch_enable_q), - .core_busy_o (core_busy_d) + .core_busy_o (core_busy_d), + .priv_mode_o ); //////////////////////// From e6f07ccde71e802056ecc96ecca53d4ca3fc0244 Mon Sep 17 00:00:00 2001 From: Szymon Bieganski Date: Fri, 1 Dec 2023 14:55:34 +0100 Subject: [PATCH 2/4] [doc] encode the the exposed op-mode directly, without any conversion Signed-off-by: Szymon Bieganski --- doc/01_specification/index.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/01_specification/index.rst b/doc/01_specification/index.rst index 36e38b6583..09db57e1bb 100644 --- a/doc/01_specification/index.rst +++ b/doc/01_specification/index.rst @@ -253,8 +253,8 @@ Operating modes (Privilege Levels) +--------+--------------------------------------------------------------+ | PVL-30 | CV32E20 shall export the CPU's operating mode as an address | | | phase attribute output signals on the Harvard memory | -| | interfaces (instruction fetch, data load/store) with machine | -| | mode defined as 1'b1 and user mode as 1'b0. | +| | interfaces (instruction fetch, data load/store) with mode | +| | encoded as per specification in [RVpriv]_. | +--------+--------------------------------------------------------------+ | PVL-40 | CV32E20 shall support the **bare** (addressing) mode, that | | | is, no support for address translation or protection. | From e74a5f616aa928a505b312082a8a5f94414a4d64 Mon Sep 17 00:00:00 2001 From: Szymon Bieganski Date: Mon, 4 Dec 2023 09:35:44 +0100 Subject: [PATCH 3/4] [rtl] use Machine/User mode encoding as per RVpriv specification the the exposed signals closes #175 Signed-off-by: Szymon Bieganski --- rtl/cve2_core.sv | 4 ++-- rtl/cve2_top.sv | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/rtl/cve2_core.sv b/rtl/cve2_core.sv index 895cd85e26..6845fb0a7e 100644 --- a/rtl/cve2_core.sv +++ b/rtl/cve2_core.sv @@ -104,7 +104,7 @@ module cve2_core import cve2_pkg::*; #( // CPU Control Signals input logic fetch_enable_i, output logic core_busy_o, - output logic priv_mode_o + priv_lvl_e priv_mode_o ); localparam int unsigned PMP_NUM_CHAN = 3; @@ -281,7 +281,7 @@ module cve2_core import cve2_pkg::*; #( // interfaces to finish ongoing operations. assign core_busy_o = ctrl_busy | if_busy | lsu_busy; - assign priv_mode_o = ( priv_mode_id == PRIV_LVL_M ); + assign priv_mode_o = priv_mode_id; ////////////// // IF stage // diff --git a/rtl/cve2_top.sv b/rtl/cve2_top.sv index 2465960704..df5a4ed841 100644 --- a/rtl/cve2_top.sv +++ b/rtl/cve2_top.sv @@ -96,7 +96,7 @@ module cve2_top import cve2_pkg::*; #( // CPU Control Signals input logic fetch_enable_i, output logic core_sleep_o, - output logic priv_mode_o + priv_lvl_e priv_mode_o ); // Scrambling Parameter From ee822c878ff17d07c6de74002e477e6445b160bc Mon Sep 17 00:00:00 2001 From: Szymon Bieganski Date: Tue, 12 Dec 2023 13:38:03 +0100 Subject: [PATCH 4/4] [rtl] expose effective priv_mode along with non-translated one Signed-off-by: Szymon Bieganski --- rtl/cve2_core.sv | 4 +++- rtl/cve2_top.sv | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/rtl/cve2_core.sv b/rtl/cve2_core.sv index 6845fb0a7e..1cd1e7f945 100644 --- a/rtl/cve2_core.sv +++ b/rtl/cve2_core.sv @@ -104,7 +104,8 @@ module cve2_core import cve2_pkg::*; #( // CPU Control Signals input logic fetch_enable_i, output logic core_busy_o, - priv_lvl_e priv_mode_o + priv_lvl_e priv_mode_o, + priv_lvl_e priv_eff_mode_o ); localparam int unsigned PMP_NUM_CHAN = 3; @@ -282,6 +283,7 @@ module cve2_core import cve2_pkg::*; #( assign core_busy_o = ctrl_busy | if_busy | lsu_busy; assign priv_mode_o = priv_mode_id; + assign priv_eff_mode_o = priv_mode_lsu; ////////////// // IF stage // diff --git a/rtl/cve2_top.sv b/rtl/cve2_top.sv index df5a4ed841..69fdf2b641 100644 --- a/rtl/cve2_top.sv +++ b/rtl/cve2_top.sv @@ -96,7 +96,8 @@ module cve2_top import cve2_pkg::*; #( // CPU Control Signals input logic fetch_enable_i, output logic core_sleep_o, - priv_lvl_e priv_mode_o + priv_lvl_e priv_mode_o, + priv_lvl_e priv_eff_mode_o ); // Scrambling Parameter @@ -230,7 +231,8 @@ module cve2_top import cve2_pkg::*; #( .fetch_enable_i (fetch_enable_q), .core_busy_o (core_busy_d), - .priv_mode_o + .priv_mode_o, + .priv_eff_mode_o ); ////////////////////////