Skip to content

Implement Zicsr Extension and Testbenches - #248

Open
Dazhou-20383 wants to merge 44 commits into
mainfrom
Zicsr
Open

Implement Zicsr Extension and Testbenches#248
Dazhou-20383 wants to merge 44 commits into
mainfrom
Zicsr

Conversation

@Dazhou-20383

Copy link
Copy Markdown
Contributor

Add initial Zicsr CSR support

Added:

  • A dedicated CSR register file
  • Support for csrrw, csrrs, and csrrc
  • CSR read-data propagation through the normal pipeline to writeback
  • Build-time gating via UTOSS_RISCV__ZICSR_ENABLED

Design notes:

  • CSRs are implemented separately from the GPR register file.
  • CSR instructions are decoded in the decode stage, where the CSR address and source operands are already available.
  • CSR read data flows through the existing pipeline datapath and is selected during writeback.
  • funct3 is used to distinguish CSR instruction variants.

Future work:

  • Immediate CSR forms (csrrwi, csrrsi, csrrci)
  • Trap and privilege-level handling
  • CSR-specific semantics and access restrictions
  • Dedicated CSR tests

funct3 = instr[14:12];

end
`ifdef UTOSS_RISCV__ZICSR_ENABLED

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for making sure to gate everything on this flag; can you add it to our build-config here:

risc-v/Makefile

Lines 18 to 25 in 2a95e8f

# =============
# Build config
# =============
UTOSS_RISCV_CONFIG ?= RV32I
UTOSS_RISCV_VERILATOR_DEFINES := $(if $(findstring B,$(UTOSS_RISCV_CONFIG)),-DUTOSS_RISCV_ENABLE_B_EXT)
UTOSS_RISCV_RISCOF_VERILATOR_DEFINES := -DUTOSS_PIPELINE_LOGGER

end
default: begin
csr_write_enable = 1'b0;
csr_write_data = data_t'(0);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

directly determine csr_write_enable in decode could potentially cause hazards (update CSRfile too early). Maybe do something like csr_write_enable_D and pass it to the next stage?

Comment thread src/modules/CSR/CSRFile.sv Outdated
`include "src/headers/types.svh"

module CSRFile
( input csr_addr_t addr

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably need separate read_addr and write_addr, since CSRfile reading and writing can be done in different addr if they are in different stages at the same time

@DanielTaoHuang123 DanielTaoHuang123 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably need to change csr_write_enable in decode and separate addr in CSRfile. read the comments for details

lappend macro_list UTOSS_RISCV_ENABLE_B_EXT
}

if {[string first "ZICSR" $config_upper] >= 0} {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if {[string first "ZICSR" $config_upper] >= 0} {
if {[string first "Zicsr" $config_upper] >= 0} {

Comment thread src/utoss_riscv.sv Outdated
Comment on lines +99 to +103
`ifdef UTOSS_RISCV__ZICSR_ENABLED
CSRFile u_csr_file
( .read_addr ( csr_addr_d )
, .write_addr ( mem_to_wb_reg.csr_addr )
, .clk ( clk )

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider moving this into decode stage's module; will check on Daniel's hazard implementation

Comment on lines +13 to +16
csr_addr_t csr_addr;
logic csr_write_enable;
data_t csr_write_data;
data_t csr_read_data;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets keep the extension-specific wires inthe stage regs at the end of the declaration + if you can wrap it into the "is enabled" macro

Comment thread src/headers/params.svh Outdated
parameter UType_lui = 7'b0110111;
parameter IType_jalr = 7'b1100111;
parameter FENCE = 7'b0001111;
parameter SYSTEM = 7'b1110011;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets enabled riscof for this extension

Comment thread src/headers/types.svh Outdated
Comment thread src/hazard_unit.sv Outdated
assign lw_stall =
(result_src_e == RESULT_SRC__READ_DATA) &&
((rs1_d == rd_e) || (rs2_d == rd_e)) &&
(rd_e != 5'd0);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, i think @DanielTaoHuang123 added some extra fixes to the hazard unit here -- #250 , i think there are merge conflicts with this PR right now, but i think should should be able to just pull out the stuff you need for hazard unit specifically. Or I guess @DanielTaoHuang123 you could also resolve the conflicts if you have time , but up to you guys.

@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown

🔧 DE1-SoC Synthesis Report Summary Diff

  • RV32I

    1. Fitter Summary

      @@ -1,12 +1,12 @@
      -Fitter Status : Successful - Sun Jul 19 20:27:50 2026
      +Fitter Status : Successful - Sun Jul 26 15:00:29 2026
       Quartus Prime Version : 25.1std.0 Build 1129 10/21/2025 SC Lite Edition
       Revision Name : utoss-risc-v
       Top-level Entity Name : top
       Family : Cyclone V
       Device : 5CSEMA5F31C6
       Timing Models : Final
      -Logic utilization (in ALMs) : 1,522 / 32,070 ( 5 % )
      -Total registers : 1566
      +Logic utilization (in ALMs) : 1,526 / 32,070 ( 5 % )
      +Total registers : 1568
       Total pins : 15 / 457 ( 3 % )
       Total virtual pins : 0
       Total block memory bits : 32,768 / 4,065,280 ( < 1 % )
    2. Fitter by entity

      @@ -1,6 +1,6 @@
       Compilation Hierarchy Node                        ALMs needed [=A-B+C]  [A] ALMs used in final placement  [B] Estimate of ALMs recoverable by dense packing  [C] Estimate of ALMs unavailable  ALMs used for memory  Combinational ALUTs  Dedicated Logic Registers  I/O Registers  Block Memory Bits  M10Ks  DSP Blocks  Pins  Virtual Pins  Full Hierarchy Name                                                                                                Entity Name         Library Name
      -|top                                              1521.5 (0.5)          1661.0 (0.5)                      164.0 (0.0)                                        24.5 (0.0)                        0.0 (0.0)             1777 (1)             1566 (0)                   0 (0)          32768              8      0           15    0             |top                                                                                                               top                 work
      -   |memory_map:memory_map|                        10.8 (10.8)           11.3 (11.3)                       0.5 (0.5)                                          0.0 (0.0)                         0.0 (0.0)             13 (13)              11 (11)                    0 (0)          32768              8      0           0     0             |top|memory_map:memory_map                                                                                         memory_map          work
      +|top                                              1525.5 (0.5)          1660.0 (0.5)                      159.5 (0.0)                                        25.0 (0.0)                        0.0 (0.0)             1779 (1)             1568 (0)                   0 (0)          32768              8      0           15    0             |top                                                                                                               top                 work
      +   |memory_map:memory_map|                        10.4 (10.4)           13.8 (13.8)                       3.6 (3.6)                                          0.1 (0.1)                         0.0 (0.0)             13 (13)              13 (13)                    0 (0)          32768              8      0           0     0             |top|memory_map:memory_map                                                                                         memory_map          work
             |altsyncram:M0_rtl_0|                       0.0 (0.0)             0.0 (0.0)                         0.0 (0.0)                                          0.0 (0.0)                         0.0 (0.0)             0 (0)                0 (0)                      0 (0)          4096               1      0           0     0             |top|memory_map:memory_map|altsyncram:M0_rtl_0                                                                     altsyncram          work
                |altsyncram_9hp1:auto_generated|         0.0 (0.0)             0.0 (0.0)                         0.0 (0.0)                                          0.0 (0.0)                         0.0 (0.0)             0 (0)                0 (0)                      0 (0)          4096               1      0           0     0             |top|memory_map:memory_map|altsyncram:M0_rtl_0|altsyncram_9hp1:auto_generated                                      altsyncram_9hp1     work
             |altsyncram:M0_rtl_1|                       0.0 (0.0)             0.0 (0.0)                         0.0 (0.0)                                          0.0 (0.0)                         0.0 (0.0)             0 (0)                0 (0)                      0 (0)          4096               1      0           0     0             |top|memory_map:memory_map|altsyncram:M0_rtl_1                                                                     altsyncram          work
      @@ -17,16 +17,16 @@
                |altsyncram_chp1:auto_generated|         0.0 (0.0)             0.0 (0.0)                         0.0 (0.0)                                          0.0 (0.0)                         0.0 (0.0)             0 (0)                0 (0)                      0 (0)          4096               1      0           0     0             |top|memory_map:memory_map|altsyncram:M3_rtl_0|altsyncram_chp1:auto_generated                                      altsyncram_chp1     work
             |altsyncram:M3_rtl_1|                       0.0 (0.0)             0.0 (0.0)                         0.0 (0.0)                                          0.0 (0.0)                         0.0 (0.0)             0 (0)                0 (0)                      0 (0)          4096               1      0           0     0             |top|memory_map:memory_map|altsyncram:M3_rtl_1                                                                     altsyncram          work
                |altsyncram_chp1:auto_generated|         0.0 (0.0)             0.0 (0.0)                         0.0 (0.0)                                          0.0 (0.0)                         0.0 (0.0)             0 (0)                0 (0)                      0 (0)          4096               1      0           0     0             |top|memory_map:memory_map|altsyncram:M3_rtl_1|altsyncram_chp1:auto_generated                                      altsyncram_chp1     work
      -   |utoss_riscv:core|                             1510.2 (591.8)        1649.2 (608.4)                    163.5 (25.0)                                       24.5 (8.4)                        0.0 (0.0)             1763 (684)           1555 (465)                 0 (0)          0                  0      0           0     0             |top|utoss_riscv:core                                                                                              utoss_riscv         work
      -      |decode_stage:u_decode_stage|               323.0 (3.5)           412.2 (3.7)                       89.7 (0.2)                                         0.5 (0.0)                         0.0 (0.0)             111 (8)              992 (0)                    0 (0)          0                  0      0           0     0             |top|utoss_riscv:core|decode_stage:u_decode_stage                                                                  decode_stage        work
      -         |Instruction_Decode:instruction_decode|  21.4 (19.9)           22.2 (20.7)                       0.8 (0.8)                                          0.0 (0.0)                         0.0 (0.0)             59 (56)              0 (0)                      0 (0)          0                  0      0           0     0             |top|utoss_riscv:core|decode_stage:u_decode_stage|Instruction_Decode:instruction_decode                            Instruction_Decode  work
      -            |ALUdecoder:instanceALUDec|           1.5 (1.5)             1.5 (1.5)                         0.0 (0.0)                                          0.0 (0.0)                         0.0 (0.0)             3 (3)                0 (0)                      0 (0)          0                  0      0           0     0             |top|utoss_riscv:core|decode_stage:u_decode_stage|Instruction_Decode:instruction_decode|ALUdecoder:instanceALUDec  ALUdecoder          work
      -         |control_fsm:u_ctrl|                     0.8 (0.8)             1.0 (1.0)                         0.2 (0.2)                                          0.0 (0.0)                         0.0 (0.0)             4 (4)                0 (0)                      0 (0)          0                  0      0           0     0             |top|utoss_riscv:core|decode_stage:u_decode_stage|control_fsm:u_ctrl                                               control_fsm         work
      -         |registerFile:RegFile|                   297.3 (297.3)         385.3 (385.3)                     88.5 (88.5)                                        0.5 (0.5)                         0.0 (0.0)             40 (40)              992 (992)                  0 (0)          0                  0      0           0     0             |top|utoss_riscv:core|decode_stage:u_decode_stage|registerFile:RegFile                                             registerFile        work
      -      |execute_stage:u_execute_stage|             446.2 (102.7)         449.6 (107.5)                     16.7 (5.7)                                         13.3 (0.9)                        0.0 (0.0)             672 (194)            0 (0)                      0 (0)          0                  0      0           0     0             |top|utoss_riscv:core|execute_stage:u_execute_stage                                                                execute_stage       work
      -         |ALU:alu|                                343.5 (343.5)         342.1 (342.1)                     11.0 (11.0)                                        12.4 (12.4)                       0.0 (0.0)             478 (478)            0 (0)                      0 (0)          0                  0      0           0     0             |top|utoss_riscv:core|execute_stage:u_execute_stage|ALU:alu                                                        ALU                 work
      -      |fetch_stage:u_fetch_stage|                 71.1 (71.1)           92.8 (92.8)                       23.7 (23.7)                                        1.9 (1.9)                         0.0 (0.0)             125 (125)            97 (97)                    0 (0)          0                  0      0           0     0             |top|utoss_riscv:core|fetch_stage:u_fetch_stage                                                                    fetch_stage         work
      -      |hazard_unit:u_hazard_unit|                 5.7 (5.7)             7.0 (7.0)                         1.3 (1.3)                                          0.0 (0.0)                         0.0 (0.0)             15 (15)              1 (1)                      0 (0)          0                  0      0           0     0             |top|utoss_riscv:core|hazard_unit:u_hazard_unit                                                                    hazard_unit         work
      -      |memory_stage:u_memory_stage|               12.2 (12.2)           12.7 (12.7)                       0.8 (0.8)                                          0.4 (0.4)                         0.0 (0.0)             27 (27)              0 (0)                      0 (0)          0                  0      0           0     0             |top|utoss_riscv:core|memory_stage:u_memory_stage                                                                  memory_stage        work
      -      |write_back_stage:u_write_back_stage|       60.2 (58.3)           66.5 (64.0)                       6.3 (5.7)                                          0.0 (0.0)                         0.0 (0.0)             129 (126)            0 (0)                      0 (0)          0                  0      0           0     0             |top|utoss_riscv:core|write_back_stage:u_write_back_stage                                                          write_back_stage    work
      -         |MemoryLoader:memory_loader|             1.8 (1.8)             2.5 (2.5)                         0.7 (0.7)                                          0.0 (0.0)                         0.0 (0.0)             3 (3)                0 (0)                      0 (0)          0                  0      0           0     0             |top|utoss_riscv:core|write_back_stage:u_write_back_stage|MemoryLoader:memory_loader                               MemoryLoader        work
      +   |utoss_riscv:core|                             1514.6 (596.0)        1645.7 (610.8)                    155.9 (23.1)                                       24.9 (8.3)                        0.0 (0.0)             1765 (684)           1555 (465)                 0 (0)          0                  0      0           0     0             |top|utoss_riscv:core                                                                                              utoss_riscv         work
      +      |decode_stage:u_decode_stage|               315.3 (3.6)           402.2 (4.2)                       87.0 (0.8)                                         0.1 (0.1)                         0.0 (0.0)             111 (8)              992 (0)                    0 (0)          0                  0      0           0     0             |top|utoss_riscv:core|decode_stage:u_decode_stage                                                                  decode_stage        work
      +         |Instruction_Decode:instruction_decode|  20.6 (19.1)           21.8 (20.2)                       1.2 (1.1)                                          0.0 (0.0)                         0.0 (0.0)             59 (56)              0 (0)                      0 (0)          0                  0      0           0     0             |top|utoss_riscv:core|decode_stage:u_decode_stage|Instruction_Decode:instruction_decode                            Instruction_Decode  work
      +            |ALUdecoder:instanceALUDec|           1.5 (1.5)             1.7 (1.7)                         0.2 (0.2)                                          0.0 (0.0)                         0.0 (0.0)             3 (3)                0 (0)                      0 (0)          0                  0      0           0     0             |top|utoss_riscv:core|decode_stage:u_decode_stage|Instruction_Decode:instruction_decode|ALUdecoder:instanceALUDec  ALUdecoder          work
      +         |control_fsm:u_ctrl|                     1.2 (1.2)             1.5 (1.5)                         0.2 (0.2)                                          0.0 (0.0)                         0.0 (0.0)             4 (4)                0 (0)                      0 (0)          0                  0      0           0     0             |top|utoss_riscv:core|decode_stage:u_decode_stage|control_fsm:u_ctrl                                               control_fsm         work
      +         |registerFile:RegFile|                   289.9 (289.9)         374.6 (374.6)                     84.8 (84.8)                                        0.1 (0.1)                         0.0 (0.0)             40 (40)              992 (992)                  0 (0)          0                  0      0           0     0             |top|utoss_riscv:core|decode_stage:u_decode_stage|registerFile:RegFile                                             registerFile        work
      +      |execute_stage:u_execute_stage|             446.2 (102.4)         454.2 (108.3)                     22.6 (7.9)                                         14.6 (1.9)                        0.0 (0.0)             672 (194)            0 (0)                      0 (0)          0                  0      0           0     0             |top|utoss_riscv:core|execute_stage:u_execute_stage                                                                execute_stage       work
      +         |ALU:alu|                                343.9 (343.9)         345.8 (345.8)                     14.7 (14.7)                                        12.7 (12.7)                       0.0 (0.0)             478 (478)            0 (0)                      0 (0)          0                  0      0           0     0             |top|utoss_riscv:core|execute_stage:u_execute_stage|ALU:alu                                                        ALU                 work
      +      |fetch_stage:u_fetch_stage|                 75.8 (75.8)           92.0 (92.0)                       16.8 (16.8)                                        0.7 (0.7)                         0.0 (0.0)             126 (126)            97 (97)                    0 (0)          0                  0      0           0     0             |top|utoss_riscv:core|fetch_stage:u_fetch_stage                                                                    fetch_stage         work
      +      |hazard_unit:u_hazard_unit|                 7.3 (7.3)             8.5 (8.5)                         1.2 (1.2)                                          0.0 (0.0)                         0.0 (0.0)             16 (16)              1 (1)                      0 (0)          0                  0      0           0     0             |top|utoss_riscv:core|hazard_unit:u_hazard_unit                                                                    hazard_unit         work
      +      |memory_stage:u_memory_stage|               12.4 (12.4)           13.5 (13.5)                       1.2 (1.2)                                          0.2 (0.2)                         0.0 (0.0)             27 (27)              0 (0)                      0 (0)          0                  0      0           0     0             |top|utoss_riscv:core|memory_stage:u_memory_stage                                                                  memory_stage        work
      +      |write_back_stage:u_write_back_stage|       61.4 (60.1)           64.5 (63.0)                       4.0 (3.8)                                          0.9 (0.9)                         0.0 (0.0)             129 (126)            0 (0)                      0 (0)          0                  0      0           0     0             |top|utoss_riscv:core|write_back_stage:u_write_back_stage                                                          write_back_stage    work
      +         |MemoryLoader:memory_loader|             1.3 (1.3)             1.5 (1.5)                         0.2 (0.2)                                          0.0 (0.0)                         0.0 (0.0)             3 (3)                0 (0)                      0 (0)          0                  0      0           0     0             |top|utoss_riscv:core|write_back_stage:u_write_back_stage|MemoryLoader:memory_loader                               MemoryLoader        work
    3. Timing

      @@ -3,11 +3,11 @@
       ------------------------------------------------------------
       
       Type  : Slow 1100mV 85C Model Setup 'CLOCK_50'
      -Slack : 2.474
      +Slack : 2.840
       TNS   : 0.000
       
       Type  : Slow 1100mV 85C Model Hold 'CLOCK_50'
      -Slack : 0.338
      +Slack : 0.345
       TNS   : 0.000
       
       Type  : Slow 1100mV 85C Model Minimum Pulse Width 'CLOCK_50'
      @@ -15,39 +15,39 @@
       TNS   : 0.000
       
       Type  : Slow 1100mV 0C Model Setup 'CLOCK_50'
      -Slack : 3.122
      +Slack : 3.012
       TNS   : 0.000
       
       Type  : Slow 1100mV 0C Model Hold 'CLOCK_50'
      -Slack : 0.326
      +Slack : 0.297
       TNS   : 0.000
       
       Type  : Slow 1100mV 0C Model Minimum Pulse Width 'CLOCK_50'
      -Slack : 8.826
      +Slack : 8.822
       TNS   : 0.000
       
       Type  : Fast 1100mV 85C Model Setup 'CLOCK_50'
      -Slack : 9.095
      +Slack : 9.668
       TNS   : 0.000
       
       Type  : Fast 1100mV 85C Model Hold 'CLOCK_50'
      -Slack : 0.190
      +Slack : 0.243
       TNS   : 0.000
       
       Type  : Fast 1100mV 85C Model Minimum Pulse Width 'CLOCK_50'
      -Slack : 8.783
      +Slack : 8.787
       TNS   : 0.000
       
       Type  : Fast 1100mV 0C Model Setup 'CLOCK_50'
      -Slack : 10.320
      +Slack : 10.656
       TNS   : 0.000
       
       Type  : Fast 1100mV 0C Model Hold 'CLOCK_50'
      -Slack : 0.172
      +Slack : 0.188
       TNS   : 0.000
       
       Type  : Fast 1100mV 0C Model Minimum Pulse Width 'CLOCK_50'
      -Slack : 8.777
      +Slack : 8.780
       TNS   : 0.000
       
       ------------------------------------------------------------
  • RV32IB

    1. Fitter Summary

      @@ -1,12 +1,12 @@
      -Fitter Status : Successful - Sun Jul 19 20:28:55 2026
      +Fitter Status : Successful - Sun Jul 26 14:59:33 2026
       Quartus Prime Version : 25.1std.0 Build 1129 10/21/2025 SC Lite Edition
       Revision Name : utoss-risc-v
       Top-level Entity Name : top
       Family : Cyclone V
       Device : 5CSEMA5F31C6
       Timing Models : Final
      -Logic utilization (in ALMs) : 1,522 / 32,070 ( 5 % )
      -Total registers : 1566
      +Logic utilization (in ALMs) : 1,526 / 32,070 ( 5 % )
      +Total registers : 1568
       Total pins : 15 / 457 ( 3 % )
       Total virtual pins : 0
       Total block memory bits : 32,768 / 4,065,280 ( < 1 % )
    2. Fitter by entity

      @@ -1,6 +1,6 @@
       Compilation Hierarchy Node                        ALMs needed [=A-B+C]  [A] ALMs used in final placement  [B] Estimate of ALMs recoverable by dense packing  [C] Estimate of ALMs unavailable  ALMs used for memory  Combinational ALUTs  Dedicated Logic Registers  I/O Registers  Block Memory Bits  M10Ks  DSP Blocks  Pins  Virtual Pins  Full Hierarchy Name                                                                                                Entity Name         Library Name
      -|top                                              1521.5 (0.5)          1661.0 (0.5)                      164.0 (0.0)                                        24.5 (0.0)                        0.0 (0.0)             1777 (1)             1566 (0)                   0 (0)          32768              8      0           15    0             |top                                                                                                               top                 work
      -   |memory_map:memory_map|                        10.8 (10.8)           11.3 (11.3)                       0.5 (0.5)                                          0.0 (0.0)                         0.0 (0.0)             13 (13)              11 (11)                    0 (0)          32768              8      0           0     0             |top|memory_map:memory_map                                                                                         memory_map          work
      +|top                                              1525.5 (0.5)          1660.0 (0.5)                      159.5 (0.0)                                        25.0 (0.0)                        0.0 (0.0)             1779 (1)             1568 (0)                   0 (0)          32768              8      0           15    0             |top                                                                                                               top                 work
      +   |memory_map:memory_map|                        10.4 (10.4)           13.8 (13.8)                       3.6 (3.6)                                          0.1 (0.1)                         0.0 (0.0)             13 (13)              13 (13)                    0 (0)          32768              8      0           0     0             |top|memory_map:memory_map                                                                                         memory_map          work
             |altsyncram:M0_rtl_0|                       0.0 (0.0)             0.0 (0.0)                         0.0 (0.0)                                          0.0 (0.0)                         0.0 (0.0)             0 (0)                0 (0)                      0 (0)          4096               1      0           0     0             |top|memory_map:memory_map|altsyncram:M0_rtl_0                                                                     altsyncram          work
                |altsyncram_9hp1:auto_generated|         0.0 (0.0)             0.0 (0.0)                         0.0 (0.0)                                          0.0 (0.0)                         0.0 (0.0)             0 (0)                0 (0)                      0 (0)          4096               1      0           0     0             |top|memory_map:memory_map|altsyncram:M0_rtl_0|altsyncram_9hp1:auto_generated                                      altsyncram_9hp1     work
             |altsyncram:M0_rtl_1|                       0.0 (0.0)             0.0 (0.0)                         0.0 (0.0)                                          0.0 (0.0)                         0.0 (0.0)             0 (0)                0 (0)                      0 (0)          4096               1      0           0     0             |top|memory_map:memory_map|altsyncram:M0_rtl_1                                                                     altsyncram          work
      @@ -17,16 +17,16 @@
                |altsyncram_chp1:auto_generated|         0.0 (0.0)             0.0 (0.0)                         0.0 (0.0)                                          0.0 (0.0)                         0.0 (0.0)             0 (0)                0 (0)                      0 (0)          4096               1      0           0     0             |top|memory_map:memory_map|altsyncram:M3_rtl_0|altsyncram_chp1:auto_generated                                      altsyncram_chp1     work
             |altsyncram:M3_rtl_1|                       0.0 (0.0)             0.0 (0.0)                         0.0 (0.0)                                          0.0 (0.0)                         0.0 (0.0)             0 (0)                0 (0)                      0 (0)          4096               1      0           0     0             |top|memory_map:memory_map|altsyncram:M3_rtl_1                                                                     altsyncram          work
                |altsyncram_chp1:auto_generated|         0.0 (0.0)             0.0 (0.0)                         0.0 (0.0)                                          0.0 (0.0)                         0.0 (0.0)             0 (0)                0 (0)                      0 (0)          4096               1      0           0     0             |top|memory_map:memory_map|altsyncram:M3_rtl_1|altsyncram_chp1:auto_generated                                      altsyncram_chp1     work
      -   |utoss_riscv:core|                             1510.2 (591.8)        1649.2 (608.4)                    163.5 (25.0)                                       24.5 (8.4)                        0.0 (0.0)             1763 (684)           1555 (465)                 0 (0)          0                  0      0           0     0             |top|utoss_riscv:core                                                                                              utoss_riscv         work
      -      |decode_stage:u_decode_stage|               323.0 (3.5)           412.2 (3.7)                       89.7 (0.2)                                         0.5 (0.0)                         0.0 (0.0)             111 (8)              992 (0)                    0 (0)          0                  0      0           0     0             |top|utoss_riscv:core|decode_stage:u_decode_stage                                                                  decode_stage        work
      -         |Instruction_Decode:instruction_decode|  21.4 (19.9)           22.2 (20.7)                       0.8 (0.8)                                          0.0 (0.0)                         0.0 (0.0)             59 (56)              0 (0)                      0 (0)          0                  0      0           0     0             |top|utoss_riscv:core|decode_stage:u_decode_stage|Instruction_Decode:instruction_decode                            Instruction_Decode  work
      -            |ALUdecoder:instanceALUDec|           1.5 (1.5)             1.5 (1.5)                         0.0 (0.0)                                          0.0 (0.0)                         0.0 (0.0)             3 (3)                0 (0)                      0 (0)          0                  0      0           0     0             |top|utoss_riscv:core|decode_stage:u_decode_stage|Instruction_Decode:instruction_decode|ALUdecoder:instanceALUDec  ALUdecoder          work
      -         |control_fsm:u_ctrl|                     0.8 (0.8)             1.0 (1.0)                         0.2 (0.2)                                          0.0 (0.0)                         0.0 (0.0)             4 (4)                0 (0)                      0 (0)          0                  0      0           0     0             |top|utoss_riscv:core|decode_stage:u_decode_stage|control_fsm:u_ctrl                                               control_fsm         work
      -         |registerFile:RegFile|                   297.3 (297.3)         385.3 (385.3)                     88.5 (88.5)                                        0.5 (0.5)                         0.0 (0.0)             40 (40)              992 (992)                  0 (0)          0                  0      0           0     0             |top|utoss_riscv:core|decode_stage:u_decode_stage|registerFile:RegFile                                             registerFile        work
      -      |execute_stage:u_execute_stage|             446.2 (102.7)         449.6 (107.5)                     16.7 (5.7)                                         13.3 (0.9)                        0.0 (0.0)             672 (194)            0 (0)                      0 (0)          0                  0      0           0     0             |top|utoss_riscv:core|execute_stage:u_execute_stage                                                                execute_stage       work
      -         |ALU:alu|                                343.5 (343.5)         342.1 (342.1)                     11.0 (11.0)                                        12.4 (12.4)                       0.0 (0.0)             478 (478)            0 (0)                      0 (0)          0                  0      0           0     0             |top|utoss_riscv:core|execute_stage:u_execute_stage|ALU:alu                                                        ALU                 work
      -      |fetch_stage:u_fetch_stage|                 71.1 (71.1)           92.8 (92.8)                       23.7 (23.7)                                        1.9 (1.9)                         0.0 (0.0)             125 (125)            97 (97)                    0 (0)          0                  0      0           0     0             |top|utoss_riscv:core|fetch_stage:u_fetch_stage                                                                    fetch_stage         work
      -      |hazard_unit:u_hazard_unit|                 5.7 (5.7)             7.0 (7.0)                         1.3 (1.3)                                          0.0 (0.0)                         0.0 (0.0)             15 (15)              1 (1)                      0 (0)          0                  0      0           0     0             |top|utoss_riscv:core|hazard_unit:u_hazard_unit                                                                    hazard_unit         work
      -      |memory_stage:u_memory_stage|               12.2 (12.2)           12.7 (12.7)                       0.8 (0.8)                                          0.4 (0.4)                         0.0 (0.0)             27 (27)              0 (0)                      0 (0)          0                  0      0           0     0             |top|utoss_riscv:core|memory_stage:u_memory_stage                                                                  memory_stage        work
      -      |write_back_stage:u_write_back_stage|       60.2 (58.3)           66.5 (64.0)                       6.3 (5.7)                                          0.0 (0.0)                         0.0 (0.0)             129 (126)            0 (0)                      0 (0)          0                  0      0           0     0             |top|utoss_riscv:core|write_back_stage:u_write_back_stage                                                          write_back_stage    work
      -         |MemoryLoader:memory_loader|             1.8 (1.8)             2.5 (2.5)                         0.7 (0.7)                                          0.0 (0.0)                         0.0 (0.0)             3 (3)                0 (0)                      0 (0)          0                  0      0           0     0             |top|utoss_riscv:core|write_back_stage:u_write_back_stage|MemoryLoader:memory_loader                               MemoryLoader        work
      +   |utoss_riscv:core|                             1514.6 (596.0)        1645.7 (610.8)                    155.9 (23.1)                                       24.9 (8.3)                        0.0 (0.0)             1765 (684)           1555 (465)                 0 (0)          0                  0      0           0     0             |top|utoss_riscv:core                                                                                              utoss_riscv         work
      +      |decode_stage:u_decode_stage|               315.3 (3.6)           402.2 (4.2)                       87.0 (0.8)                                         0.1 (0.1)                         0.0 (0.0)             111 (8)              992 (0)                    0 (0)          0                  0      0           0     0             |top|utoss_riscv:core|decode_stage:u_decode_stage                                                                  decode_stage        work
      +         |Instruction_Decode:instruction_decode|  20.6 (19.1)           21.8 (20.2)                       1.2 (1.1)                                          0.0 (0.0)                         0.0 (0.0)             59 (56)              0 (0)                      0 (0)          0                  0      0           0     0             |top|utoss_riscv:core|decode_stage:u_decode_stage|Instruction_Decode:instruction_decode                            Instruction_Decode  work
      +            |ALUdecoder:instanceALUDec|           1.5 (1.5)             1.7 (1.7)                         0.2 (0.2)                                          0.0 (0.0)                         0.0 (0.0)             3 (3)                0 (0)                      0 (0)          0                  0      0           0     0             |top|utoss_riscv:core|decode_stage:u_decode_stage|Instruction_Decode:instruction_decode|ALUdecoder:instanceALUDec  ALUdecoder          work
      +         |control_fsm:u_ctrl|                     1.2 (1.2)             1.5 (1.5)                         0.2 (0.2)                                          0.0 (0.0)                         0.0 (0.0)             4 (4)                0 (0)                      0 (0)          0                  0      0           0     0             |top|utoss_riscv:core|decode_stage:u_decode_stage|control_fsm:u_ctrl                                               control_fsm         work
      +         |registerFile:RegFile|                   289.9 (289.9)         374.6 (374.6)                     84.8 (84.8)                                        0.1 (0.1)                         0.0 (0.0)             40 (40)              992 (992)                  0 (0)          0                  0      0           0     0             |top|utoss_riscv:core|decode_stage:u_decode_stage|registerFile:RegFile                                             registerFile        work
      +      |execute_stage:u_execute_stage|             446.2 (102.4)         454.2 (108.3)                     22.6 (7.9)                                         14.6 (1.9)                        0.0 (0.0)             672 (194)            0 (0)                      0 (0)          0                  0      0           0     0             |top|utoss_riscv:core|execute_stage:u_execute_stage                                                                execute_stage       work
      +         |ALU:alu|                                343.9 (343.9)         345.8 (345.8)                     14.7 (14.7)                                        12.7 (12.7)                       0.0 (0.0)             478 (478)            0 (0)                      0 (0)          0                  0      0           0     0             |top|utoss_riscv:core|execute_stage:u_execute_stage|ALU:alu                                                        ALU                 work
      +      |fetch_stage:u_fetch_stage|                 75.8 (75.8)           92.0 (92.0)                       16.8 (16.8)                                        0.7 (0.7)                         0.0 (0.0)             126 (126)            97 (97)                    0 (0)          0                  0      0           0     0             |top|utoss_riscv:core|fetch_stage:u_fetch_stage                                                                    fetch_stage         work
      +      |hazard_unit:u_hazard_unit|                 7.3 (7.3)             8.5 (8.5)                         1.2 (1.2)                                          0.0 (0.0)                         0.0 (0.0)             16 (16)              1 (1)                      0 (0)          0                  0      0           0     0             |top|utoss_riscv:core|hazard_unit:u_hazard_unit                                                                    hazard_unit         work
      +      |memory_stage:u_memory_stage|               12.4 (12.4)           13.5 (13.5)                       1.2 (1.2)                                          0.2 (0.2)                         0.0 (0.0)             27 (27)              0 (0)                      0 (0)          0                  0      0           0     0             |top|utoss_riscv:core|memory_stage:u_memory_stage                                                                  memory_stage        work
      +      |write_back_stage:u_write_back_stage|       61.4 (60.1)           64.5 (63.0)                       4.0 (3.8)                                          0.9 (0.9)                         0.0 (0.0)             129 (126)            0 (0)                      0 (0)          0                  0      0           0     0             |top|utoss_riscv:core|write_back_stage:u_write_back_stage                                                          write_back_stage    work
      +         |MemoryLoader:memory_loader|             1.3 (1.3)             1.5 (1.5)                         0.2 (0.2)                                          0.0 (0.0)                         0.0 (0.0)             3 (3)                0 (0)                      0 (0)          0                  0      0           0     0             |top|utoss_riscv:core|write_back_stage:u_write_back_stage|MemoryLoader:memory_loader                               MemoryLoader        work
    3. Timing

      @@ -3,11 +3,11 @@
       ------------------------------------------------------------
       
       Type  : Slow 1100mV 85C Model Setup 'CLOCK_50'
      -Slack : 2.474
      +Slack : 2.840
       TNS   : 0.000
       
       Type  : Slow 1100mV 85C Model Hold 'CLOCK_50'
      -Slack : 0.338
      +Slack : 0.345
       TNS   : 0.000
       
       Type  : Slow 1100mV 85C Model Minimum Pulse Width 'CLOCK_50'
      @@ -15,39 +15,39 @@
       TNS   : 0.000
       
       Type  : Slow 1100mV 0C Model Setup 'CLOCK_50'
      -Slack : 3.122
      +Slack : 3.012
       TNS   : 0.000
       
       Type  : Slow 1100mV 0C Model Hold 'CLOCK_50'
      -Slack : 0.326
      +Slack : 0.297
       TNS   : 0.000
       
       Type  : Slow 1100mV 0C Model Minimum Pulse Width 'CLOCK_50'
      -Slack : 8.826
      +Slack : 8.822
       TNS   : 0.000
       
       Type  : Fast 1100mV 85C Model Setup 'CLOCK_50'
      -Slack : 9.095
      +Slack : 9.668
       TNS   : 0.000
       
       Type  : Fast 1100mV 85C Model Hold 'CLOCK_50'
      -Slack : 0.190
      +Slack : 0.243
       TNS   : 0.000
       
       Type  : Fast 1100mV 85C Model Minimum Pulse Width 'CLOCK_50'
      -Slack : 8.783
      +Slack : 8.787
       TNS   : 0.000
       
       Type  : Fast 1100mV 0C Model Setup 'CLOCK_50'
      -Slack : 10.320
      +Slack : 10.656
       TNS   : 0.000
       
       Type  : Fast 1100mV 0C Model Hold 'CLOCK_50'
      -Slack : 0.172
      +Slack : 0.188
       TNS   : 0.000
       
       Type  : Fast 1100mV 0C Model Minimum Pulse Width 'CLOCK_50'
      -Slack : 8.777
      +Slack : 8.780
       TNS   : 0.000
       
       ------------------------------------------------------------

Comparing synthesis results from main branch vs. this PR

@Dazhou-20383 Dazhou-20383 changed the title Implement basic CSR infrastructure and Zicsr instruction support Implement Zicsr Extension and Testbenches Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Zicsr extension

3 participants