Comparing the Logic Synthesis Results of BOOM and My Own CPU (5. Improving LDQ/STQ Address Information Management)

I want to compare the synthesis results of BOOM and my own CPU and investigate which parts are the bottlenecks. Starting with area.

The LDQ/STQ managed address information with separate physical and virtual addresses. I will unify these and manage the address information as a single field covering both virtual and physical addresses.

I adopt the longer of the virtual and physical address fields, and check whether the address has already been translated to a physical address.

diff --git a/src/scariv_pkg.sv b/src/scariv_pkg.sv
index 93eaf30..d274670 100644
--- a/src/scariv_pkg.sv
+++ b/src/scariv_pkg.sv
@@ -12,6 +12,8 @@ package scariv_pkg;

   localparam INST_BUF_SIZE = scariv_conf_pkg::INST_BUF_SIZE;

+  localparam MAX_ADDR_W = VADDR_W > PADDR_W ? VADDR_W : PADDR_W;
+
   localparam REL_BUS_SIZE = ALU_INST_NUM +
                             LSU_INST_NUM +
                             1 +              // BRU
@@ -60,6 +62,7 @@ typedef logic [ALEN_W/8-1: 0] alenb_t;

 typedef logic [riscv_pkg::VADDR_W-1: 0] vaddr_t;
 typedef logic [riscv_pkg::PADDR_W-1: 0] paddr_t;
+typedef logic [MAX_ADDR_W-1: 0]         maxaddr_t;

Once the virtual address has been translated to a physical address, a flag is set and only the physical address is kept.

diff --git a/src/scariv_lsu_pkg.sv b/src/scariv_lsu_pkg.sv
index 6c5774b..cba0dc5 100644
--- a/src/scariv_lsu_pkg.sv
+++ b/src/scariv_lsu_pkg.sv
@@ -472,8 +472,9 @@ typedef struct packed {
   // scariv_pkg::issue_t inst;
   decoder_lsu_ctrl_pkg::size_t    size; // Memory Access Size
   stq_state_t        state;
-  scariv_pkg::vaddr_t  vaddr;
-  scariv_pkg::paddr_t  paddr;
+  // scariv_pkg::vaddr_t  vaddr;
+  // scariv_pkg::paddr_t  paddr;
+  scariv_pkg::maxaddr_t  addr;
   logic                                 paddr_valid;
   logic                                 is_rs2_get;
   scariv_pkg::alen_t                      rs2_data;
@@ -607,8 +608,9 @@ typedef struct packed {
   decoder_lsu_ctrl_pkg::size_t    size; // Memory Access Size
   ldq_state_t                     state;
   logic                           is_get_data;
-  scariv_pkg::vaddr_t vaddr;
-  scariv_pkg::paddr_t paddr;
+  // scariv_pkg::vaddr_t vaddr;
+  // scariv_pkg::paddr_t paddr;
+  scariv_pkg::maxaddr_t  addr;
   logic [scariv_conf_pkg::MISSU_ENTRY_SIZE-1: 0] missu_haz_index_oh;
   logic [scariv_conf_pkg::STQ_SIZE-1: 0]  hazard_index;

One thing to watch out for: when a memory access exception occurs, the virtual address that was accessed must be retained so that the exception can be reported.

--- a/src/scariv_stq_entry.sv
+++ b/src/scariv_stq_entry.sv
@@ -216,8 +216,8 @@ always_comb begin
                                        STQ_DONE_EX2;
         w_entry_next.except_valid    = i_ex1_q_updates.tlb_except_valid;
         w_entry_next.except_type     = i_ex1_q_updates.tlb_except_type;
-        w_entry_next.vaddr           = i_ex1_q_updates.vaddr;
-        w_entry_next.paddr           = i_ex1_q_updates.paddr;
+        w_entry_next.addr            = i_ex1_q_updates.tlb_except_valid ? i_ex1_q_updates.vaddr :
+                                       i_ex1_q_updates.paddr;
         w_entry_next.paddr_valid     = i_ex1_q_updates.hazard_typ != EX1_HAZ_TLB_MISS;
         w_entry_next.size            = i_ex1_q_updates.size;
         w_entry_next.is_uc           = i_ex1_q_updates.hazard_typ == EX1_HAZ_NONE ? i_ex1_q_updates.tlb_uc :

I ran logic synthesis again in this state, but it doesn't get much smaller...


This is an English translation of the original Japanese post: BOOMの論理合成結果と自作CPUの論理合成結果比較 (5. LDQ/STQのアドレス情報管理の改善)