diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 36198bcf54..e3ed643c01 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,7 +42,9 @@ jobs: cache-name: cache-spike with: path: tools/spike/ - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('verif/regress/install-spike.sh', 'verif/core-v-verif/vendor/riscv/') }} + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('verif/regress/install-spike.sh', + 'verif/core-v-verif/vendor/riscv/riscv-isa-sim/**/*', + 'verif/core-v-verif/vendor/riscv/riscv-isa-sim/*') }} - name: Prepare run: | @@ -95,7 +97,9 @@ jobs: cache-name: cache-spike with: path: tools/spike/ - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('verif/regress/install-spike.sh', 'verif/core-v-verif/vendor/riscv/') }} + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('verif/regress/install-spike.sh', + 'verif/core-v-verif/vendor/riscv/riscv-isa-sim/**/*', + 'verif/core-v-verif/vendor/riscv/riscv-isa-sim/*') }} - name: Run Tests run: | @@ -155,7 +159,9 @@ jobs: cache-name: cache-spike with: path: tools/spike/ - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('verif/regress/install-spike.sh', 'verif/core-v-verif/vendor/riscv/') }} + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('verif/regress/install-spike.sh', + 'verif/core-v-verif/vendor/riscv/riscv-isa-sim/**/*', + 'verif/core-v-verif/vendor/riscv/riscv-isa-sim/*') }} - name: Run Tests run: | diff --git a/.gitignore b/.gitignore index 95fe18e071..4ceeee9048 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,7 @@ build/* /Bender.local build/ *.vcd +*.fsdb *.log *.out *.jou diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 407093de9e..98153edd01 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -228,24 +228,24 @@ asic-synthesis: DASHBOARD_JOB_DESCRIPTION: "Synthesis indicator with specific Techno" DASHBOARD_SORT_INDEX: 5 DASHBOARD_JOB_CATEGORY: "Synthesis" - INPUT_DELAY: "0.46" - OUTPUT_DELAY: "0.11" - PERIOD: "0.85" - DV_TARGET: "cv32a6_embedded" + PERIOD: "15" + DV_TARGET: cv32a65x script: - - echo $SYNTH_PERIOD - - echo $INPUT_DELAY - - echo $OUTPUT_DELAY - - echo $NAND2_AREA - - echo $FOUNDRY_PATH - echo $PERIOD - - echo $TECH_NAME - echo $DV_TARGET - source ./verif/sim/setup-env.sh + - git clone ${SYNTH_SCRIPT} ${SYNTH_SCRIPT_PATH} + - cp -r ${SYNTH_SCRIPT_PATH}/cva6/ ../ + - git apply ${SYNTH_SCRIPT_PATH}/patches/*.patch - echo $SYN_DCSHELL_BASHRC; source $SYN_DCSHELL_BASHRC - - make -C pd/synth cva6_synth TARGET="$DV_TARGET" - - mv pd/synth/cva6_${DV_TARGET}_synth_modified.v artifacts/cva6_${DV_TARGET}_synth_modified.v - - python3 .gitlab-ci/scripts/report_synth.py pd/synth/cva6_${DV_TARGET}/reports/$PERIOD/cva6_$(echo $TECH_NAME)_synth_area.rpt pd/synth/synthesis_batch.log + - cp -r ${SYNTH_FLOW} ./ + - python3 ${SYNTH_SCRIPT_PATH}/scharm -p configs/modules/CVA6.yml --runner=True --compaign="only-synth" + - export NAND2_AREA=$(cat pd/synth/cva6_${DV_TARGET}/nand2area.txt) + - python3 .gitlab-ci/scripts/report_synth.py pd/synth/cva6_${DV_TARGET}/$PERIOD/reports/cva6_${DV_TARGET}_synth_area.rpt pd/synth/cva6_${DV_TARGET}/$PERIOD/reports/cva6_${DV_TARGET}_synthesis.log + - mv ${SYNTH_SCRIPT_PATH}/artifacts/ artifacts/artifacts_synth/ + - mv pd/synth/cva6_${DV_TARGET}/ artifacts/ + - mv pd/synth/cva6_${DV_TARGET}_synth.v artifacts/ + - mv pd/synth/cva6_${DV_TARGET}_synth.sdf artifacts/ fpga-build: extends: @@ -454,33 +454,41 @@ csr_embedded_tests: - mkdir -p artifacts/{reports,logs} - python3 .gitlab-ci/scripts/report_fail.py -smoke-gate: +simu-gate: + timeout : 4 hours extends: - .backend_test needs: - build_tools - asic-synthesis + parallel: + matrix: + - SIMU_PERIOD: ["20"] # 50 Mhz + PERIOD: ["15"] # 66 Mhz variables: - DV_TARGET: cv32a6_embedded - DASHBOARD_JOB_TITLE: "Smoke Gate $DV_TARGET" - DASHBOARD_JOB_DESCRIPTION: "Simple test to check netlist from ASIC synthesis" + DASHBOARD_JOB_TITLE: "Gate Level Simulation $DV_TARGET" + DASHBOARD_JOB_DESCRIPTION: "Tests to check netlist from ASIC synthesis and power consumption over different patterns" DASHBOARD_SORT_INDEX: 6 DASHBOARD_JOB_CATEGORY: "Post Synthesis" + DV_TARGET: cv32a65x + TARGET: $DV_TARGET script: - git -C verif/core-v-verif fetch --unshallow - mkdir -p tools - mv artifacts/tools/spike tools - echo $SYN_VCS_BASHRC; source $SYN_VCS_BASHRC - - echo $LIB_VERILOG - - echo $FOUNDRY_PATH - echo $PERIOD - - echo $TECH_NAME - source ./verif/sim/setup-env.sh + - git clone ${SYNTH_SCRIPT} ${SYNTH_SCRIPT_PATH} + - cp -r ${SYNTH_SCRIPT_PATH}/cva6/ ../ + - git apply ${SYNTH_SCRIPT_PATH}/patches/*.patch - source verif/regress/install-riscv-tests.sh - - mv artifacts/cva6_${DV_TARGET}_synth_modified.v pd/synth/cva6_${DV_TARGET}_synth_modified.v - - cd verif/sim - - make vcs_clean_all - - python3 cva6.py --testlist=../tests/testlist_riscv-tests-cv32a60x-p.yaml --test rv32ui-p-lw --iss_yaml cva6.yaml --target $DV_TARGET --iss=spike,vcs-gate $DV_OPTS + - mv artifacts/cva6_${DV_TARGET} pd/synth/ + - mv artifacts/cva6_${DV_TARGET}_synth.v pd/synth/ + - mv artifacts/cva6_${DV_TARGET}_synth.sdf pd/synth/ + - mkdir -p pd/synth/cva6_${DV_TARGET}/outputs/ + - python3 ${SYNTH_SCRIPT_PATH}/scharm -p configs/modules/CVA6.yml --runner=True --compaign="simu-gate" --name=$PROG_NAME + - mv ${SYNTH_SCRIPT_PATH}/artifacts/ artifacts/artifacts_gate/ after_script: *simu_after_script fpga-boot: diff --git a/.gitlab-ci/expected_synth.yml b/.gitlab-ci/expected_synth.yml index a746dd7d19..50d70c3f69 100644 --- a/.gitlab-ci/expected_synth.yml +++ b/.gitlab-ci/expected_synth.yml @@ -1,4 +1,4 @@ cv32a6_embedded: gates: 110095 cv32a65x: - gates: 109555 + gates: 128136 diff --git a/.gitlab-ci/scripts/report_coverage.py b/.gitlab-ci/scripts/report_coverage.py index 6804bfc701..0de0a7b06b 100644 --- a/.gitlab-ci/scripts/report_coverage.py +++ b/.gitlab-ci/scripts/report_coverage.py @@ -43,7 +43,6 @@ def get_fc_scores(component): "controller_i", "csr_regfile_i", "ex_stage_i", - "gen_cache_hpd.i_cache_subsystem", "i_frontend", "id_stage_i", "issue_stage_i", diff --git a/.gitlab-ci/scripts/report_synth.py b/.gitlab-ci/scripts/report_synth.py index 7917dc309b..06cf9833b0 100644 --- a/.gitlab-ci/scripts/report_synth.py +++ b/.gitlab-ci/scripts/report_synth.py @@ -20,6 +20,9 @@ with open(str(sys.argv[2]), 'r') as f: synthesis_log = f.read() +ignored_warning = ["RM-Error", "TFCHK-014", "TFCHK-012", "TFCHK-049", + "MV-021", "MV-028", "TLUP-004", "TLUP-005", + "TIM-164", "PWR-890", "PWR-80", "OPT-1413"] kgate_ratio = int(os.environ["NAND2_AREA"]) path_re = r'^pd/synth/cva6_([^/]+)' with open(".gitlab-ci/expected_synth.yml", "r") as f: @@ -30,6 +33,8 @@ error_log = [] warning_log = [] for line in synthesis_log.splitlines(): + if any (el in line for el in ignored_warning): + continue if os.environ['FOUNDRY_PATH'] in line: continue if os.environ['TECH_NAME'] in line: diff --git a/Makefile b/Makefile index e7b4ff5920..54208aa8e3 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,8 @@ vcs-library ?= work-vcs dpi-library ?= work-dpi # Top level module to compile top_level ?= ariane_tb +# Top level path +top_level_path ?= corev_apu/tb/$(top_level).sv # Maximum amount of cycles for a successful simulation run max_cycles ?= 10000000 # Test case to run @@ -222,7 +224,7 @@ fpga_src := $(wildcard corev_apu/fpga/src/*.sv) $(wildcard corev_apu/fpga/src/a fpga_src := $(addprefix $(root-dir), $(fpga_src)) src/bootrom/bootrom_$(XLEN).sv # look for testbenches -tbs := corev_apu/tb/ariane_tb.sv corev_apu/tb/ariane_testharness.sv core/cva6_rvfi.sv +tbs := $(top_level_path) corev_apu/tb/ariane_testharness.sv core/cva6_rvfi.sv tbs := $(addprefix $(root-dir), $(tbs)) @@ -258,7 +260,7 @@ compile_flag += -incr -64 -nologo -quiet -suppress 13262 -suppress 8607 -per vopt_flag += -suppress 2085 -suppress 7063 -suppress 2698 -suppress 13262 uvm-flags += +UVM_NO_RELNOTES +UVM_VERBOSITY=UVM_LOW -questa-flags += -t 1ns -64 $(gui-sim) $(QUESTASIM_FLAGS) +tohost_addr=$(tohost_addr) +define+QUESTA -suppress 3356 +questa-flags += -t 1ns -64 $(gui-sim) $(QUESTASIM_FLAGS) +tohost_addr=$(tohost_addr) +define+QUESTA -suppress 3356 -suppress 3579 compile_flag_vhd += -64 -nologo -quiet -2008 # Iterate over all include directories and write them with +incdir+ prefixed @@ -298,16 +300,19 @@ else questa-cmd += +jtag_rbb_enable=0 endif +flist ?= core/Flist.cva6 + vcs_build: $(dpi-library)/ariane_dpi.so mkdir -p $(vcs-library) cd $(vcs-library) &&\ - vlogan $(if $(VERDI), -kdb,) -full64 -nc -sverilog +define+$(defines) -assert svaext -f ../core/Flist.cva6 $(list_incdir) &&\ + vlogan $(if $(VERDI), -kdb,) -full64 -nc -sverilog +define+$(defines) -assert svaext -f $(flist) $(list_incdir) ../corev_apu/tb/common/mock_uart.sv -timescale=1ns/1ns &&\ vlogan $(if $(VERDI), -kdb,) -full64 -nc -sverilog +define+$(defines) $(filter %.sv,$(ariane_pkg)) +incdir+core/include/+$(VCS_HOME)/etc/uvm-1.2/dpi &&\ vhdlan $(if $(VERDI), -kdb,) -full64 -nc $(filter %.vhd,$(uart_src)) &&\ vlogan $(if $(VERDI), -kdb,) -full64 -nc -sverilog -assert svaext +define+$(defines) +incdir+$(VCS_HOME)/etc/uvm/src $(VCS_HOME)/etc/uvm/src/uvm_pkg.sv $(filter %.sv,$(src)) $(list_incdir) &&\ vlogan $(if $(VERDI), -kdb,) -full64 -nc -sverilog -ntb_opts uvm-1.2 &&\ vlogan $(if $(VERDI), -kdb,) -full64 -nc -sverilog -ntb_opts uvm-1.2 $(tbs) +define+$(defines) $(list_incdir) &&\ - vcs $(if $(DEBUG), -debug_access+all $(if $(VERDI), -kdb),) $(if $(TRACE_COMPACT),+vcs+fsdbon) -full64 -timescale=1ns/1ns -ntb_opts uvm-1.2 work.ariane_tb -error="IWNF" + vcs $(if $(DEBUG), -debug_access+all $(if $(VERDI), -kdb),) $(if $(TRACE_COMPACT),+vcs+fsdbon) -ignore initializer_driver_checks -timescale=1ns/1ns -ntb_opts uvm-1.2 work.$(top_level) -error="IWNF" \ + $(if $(gate), -sdf Max:ariane_gate_tb.i_ariane.i_cva6:$(CVA6_REPO_DIR)/pd/synth/cva6_$(TARGET)_synth.sdf +neg_tchk, +notimingcheck) vcs: vcs_build cd $(vcs-library) && \ diff --git a/ci/setup.sh b/ci/setup.sh index 2226a20fb3..7fae01f4e6 100755 --- a/ci/setup.sh +++ b/ci/setup.sh @@ -21,7 +21,7 @@ if [ -d ${VERILATOR_BUILD_DIR} ]; then fi if [ -f ${SPIKE_PATH}/spike ]; then - spike_version="$(git -C ${SPIKE_SRC_DIR} log -1 --pretty=tformat:%h -- ${SPIKE_SRC_DIR}/ )" + spike_version="$(git -C ${SPIKE_SRC_DIR} log -1 --pretty=tformat:%h )" spike_installed_version="$(${SPIKE_PATH}/spike -v |& cut -d ' ' -f 2)" if [ "$spike_installed_version" != "$spike_version" ]; then rm -rf ${SPIKE_INSTALL_DIR} diff --git a/common/local/util/sram.sv b/common/local/util/sram.sv index 4c0f2d25ad..f8dd934256 100644 --- a/common/local/util/sram.sv +++ b/common/local/util/sram.sv @@ -48,6 +48,7 @@ logic [BE_WIDTH_ALIGNED-1:0] be_aligned; logic [DATA_WIDTH_ALIGNED-1:0] rdata_aligned; logic [USER_WIDTH_ALIGNED-1:0] ruser_aligned; + // align to 64 bits for inferrable macro below always_comb begin : p_align wdata_aligned ='0; @@ -100,8 +101,17 @@ end .addr_i ( addr_i ), .rdata_o ( ruser_aligned[k*64 +: 64] ) ); - end else begin - assign ruser_aligned[k*64 +: 64] = '0; + end else begin : gen_mem_user + assign ruser_aligned[k*64 +: 64] = '0; + // synthesis translate_off + begin: i_tc_sram_wrapper_user + begin: i_tc_sram + logic init_val; + localparam type data_t = logic [63:0]; + data_t sram [NUM_WORDS-1:0] /* verilator public_flat */; + end + end + // synthesis translate_on end end endmodule : sram diff --git a/common/local/util/sram_cache.sv b/common/local/util/sram_cache.sv new file mode 100644 index 0000000000..7ca7559b7c --- /dev/null +++ b/common/local/util/sram_cache.sv @@ -0,0 +1,126 @@ +// Copyright 2018 ETH Zurich and University of Bologna. +// Copyright and related rights are licensed under the Solderpad Hardware +// License, Version 0.51 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://solderpad.org/licenses/SHL-0.51. Unless required by applicable law +// or agreed to in writing, software, hardware and materials distributed under +// this License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, either express or implied. See the License for the +// specific language governing permissions and limitations under the License. +// +// Author: Florian Zaruba , ETH Zurich +// Michael Schaffner , ETH Zurich +// Date: 15.08.2018 +// Description: SRAM wrapper for FPGA (requires the fpga-support submodule) +// +// Note: the wrapped module contains two different implementations for +// ALTERA and XILINX tools, since these follow different coding styles for +// inferrable RAMS with byte enable. define `FPGA_TARGET_XILINX or +// `FPGA_TARGET_ALTERA in your build environment (default is ALTERA) + +module sram_cache #( + parameter DATA_WIDTH = 64, + parameter USER_WIDTH = 1, + parameter USER_EN = 0, + parameter NUM_WORDS = 1024, + parameter SIM_INIT = "none", + parameter BYTE_ACCESS = 1, + parameter TECHNO_CUT = 0, + parameter OUT_REGS = 0 // enables output registers in FPGA macro (read lat = 2) +)( + input logic clk_i, + input logic rst_ni, + input logic req_i, + input logic we_i, + input logic [$clog2(NUM_WORDS)-1:0] addr_i, + input logic [USER_WIDTH-1:0] wuser_i, + input logic [DATA_WIDTH-1:0] wdata_i, + input logic [(DATA_WIDTH+7)/8-1:0] be_i, + output logic [USER_WIDTH-1:0] ruser_o, + output logic [DATA_WIDTH-1:0] rdata_o +); + localparam DATA_AND_USER_WIDTH = USER_EN ? DATA_WIDTH + USER_WIDTH : DATA_WIDTH; + if (TECHNO_CUT) begin : gen_techno_cut + if (USER_EN > 0) begin + logic [DATA_WIDTH + USER_WIDTH-1:0] wdata_user; + logic [DATA_WIDTH + USER_WIDTH-1:0] rdata_user; + logic [(DATA_WIDTH+7)/8+(DATA_WIDTH+7)/8-1:0] be; + + always_comb begin + wdata_user = {wdata_i, wuser_i}; + be = {be_i, be_i}; + rdata_o = rdata_user[DATA_AND_USER_WIDTH-1:DATA_WIDTH]; + ruser_o = rdata_user[USER_WIDTH-1:0]; + end + tc_sram_wrapper_cache_techno #( + .NumWords(NUM_WORDS), // Number of Words in data array + .DataWidth(DATA_AND_USER_WIDTH),// Data signal width + .ByteWidth(32'd8), // Width of a data byte + .NumPorts(32'd1), // Number of read and write ports + .Latency(32'd1), // Latency when the read data is available + .SimInit(SIM_INIT), // Simulation initialization + .BYTE_ACCESS(BYTE_ACCESS), // ACCESS byte or full word + .PrintSimCfg(1'b0) // Print configuration + ) i_tc_sram_wrapper ( + .clk_i ( clk_i ), + .rst_ni ( rst_ni ), + .req_i ( req_i ), + .we_i ( we_i ), + .be_i ( be ), + .wdata_i ( wdata_user ), + .addr_i ( addr_i ), + .rdata_o ( rdata_user ) + ); + end else begin + logic [DATA_WIDTH-1:0] wdata_user; + logic [DATA_WIDTH-1:0] rdata_user; + logic [(DATA_WIDTH+7)/8-1:0] be; + + always_comb begin + wdata_user = wdata_i; + be = be_i; + rdata_o = rdata_user; + ruser_o = '0; + end + tc_sram_wrapper_cache_techno #( + .NumWords(NUM_WORDS), // Number of Words in data array + .DataWidth(DATA_AND_USER_WIDTH),// Data signal width + .ByteWidth(32'd8), // Width of a data byte + .NumPorts(32'd1), // Number of read and write ports + .Latency(32'd1), // Latency when the read data is available + .SimInit(SIM_INIT), // Simulation initialization + .BYTE_ACCESS(BYTE_ACCESS), // ACCESS byte or full word + .PrintSimCfg(1'b0) // Print configuration + ) i_tc_sram_wrapper ( + .clk_i ( clk_i ), + .rst_ni ( rst_ni ), + .req_i ( req_i ), + .we_i ( we_i ), + .be_i ( be ), + .wdata_i ( wdata_user ), + .addr_i ( addr_i ), + .rdata_o ( rdata_user ) + ); + end + end else begin + sram #( + .USER_WIDTH (USER_WIDTH), + .DATA_WIDTH (DATA_WIDTH), + .USER_EN (USER_EN), + .NUM_WORDS (NUM_WORDS) + ) data_sram ( + .clk_i (clk_i), + .rst_ni (rst_ni), + .req_i (req_i), + .we_i (we_i), + .addr_i (addr_i), + .wuser_i(wuser_i), + .wdata_i(wdata_i), + .be_i (be_i), + .ruser_o(ruser_o), + .rdata_o(rdata_o) + ); + end + + +endmodule : sram_cache diff --git a/common/local/util/tc_sram_wrapper_cache_techno.sv b/common/local/util/tc_sram_wrapper_cache_techno.sv new file mode 100644 index 0000000000..31868b5457 --- /dev/null +++ b/common/local/util/tc_sram_wrapper_cache_techno.sv @@ -0,0 +1,64 @@ +// Copyright 2022 Thales DIS design services SAS +// +// Licensed under the Solderpad Hardware Licence, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// SPDX-License-Identifier: Apache-2.0 WITH SHL-2.0 +// You may obtain a copy of the License at https://solderpad.org/licenses/ +// +// Original Author: Jean-Roch COULON - Thales + +// Copy of tc_sram_wrapper_cache +// To be replaced by the wrapper of the technology used to avoid having black box at synthesis + +module tc_sram_wrapper_cache_techno #( + parameter int unsigned NumWords = 32'd1024, // Number of Words in data array + parameter int unsigned DataWidth = 32'd128, // Data signal width + parameter int unsigned ByteWidth = 32'd8, // Width of a data byte + parameter int unsigned NumPorts = 32'd2, // Number of read and write ports + parameter int unsigned Latency = 32'd1, // Latency when the read data is available + parameter SimInit = "none", // Simulation initialization + parameter BYTE_ACCESS = 1, + parameter bit PrintSimCfg = 1'b0, // Print configuration + // DEPENDENT PARAMETERS, DO NOT OVERWRITE! + parameter int unsigned AddrWidth = (NumWords > 32'd1) ? $clog2(NumWords) : 32'd1, + parameter int unsigned BeWidth = (DataWidth + ByteWidth - 32'd1) / ByteWidth, // ceil_div + parameter type addr_t = logic [AddrWidth-1:0], + parameter type data_t = logic [DataWidth-1:0], + parameter type be_t = logic [BeWidth-1:0] +) ( + input logic clk_i, // Clock + input logic rst_ni, // Asynchronous reset active low + // input ports + input logic [NumPorts-1:0] req_i, // request + input logic [NumPorts-1:0] we_i, // write enable + input addr_t [NumPorts-1:0] addr_i, // request address + input data_t [NumPorts-1:0] wdata_i, // write data + input be_t [NumPorts-1:0] be_i, // write byte enable + // output ports + output data_t [NumPorts-1:0] rdata_o // read data +); + +// synthesis translate_off + + tc_sram #( + .NumWords(NumWords), + .DataWidth(DataWidth), + .ByteWidth(ByteWidth), + .NumPorts(NumPorts), + .Latency(Latency), + .SimInit(SimInit), + .PrintSimCfg(PrintSimCfg) + ) i_tc_sram ( + .clk_i ( clk_i ), + .rst_ni ( rst_ni ), + .req_i ( req_i ), + .we_i ( we_i ), + .be_i ( be_i ), + .wdata_i ( wdata_i ), + .addr_i ( addr_i ), + .rdata_o ( rdata_o ) + ); + +// synthesis translate_on + +endmodule diff --git a/config/gen_from_riscv_config/README.md b/config/gen_from_riscv_config/README.md index 33a4303352..5a60339a05 100644 --- a/config/gen_from_riscv_config/README.md +++ b/config/gen_from_riscv_config/README.md @@ -53,10 +53,10 @@ python3 scripts/riscv_config_gen.py -s ../riscv-config/cv32a65x/generated/isa_ge You could find your output files in this directory : if the output is ISA Documentation: - [Config_Name]\isa\ + `/isa/` if the output is CSR Documentation : - [Config_Name]\csr\ + `/csr/` for more details about How to write CSR or ISA Updater,see [UPDATERS](##Updaters) section @@ -86,7 +86,7 @@ If you want to add an extension to documentation not existed by default u can pu - Format : - [Extension_Name]: True + : True - Example : @@ -96,7 +96,7 @@ If you want to remove an extension from documentation not existed by default u c - Format : - [Extension_Name]: False + : False - Example : @@ -107,7 +107,7 @@ If you want to remove an extension from documentation already existed : - Format : - [Extension_Name]: False + : False - Example : @@ -191,7 +191,7 @@ Risc-V Config Yaml file is generated based on Risc-Config tool which include all . -You can execute the tool from `Config/riscv-config` repo : +You can execute the tool from `../config/riscv-config` repo : - It needs python dependancies with : diff --git a/config/gen_from_riscv_config/cv32a65x/csr/csr.md b/config/gen_from_riscv_config/cv32a65x/csr/csr.md index a143001046..ada6ddbe51 100644 --- a/config/gen_from_riscv_config/cv32a65x/csr/csr.md +++ b/config/gen_from_riscv_config/cv32a65x/csr/csr.md @@ -12,349 +12,342 @@ Author: Abdessamii Oukalrazqou |Address|Register Name|Description| | :--- | :--- | :--- | -|0x300|[mstatus](#mstatus)|The mstatus register keeps track of and controls the hart’s current operating state.| -|0x300|[mstatush](#mstatush)|The mstatush register keeps track of and controls the hart’s current operating state.| -|0x301|[misa](#misa)|misa is a read-write register reporting the ISA supported by the hart.| -|0x304|[mie](#mie)|The mie register is an MXLEN-bit read/write register containing interrupt enable bits.| -|0x305|[mtvec](#mtvec)|MXLEN-bit read/write register that holds trap vector configuration.| -|0x320|[mcountinhibit](#mcountinhibit)|The mcountinhibit is a 32-bit WARL register that controls which of the hardware performance-monitoring counters increment.| -|0x323-0x33f|[mhpmevent[3-31]](#mhpmevent[3-31])|The mhpmevent is a MXLEN-bit event register which controls mhpmcounter3.| -|0x340|[mscratch](#mscratch)|The mscratch register is an MXLEN-bit read/write register dedicated for use by machine mode.| -|0x341|[mepc](#mepc)|The mepc is a warl register that must be able to hold all valid physical and virtual addresses.| -|0x342|[mcause](#mcause)|The mcause register stores the information regarding the trap.| -|0x343|[mtval](#mtval)|The mtval is a warl register that holds the address of the instruction which caused the exception.| -|0x344|[mip](#mip)|The mip register is an MXLEN-bit read/write register containing information on pending interrupts.| -|0x3a0-0x3af|[pmpcfg[0-15]](#pmpcfg[0-15])|PMP configuration register| -|0x3b0-0x3ef|[pmpaddr[0-63]](#pmpaddr[0-63])|Physical memory protection address register| -|0xb00|[mcycle](#mcycle)|Counts the number of clock cycles executed from an arbitrary point in time.| -|0xb02|[minstret](#minstret)|Counts the number of instructions completed from an arbitrary point in time.| -|0xb03-0xb1f|[mhpmcounter[3-31]](#mhpmcounter[3-31])|The mhpmcounter is a 64-bit counter. Returns lower 32 bits in RV32I mode.| -|0xb80|[mcycleh](#mcycleh)|upper 32 bits of mcycle| -|0xb82|[minstreth](#minstreth)|Upper 32 bits of minstret.| -|0xb83-0xb9f|[mhpmcounter[3-31]h](#mhpmcounter[3-31]h)|The mhpmcounterh returns the upper half word in RV32I systems.| -|0xf11|[mvendorid](#mvendorid)|| -|0xf12|[marchid](#marchid)|MXLEN-bit read-only register encoding the base microarchitecture of the hart.| -|0xf13|[mimpid](#mimpid)|Provides a unique encoding of the version of the processor implementation.| -|0xf14|[mhartid](#mhartid)|MXLEN-bit read-only register containing the integer ID of the hardware thread running the code.| +|0x300|[MSTATUS](#MSTATUS)|The mstatus register keeps track of and controls the hart’s current operating state.| +|0x300|[MSTATUSH](#MSTATUSH)|The mstatush register keeps track of and controls the hart’s current operating state.| +|0x301|[MISA](#MISA)|misa is a read-write register reporting the ISA supported by the hart.| +|0x304|[MIE](#MIE)|The mie register is an MXLEN-bit read/write register containing interrupt enable bits.| +|0x305|[MTVEC](#MTVEC)|MXLEN-bit read/write register that holds trap vector configuration.| +|0x323-0x33f|[MHPMEVENT[3-31]](#MHPMEVENT[3-31])|The mhpmevent is a MXLEN-bit event register which controls mhpmcounter3.| +|0x340|[MSCRATCH](#MSCRATCH)|The mscratch register is an MXLEN-bit read/write register dedicated for use by machine mode.| +|0x341|[MEPC](#MEPC)|The mepc is a warl register that must be able to hold all valid physical and virtual addresses.| +|0x342|[MCAUSE](#MCAUSE)|The mcause register stores the information regarding the trap.| +|0x343|[MTVAL](#MTVAL)|The mtval is a warl register that holds the address of the instruction which caused the exception.| +|0x344|[MIP](#MIP)|The mip register is an MXLEN-bit read/write register containing information on pending interrupts.| +|0x3a0-0x3a1|[PMPCFG[0-1]](#PMPCFG[0-1])|PMP configuration register| +|0x3b0-0x3b7|[PMPADDR[0-7]](#PMPADDR[0-7])|Physical memory protection address register| +|0xb00|[MCYCLE](#MCYCLE)|Counts the number of clock cycles executed from an arbitrary point in time.| +|0xb02|[MINSTRET](#MINSTRET)|Counts the number of instructions completed from an arbitrary point in time.| +|0xb03-0xb1f|[MHPMCOUNTER[3-31]](#MHPMCOUNTER[3-31])|The mhpmcounter is a 64-bit counter. Returns lower 32 bits in RV32I mode.| +|0xb80|[MCYCLEH](#MCYCLEH)|upper 32 bits of mcycle| +|0xb82|[MINSTRETH](#MINSTRETH)|Upper 32 bits of minstret.| +|0xb83-0xb9f|[MHPMCOUNTER[3-31]H](#MHPMCOUNTER[3-31]H)|The mhpmcounterh returns the upper half word in RV32I systems.| +|0xf11|[MVENDORID](#MVENDORID)|32-bit read-only register providing the JEDEC manufacturer ID of the provider of the core.| +|0xf12|[MARCHID](#MARCHID)|MXLEN-bit read-only register encoding the base microarchitecture of the hart.| +|0xf13|[MIMPID](#MIMPID)|Provides a unique encoding of the version of the processor implementation.| +|0xf14|[MHARTID](#MHARTID)|MXLEN-bit read-only register containing the integer ID of the hardware thread running the code.| ### Registers Description -#### mstatus +#### MSTATUS --- **Address** 0x300 **Reset Value** 0x1800 **Privilege Mode** M **Description** The mstatus register keeps track of and controls the hart’s current operating state. -|Bits|Field Name|Legal Values|Mask|Access|Description| +|Bits|Field Name|Legal Values|Reset|Type|Description| | :--- | :--- | :--- | :--- | :--- | :--- | -|0|uie|||RW|Stores the state of the user mode interrupts.| -|1|sie|||RW|Stores the state of the supervisor mode interrupts.| -|3|mie|0|1|RW|Stores the state of the machine mode interrupts.| -|4|upie|||RW|Stores the state of the user mode interrupts prior to the trap.| -|5|spie|||RW|Stores the state of the supervisor mode interrupts prior to the trap.| -|7|mpie|0|1|RW|Stores the state of the machine mode interrupts prior to the trap.| -|8|spp|||RW|Stores the previous priority mode for supervisor.| -|[12:11]|mpp|0|3|RW|Stores the previous priority mode for machine.| -|[14:13]|fs|||RW|Encodes the status of the floating-point unit, including the CSR fcsr and floating-point data registers.| -|[16:15]|xs|||RW|Encodes the status of additional user-mode extensions and associated state.| -|17|mprv|||RW|Modifies the privilege level at which loads and stores execute in all privilege modes.| -|18|sum|||RW|Modifies the privilege with which S-mode loads and stores access virtual memory.| -|19|mxr|||RW|Modifies the privilege with which loads access virtual memory.| -|20|tvm|||RW|Supports intercepting supervisor virtual-memory management operations.| -|21|tw|||RW|Supports intercepting the WFI instruction.| -|22|tsr|||RW|Supports intercepting the supervisor exception return instruction.| -|23|spelp|||RW|Supervisor mode previous expected-landing-pad (ELP) state.| -|31|sd|||RW|Read-only bit that summarizes whether either the FS field or XS field signals the presence of some dirty state.| -|[30:24]|Reserved_24|||Reserved|Reserved| +|0|UIE||0x0|WARL|Stores the state of the user mode interrupts.| +|1|SIE||0x0|WARL|Stores the state of the supervisor mode interrupts.| +|2|RESERVED_2||0x0|WPRI|RESERVED| +|3|MIE|[0 , 1]|0x0|WLRL|Stores the state of the machine mode interrupts.| +|4|UPIE||0x0|WARL|Stores the state of the user mode interrupts prior to the trap.| +|5|SPIE||0x0|WARL|Stores the state of the supervisor mode interrupts prior to the trap.| +|6|RESERVED_6||0x0|WPRI|RESERVED| +|7|MPIE|[0 , 1]|0x0|WLRL|Stores the state of the machine mode interrupts prior to the trap.| +|8|SPP||0x0|WARL|Stores the previous priority mode for supervisor.| +|[10:9]|RESERVED_9||0x0|WPRI|RESERVED| +|[12:11]|MPP|[0x3]|0x3|WARL|Stores the previous priority mode for machine.| +|[14:13]|FS||0x0|WARL|Encodes the status of the floating-point unit, including the CSR fcsr and floating-point data registers.| +|[16:15]|XS||0x0|WARL|Encodes the status of additional user-mode extensions and associated state.| +|17|MPRV||0x0|WARL|Modifies the privilege level at which loads and stores execute in all privilege modes.| +|18|SUM||0x0|WARL|Modifies the privilege with which S-mode loads and stores access virtual memory.| +|19|MXR||0x0|WARL|Modifies the privilege with which loads access virtual memory.| +|20|TVM||0x0|WARL|Supports intercepting supervisor virtual-memory management operations.| +|21|TW||0x0|WARL|Supports intercepting the WFI instruction.| +|22|TSR||0x0|WARL|Supports intercepting the supervisor exception return instruction.| +|23|SPELP||0x0|WARL|Supervisor mode previous expected-landing-pad (ELP) state.| +|[30:24]|RESERVED_24||0x0|WPRI|RESERVED| +|31|SD||0x0|WARL|Read-only bit that summarizes whether either the FS field or XS field signals the presence of some dirty state.| -#### mstatush +#### MSTATUSH --- **Address** 0x300 **Reset Value** 0x0 **Privilege Mode** M **Description** The mstatush register keeps track of and controls the hart’s current operating state. -|Bits|Field Name|Legal Values|Mask|Access|Description| +|Bits|Field Name|Legal Values|Reset|Type|Description| | :--- | :--- | :--- | :--- | :--- | :--- | -|4|sbe|||RW|control the endianness of memory accesses other than instruction fetches for supervisor mode| -|5|mbe|||RW|control the endianness of memory accesses other than instruction fetches for machine mode| -|6|gva|||RW|Stores the state of the supervisor mode interrupts.| -|7|mpv|||RW|Stores the state of the user mode interrupts.| -|9|mpelp|||RW|Machine mode previous expected-landing-pad (ELP) state.| -|[31:10]|Reserved_10|||Reserved|Reserved| +|[3:0]|RESERVED_0||0x0|WPRI|RESERVED| +|4|SBE||0x0|WARL|control the endianness of memory accesses other than instruction fetches for supervisor mode| +|5|MBE||0x0|WARL|control the endianness of memory accesses other than instruction fetches for machine mode| +|6|GVA||0x0|WARL|Stores the state of the supervisor mode interrupts.| +|7|MPV||0x0|WARL|Stores the state of the user mode interrupts.| +|8|RESERVED_8||0x0|WPRI|RESERVED| +|9|MPELP||0x0|WARL|Machine mode previous expected-landing-pad (ELP) state.| +|[31:10]|RESERVED_10||0x0|WPRI|RESERVED| -#### misa +#### MISA --- **Address** 0x301 -**Reset Value** 0x40001104 +**Reset Value** 0x40001106 **Privilege Mode** M **Description** misa is a read-write register reporting the ISA supported by the hart. -|Bits|Field Name|Legal Values|Mask|Access|Description| +|Bits|Field Name|Legal Values|Reset|Type|Description| | :--- | :--- | :--- | :--- | :--- | :--- | -|[25:0]|extensions|0x0000000|0x3FFFFFF|RW|Encodes the presence of the standard extensions, with a single bit per letter of the alphabet.| -|[31:30]|mxl|0|1||Encodes the native base integer ISA width.| -|[29:26]|Reserved_26|||Reserved|Reserved| +|[25:0]|EXTENSIONS|[0x0000000:0x3FFFFFF]|0x1106|WARL|Encodes the presence of the standard extensions, with a single bit per letter of the alphabet.| +|[29:26]|RESERVED_26||0x0|WPRI|RESERVED| +|[31:30]|MXL|[0x1]|0x1|WARL|Encodes the native base integer ISA width.| -#### mie +#### MIE --- **Address** 0x304 **Reset Value** 0x0 **Privilege Mode** M **Description** The mie register is an MXLEN-bit read/write register containing interrupt enable bits. -|Bits|Field Name|Legal Values|Mask|Access|Description| +|Bits|Field Name|Legal Values|Reset|Type|Description| | :--- | :--- | :--- | :--- | :--- | :--- | -|0|usie|||RW|User Software Interrupt enable.| -|1|ssie|||RW|Supervisor Software Interrupt enable.| -|2|vssie|||RW|VS-level Software Interrupt enable.| -|3|msie|0x0|0x1|RW|Machine Software Interrupt enable.| -|4|utie|||RW|User Timer Interrupt enable.| -|5|stie|||RW|Supervisor Timer Interrupt enable.| -|6|vstie|||RW|VS-level Timer Interrupt enable.| -|7|mtie|0|1|RW|Machine Timer Interrupt enable.| -|8|ueie|||RW|User External Interrupt enable.| -|9|seie|||RW|Supervisor External Interrupt enable.| -|10|vseie|||RW|VS-level External Interrupt enable.| -|11|meie|0|1|RW|Machine External Interrupt enable.| -|12|sgeie|||RW|HS-level External Interrupt enable.| -|[31:13]|Reserved_13|||Reserved|Reserved| +|0|USIE||0x0|WARL|User Software Interrupt enable.| +|1|SSIE||0x0|WARL|Supervisor Software Interrupt enable.| +|2|VSSIE||0x0|WARL|VS-level Software Interrupt enable.| +|3|MSIE|[0x0 , 0x1]|0x0|WLRL|Machine Software Interrupt enable.| +|4|UTIE||0x0|WARL|User Timer Interrupt enable.| +|5|STIE||0x0|WARL|Supervisor Timer Interrupt enable.| +|6|VSTIE||0x0|WARL|VS-level Timer Interrupt enable.| +|7|MTIE|[0 , 1]|0x0|WLRL|Machine Timer Interrupt enable.| +|8|UEIE||0x0|WARL|User External Interrupt enable.| +|9|SEIE||0x0|WARL|Supervisor External Interrupt enable.| +|10|VSEIE||0x0|WARL|VS-level External Interrupt enable.| +|11|MEIE|[0 , 1]|0x0|WLRL|Machine External Interrupt enable.| +|12|SGEIE||0x0|WARL|HS-level External Interrupt enable.| +|[31:13]|RESERVED_13||0x0|WPRI|RESERVED| -#### mtvec +#### MTVEC --- **Address** 0x305 **Reset Value** 0x80010000 **Privilege Mode** M **Description** MXLEN-bit read/write register that holds trap vector configuration. -|Bits|Field Name|Legal Values|Mask|Access|Description| +|Bits|Field Name|Legal Values|Reset|Type|Description| | :--- | :--- | :--- | :--- | :--- | :--- | -|[1:0]|mode|0|0|RW|Vector mode.| -|[31:2]|base|0x3FFFFFFF|0x00000000|RW|Vector base address.| +|[1:0]|MODE|[0x0]|0x0|WARL|Vector mode.| +|[31:2]|BASE|[0x3FFFFFFF, 0x00000000]|0x20004000|WARL|Vector base address.| -#### mcountinhibit - ---- -**Address** 0x320 -**Reset Value** 0x0 -**Privilege Mode** M -**Description** The mcountinhibit is a 32-bit WARL register that controls which of the hardware performance-monitoring counters increment. -|Bits|Field Name|Legal Values|Mask|Access|Description| -| :--- | :--- | :--- | :--- | :--- | :--- | -|[31:0]|mcountinhibit|0x00000000|0xFFFFFFFF|RW|The mcountinhibit is a 32-bit WARL register that controls which of the hardware performance-monitoring counters increment.| - -#### mhpmevent[3-31] +#### MHPMEVENT[3-31] --- **Address** 0x323-0x33f **Reset Value** 0x0 **Privilege Mode** M **Description** The mhpmevent is a MXLEN-bit event register which controls mhpmcounter3. -|Bits|Field Name|Legal Values|Mask|Access|Description| +|Bits|Field Name|Legal Values|Reset|Type|Description| | :--- | :--- | :--- | :--- | :--- | :--- | -|[31:0]|mhpmevent[i]|0x00000000|0xFFFFFFFF|RW|The mhpmevent is a MXLEN-bit event register which controls mhpmcounter3.| +|[31:0]|MHPMEVENT[I]|[0x00000000 , 0xFFFFFFFF]|0x00000000|WARL|The mhpmevent is a MXLEN-bit event register which controls mhpmcounter3.| -#### mscratch +#### MSCRATCH --- **Address** 0x340 **Reset Value** 0x0 **Privilege Mode** M **Description** The mscratch register is an MXLEN-bit read/write register dedicated for use by machine mode. -|Bits|Field Name|Legal Values|Mask|Access|Description| +|Bits|Field Name|Legal Values|Reset|Type|Description| | :--- | :--- | :--- | :--- | :--- | :--- | -|[31:0]|mscratch|0x00000000|0xFFFFFFFF|RW|The mscratch register is an MXLEN-bit read/write register dedicated for use by machine mode.| +|[31:0]|MSCRATCH|[0x00000000 , 0xFFFFFFFF]|0x00000000|WARL|The mscratch register is an MXLEN-bit read/write register dedicated for use by machine mode.| -#### mepc +#### MEPC --- **Address** 0x341 **Reset Value** 0x0 **Privilege Mode** M **Description** The mepc is a warl register that must be able to hold all valid physical and virtual addresses. -|Bits|Field Name|Legal Values|Mask|Access|Description| +|Bits|Field Name|Legal Values|Reset|Type|Description| | :--- | :--- | :--- | :--- | :--- | :--- | -|[31:0]|mepc|0x00000000|0xFFFFFFFF|RW|The mepc is a warl register that must be able to hold all valid physical and virtual addresses.| +|[31:0]|MEPC|[0x00000000 , 0xFFFFFFFF]|0x00000000|WARL|The mepc is a warl register that must be able to hold all valid physical and virtual addresses.| -#### mcause +#### MCAUSE --- **Address** 0x342 **Reset Value** 0x0 **Privilege Mode** M **Description** The mcause register stores the information regarding the trap. -|Bits|Field Name|Legal Values|Mask|Access|Description| +|Bits|Field Name|Legal Values|Reset|Type|Description| | :--- | :--- | :--- | :--- | :--- | :--- | -|[30:0]|exception_code|0|15|RW|Encodes the exception code.| -|31|interrupt|0x0|0x1|RW|Indicates whether the trap was due to an interrupt.| +|[30:0]|EXCEPTION_CODE|[0 , 15]|0x0|WLRL|Encodes the exception code.| +|31|INTERRUPT|[0x0 , 0x1]|0x0|WLRL|Indicates whether the trap was due to an interrupt.| -#### mtval +#### MTVAL --- **Address** 0x343 **Reset Value** 0x0 **Privilege Mode** M **Description** The mtval is a warl register that holds the address of the instruction which caused the exception. -|Bits|Field Name|Legal Values|Mask|Access|Description| +|Bits|Field Name|Legal Values|Reset|Type|Description| | :--- | :--- | :--- | :--- | :--- | :--- | -|[31:0]|mtval|0x00000000|0xFFFFFFFF|RW|The mtval is a warl register that holds the address of the instruction which caused the exception.| +|[31:0]|MTVAL|[0x00000000 , 0xFFFFFFFF]|0x00000000|WARL|The mtval is a warl register that holds the address of the instruction which caused the exception.| -#### mip +#### MIP --- **Address** 0x344 **Reset Value** 0x0 **Privilege Mode** M **Description** The mip register is an MXLEN-bit read/write register containing information on pending interrupts. -|Bits|Field Name|Legal Values|Mask|Access|Description| +|Bits|Field Name|Legal Values|Reset|Type|Description| | :--- | :--- | :--- | :--- | :--- | :--- | -|0|usip|||RW|User Software Interrupt Pending.| -|1|ssip|||RW|Supervisor Software Interrupt Pending.| -|2|vssip|||RW|VS-level Software Interrupt Pending.| -|3|msip|0x1|0|RW|Machine Software Interrupt Pending.| -|4|utip|||RW|User Timer Interrupt Pending.| -|5|stip|||RW|Supervisor Timer Interrupt Pending.| -|6|vstip|||RW|VS-level Timer Interrupt Pending.| -|7|mtip|0x1|0|RW|Machine Timer Interrupt Pending.| -|8|ueip|||RW|User External Interrupt Pending.| -|9|seip|||RW|Supervisor External Interrupt Pending.| -|10|vseip|||RW|VS-level External Interrupt Pending.| -|11|meip|0x1|0|RW|Machine External Interrupt Pending.| -|12|sgeip|||RW|HS-level External Interrupt Pending.| -|[31:13]|Reserved_13|||Reserved|Reserved| +|0|USIP||0x0|WARL|User Software Interrupt Pending.| +|1|SSIP||0x0|WARL|Supervisor Software Interrupt Pending.| +|2|VSSIP||0x0|WARL|VS-level Software Interrupt Pending.| +|3|MSIP|0x1|0x0|RO_VARIABLE|Machine Software Interrupt Pending.| +|4|UTIP||0x0|WARL|User Timer Interrupt Pending.| +|5|STIP||0x0|WARL|Supervisor Timer Interrupt Pending.| +|6|VSTIP||0x0|WARL|VS-level Timer Interrupt Pending.| +|7|MTIP|0x1|0x0|RO_VARIABLE|Machine Timer Interrupt Pending.| +|8|UEIP||0x0|WARL|User External Interrupt Pending.| +|9|SEIP||0x0|WARL|Supervisor External Interrupt Pending.| +|10|VSEIP||0x0|WARL|VS-level External Interrupt Pending.| +|11|MEIP|0x1|0x0|RO_VARIABLE|Machine External Interrupt Pending.| +|12|SGEIP||0x0|WARL|HS-level External Interrupt Pending.| +|[31:13]|RESERVED_13||0x0|WPRI|RESERVED| -#### pmpcfg[0-15] +#### PMPCFG[0-1] --- -**Address** 0x3a0-0x3af +**Address** 0x3a0-0x3a1 **Reset Value** 0x0 **Privilege Mode** M **Description** PMP configuration register -|Bits|Field Name|Legal Values|Mask|Access|Description| +|Bits|Field Name|Legal Values|Reset|Type|Description| | :--- | :--- | :--- | :--- | :--- | :--- | -|[7:0]|pmp[i*4 + 0]cfg|0x00|0xFF|RW|pmp configuration bits| -|[15:8]|pmp[i*4 + 1]cfg|0x00|0xFF|RW|pmp configuration bits| -|[23:16]|pmp[i*4 + 2]cfg|0x00|0xFF|RW|pmp configuration bits| -|[31:24]|pmp[i*4 + 3]cfg|0x00|0xFF|RW|pmp configuration bits| +|[7:0]|PMP[I*4 + 0]CFG|[0x00:0xFF]|0x0|WARL|pmp configuration bits| +|[15:8]|PMP[I*4 + 1]CFG|[0x00:0xFF]|0x0|WARL|pmp configuration bits| +|[23:16]|PMP[I*4 + 2]CFG|[0x00:0xFF]|0x0|WARL|pmp configuration bits| +|[31:24]|PMP[I*4 + 3]CFG|[0x00:0xFF]|0x0|WARL|pmp configuration bits| -#### pmpaddr[0-63] +#### PMPADDR[0-7] --- -**Address** 0x3b0-0x3ef -**Reset Value** 0x20 +**Address** 0x3b0-0x3b7 +**Reset Value** 0x0 **Privilege Mode** M **Description** Physical memory protection address register -|Bits|Field Name|Legal Values|Mask|Access|Description| +|Bits|Field Name|Legal Values|Reset|Type|Description| | :--- | :--- | :--- | :--- | :--- | :--- | -|[31:0]|pmpaddr[i]|0x00000000|0xFFFFFFFF|RW|Physical memory protection address register| +|[31:0]|PMPADDR[I]|[0x00000000 , 0xFFFFFFFF]|0x00000000|WARL|Physical memory protection address register| -#### mcycle +#### MCYCLE --- **Address** 0xb00 -**Reset Value** 0x1e253 +**Reset Value** 0x0 **Privilege Mode** M **Description** Counts the number of clock cycles executed from an arbitrary point in time. -|Bits|Field Name|Legal Values|Mask|Access|Description| +|Bits|Field Name|Legal Values|Reset|Type|Description| | :--- | :--- | :--- | :--- | :--- | :--- | -|[31:0]|mcycle|0x00000000|0xFFFFFFFF|RW|Counts the number of clock cycles executed from an arbitrary point in time.| +|[31:0]|MCYCLE|[0x00000000 , 0xFFFFFFFF]|0x00000000|WARL|Counts the number of clock cycles executed from an arbitrary point in time.| -#### minstret +#### MINSTRET --- **Address** 0xb02 **Reset Value** 0x0 **Privilege Mode** M **Description** Counts the number of instructions completed from an arbitrary point in time. -|Bits|Field Name|Legal Values|Mask|Access|Description| +|Bits|Field Name|Legal Values|Reset|Type|Description| | :--- | :--- | :--- | :--- | :--- | :--- | -|[31:0]|minstret|0x00000000|0xFFFFFFFF|RW|Counts the number of instructions completed from an arbitrary point in time.| +|[31:0]|MINSTRET|[0x00000000 , 0xFFFFFFFF]|0x00000000|WARL|Counts the number of instructions completed from an arbitrary point in time.| -#### mhpmcounter[3-31] +#### MHPMCOUNTER[3-31] --- **Address** 0xb03-0xb1f **Reset Value** 0x0 **Privilege Mode** M **Description** The mhpmcounter is a 64-bit counter. Returns lower 32 bits in RV32I mode. -|Bits|Field Name|Legal Values|Mask|Access|Description| +|Bits|Field Name|Legal Values|Reset|Type|Description| | :--- | :--- | :--- | :--- | :--- | :--- | -|[31:0]|mhpmcounter[i]|0x00000000|0xFFFFFFFF|RW|The mhpmcounter is a 64-bit counter. Returns lower 32 bits in RV32I mode.| +|[31:0]|MHPMCOUNTER[I]|[0x00000000 , 0xFFFFFFFF]|0x00000000|WARL|The mhpmcounter is a 64-bit counter. Returns lower 32 bits in RV32I mode.| -#### mcycleh +#### MCYCLEH --- **Address** 0xb80 **Reset Value** 0x0 **Privilege Mode** M **Description** upper 32 bits of mcycle -|Bits|Field Name|Legal Values|Mask|Access|Description| +|Bits|Field Name|Legal Values|Reset|Type|Description| | :--- | :--- | :--- | :--- | :--- | :--- | -|[31:0]|mcycleh|0x00000000|0xFFFFFFFF|RW|upper 32 bits of mcycle| +|[31:0]|MCYCLEH|[0x00000000 , 0xFFFFFFFF]|0x00000000|WARL|upper 32 bits of mcycle| -#### minstreth +#### MINSTRETH --- **Address** 0xb82 **Reset Value** 0x0 **Privilege Mode** M **Description** Upper 32 bits of minstret. -|Bits|Field Name|Legal Values|Mask|Access|Description| +|Bits|Field Name|Legal Values|Reset|Type|Description| | :--- | :--- | :--- | :--- | :--- | :--- | -|[31:0]|minstreth|0x00000000|0xFFFFFFFF|RW|Upper 32 bits of minstret.| +|[31:0]|MINSTRETH|[0x00000000 , 0xFFFFFFFF]|0x00000000|WARL|Upper 32 bits of minstret.| -#### mhpmcounter[3-31]h +#### MHPMCOUNTER[3-31]H --- **Address** 0xb83-0xb9f **Reset Value** 0x0 **Privilege Mode** M **Description** The mhpmcounterh returns the upper half word in RV32I systems. -|Bits|Field Name|Legal Values|Mask|Access|Description| +|Bits|Field Name|Legal Values|Reset|Type|Description| | :--- | :--- | :--- | :--- | :--- | :--- | -|[31:0]|mhpmcounter[i]h|0x00000000|0xFFFFFFFF|RW|The mhpmcounterh returns the upper half word in RV32I systems.| +|[31:0]|MHPMCOUNTER[I]H|[0x00000000 , 0xFFFFFFFF]|0x00000000|WARL|The mhpmcounterh returns the upper half word in RV32I systems.| -#### mvendorid +#### MVENDORID --- **Address** 0xf11 **Reset Value** 0x602 **Privilege Mode** M -**Description** -|Bits|Field Name|Legal Values|Mask|Access|Description| +**Description** 32-bit read-only register providing the JEDEC manufacturer ID of the provider of the core. +|Bits|Field Name|Legal Values|Reset|Type|Description| | :--- | :--- | :--- | :--- | :--- | :--- | -|[31:0]|mvendorid|0x602|0|RW|| +|[31:0]|MVENDORID|0x00000602|0x00000602|RO_CONSTANT|32-bit read-only register providing the JEDEC manufacturer ID of the provider of the core.| -#### marchid +#### MARCHID --- **Address** 0xf12 **Reset Value** 0x3 **Privilege Mode** M **Description** MXLEN-bit read-only register encoding the base microarchitecture of the hart. -|Bits|Field Name|Legal Values|Mask|Access|Description| +|Bits|Field Name|Legal Values|Reset|Type|Description| | :--- | :--- | :--- | :--- | :--- | :--- | -|[31:0]|marchid|0x3|0|RW|MXLEN-bit read-only register encoding the base microarchitecture of the hart.| +|[31:0]|MARCHID|0x00000003|0x00000003|RO_CONSTANT|MXLEN-bit read-only register encoding the base microarchitecture of the hart.| -#### mimpid +#### MIMPID --- **Address** 0xf13 **Reset Value** 0x0 **Privilege Mode** M **Description** Provides a unique encoding of the version of the processor implementation. -|Bits|Field Name|Legal Values|Mask|Access|Description| +|Bits|Field Name|Legal Values|Reset|Type|Description| | :--- | :--- | :--- | :--- | :--- | :--- | -|[31:0]|mimpid|0x0|0|RW|Provides a unique encoding of the version of the processor implementation.| +|[31:0]|MIMPID|0x00000000|0x00000000|RO_CONSTANT|Provides a unique encoding of the version of the processor implementation.| -#### mhartid +#### MHARTID --- **Address** 0xf14 **Reset Value** 0x0 **Privilege Mode** M **Description** MXLEN-bit read-only register containing the integer ID of the hardware thread running the code. -|Bits|Field Name|Legal Values|Mask|Access|Description| +|Bits|Field Name|Legal Values|Reset|Type|Description| | :--- | :--- | :--- | :--- | :--- | :--- | -|[31:0]|mhartid|0x0|0|RW|MXLEN-bit read-only register containing the integer ID of the hardware thread running the code.| +|[31:0]|MHARTID|0x00000000|0x00000000|RO_CONSTANT|MXLEN-bit read-only register containing the integer ID of the hardware thread running the code.| diff --git a/config/gen_from_riscv_config/cv32a65x/csr/csr.rst b/config/gen_from_riscv_config/cv32a65x/csr/csr.rst index 5b8eccc2b1..8eaf9afe39 100644 --- a/config/gen_from_riscv_config/cv32a65x/csr/csr.rst +++ b/config/gen_from_riscv_config/cv32a65x/csr/csr.rst @@ -12,61 +12,59 @@ csr Register Summary ---------------- -+-------------+--------------------+----------------------------------------------------------------------------------------------------------------------------+ -| Address | Register Name | Description | -+=============+====================+============================================================================================================================+ -| 0x300 | mstatus | The mstatus register keeps track of and controls the hart’s current operating state. | -+-------------+--------------------+----------------------------------------------------------------------------------------------------------------------------+ -| 0x300 | mstatush | The mstatush register keeps track of and controls the hart’s current operating state. | -+-------------+--------------------+----------------------------------------------------------------------------------------------------------------------------+ -| 0x301 | misa | misa is a read-write register reporting the ISA supported by the hart. | -+-------------+--------------------+----------------------------------------------------------------------------------------------------------------------------+ -| 0x304 | mie | The mie register is an MXLEN-bit read/write register containing interrupt enable bits. | -+-------------+--------------------+----------------------------------------------------------------------------------------------------------------------------+ -| 0x305 | mtvec | MXLEN-bit read/write register that holds trap vector configuration. | -+-------------+--------------------+----------------------------------------------------------------------------------------------------------------------------+ -| 0x320 | mcountinhibit | The mcountinhibit is a 32-bit WARL register that controls which of the hardware performance-monitoring counters increment. | -+-------------+--------------------+----------------------------------------------------------------------------------------------------------------------------+ -| 0x323-0x33f | mhpmevent[3-31] | The mhpmevent is a MXLEN-bit event register which controls mhpmcounter3. | -+-------------+--------------------+----------------------------------------------------------------------------------------------------------------------------+ -| 0x340 | mscratch | The mscratch register is an MXLEN-bit read/write register dedicated for use by machine mode. | -+-------------+--------------------+----------------------------------------------------------------------------------------------------------------------------+ -| 0x341 | mepc | The mepc is a warl register that must be able to hold all valid physical and virtual addresses. | -+-------------+--------------------+----------------------------------------------------------------------------------------------------------------------------+ -| 0x342 | mcause | The mcause register stores the information regarding the trap. | -+-------------+--------------------+----------------------------------------------------------------------------------------------------------------------------+ -| 0x343 | mtval | The mtval is a warl register that holds the address of the instruction which caused the exception. | -+-------------+--------------------+----------------------------------------------------------------------------------------------------------------------------+ -| 0x344 | mip | The mip register is an MXLEN-bit read/write register containing information on pending interrupts. | -+-------------+--------------------+----------------------------------------------------------------------------------------------------------------------------+ -| 0x3a0-0x3af | pmpcfg[0-15] | PMP configuration register | -+-------------+--------------------+----------------------------------------------------------------------------------------------------------------------------+ -| 0x3b0-0x3ef | pmpaddr[0-63] | Physical memory protection address register | -+-------------+--------------------+----------------------------------------------------------------------------------------------------------------------------+ -| 0xb00 | mcycle | Counts the number of clock cycles executed from an arbitrary point in time. | -+-------------+--------------------+----------------------------------------------------------------------------------------------------------------------------+ -| 0xb02 | minstret | Counts the number of instructions completed from an arbitrary point in time. | -+-------------+--------------------+----------------------------------------------------------------------------------------------------------------------------+ -| 0xb03-0xb1f | mhpmcounter[3-31] | The mhpmcounter is a 64-bit counter. Returns lower 32 bits in RV32I mode. | -+-------------+--------------------+----------------------------------------------------------------------------------------------------------------------------+ -| 0xb80 | mcycleh | upper 32 bits of mcycle | -+-------------+--------------------+----------------------------------------------------------------------------------------------------------------------------+ -| 0xb82 | minstreth | Upper 32 bits of minstret. | -+-------------+--------------------+----------------------------------------------------------------------------------------------------------------------------+ -| 0xb83-0xb9f | mhpmcounter[3-31]h | The mhpmcounterh returns the upper half word in RV32I systems. | -+-------------+--------------------+----------------------------------------------------------------------------------------------------------------------------+ -| 0xf11 | mvendorid | | -+-------------+--------------------+----------------------------------------------------------------------------------------------------------------------------+ -| 0xf12 | marchid | MXLEN-bit read-only register encoding the base microarchitecture of the hart. | -+-------------+--------------------+----------------------------------------------------------------------------------------------------------------------------+ -| 0xf13 | mimpid | Provides a unique encoding of the version of the processor implementation. | -+-------------+--------------------+----------------------------------------------------------------------------------------------------------------------------+ -| 0xf14 | mhartid | MXLEN-bit read-only register containing the integer ID of the hardware thread running the code. | -+-------------+--------------------+----------------------------------------------------------------------------------------------------------------------------+ ++-------------+--------------------+----------------------------------------------------------------------------------------------------+ +| Address | Register Name | Description | ++=============+====================+====================================================================================================+ +| 0x300 | MSTATUS | The mstatus register keeps track of and controls the hart’s current operating state. | ++-------------+--------------------+----------------------------------------------------------------------------------------------------+ +| 0x300 | MSTATUSH | The mstatush register keeps track of and controls the hart’s current operating state. | ++-------------+--------------------+----------------------------------------------------------------------------------------------------+ +| 0x301 | MISA | misa is a read-write register reporting the ISA supported by the hart. | ++-------------+--------------------+----------------------------------------------------------------------------------------------------+ +| 0x304 | MIE | The mie register is an MXLEN-bit read/write register containing interrupt enable bits. | ++-------------+--------------------+----------------------------------------------------------------------------------------------------+ +| 0x305 | MTVEC | MXLEN-bit read/write register that holds trap vector configuration. | ++-------------+--------------------+----------------------------------------------------------------------------------------------------+ +| 0x323-0x33f | MHPMEVENT[3-31] | The mhpmevent is a MXLEN-bit event register which controls mhpmcounter3. | ++-------------+--------------------+----------------------------------------------------------------------------------------------------+ +| 0x340 | MSCRATCH | The mscratch register is an MXLEN-bit read/write register dedicated for use by machine mode. | ++-------------+--------------------+----------------------------------------------------------------------------------------------------+ +| 0x341 | MEPC | The mepc is a warl register that must be able to hold all valid physical and virtual addresses. | ++-------------+--------------------+----------------------------------------------------------------------------------------------------+ +| 0x342 | MCAUSE | The mcause register stores the information regarding the trap. | ++-------------+--------------------+----------------------------------------------------------------------------------------------------+ +| 0x343 | MTVAL | The mtval is a warl register that holds the address of the instruction which caused the exception. | ++-------------+--------------------+----------------------------------------------------------------------------------------------------+ +| 0x344 | MIP | The mip register is an MXLEN-bit read/write register containing information on pending interrupts. | ++-------------+--------------------+----------------------------------------------------------------------------------------------------+ +| 0x3a0-0x3a1 | PMPCFG[0-1] | PMP configuration register | ++-------------+--------------------+----------------------------------------------------------------------------------------------------+ +| 0x3b0-0x3b7 | PMPADDR[0-7] | Physical memory protection address register | ++-------------+--------------------+----------------------------------------------------------------------------------------------------+ +| 0xb00 | MCYCLE | Counts the number of clock cycles executed from an arbitrary point in time. | ++-------------+--------------------+----------------------------------------------------------------------------------------------------+ +| 0xb02 | MINSTRET | Counts the number of instructions completed from an arbitrary point in time. | ++-------------+--------------------+----------------------------------------------------------------------------------------------------+ +| 0xb03-0xb1f | MHPMCOUNTER[3-31] | The mhpmcounter is a 64-bit counter. Returns lower 32 bits in RV32I mode. | ++-------------+--------------------+----------------------------------------------------------------------------------------------------+ +| 0xb80 | MCYCLEH | upper 32 bits of mcycle | ++-------------+--------------------+----------------------------------------------------------------------------------------------------+ +| 0xb82 | MINSTRETH | Upper 32 bits of minstret. | ++-------------+--------------------+----------------------------------------------------------------------------------------------------+ +| 0xb83-0xb9f | MHPMCOUNTER[3-31]H | The mhpmcounterh returns the upper half word in RV32I systems. | ++-------------+--------------------+----------------------------------------------------------------------------------------------------+ +| 0xf11 | MVENDORID | 32-bit read-only register providing the JEDEC manufacturer ID of the provider of the core. | ++-------------+--------------------+----------------------------------------------------------------------------------------------------+ +| 0xf12 | MARCHID | MXLEN-bit read-only register encoding the base microarchitecture of the hart. | ++-------------+--------------------+----------------------------------------------------------------------------------------------------+ +| 0xf13 | MIMPID | Provides a unique encoding of the version of the processor implementation. | ++-------------+--------------------+----------------------------------------------------------------------------------------------------+ +| 0xf14 | MHARTID | MXLEN-bit read-only register containing the integer ID of the hardware thread running the code. | ++-------------+--------------------+----------------------------------------------------------------------------------------------------+ Register Description -------------------- -mstatus +MSTATUS ------- :Address: 0x300 @@ -75,49 +73,55 @@ mstatus :Description: The mstatus register keeps track of and controls the hart’s current operating state. -+---------+--------------+----------------+--------+----------+-----------------------------------------------------------------------------------------------------------------+ -| Bits | Field Name | Legal Values | Mask | Access | Description | -+=========+==============+================+========+==========+=================================================================================================================+ -| 0 | uie | | | RW | Stores the state of the user mode interrupts. | -+---------+--------------+----------------+--------+----------+-----------------------------------------------------------------------------------------------------------------+ -| 1 | sie | | | RW | Stores the state of the supervisor mode interrupts. | -+---------+--------------+----------------+--------+----------+-----------------------------------------------------------------------------------------------------------------+ -| 3 | mie | 0 | 1 | RW | Stores the state of the machine mode interrupts. | -+---------+--------------+----------------+--------+----------+-----------------------------------------------------------------------------------------------------------------+ -| 4 | upie | | | RW | Stores the state of the user mode interrupts prior to the trap. | -+---------+--------------+----------------+--------+----------+-----------------------------------------------------------------------------------------------------------------+ -| 5 | spie | | | RW | Stores the state of the supervisor mode interrupts prior to the trap. | -+---------+--------------+----------------+--------+----------+-----------------------------------------------------------------------------------------------------------------+ -| 7 | mpie | 0 | 1 | RW | Stores the state of the machine mode interrupts prior to the trap. | -+---------+--------------+----------------+--------+----------+-----------------------------------------------------------------------------------------------------------------+ -| 8 | spp | | | RW | Stores the previous priority mode for supervisor. | -+---------+--------------+----------------+--------+----------+-----------------------------------------------------------------------------------------------------------------+ -| [12:11] | mpp | 0 | 3 | RW | Stores the previous priority mode for machine. | -+---------+--------------+----------------+--------+----------+-----------------------------------------------------------------------------------------------------------------+ -| [14:13] | fs | | | RW | Encodes the status of the floating-point unit, including the CSR fcsr and floating-point data registers. | -+---------+--------------+----------------+--------+----------+-----------------------------------------------------------------------------------------------------------------+ -| [16:15] | xs | | | RW | Encodes the status of additional user-mode extensions and associated state. | -+---------+--------------+----------------+--------+----------+-----------------------------------------------------------------------------------------------------------------+ -| 17 | mprv | | | RW | Modifies the privilege level at which loads and stores execute in all privilege modes. | -+---------+--------------+----------------+--------+----------+-----------------------------------------------------------------------------------------------------------------+ -| 18 | sum | | | RW | Modifies the privilege with which S-mode loads and stores access virtual memory. | -+---------+--------------+----------------+--------+----------+-----------------------------------------------------------------------------------------------------------------+ -| 19 | mxr | | | RW | Modifies the privilege with which loads access virtual memory. | -+---------+--------------+----------------+--------+----------+-----------------------------------------------------------------------------------------------------------------+ -| 20 | tvm | | | RW | Supports intercepting supervisor virtual-memory management operations. | -+---------+--------------+----------------+--------+----------+-----------------------------------------------------------------------------------------------------------------+ -| 21 | tw | | | RW | Supports intercepting the WFI instruction. | -+---------+--------------+----------------+--------+----------+-----------------------------------------------------------------------------------------------------------------+ -| 22 | tsr | | | RW | Supports intercepting the supervisor exception return instruction. | -+---------+--------------+----------------+--------+----------+-----------------------------------------------------------------------------------------------------------------+ -| 23 | spelp | | | RW | Supervisor mode previous expected-landing-pad (ELP) state. | -+---------+--------------+----------------+--------+----------+-----------------------------------------------------------------------------------------------------------------+ -| 31 | sd | | | RW | Read-only bit that summarizes whether either the FS field or XS field signals the presence of some dirty state. | -+---------+--------------+----------------+--------+----------+-----------------------------------------------------------------------------------------------------------------+ -| [30:24] | Reserved_24 | | | Reserved | Reserved | -+---------+--------------+----------------+--------+----------+-----------------------------------------------------------------------------------------------------------------+ - -mstatush ++---------+--------------+----------------+---------+--------+-----------------------------------------------------------------------------------------------------------------+ +| Bits | Field Name | Legal Values | Reset | Type | Description | ++=========+==============+================+=========+========+=================================================================================================================+ +| 0 | UIE | | 0x0 | WARL | Stores the state of the user mode interrupts. | ++---------+--------------+----------------+---------+--------+-----------------------------------------------------------------------------------------------------------------+ +| 1 | SIE | | 0x0 | WARL | Stores the state of the supervisor mode interrupts. | ++---------+--------------+----------------+---------+--------+-----------------------------------------------------------------------------------------------------------------+ +| 2 | RESERVED_2 | | 0x0 | WPRI | RESERVED | ++---------+--------------+----------------+---------+--------+-----------------------------------------------------------------------------------------------------------------+ +| 3 | MIE | [0 , 1] | 0x0 | WLRL | Stores the state of the machine mode interrupts. | ++---------+--------------+----------------+---------+--------+-----------------------------------------------------------------------------------------------------------------+ +| 4 | UPIE | | 0x0 | WARL | Stores the state of the user mode interrupts prior to the trap. | ++---------+--------------+----------------+---------+--------+-----------------------------------------------------------------------------------------------------------------+ +| 5 | SPIE | | 0x0 | WARL | Stores the state of the supervisor mode interrupts prior to the trap. | ++---------+--------------+----------------+---------+--------+-----------------------------------------------------------------------------------------------------------------+ +| 6 | RESERVED_6 | | 0x0 | WPRI | RESERVED | ++---------+--------------+----------------+---------+--------+-----------------------------------------------------------------------------------------------------------------+ +| 7 | MPIE | [0 , 1] | 0x0 | WLRL | Stores the state of the machine mode interrupts prior to the trap. | ++---------+--------------+----------------+---------+--------+-----------------------------------------------------------------------------------------------------------------+ +| 8 | SPP | | 0x0 | WARL | Stores the previous priority mode for supervisor. | ++---------+--------------+----------------+---------+--------+-----------------------------------------------------------------------------------------------------------------+ +| [10:9] | RESERVED_9 | | 0x0 | WPRI | RESERVED | ++---------+--------------+----------------+---------+--------+-----------------------------------------------------------------------------------------------------------------+ +| [12:11] | MPP | [0x3] | 0x3 | WARL | Stores the previous priority mode for machine. | ++---------+--------------+----------------+---------+--------+-----------------------------------------------------------------------------------------------------------------+ +| [14:13] | FS | | 0x0 | WARL | Encodes the status of the floating-point unit, including the CSR fcsr and floating-point data registers. | ++---------+--------------+----------------+---------+--------+-----------------------------------------------------------------------------------------------------------------+ +| [16:15] | XS | | 0x0 | WARL | Encodes the status of additional user-mode extensions and associated state. | ++---------+--------------+----------------+---------+--------+-----------------------------------------------------------------------------------------------------------------+ +| 17 | MPRV | | 0x0 | WARL | Modifies the privilege level at which loads and stores execute in all privilege modes. | ++---------+--------------+----------------+---------+--------+-----------------------------------------------------------------------------------------------------------------+ +| 18 | SUM | | 0x0 | WARL | Modifies the privilege with which S-mode loads and stores access virtual memory. | ++---------+--------------+----------------+---------+--------+-----------------------------------------------------------------------------------------------------------------+ +| 19 | MXR | | 0x0 | WARL | Modifies the privilege with which loads access virtual memory. | ++---------+--------------+----------------+---------+--------+-----------------------------------------------------------------------------------------------------------------+ +| 20 | TVM | | 0x0 | WARL | Supports intercepting supervisor virtual-memory management operations. | ++---------+--------------+----------------+---------+--------+-----------------------------------------------------------------------------------------------------------------+ +| 21 | TW | | 0x0 | WARL | Supports intercepting the WFI instruction. | ++---------+--------------+----------------+---------+--------+-----------------------------------------------------------------------------------------------------------------+ +| 22 | TSR | | 0x0 | WARL | Supports intercepting the supervisor exception return instruction. | ++---------+--------------+----------------+---------+--------+-----------------------------------------------------------------------------------------------------------------+ +| 23 | SPELP | | 0x0 | WARL | Supervisor mode previous expected-landing-pad (ELP) state. | ++---------+--------------+----------------+---------+--------+-----------------------------------------------------------------------------------------------------------------+ +| [30:24] | RESERVED_24 | | 0x0 | WPRI | RESERVED | ++---------+--------------+----------------+---------+--------+-----------------------------------------------------------------------------------------------------------------+ +| 31 | SD | | 0x0 | WARL | Read-only bit that summarizes whether either the FS field or XS field signals the presence of some dirty state. | ++---------+--------------+----------------+---------+--------+-----------------------------------------------------------------------------------------------------------------+ + +MSTATUSH -------- :Address: 0x300 @@ -126,42 +130,46 @@ mstatush :Description: The mstatush register keeps track of and controls the hart’s current operating state. -+---------+--------------+----------------+--------+----------+----------------------------------------------------------------------------------------------+ -| Bits | Field Name | Legal Values | Mask | Access | Description | -+=========+==============+================+========+==========+==============================================================================================+ -| 4 | sbe | | | RW | control the endianness of memory accesses other than instruction fetches for supervisor mode | -+---------+--------------+----------------+--------+----------+----------------------------------------------------------------------------------------------+ -| 5 | mbe | | | RW | control the endianness of memory accesses other than instruction fetches for machine mode | -+---------+--------------+----------------+--------+----------+----------------------------------------------------------------------------------------------+ -| 6 | gva | | | RW | Stores the state of the supervisor mode interrupts. | -+---------+--------------+----------------+--------+----------+----------------------------------------------------------------------------------------------+ -| 7 | mpv | | | RW | Stores the state of the user mode interrupts. | -+---------+--------------+----------------+--------+----------+----------------------------------------------------------------------------------------------+ -| 9 | mpelp | | | RW | Machine mode previous expected-landing-pad (ELP) state. | -+---------+--------------+----------------+--------+----------+----------------------------------------------------------------------------------------------+ -| [31:10] | Reserved_10 | | | Reserved | Reserved | -+---------+--------------+----------------+--------+----------+----------------------------------------------------------------------------------------------+ - -misa ++---------+--------------+----------------+---------+--------+----------------------------------------------------------------------------------------------+ +| Bits | Field Name | Legal Values | Reset | Type | Description | ++=========+==============+================+=========+========+==============================================================================================+ +| [3:0] | RESERVED_0 | | 0x0 | WPRI | RESERVED | ++---------+--------------+----------------+---------+--------+----------------------------------------------------------------------------------------------+ +| 4 | SBE | | 0x0 | WARL | control the endianness of memory accesses other than instruction fetches for supervisor mode | ++---------+--------------+----------------+---------+--------+----------------------------------------------------------------------------------------------+ +| 5 | MBE | | 0x0 | WARL | control the endianness of memory accesses other than instruction fetches for machine mode | ++---------+--------------+----------------+---------+--------+----------------------------------------------------------------------------------------------+ +| 6 | GVA | | 0x0 | WARL | Stores the state of the supervisor mode interrupts. | ++---------+--------------+----------------+---------+--------+----------------------------------------------------------------------------------------------+ +| 7 | MPV | | 0x0 | WARL | Stores the state of the user mode interrupts. | ++---------+--------------+----------------+---------+--------+----------------------------------------------------------------------------------------------+ +| 8 | RESERVED_8 | | 0x0 | WPRI | RESERVED | ++---------+--------------+----------------+---------+--------+----------------------------------------------------------------------------------------------+ +| 9 | MPELP | | 0x0 | WARL | Machine mode previous expected-landing-pad (ELP) state. | ++---------+--------------+----------------+---------+--------+----------------------------------------------------------------------------------------------+ +| [31:10] | RESERVED_10 | | 0x0 | WPRI | RESERVED | ++---------+--------------+----------------+---------+--------+----------------------------------------------------------------------------------------------+ + +MISA ---- :Address: 0x301 -:Reset Value: 0x40001104 +:Reset Value: 0x40001106 :Privilege Mode: M :Description: misa is a read-write register reporting the ISA supported by the hart. -+---------+--------------+----------------+-----------+----------+------------------------------------------------------------------------------------------------+ -| Bits | Field Name | Legal Values | Mask | Access | Description | -+=========+==============+================+===========+==========+================================================================================================+ -| [25:0] | extensions | 0x0000000 | 0x3FFFFFF | RW | Encodes the presence of the standard extensions, with a single bit per letter of the alphabet. | -+---------+--------------+----------------+-----------+----------+------------------------------------------------------------------------------------------------+ -| [31:30] | mxl | 0 | 1 | | Encodes the native base integer ISA width. | -+---------+--------------+----------------+-----------+----------+------------------------------------------------------------------------------------------------+ -| [29:26] | Reserved_26 | | | Reserved | Reserved | -+---------+--------------+----------------+-----------+----------+------------------------------------------------------------------------------------------------+ - -mie ++---------+--------------+-----------------------+---------+--------+------------------------------------------------------------------------------------------------+ +| Bits | Field Name | Legal Values | Reset | Type | Description | ++=========+==============+=======================+=========+========+================================================================================================+ +| [25:0] | EXTENSIONS | [0x0000000:0x3FFFFFF] | 0x1106 | WARL | Encodes the presence of the standard extensions, with a single bit per letter of the alphabet. | ++---------+--------------+-----------------------+---------+--------+------------------------------------------------------------------------------------------------+ +| [29:26] | RESERVED_26 | | 0x0 | WPRI | RESERVED | ++---------+--------------+-----------------------+---------+--------+------------------------------------------------------------------------------------------------+ +| [31:30] | MXL | [0x1] | 0x1 | WARL | Encodes the native base integer ISA width. | ++---------+--------------+-----------------------+---------+--------+------------------------------------------------------------------------------------------------+ + +MIE --- :Address: 0x304 @@ -170,39 +178,39 @@ mie :Description: The mie register is an MXLEN-bit read/write register containing interrupt enable bits. -+---------+--------------+----------------+--------+----------+---------------------------------------+ -| Bits | Field Name | Legal Values | Mask | Access | Description | -+=========+==============+================+========+==========+=======================================+ -| 0 | usie | | | RW | User Software Interrupt enable. | -+---------+--------------+----------------+--------+----------+---------------------------------------+ -| 1 | ssie | | | RW | Supervisor Software Interrupt enable. | -+---------+--------------+----------------+--------+----------+---------------------------------------+ -| 2 | vssie | | | RW | VS-level Software Interrupt enable. | -+---------+--------------+----------------+--------+----------+---------------------------------------+ -| 3 | msie | 0x0 | 0x1 | RW | Machine Software Interrupt enable. | -+---------+--------------+----------------+--------+----------+---------------------------------------+ -| 4 | utie | | | RW | User Timer Interrupt enable. | -+---------+--------------+----------------+--------+----------+---------------------------------------+ -| 5 | stie | | | RW | Supervisor Timer Interrupt enable. | -+---------+--------------+----------------+--------+----------+---------------------------------------+ -| 6 | vstie | | | RW | VS-level Timer Interrupt enable. | -+---------+--------------+----------------+--------+----------+---------------------------------------+ -| 7 | mtie | 0 | 1 | RW | Machine Timer Interrupt enable. | -+---------+--------------+----------------+--------+----------+---------------------------------------+ -| 8 | ueie | | | RW | User External Interrupt enable. | -+---------+--------------+----------------+--------+----------+---------------------------------------+ -| 9 | seie | | | RW | Supervisor External Interrupt enable. | -+---------+--------------+----------------+--------+----------+---------------------------------------+ -| 10 | vseie | | | RW | VS-level External Interrupt enable. | -+---------+--------------+----------------+--------+----------+---------------------------------------+ -| 11 | meie | 0 | 1 | RW | Machine External Interrupt enable. | -+---------+--------------+----------------+--------+----------+---------------------------------------+ -| 12 | sgeie | | | RW | HS-level External Interrupt enable. | -+---------+--------------+----------------+--------+----------+---------------------------------------+ -| [31:13] | Reserved_13 | | | Reserved | Reserved | -+---------+--------------+----------------+--------+----------+---------------------------------------+ - -mtvec ++---------+--------------+----------------+---------+--------+---------------------------------------+ +| Bits | Field Name | Legal Values | Reset | Type | Description | ++=========+==============+================+=========+========+=======================================+ +| 0 | USIE | | 0x0 | WARL | User Software Interrupt enable. | ++---------+--------------+----------------+---------+--------+---------------------------------------+ +| 1 | SSIE | | 0x0 | WARL | Supervisor Software Interrupt enable. | ++---------+--------------+----------------+---------+--------+---------------------------------------+ +| 2 | VSSIE | | 0x0 | WARL | VS-level Software Interrupt enable. | ++---------+--------------+----------------+---------+--------+---------------------------------------+ +| 3 | MSIE | [0x0 , 0x1] | 0x0 | WLRL | Machine Software Interrupt enable. | ++---------+--------------+----------------+---------+--------+---------------------------------------+ +| 4 | UTIE | | 0x0 | WARL | User Timer Interrupt enable. | ++---------+--------------+----------------+---------+--------+---------------------------------------+ +| 5 | STIE | | 0x0 | WARL | Supervisor Timer Interrupt enable. | ++---------+--------------+----------------+---------+--------+---------------------------------------+ +| 6 | VSTIE | | 0x0 | WARL | VS-level Timer Interrupt enable. | ++---------+--------------+----------------+---------+--------+---------------------------------------+ +| 7 | MTIE | [0 , 1] | 0x0 | WLRL | Machine Timer Interrupt enable. | ++---------+--------------+----------------+---------+--------+---------------------------------------+ +| 8 | UEIE | | 0x0 | WARL | User External Interrupt enable. | ++---------+--------------+----------------+---------+--------+---------------------------------------+ +| 9 | SEIE | | 0x0 | WARL | Supervisor External Interrupt enable. | ++---------+--------------+----------------+---------+--------+---------------------------------------+ +| 10 | VSEIE | | 0x0 | WARL | VS-level External Interrupt enable. | ++---------+--------------+----------------+---------+--------+---------------------------------------+ +| 11 | MEIE | [0 , 1] | 0x0 | WLRL | Machine External Interrupt enable. | ++---------+--------------+----------------+---------+--------+---------------------------------------+ +| 12 | SGEIE | | 0x0 | WARL | HS-level External Interrupt enable. | ++---------+--------------+----------------+---------+--------+---------------------------------------+ +| [31:13] | RESERVED_13 | | 0x0 | WPRI | RESERVED | ++---------+--------------+----------------+---------+--------+---------------------------------------+ + +MTVEC ----- :Address: 0x305 @@ -211,30 +219,15 @@ mtvec :Description: MXLEN-bit read/write register that holds trap vector configuration. -+--------+--------------+----------------+------------+----------+----------------------+ -| Bits | Field Name | Legal Values | Mask | Access | Description | -+========+==============+================+============+==========+======================+ -| [1:0] | mode | 0 | 0 | RW | Vector mode. | -+--------+--------------+----------------+------------+----------+----------------------+ -| [31:2] | base | 0x3FFFFFFF | 0x00000000 | RW | Vector base address. | -+--------+--------------+----------------+------------+----------+----------------------+ ++--------+--------------+--------------------------+------------+--------+----------------------+ +| Bits | Field Name | Legal Values | Reset | Type | Description | ++========+==============+==========================+============+========+======================+ +| [1:0] | MODE | [0x0] | 0x0 | WARL | Vector mode. | ++--------+--------------+--------------------------+------------+--------+----------------------+ +| [31:2] | BASE | [0x3FFFFFFF, 0x00000000] | 0x20004000 | WARL | Vector base address. | ++--------+--------------+--------------------------+------------+--------+----------------------+ -mcountinhibit -------------- - -:Address: 0x320 -:Reset Value: 0x00000000 -:Privilege Mode: M -:Description: The mcountinhibit is a 32-bit WARL register that controls - which of the hardware performance-monitoring counters increment. - -+--------+---------------+----------------+------------+----------+----------------------------------------------------------------------------------------------------------------------------+ -| Bits | Field Name | Legal Values | Mask | Access | Description | -+========+===============+================+============+==========+============================================================================================================================+ -| [31:0] | mcountinhibit | 0x00000000 | 0xFFFFFFFF | RW | The mcountinhibit is a 32-bit WARL register that controls which of the hardware performance-monitoring counters increment. | -+--------+---------------+----------------+------------+----------+----------------------------------------------------------------------------------------------------------------------------+ - -mhpmevent[3-31] +MHPMEVENT[3-31] --------------- :Address: 0x323-0x33f @@ -243,13 +236,13 @@ mhpmevent[3-31] :Description: The mhpmevent is a MXLEN-bit event register which controls mhpmcounter3. -+--------+--------------+----------------+------------+----------+--------------------------------------------------------------------------+ -| Bits | Field Name | Legal Values | Mask | Access | Description | -+========+==============+================+============+==========+==========================================================================+ -| [31:0] | mhpmevent[i] | 0x00000000 | 0xFFFFFFFF | RW | The mhpmevent is a MXLEN-bit event register which controls mhpmcounter3. | -+--------+--------------+----------------+------------+----------+--------------------------------------------------------------------------+ ++--------+--------------+---------------------------+------------+--------+--------------------------------------------------------------------------+ +| Bits | Field Name | Legal Values | Reset | Type | Description | ++========+==============+===========================+============+========+==========================================================================+ +| [31:0] | MHPMEVENT[I] | [0x00000000 , 0xFFFFFFFF] | 0x00000000 | WARL | The mhpmevent is a MXLEN-bit event register which controls mhpmcounter3. | ++--------+--------------+---------------------------+------------+--------+--------------------------------------------------------------------------+ -mscratch +MSCRATCH -------- :Address: 0x340 @@ -258,13 +251,13 @@ mscratch :Description: The mscratch register is an MXLEN-bit read/write register dedicated for use by machine mode. -+--------+--------------+----------------+------------+----------+----------------------------------------------------------------------------------------------+ -| Bits | Field Name | Legal Values | Mask | Access | Description | -+========+==============+================+============+==========+==============================================================================================+ -| [31:0] | mscratch | 0x00000000 | 0xFFFFFFFF | RW | The mscratch register is an MXLEN-bit read/write register dedicated for use by machine mode. | -+--------+--------------+----------------+------------+----------+----------------------------------------------------------------------------------------------+ ++--------+--------------+---------------------------+------------+--------+----------------------------------------------------------------------------------------------+ +| Bits | Field Name | Legal Values | Reset | Type | Description | ++========+==============+===========================+============+========+==============================================================================================+ +| [31:0] | MSCRATCH | [0x00000000 , 0xFFFFFFFF] | 0x00000000 | WARL | The mscratch register is an MXLEN-bit read/write register dedicated for use by machine mode. | ++--------+--------------+---------------------------+------------+--------+----------------------------------------------------------------------------------------------+ -mepc +MEPC ---- :Address: 0x341 @@ -273,13 +266,13 @@ mepc :Description: The mepc is a warl register that must be able to hold all valid physical and virtual addresses. -+--------+--------------+----------------+------------+----------+-------------------------------------------------------------------------------------------------+ -| Bits | Field Name | Legal Values | Mask | Access | Description | -+========+==============+================+============+==========+=================================================================================================+ -| [31:0] | mepc | 0x00000000 | 0xFFFFFFFF | RW | The mepc is a warl register that must be able to hold all valid physical and virtual addresses. | -+--------+--------------+----------------+------------+----------+-------------------------------------------------------------------------------------------------+ ++--------+--------------+---------------------------+------------+--------+-------------------------------------------------------------------------------------------------+ +| Bits | Field Name | Legal Values | Reset | Type | Description | ++========+==============+===========================+============+========+=================================================================================================+ +| [31:0] | MEPC | [0x00000000 , 0xFFFFFFFF] | 0x00000000 | WARL | The mepc is a warl register that must be able to hold all valid physical and virtual addresses. | ++--------+--------------+---------------------------+------------+--------+-------------------------------------------------------------------------------------------------+ -mcause +MCAUSE ------ :Address: 0x342 @@ -288,15 +281,15 @@ mcause :Description: The mcause register stores the information regarding the trap. -+--------+----------------+----------------+--------+----------+-----------------------------------------------------+ -| Bits | Field Name | Legal Values | Mask | Access | Description | -+========+================+================+========+==========+=====================================================+ -| [30:0] | exception_code | 0 | 15 | RW | Encodes the exception code. | -+--------+----------------+----------------+--------+----------+-----------------------------------------------------+ -| 31 | interrupt | 0x0 | 0x1 | RW | Indicates whether the trap was due to an interrupt. | -+--------+----------------+----------------+--------+----------+-----------------------------------------------------+ ++--------+----------------+----------------+---------+--------+-----------------------------------------------------+ +| Bits | Field Name | Legal Values | Reset | Type | Description | ++========+================+================+=========+========+=====================================================+ +| [30:0] | EXCEPTION_CODE | [0 , 15] | 0x0 | WLRL | Encodes the exception code. | ++--------+----------------+----------------+---------+--------+-----------------------------------------------------+ +| 31 | INTERRUPT | [0x0 , 0x1] | 0x0 | WLRL | Indicates whether the trap was due to an interrupt. | ++--------+----------------+----------------+---------+--------+-----------------------------------------------------+ -mtval +MTVAL ----- :Address: 0x343 @@ -305,13 +298,13 @@ mtval :Description: The mtval is a warl register that holds the address of the instruction which caused the exception. -+--------+--------------+----------------+------------+----------+----------------------------------------------------------------------------------------------------+ -| Bits | Field Name | Legal Values | Mask | Access | Description | -+========+==============+================+============+==========+====================================================================================================+ -| [31:0] | mtval | 0x00000000 | 0xFFFFFFFF | RW | The mtval is a warl register that holds the address of the instruction which caused the exception. | -+--------+--------------+----------------+------------+----------+----------------------------------------------------------------------------------------------------+ ++--------+--------------+---------------------------+------------+--------+----------------------------------------------------------------------------------------------------+ +| Bits | Field Name | Legal Values | Reset | Type | Description | ++========+==============+===========================+============+========+====================================================================================================+ +| [31:0] | MTVAL | [0x00000000 , 0xFFFFFFFF] | 0x00000000 | WARL | The mtval is a warl register that holds the address of the instruction which caused the exception. | ++--------+--------------+---------------------------+------------+--------+----------------------------------------------------------------------------------------------------+ -mip +MIP --- :Address: 0x344 @@ -320,88 +313,88 @@ mip :Description: The mip register is an MXLEN-bit read/write register containing information on pending interrupts. -+---------+--------------+----------------+--------+----------+----------------------------------------+ -| Bits | Field Name | Legal Values | Mask | Access | Description | -+=========+==============+================+========+==========+========================================+ -| 0 | usip | | | RW | User Software Interrupt Pending. | -+---------+--------------+----------------+--------+----------+----------------------------------------+ -| 1 | ssip | | | RW | Supervisor Software Interrupt Pending. | -+---------+--------------+----------------+--------+----------+----------------------------------------+ -| 2 | vssip | | | RW | VS-level Software Interrupt Pending. | -+---------+--------------+----------------+--------+----------+----------------------------------------+ -| 3 | msip | 0x1 | 0 | RW | Machine Software Interrupt Pending. | -+---------+--------------+----------------+--------+----------+----------------------------------------+ -| 4 | utip | | | RW | User Timer Interrupt Pending. | -+---------+--------------+----------------+--------+----------+----------------------------------------+ -| 5 | stip | | | RW | Supervisor Timer Interrupt Pending. | -+---------+--------------+----------------+--------+----------+----------------------------------------+ -| 6 | vstip | | | RW | VS-level Timer Interrupt Pending. | -+---------+--------------+----------------+--------+----------+----------------------------------------+ -| 7 | mtip | 0x1 | 0 | RW | Machine Timer Interrupt Pending. | -+---------+--------------+----------------+--------+----------+----------------------------------------+ -| 8 | ueip | | | RW | User External Interrupt Pending. | -+---------+--------------+----------------+--------+----------+----------------------------------------+ -| 9 | seip | | | RW | Supervisor External Interrupt Pending. | -+---------+--------------+----------------+--------+----------+----------------------------------------+ -| 10 | vseip | | | RW | VS-level External Interrupt Pending. | -+---------+--------------+----------------+--------+----------+----------------------------------------+ -| 11 | meip | 0x1 | 0 | RW | Machine External Interrupt Pending. | -+---------+--------------+----------------+--------+----------+----------------------------------------+ -| 12 | sgeip | | | RW | HS-level External Interrupt Pending. | -+---------+--------------+----------------+--------+----------+----------------------------------------+ -| [31:13] | Reserved_13 | | | Reserved | Reserved | -+---------+--------------+----------------+--------+----------+----------------------------------------+ - -pmpcfg[0-15] ------------- - -:Address: 0x3a0-0x3af ++---------+--------------+----------------+---------+-------------+----------------------------------------+ +| Bits | Field Name | Legal Values | Reset | Type | Description | ++=========+==============+================+=========+=============+========================================+ +| 0 | USIP | | 0x0 | WARL | User Software Interrupt Pending. | ++---------+--------------+----------------+---------+-------------+----------------------------------------+ +| 1 | SSIP | | 0x0 | WARL | Supervisor Software Interrupt Pending. | ++---------+--------------+----------------+---------+-------------+----------------------------------------+ +| 2 | VSSIP | | 0x0 | WARL | VS-level Software Interrupt Pending. | ++---------+--------------+----------------+---------+-------------+----------------------------------------+ +| 3 | MSIP | 0x1 | 0x0 | RO_VARIABLE | Machine Software Interrupt Pending. | ++---------+--------------+----------------+---------+-------------+----------------------------------------+ +| 4 | UTIP | | 0x0 | WARL | User Timer Interrupt Pending. | ++---------+--------------+----------------+---------+-------------+----------------------------------------+ +| 5 | STIP | | 0x0 | WARL | Supervisor Timer Interrupt Pending. | ++---------+--------------+----------------+---------+-------------+----------------------------------------+ +| 6 | VSTIP | | 0x0 | WARL | VS-level Timer Interrupt Pending. | ++---------+--------------+----------------+---------+-------------+----------------------------------------+ +| 7 | MTIP | 0x1 | 0x0 | RO_VARIABLE | Machine Timer Interrupt Pending. | ++---------+--------------+----------------+---------+-------------+----------------------------------------+ +| 8 | UEIP | | 0x0 | WARL | User External Interrupt Pending. | ++---------+--------------+----------------+---------+-------------+----------------------------------------+ +| 9 | SEIP | | 0x0 | WARL | Supervisor External Interrupt Pending. | ++---------+--------------+----------------+---------+-------------+----------------------------------------+ +| 10 | VSEIP | | 0x0 | WARL | VS-level External Interrupt Pending. | ++---------+--------------+----------------+---------+-------------+----------------------------------------+ +| 11 | MEIP | 0x1 | 0x0 | RO_VARIABLE | Machine External Interrupt Pending. | ++---------+--------------+----------------+---------+-------------+----------------------------------------+ +| 12 | SGEIP | | 0x0 | WARL | HS-level External Interrupt Pending. | ++---------+--------------+----------------+---------+-------------+----------------------------------------+ +| [31:13] | RESERVED_13 | | 0x0 | WPRI | RESERVED | ++---------+--------------+----------------+---------+-------------+----------------------------------------+ + +PMPCFG[0-1] +----------- + +:Address: 0x3a0-0x3a1 :Reset Value: 0x00000000 :Privilege Mode: M :Description: PMP configuration register -+---------+-----------------+----------------+--------+----------+------------------------+ -| Bits | Field Name | Legal Values | Mask | Access | Description | -+=========+=================+================+========+==========+========================+ -| [7:0] | pmp[i*4 + 0]cfg | 0x00 | 0xFF | RW | pmp configuration bits | -+---------+-----------------+----------------+--------+----------+------------------------+ -| [15:8] | pmp[i*4 + 1]cfg | 0x00 | 0xFF | RW | pmp configuration bits | -+---------+-----------------+----------------+--------+----------+------------------------+ -| [23:16] | pmp[i*4 + 2]cfg | 0x00 | 0xFF | RW | pmp configuration bits | -+---------+-----------------+----------------+--------+----------+------------------------+ -| [31:24] | pmp[i*4 + 3]cfg | 0x00 | 0xFF | RW | pmp configuration bits | -+---------+-----------------+----------------+--------+----------+------------------------+ - -pmpaddr[0-63] -------------- - -:Address: 0x3b0-0x3ef -:Reset Value: 0x00000020 ++---------+-----------------+----------------+---------+--------+------------------------+ +| Bits | Field Name | Legal Values | Reset | Type | Description | ++=========+=================+================+=========+========+========================+ +| [7:0] | PMP[I*4 + 0]CFG | [0x00:0xFF] | 0x0 | WARL | pmp configuration bits | ++---------+-----------------+----------------+---------+--------+------------------------+ +| [15:8] | PMP[I*4 + 1]CFG | [0x00:0xFF] | 0x0 | WARL | pmp configuration bits | ++---------+-----------------+----------------+---------+--------+------------------------+ +| [23:16] | PMP[I*4 + 2]CFG | [0x00:0xFF] | 0x0 | WARL | pmp configuration bits | ++---------+-----------------+----------------+---------+--------+------------------------+ +| [31:24] | PMP[I*4 + 3]CFG | [0x00:0xFF] | 0x0 | WARL | pmp configuration bits | ++---------+-----------------+----------------+---------+--------+------------------------+ + +PMPADDR[0-7] +------------ + +:Address: 0x3b0-0x3b7 +:Reset Value: 0x00000000 :Privilege Mode: M :Description: Physical memory protection address register -+--------+--------------+----------------+------------+----------+---------------------------------------------+ -| Bits | Field Name | Legal Values | Mask | Access | Description | -+========+==============+================+============+==========+=============================================+ -| [31:0] | pmpaddr[i] | 0x00000000 | 0xFFFFFFFF | RW | Physical memory protection address register | -+--------+--------------+----------------+------------+----------+---------------------------------------------+ ++--------+--------------+---------------------------+------------+--------+---------------------------------------------+ +| Bits | Field Name | Legal Values | Reset | Type | Description | ++========+==============+===========================+============+========+=============================================+ +| [31:0] | PMPADDR[I] | [0x00000000 , 0xFFFFFFFF] | 0x00000000 | WARL | Physical memory protection address register | ++--------+--------------+---------------------------+------------+--------+---------------------------------------------+ -mcycle +MCYCLE ------ :Address: 0xb00 -:Reset Value: 0x0001e253 +:Reset Value: 0x00000000 :Privilege Mode: M :Description: Counts the number of clock cycles executed from an arbitrary point in time. -+--------+--------------+----------------+------------+----------+-----------------------------------------------------------------------------+ -| Bits | Field Name | Legal Values | Mask | Access | Description | -+========+==============+================+============+==========+=============================================================================+ -| [31:0] | mcycle | 0x00000000 | 0xFFFFFFFF | RW | Counts the number of clock cycles executed from an arbitrary point in time. | -+--------+--------------+----------------+------------+----------+-----------------------------------------------------------------------------+ ++--------+--------------+---------------------------+------------+--------+-----------------------------------------------------------------------------+ +| Bits | Field Name | Legal Values | Reset | Type | Description | ++========+==============+===========================+============+========+=============================================================================+ +| [31:0] | MCYCLE | [0x00000000 , 0xFFFFFFFF] | 0x00000000 | WARL | Counts the number of clock cycles executed from an arbitrary point in time. | ++--------+--------------+---------------------------+------------+--------+-----------------------------------------------------------------------------+ -minstret +MINSTRET -------- :Address: 0xb02 @@ -410,13 +403,13 @@ minstret :Description: Counts the number of instructions completed from an arbitrary point in time. -+--------+--------------+----------------+------------+----------+------------------------------------------------------------------------------+ -| Bits | Field Name | Legal Values | Mask | Access | Description | -+========+==============+================+============+==========+==============================================================================+ -| [31:0] | minstret | 0x00000000 | 0xFFFFFFFF | RW | Counts the number of instructions completed from an arbitrary point in time. | -+--------+--------------+----------------+------------+----------+------------------------------------------------------------------------------+ ++--------+--------------+---------------------------+------------+--------+------------------------------------------------------------------------------+ +| Bits | Field Name | Legal Values | Reset | Type | Description | ++========+==============+===========================+============+========+==============================================================================+ +| [31:0] | MINSTRET | [0x00000000 , 0xFFFFFFFF] | 0x00000000 | WARL | Counts the number of instructions completed from an arbitrary point in time. | ++--------+--------------+---------------------------+------------+--------+------------------------------------------------------------------------------+ -mhpmcounter[3-31] +MHPMCOUNTER[3-31] ----------------- :Address: 0xb03-0xb1f @@ -425,13 +418,13 @@ mhpmcounter[3-31] :Description: The mhpmcounter is a 64-bit counter. Returns lower 32 bits in RV32I mode. -+--------+----------------+----------------+------------+----------+---------------------------------------------------------------------------+ -| Bits | Field Name | Legal Values | Mask | Access | Description | -+========+================+================+============+==========+===========================================================================+ -| [31:0] | mhpmcounter[i] | 0x00000000 | 0xFFFFFFFF | RW | The mhpmcounter is a 64-bit counter. Returns lower 32 bits in RV32I mode. | -+--------+----------------+----------------+------------+----------+---------------------------------------------------------------------------+ ++--------+----------------+---------------------------+------------+--------+---------------------------------------------------------------------------+ +| Bits | Field Name | Legal Values | Reset | Type | Description | ++========+================+===========================+============+========+===========================================================================+ +| [31:0] | MHPMCOUNTER[I] | [0x00000000 , 0xFFFFFFFF] | 0x00000000 | WARL | The mhpmcounter is a 64-bit counter. Returns lower 32 bits in RV32I mode. | ++--------+----------------+---------------------------+------------+--------+---------------------------------------------------------------------------+ -mcycleh +MCYCLEH ------- :Address: 0xb80 @@ -439,13 +432,13 @@ mcycleh :Privilege Mode: M :Description: upper 32 bits of mcycle -+--------+--------------+----------------+------------+----------+-------------------------+ -| Bits | Field Name | Legal Values | Mask | Access | Description | -+========+==============+================+============+==========+=========================+ -| [31:0] | mcycleh | 0x00000000 | 0xFFFFFFFF | RW | upper 32 bits of mcycle | -+--------+--------------+----------------+------------+----------+-------------------------+ ++--------+--------------+---------------------------+------------+--------+-------------------------+ +| Bits | Field Name | Legal Values | Reset | Type | Description | ++========+==============+===========================+============+========+=========================+ +| [31:0] | MCYCLEH | [0x00000000 , 0xFFFFFFFF] | 0x00000000 | WARL | upper 32 bits of mcycle | ++--------+--------------+---------------------------+------------+--------+-------------------------+ -minstreth +MINSTRETH --------- :Address: 0xb82 @@ -453,13 +446,13 @@ minstreth :Privilege Mode: M :Description: Upper 32 bits of minstret. -+--------+--------------+----------------+------------+----------+----------------------------+ -| Bits | Field Name | Legal Values | Mask | Access | Description | -+========+==============+================+============+==========+============================+ -| [31:0] | minstreth | 0x00000000 | 0xFFFFFFFF | RW | Upper 32 bits of minstret. | -+--------+--------------+----------------+------------+----------+----------------------------+ ++--------+--------------+---------------------------+------------+--------+----------------------------+ +| Bits | Field Name | Legal Values | Reset | Type | Description | ++========+==============+===========================+============+========+============================+ +| [31:0] | MINSTRETH | [0x00000000 , 0xFFFFFFFF] | 0x00000000 | WARL | Upper 32 bits of minstret. | ++--------+--------------+---------------------------+------------+--------+----------------------------+ -mhpmcounter[3-31]h +MHPMCOUNTER[3-31]H ------------------ :Address: 0xb83-0xb9f @@ -468,27 +461,28 @@ mhpmcounter[3-31]h :Description: The mhpmcounterh returns the upper half word in RV32I systems. -+--------+-----------------+----------------+------------+----------+----------------------------------------------------------------+ -| Bits | Field Name | Legal Values | Mask | Access | Description | -+========+=================+================+============+==========+================================================================+ -| [31:0] | mhpmcounter[i]h | 0x00000000 | 0xFFFFFFFF | RW | The mhpmcounterh returns the upper half word in RV32I systems. | -+--------+-----------------+----------------+------------+----------+----------------------------------------------------------------+ ++--------+-----------------+---------------------------+------------+--------+----------------------------------------------------------------+ +| Bits | Field Name | Legal Values | Reset | Type | Description | ++========+=================+===========================+============+========+================================================================+ +| [31:0] | MHPMCOUNTER[I]H | [0x00000000 , 0xFFFFFFFF] | 0x00000000 | WARL | The mhpmcounterh returns the upper half word in RV32I systems. | ++--------+-----------------+---------------------------+------------+--------+----------------------------------------------------------------+ -mvendorid +MVENDORID --------- :Address: 0xf11 :Reset Value: 0x00000602 :Privilege Mode: M -:Description: +:Description: 32-bit read-only register providing the JEDEC manufacturer + ID of the provider of the core. -+--------+--------------+----------------+--------+----------+---------------+ -| Bits | Field Name | Legal Values | Mask | Access | Description | -+========+==============+================+========+==========+===============+ -| [31:0] | mvendorid | 0x602 | 0 | RW | | -+--------+--------------+----------------+--------+----------+---------------+ ++--------+--------------+----------------+------------+-------------+--------------------------------------------------------------------------------------------+ +| Bits | Field Name | Legal Values | Reset | Type | Description | ++========+==============+================+============+=============+============================================================================================+ +| [31:0] | MVENDORID | 0x00000602 | 0x00000602 | RO_CONSTANT | 32-bit read-only register providing the JEDEC manufacturer ID of the provider of the core. | ++--------+--------------+----------------+------------+-------------+--------------------------------------------------------------------------------------------+ -marchid +MARCHID ------- :Address: 0xf12 @@ -497,13 +491,13 @@ marchid :Description: MXLEN-bit read-only register encoding the base microarchitecture of the hart. -+--------+--------------+----------------+--------+----------+-------------------------------------------------------------------------------+ -| Bits | Field Name | Legal Values | Mask | Access | Description | -+========+==============+================+========+==========+===============================================================================+ -| [31:0] | marchid | 0x3 | 0 | RW | MXLEN-bit read-only register encoding the base microarchitecture of the hart. | -+--------+--------------+----------------+--------+----------+-------------------------------------------------------------------------------+ ++--------+--------------+----------------+------------+-------------+-------------------------------------------------------------------------------+ +| Bits | Field Name | Legal Values | Reset | Type | Description | ++========+==============+================+============+=============+===============================================================================+ +| [31:0] | MARCHID | 0x00000003 | 0x00000003 | RO_CONSTANT | MXLEN-bit read-only register encoding the base microarchitecture of the hart. | ++--------+--------------+----------------+------------+-------------+-------------------------------------------------------------------------------+ -mimpid +MIMPID ------ :Address: 0xf13 @@ -512,13 +506,13 @@ mimpid :Description: Provides a unique encoding of the version of the processor implementation. -+--------+--------------+----------------+--------+----------+----------------------------------------------------------------------------+ -| Bits | Field Name | Legal Values | Mask | Access | Description | -+========+==============+================+========+==========+============================================================================+ -| [31:0] | mimpid | 0x0 | 0 | RW | Provides a unique encoding of the version of the processor implementation. | -+--------+--------------+----------------+--------+----------+----------------------------------------------------------------------------+ ++--------+--------------+----------------+------------+-------------+----------------------------------------------------------------------------+ +| Bits | Field Name | Legal Values | Reset | Type | Description | ++========+==============+================+============+=============+============================================================================+ +| [31:0] | MIMPID | 0x00000000 | 0x00000000 | RO_CONSTANT | Provides a unique encoding of the version of the processor implementation. | ++--------+--------------+----------------+------------+-------------+----------------------------------------------------------------------------+ -mhartid +MHARTID ------- :Address: 0xf14 @@ -527,9 +521,9 @@ mhartid :Description: MXLEN-bit read-only register containing the integer ID of the hardware thread running the code. -+--------+--------------+----------------+--------+----------+-------------------------------------------------------------------------------------------------+ -| Bits | Field Name | Legal Values | Mask | Access | Description | -+========+==============+================+========+==========+=================================================================================================+ -| [31:0] | mhartid | 0x0 | 0 | RW | MXLEN-bit read-only register containing the integer ID of the hardware thread running the code. | -+--------+--------------+----------------+--------+----------+-------------------------------------------------------------------------------------------------+ ++--------+--------------+----------------+------------+-------------+-------------------------------------------------------------------------------------------------+ +| Bits | Field Name | Legal Values | Reset | Type | Description | ++========+==============+================+============+=============+=================================================================================================+ +| [31:0] | MHARTID | 0x00000000 | 0x00000000 | RO_CONSTANT | MXLEN-bit read-only register containing the integer ID of the hardware thread running the code. | ++--------+--------------+----------------+------------+-------------+-------------------------------------------------------------------------------------------------+ diff --git a/config/gen_from_riscv_config/cv32a65x/isa/isa.md b/config/gen_from_riscv_config/cv32a65x/isa/isa.md index c0ffc45bc1..544e208654 100644 --- a/config/gen_from_riscv_config/cv32a65x/isa/isa.md +++ b/config/gen_from_riscv_config/cv32a65x/isa/isa.md @@ -18,17 +18,17 @@ Author: Abdessamii Oukalrazqou |Zicsr|[RV32Zicsr Control and Status Register Instructions](#RV32Zicsr Control and Status Register Instructions)|All CSR instructions atomically read-modify-write a single CSR, whose CSR specifier is encoded in the 12-bit csr field of the instruction held in bits 31–20. The immediate forms use a 5-bit zero-extended immediate encoded in the rs1 field. | |Zifencei|[RVZifencei Instruction Fetch Fence](#RVZifencei Instruction Fetch Fence)|FENCE.I instruction that provides explicit synchronization between writes to instruction memory and instruction fetches on the same hart. Currently, this instruction is the only standard mechanism to ensure that stores visible to a hart will also be visible to it instruction fetches. | |Zba|[RVZba Address generation instructions](#RVZba Address generation instructions)|The Zba instructions can be used to accelerate the generation of addresses that index into arrays of basic types (halfword, word, doubleword) using both unsigned word-sized and XLEN-sized indices: a shifted index is added to a base address. The shift and add instructions do a left shift of 1, 2, or 3 because these are commonly found in real-world code and because they can be implemented with a minimal amount of additional hardware beyond that of the simple adder. This avoids lengthening the critical path in implementations. While the shift and add instructions are limited to a maximum left shift of 3, the slli instruction (from the base ISA) can be used to perform similar shifts for indexing into arrays of wider elements. The slli.uw added in this extension can be used when the index is to be interpreted as an unsigned word. | +|Zbb|[RVZbb Basic bit-manipulation](#RVZbb Basic bit-manipulation)|The bit-manipulation (bitmanip) extension collection is comprised of several component extensions to the base RISC-V architecture that are intended to provide some combination of code size reduction, performance improvement, and energy reduction. While the instructions are intended to have general use, some instructions are more useful in some domains than others. Hence, several smaller bitmanip extensions are provided. Each of these smaller extensions is grouped by common function and use case, and each has its own Zb*-extension name. | +|Zbc|[RVZbc Carry-less multiplication](#RVZbc Carry-less multiplication)|Carry-less multiplication is the multiplication in the polynomial ring over GF(2). clmul produces the lower half of the carry-less product and clmulh produces the upper half of the 2✕XLEN carry-less product. clmulr produces bits 2✕XLEN−2:XLEN-1 of the 2✕XLEN carry-less product. | |Zbs|[RVZbs Single bit Instructions](#RVZbs Single bit Instructions)|The single-bit instructions provide a mechanism to set, clear, invert, or extract a single bit in a register. The bit is specified by its index. | -|Zicond|[RV32Zicond Integer Conditional Instructions](#RV32Zicond Integer Conditional Instructions)|The instructions follow the format for R-type instructions with 3 operands (i.e., 2 source operands and 1 destination operand). Using these instructions, branchless sequences can be implemented (typically in two-instruction sequences) without the need for instruction fusion, special provisions during the decoding of architectural instructions, or other microarchitectural provisions | +|Zcb|[RV32Zcb Code Size Reduction Instructions](#RV32Zcb Code Size Reduction Instructions)|Zcb belongs to the group of extensions called RISC-V Code Size Reduction Extension (Zc*). Zc* has become the superset of the Standard C extension adding more 16-bit instructions to the ISA. Zcb includes the 16-bit version of additional Integer (I), Multiply (M), and Bit-Manipulation (Zbb) Instructions. All the Zcb instructions require at least standard C extension support as a prerequisite, along with M and Zbb extensions for the 16-bit version of the respective instructions. | |Zicntr|[Zicntr](#Zicntr)|No info found yet for extension Zicntr| -|Zbb|[Zbb](#Zbb)|No info found yet for extension Zbb| -|Zbc|[Zbc](#Zbc)|No info found yet for extension Zbc| ### RV32I Base Integer Instructions |Name|Format|Pseudocode|Invalid_values|Exception_raised|Description|Op Name| | :--- | :--- | :--- | :--- | :--- | :--- | :--- | -|ADDI |[addi](#addi)|x[rd] = x[rs1] + sext(imm[11:0])|NONE|NONE |add sign-extended 12-bit immediate to register rs1, and store the result in register rd.|Integer_Register_Immediate_Operations| +|ADDI |[addi rd, rs1, imm[11:0]](#addi rd, rs1, imm[11:0])|x[rd] = x[rs1] + sext(imm[11:0])|NONE|NONE |add sign-extended 12-bit immediate to register rs1, and store the result in register rd.|Integer_Register_Immediate_Operations| |ANDI |[andi rd, rs1, imm[11:0]](#andi rd, rs1, imm[11:0])|x[rd] = x[rs1] & sext(imm[11:0])|NONE|NONE |perform bitwise AND on register rs1 and the sign-extended 12-bit immediate and place the result in rd.|Integer_Register_Immediate_Operations| |ORI |[ori rd, rs1, imm[11:0]](#ori rd, rs1, imm[11:0])|x[rd] = x[rs1] \| sext(imm[11:0])|NONE|NONE |perform bitwise OR on register rs1 and the sign-extended 12-bit immediate and place the result in rd.|Integer_Register_Immediate_Operations| |XORI |[xori rd, rs1, imm[11:0]](#xori rd, rs1, imm[11:0])|x[rd] = x[rs1] ^ sext(imm[11:0])|NONE|NONE |perform bitwise XOR on register rs1 and the sign-extended 12-bit immediate and place the result in rd.|Integer_Register_Immediate_Operations| @@ -143,6 +143,43 @@ Author: Abdessamii Oukalrazqou |SH3ADD.UW |[sh3add.uw rd, rs1, rs2](#sh3add.uw rd, rs1, rs2)|X(rd) = rs2 + (EXTZ(X(rs1)[31..0]) << 3)|NONE|NONE |This instruction performs an XLEN-wide addition of two addends. The first addend is rs2. The second addend is the unsigned value formed by extracting the least-significant word of rs1 and shifting it left by 3 places. |Address generation instructions| |SLLI.UW |[slli.uw rd, rs1, imm](#slli.uw rd, rs1, imm)|X(rd) = (EXTZ(X(rs)[31..0]) << imm)|NONE|NONE |This instruction takes the least-significant word of rs1, zero-extends it, and shifts it left by the immediate. |Address generation instructions| +### RVZbb Basic bit-manipulation + +|Name|Format|Pseudocode|Invalid_values|Exception_raised|Description|Op Name| +| :--- | :--- | :--- | :--- | :--- | :--- | :--- | +|ANDN |[andn rd, rs1, rs2](#andn rd, rs1, rs2)|X(rd) = X(rs1) & ~X(rs2)|NONE|NONE |Performs bitwise AND operation between rs1 and bitwise inversion of rs2.|Logical_with_negate| +|ORN |[orn rd, rs1, rs2](#orn rd, rs1, rs2)|X(rd) = X(rs1) \| ~X(rs2)|NONE|NONE |Performs bitwise OR operation between rs1 and bitwise inversion of rs2.|Logical_with_negate| +|XNOR |[xnor rd, rs1, rs2](#xnor rd, rs1, rs2)|X(rd) = ~(X(rs1) ^ X(rs2))|NONE|NONE |Performs bitwise XOR operation between rs1 and rs2, then complements the result.|Logical_with_negate| +|CLZ |[clz rd, rs](#clz rd, rs)|if [x[i]] == 1 then return(i) else return -1|NONE|NONE |Counts leading zero bits in rs.|Count_leading_trailing_zero_bits| +|CTZ |[ctz rd, rs](#ctz rd, rs)|if [x[i]] == 1 then return(i) else return xlen;|NONE|NONE |Counts trailing zero bits in rs.|Count_leading_trailing_zero_bits| +|CLZW |[clzw rd, rs](#clzw rd, rs)|if [x[i]] == 1 then return(i) else return -1|NONE|NONE |Counts leading zero bits in the least-significant word of rs.|Count_leading_trailing_zero_bits| +|CTZW |[ctzw rd, rs](#ctzw rd, rs)|if [x[i]] == 1 then return(i) else return 32;|NONE|NONE |Counts trailing zero bits in the least-significant word of rs.|Count_leading_trailing_zero_bits| +|CPOP |[cpop rd, rs](#cpop rd, rs)|if rs[i] == 1 then bitcount = bitcount + 1 else ()|NONE|NONE |Counts set bits in rs.|Count_population| +|CPOPW |[cpopw rd, rs](#cpopw rd, rs)|if rs[i] == 0b1 then bitcount = bitcount + 1 else ()|NONE|NONE |Counts set bits in the least-significant word of rs.|Count_population| +|MAX |[max rd, rs1, rs2](#max rd, rs1, rs2)|if rs1_val <_s rs2_val then rs2_val else rs1_val|NONE|NONE |Returns the larger of two signed integers.|Integer_minimum_maximum| +|MAXU |[maxu rd, rs1, rs2](#maxu rd, rs1, rs2)|if rs1_val <_u rs2_val then rs2_val else rs1_val|NONE|NONE |Returns the larger of two unsigned integers.|Integer_minimum_maximum| +|MIN |[min rd, rs1, rs2](#min rd, rs1, rs2)|if rs1_val <_s rs2_val then rs1_val else rs2_val|NONE|NONE |Returns the smaller of two signed integers.|Integer_minimum_maximum| +|MINU |[minu rd, rs1, rs2](#minu rd, rs1, rs2)|if rs1_val <_u rs2_val then rs1_val else rs2_val|NONE|NONE |Returns the smaller of two unsigned integers.|Integer_minimum_maximum| +|SEXT.B |[sext.b rd, rs](#sext.b rd, rs)|X(rd) = EXTS(X(rs)[7..0])|NONE|NONE |Sign-extends the least-significant byte in the source to XLEN.|Sign_and_zero_extension| +|SEXT.H |[sext.h rd, rs](#sext.h rd, rs)|X(rd) = EXTS(X(rs)[15..0])|NONE|NONE |Sign-extends the least-significant halfword in rs to XLEN.|Sign_and_zero_extension| +|ZEXT.H |[zext.h rd, rs](#zext.h rd, rs)|X(rd) = EXTZ(X(rs)[15..0])|NONE|NONE |Zero-extends the least-significant halfword of the source to XLEN.|Sign_and_zero_extension| +|ROL |[rol rd, rs1, rs2](#rol rd, rs1, rs2)|(X(rs1) << log2(XLEN)) \| (X(rs1) >> (xlen - log2(XLEN)))|NONE|NONE |Performs a rotate left of rs1 by the amount in least-significant log2(XLEN) bits of rs2.|Bitwise_rotation| +|ROR |[ror rd, rs1, rs2](#ror rd, rs1, rs2)|(X(rs1) >> log2(XLEN)) \| (X(rs1) << (xlen - log2(XLEN)))|NONE|NONE |Performs a rotate right of rs1 by the amount in least-significant log2(XLEN) bits of rs2.|Bitwise_rotation| +|RORI |[rori rd, rs1, shamt](#rori rd, rs1, shamt)|(X(rs1) >> log2(XLEN)) \| (X(rs1) << (xlen - log2(XLEN)))|NONE|NONE |Performs a rotate right of rs1 by the amount in least-significant log2(XLEN) bits of shamt.|Bitwise_rotation| +|ROLW |[rolw rd, rs1, rs2](#rolw rd, rs1, rs2)|EXTS((rs1 << X(rs2)[4..0]) \| (rs1 >> (32 - X(rs2)[4..0])))|NONE|NONE |Performs a rotate left on the least-significant word of rs1 by the amount in least-significant 5 bits of rs2.|Bitwise_rotation| +|RORIW |[roriw rd, rs1, shamt](#roriw rd, rs1, shamt)|(rs1_data >> shamt[4..0]) \| (rs1_data << (32 - shamt[4..0]))|NONE|NONE |Performs a rotate right on the least-significant word of rs1 by the amount in least-significant log2(XLEN) bits of shamt.|Bitwise_rotation| +|RORW |[rorw rd, rs1, rs2](#rorw rd, rs1, rs2)|(rs1 >> X(rs2)[4..0]) \| (rs1 << (32 - X(rs2)[4..0]))|NONE|NONE |Performs a rotate right on the least-significant word of rs1 by the amount in least-significant 5 bits of rs2.|Bitwise_rotation| +|ORC.b |[orc.b rd, rs](#orc.b rd, rs)|if { input[(i + 7)..i] == 0 then 0b00000000 else 0b11111111|NONE|NONE |Sets the bits of each byte in rd to all zeros if no bit within the respective byte of rs is set, or to all ones if any bit within the respective byte of rs is set.|OR_Combine| +|REV8 |[rev8 rd, rs](#rev8 rd, rs)|output[i..(i + 7)] = input[(j - 7)..j]|NONE|NONE |Reverses the order of the bytes in rs.|Byte_reverse| + +### RVZbc Carry-less multiplication + +|Name|Format|Pseudocode|Invalid_values|Exception_raised|Description|Op Name| +| :--- | :--- | :--- | :--- | :--- | :--- | :--- | +|CLMUL |[clmul rd, rs1, rs2](#clmul rd, rs1, rs2)|foreach (i from 1 to xlen by 1) { output = if ((rs2 >> i) & 1) then output ^ (rs1 << i); else output; } |NONE|NONE |clmul produces the lower half of the 2.XLEN carry-less product. |Carry-less multiplication Operations| +|CLMULH |[clmulh rd, rs1, rs2](#clmulh rd, rs1, rs2)|foreach (i from 1 to xlen by 1) { output = if ((rs2_val >> i) & 1) then output ^ (rs1_val >> (xlen - i)) else output } |NONE|NONE |clmulh produces the upper half of the 2.XLEN carry-less product. |Carry-less multiplication Operations| +|CLMULR |[clmulr rd, rs1, rs2](#clmulr rd, rs1, rs2)|foreach (i from 0 to (xlen - 1) by 1) { output = if ((rs2_val >> i) & 1) then output ^ (rs1_val >> (xlen - i - 1)) else output } |NONE|NONE |clmulr produces bits 2.XLEN-2:XLEN-1 of the 2.XLEN carry-less product. |Carry-less multiplication Operations| + ### RVZbs Single bit Instructions |Name|Format|Pseudocode|Invalid_values|Exception_raised|Description|Op Name| @@ -156,9 +193,18 @@ Author: Abdessamii Oukalrazqou |BSET |[bset rd, rs1, rs2](#bset rd, rs1, rs2)|X(rd) = X(rs1) \| (1 << (X(rs2) & (XLEN - 1)))|NONE|NONE |This instruction returns rs1 with a single bit set at the index specified in rs2. The index is read from the lower log2(XLEN) bits of rs2. |Single_bit_Operations| |BSETI |[bseti rd, rs1, shamt](#bseti rd, rs1, shamt)|X(rd) = X(rs1) \| (1 << (shamt & (XLEN - 1)))|NONE|NONE |This instruction returns rs1 with a single bit set at the index specified in shamt. The index is read from the lower log2(XLEN) bits of shamt. For RV32, the encodings corresponding to shamt[5]=1 are reserved. |Single_bit_Operations| -### RV32Zicond Integer Conditional Instructions +### RV32Zcb Code Size Reduction Instructions |Name|Format|Pseudocode|Invalid_values|Exception_raised|Description|Op Name| | :--- | :--- | :--- | :--- | :--- | :--- | :--- | -|CZERO.EQZ |[czero.eqz rd, rs1, rs2](#czero.eqz rd, rs1, rs2)|if (x[rs2] == 0) x[rd] = 0 else x[rs1]|NONE|NONE |This instruction behaves as if there is a conditional branch dependent on rs2 being equal to zero, wherein it branches to code that writes a 0 into rd when the equivalence is true, and otherwise falls through to code that moves rs1 into rd. |Integer Conditional Operations| -|CZERO.NEZ |[czero.nez rd, rs1, rs2](#czero.nez rd, rs1, rs2)|if (x[rs2] != 0) x[rd] = 0 else x[rs1]|NONE|NONE |This instruction behaves as if there is a conditional branch dependent on rs2 being not equal to zero, wherein it branches to code that writes a 0 into rd when the equivalence is true, and otherwise falls through to code that moves rs1 into rd. |Integer Conditional Operations| +|C.ZEXT.B |[c.zext.b rd'](#c.zext.b rd')|x[8 + rd'] = zext(x[8 + rd'][7:0])|NONE|NONE |This instruction takes a single source/destination operand. It zero-extends the least-significant byte of the operand by inserting zeros into all of the bits more significant than 7. |Code Size Reduction Operations| +|C.SEXT.B |[c.sext.b rd'](#c.sext.b rd')|x[8 + rd'] = sext(x[8 + rd'][7:0])|NONE|NONE |This instruction takes a single source/destination operand. It sign-extends the least-significant byte in the operand by copying the most-significant bit in the byte (i.e., bit 7) to all of the more-significant bits. It also requires Bit-Manipulation (Zbb) extension support. |Code Size Reduction Operations| +|C.ZEXT.H |[c.zext.h rd'](#c.zext.h rd')|x[8 + rd'] = zext(x[8 + rd'][15:0])|NONE|NONE |This instruction takes a single source/destination operand. It zero-extends the least-significant halfword of the operand by inserting zeros into all of the bits more significant than 15. It also requires Bit-Manipulation (Zbb) extension support. |Code Size Reduction Operations| +|C.SEXT.H |[c.sext.h rd'](#c.sext.h rd')|x[8 + rd'] = sext(x[8 + rd'][15:0])|NONE|NONE |This instruction takes a single source/destination operand. It sign-extends the least-significant halfword in the operand by copying the most-significant bit in the halfword (i.e., bit 15) to all of the more-significant bits. It also requires Bit-Manipulation (Zbb) extension support. |Code Size Reduction Operations| +|C.NOT |[c.not rd'](#c.not rd')|x[8 + rd'] = x[8 + rd'] ^ -1|NONE|NONE |This instruction takes the one’s complement of rd'/rs1' and writes the result to the same register. |Code Size Reduction Operations| +|C.MUL |[c.mul rd', rs2'](#c.mul rd', rs2')|x[8 + rd'] = (x[8 + rd'] * x[8 + rs2'])[31:0]|NONE|NONE |performs a 32-bit × 32-bit multiplication and places the lower 32 bits in the destination register (Both rd' and rs2' treated as signed numbers). It also requires M extension support. |Code Size Reduction Operations| +|C.LHU |[c.lhu rd', uimm(rs1')](#c.lhu rd', uimm(rs1'))|x[8+rd'] = zext(M[x[8+rs1'] + zext(uimm[1])][15:0])|NONE|an exception raised if the memory address isn't aligned (2-byte boundary).|This instruction loads a halfword from the memory address formed by adding rs1' to the zero extended immediate uimm. The resulting halfword is zero extended and is written to rd'. |Code Size Reduction Operations| +|C.LH |[c.lh rd', uimm(rs1')](#c.lh rd', uimm(rs1'))|x[8+rd'] = sext(M[x[8+rs1'] + zext(uimm[1])][15:0])|NONE|an exception raised if the memory address isn't aligned (2-byte boundary).|This instruction loads a halfword from the memory address formed by adding rs1' to the zero extended immediate uimm. The resulting halfword is sign extended and is written to rd'. |Code Size Reduction Operations| +|C.LBU |[c.lbu rd', uimm(rs1')](#c.lbu rd', uimm(rs1'))|x[8+rd'] = zext(M[x[8+rs1'] + zext(uimm[1:0])][7:0])|NONE|NONE |This instruction loads a byte from the memory address formed by adding rs1' to the zero extended immediate uimm. The resulting byte is zero extended and is written to rd'. |Code Size Reduction Operations| +|C.SH |[c.sh rs2', uimm(rs1')](#c.sh rs2', uimm(rs1'))|M[x[8+rs1'] + zext(uimm[1])][15:0] = x[8+rs2']|NONE|an exception raised if the memory address isn't aligned (2-byte boundary).|This instruction stores the least significant halfword of rs2' to the memory address formed by adding rs1' to the zero extended immediate uimm. |Code Size Reduction Operations| +|C.SB |[c.sb rs2', uimm(rs1')](#c.sb rs2', uimm(rs1'))|M[x[8+rs1'] + zext(uimm[1:0])][7:0] = x[8+rs2']|NONE|NONE |This instruction stores the least significant byte of rs2' to the memory address formed by adding rs1' to the zero extended immediate uimm. |Code Size Reduction Operations| diff --git a/config/gen_from_riscv_config/cv32a65x/isa/isa.rst b/config/gen_from_riscv_config/cv32a65x/isa/isa.rst index ea02248e80..9b5c3f4774 100644 --- a/config/gen_from_riscv_config/cv32a65x/isa/isa.rst +++ b/config/gen_from_riscv_config/cv32a65x/isa/isa.rst @@ -37,15 +37,18 @@ Instructions +---------------+-----------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Zba | RVZba Address generation instructions_ | The Zba instructions can be used to accelerate the generation of addresses that index into arrays of basic types (halfword, word, doubleword) using both unsigned word-sized and XLEN-sized indices: a shifted index is added to a base address. The shift and add instructions do a left shift of 1, 2, or 3 because these are commonly found in real-world code and because they can be implemented with a minimal amount of additional hardware beyond that of the simple adder. This avoids lengthening the critical path in implementations. While the shift and add instructions are limited to a maximum left shift of 3, the slli instruction (from the base ISA) can be used to perform similar shifts for indexing into arrays of wider elements. The slli.uw added in this extension can be used when the index is to be interpreted as an unsigned word. | +---------------+-----------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| Zbs | RVZbs Single bit Instructions_ | The single-bit instructions provide a mechanism to set, clear, invert, or extract a single bit in a register. The bit is specified by its index. | +| Zbb | RVZbb Basic bit-manipulation_ | The bit-manipulation (bitmanip) extension collection is comprised of several component extensions to the base RISC-V architecture that are intended to provide some combination of code size reduction, performance improvement, and energy reduction. | +| | | While the instructions are intended to have general use, some instructions are more useful in some domains than others. Hence, several smaller bitmanip extensions are provided. Each of these smaller extensions is grouped by common function and use case, and each has its own Zb*-extension name. | +---------------+-----------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| Zicond | RV32Zicond Integer Conditional Instructions_ | The instructions follow the format for R-type instructions with 3 operands (i.e., 2 source operands and 1 destination operand). Using these instructions, branchless sequences can be implemented (typically in two-instruction sequences) without the need for instruction fusion, special provisions during the decoding of architectural instructions, or other microarchitectural provisions | +| Zbc | RVZbc Carry-less multiplication_ | Carry-less multiplication is the multiplication in the polynomial ring over GF(2). | +| | | clmul produces the lower half of the carry-less product and clmulh produces the upper half of the 2✕XLEN carry-less product. | +| | | clmulr produces bits 2✕XLEN−2:XLEN-1 of the 2✕XLEN carry-less product. | +---------------+-----------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| Zicntr | Zicntr_ | No info found yet for extension Zicntr | +| Zbs | RVZbs Single bit Instructions_ | The single-bit instructions provide a mechanism to set, clear, invert, or extract a single bit in a register. The bit is specified by its index. | +---------------+-----------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| Zbb | Zbb_ | No info found yet for extension Zbb | +| Zcb | RV32Zcb Code Size Reduction Instructions_ | Zcb belongs to the group of extensions called RISC-V Code Size Reduction Extension (Zc*). Zc* has become the superset of the Standard C extension adding more 16-bit instructions to the ISA. Zcb includes the 16-bit version of additional Integer (I), Multiply (M), and Bit-Manipulation (Zbb) Instructions. All the Zcb instructions require at least standard C extension support as a prerequisite, along with M and Zbb extensions for the 16-bit version of the respective instructions. | +---------------+-----------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| Zbc | Zbc_ | No info found yet for extension Zbc | +| Zicntr | Zicntr_ | No info found yet for extension Zicntr | +---------------+-----------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ RV32I Base Integer Instructions @@ -55,7 +58,7 @@ RV32I Base Integer Instructions +--------+--------------------------+-------------------------------------------------------------------+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------+ | Name | Format | Pseudocode | Invalid_values | Exception_raised | Description | Op Name | +========+==========================+===================================================================+==================+================================================================================================================================================================================================================================================================================+=============================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================+==================================================+ -| ADDI | addi | x[rd] = x[rs1] + sext(imm[11:0]) | NONE | NONE | add sign-extended 12-bit immediate to register rs1, and store the result in register rd. | Integer_Register_Immediate_Operations | +| ADDI | addi rd, rs1, imm[11:0] | x[rd] = x[rs1] + sext(imm[11:0]) | NONE | NONE | add sign-extended 12-bit immediate to register rs1, and store the result in register rd. | Integer_Register_Immediate_Operations | +--------+--------------------------+-------------------------------------------------------------------+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------+ | ANDI | andi rd, rs1, imm[11:0] | x[rd] = x[rs1] & sext(imm[11:0]) | NONE | NONE | perform bitwise AND on register rs1 and the sign-extended 12-bit immediate and place the result in rd. | Integer_Register_Immediate_Operations | +--------+--------------------------+-------------------------------------------------------------------+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------+ @@ -274,6 +277,82 @@ RVZba Address generation instructions | SLLI.UW | slli.uw rd, rs1, imm | X(rd) = (EXTZ(X(rs)[31..0]) << imm) | NONE | NONE | This instruction takes the least-significant word of rs1, zero-extends it, and shifts it left by the immediate. | Address generation instructions | +-----------+------------------------+------------------------------------------+------------------+--------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------+ +RVZbb Basic bit-manipulation +---------------------------- + + ++--------+----------------------+--------------------------------------------------------------+------------------+--------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+ +| Name | Format | Pseudocode | Invalid_values | Exception_raised | Description | Op Name | ++========+======================+==============================================================+==================+====================+=====================================================================================================================================================================+==================================+ +| ANDN | andn rd, rs1, rs2 | X(rd) = X(rs1) & ~X(rs2) | NONE | NONE | Performs bitwise AND operation between rs1 and bitwise inversion of rs2. | Logical_with_negate | ++--------+----------------------+--------------------------------------------------------------+------------------+--------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+ +| ORN | orn rd, rs1, rs2 | X(rd) = X(rs1) | ~X(rs2) | NONE | NONE | Performs bitwise OR operation between rs1 and bitwise inversion of rs2. | Logical_with_negate | ++--------+----------------------+--------------------------------------------------------------+------------------+--------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+ +| XNOR | xnor rd, rs1, rs2 | X(rd) = ~(X(rs1) ^ X(rs2)) | NONE | NONE | Performs bitwise XOR operation between rs1 and rs2, then complements the result. | Logical_with_negate | ++--------+----------------------+--------------------------------------------------------------+------------------+--------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+ +| CLZ | clz rd, rs | if [x[i]] == 1 then return(i) else return -1 | NONE | NONE | Counts leading zero bits in rs. | Count_leading_trailing_zero_bits | ++--------+----------------------+--------------------------------------------------------------+------------------+--------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+ +| CTZ | ctz rd, rs | if [x[i]] == 1 then return(i) else return xlen; | NONE | NONE | Counts trailing zero bits in rs. | Count_leading_trailing_zero_bits | ++--------+----------------------+--------------------------------------------------------------+------------------+--------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+ +| CLZW | clzw rd, rs | if [x[i]] == 1 then return(i) else return -1 | NONE | NONE | Counts leading zero bits in the least-significant word of rs. | Count_leading_trailing_zero_bits | ++--------+----------------------+--------------------------------------------------------------+------------------+--------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+ +| CTZW | ctzw rd, rs | if [x[i]] == 1 then return(i) else return 32; | NONE | NONE | Counts trailing zero bits in the least-significant word of rs. | Count_leading_trailing_zero_bits | ++--------+----------------------+--------------------------------------------------------------+------------------+--------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+ +| CPOP | cpop rd, rs | if rs[i] == 1 then bitcount = bitcount + 1 else () | NONE | NONE | Counts set bits in rs. | Count_population | ++--------+----------------------+--------------------------------------------------------------+------------------+--------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+ +| CPOPW | cpopw rd, rs | if rs[i] == 0b1 then bitcount = bitcount + 1 else () | NONE | NONE | Counts set bits in the least-significant word of rs. | Count_population | ++--------+----------------------+--------------------------------------------------------------+------------------+--------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+ +| MAX | max rd, rs1, rs2 | if rs1_val <_s rs2_val then rs2_val else rs1_val | NONE | NONE | Returns the larger of two signed integers. | Integer_minimum_maximum | ++--------+----------------------+--------------------------------------------------------------+------------------+--------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+ +| MAXU | maxu rd, rs1, rs2 | if rs1_val <_u rs2_val then rs2_val else rs1_val | NONE | NONE | Returns the larger of two unsigned integers. | Integer_minimum_maximum | ++--------+----------------------+--------------------------------------------------------------+------------------+--------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+ +| MIN | min rd, rs1, rs2 | if rs1_val <_s rs2_val then rs1_val else rs2_val | NONE | NONE | Returns the smaller of two signed integers. | Integer_minimum_maximum | ++--------+----------------------+--------------------------------------------------------------+------------------+--------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+ +| MINU | minu rd, rs1, rs2 | if rs1_val <_u rs2_val then rs1_val else rs2_val | NONE | NONE | Returns the smaller of two unsigned integers. | Integer_minimum_maximum | ++--------+----------------------+--------------------------------------------------------------+------------------+--------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+ +| SEXT.B | sext.b rd, rs | X(rd) = EXTS(X(rs)[7..0]) | NONE | NONE | Sign-extends the least-significant byte in the source to XLEN. | Sign_and_zero_extension | ++--------+----------------------+--------------------------------------------------------------+------------------+--------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+ +| SEXT.H | sext.h rd, rs | X(rd) = EXTS(X(rs)[15..0]) | NONE | NONE | Sign-extends the least-significant halfword in rs to XLEN. | Sign_and_zero_extension | ++--------+----------------------+--------------------------------------------------------------+------------------+--------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+ +| ZEXT.H | zext.h rd, rs | X(rd) = EXTZ(X(rs)[15..0]) | NONE | NONE | Zero-extends the least-significant halfword of the source to XLEN. | Sign_and_zero_extension | ++--------+----------------------+--------------------------------------------------------------+------------------+--------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+ +| ROL | rol rd, rs1, rs2 | (X(rs1) << log2(XLEN)) | (X(rs1) >> (xlen - log2(XLEN))) | NONE | NONE | Performs a rotate left of rs1 by the amount in least-significant log2(XLEN) bits of rs2. | Bitwise_rotation | ++--------+----------------------+--------------------------------------------------------------+------------------+--------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+ +| ROR | ror rd, rs1, rs2 | (X(rs1) >> log2(XLEN)) | (X(rs1) << (xlen - log2(XLEN))) | NONE | NONE | Performs a rotate right of rs1 by the amount in least-significant log2(XLEN) bits of rs2. | Bitwise_rotation | ++--------+----------------------+--------------------------------------------------------------+------------------+--------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+ +| RORI | rori rd, rs1, shamt | (X(rs1) >> log2(XLEN)) | (X(rs1) << (xlen - log2(XLEN))) | NONE | NONE | Performs a rotate right of rs1 by the amount in least-significant log2(XLEN) bits of shamt. | Bitwise_rotation | ++--------+----------------------+--------------------------------------------------------------+------------------+--------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+ +| ROLW | rolw rd, rs1, rs2 | EXTS((rs1 << X(rs2)[4..0]) | (rs1 >> (32 - X(rs2)[4..0]))) | NONE | NONE | Performs a rotate left on the least-significant word of rs1 by the amount in least-significant 5 bits of rs2. | Bitwise_rotation | ++--------+----------------------+--------------------------------------------------------------+------------------+--------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+ +| RORIW | roriw rd, rs1, shamt | (rs1_data >> shamt[4..0]) | (rs1_data << (32 - shamt[4..0])) | NONE | NONE | Performs a rotate right on the least-significant word of rs1 by the amount in least-significant log2(XLEN) bits of shamt. | Bitwise_rotation | ++--------+----------------------+--------------------------------------------------------------+------------------+--------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+ +| RORW | rorw rd, rs1, rs2 | (rs1 >> X(rs2)[4..0]) | (rs1 << (32 - X(rs2)[4..0])) | NONE | NONE | Performs a rotate right on the least-significant word of rs1 by the amount in least-significant 5 bits of rs2. | Bitwise_rotation | ++--------+----------------------+--------------------------------------------------------------+------------------+--------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+ +| ORC.b | orc.b rd, rs | if { input[(i + 7)..i] == 0 then 0b00000000 else 0b11111111 | NONE | NONE | Sets the bits of each byte in rd to all zeros if no bit within the respective byte of rs is set, or to all ones if any bit within the respective byte of rs is set. | OR_Combine | ++--------+----------------------+--------------------------------------------------------------+------------------+--------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+ +| REV8 | rev8 rd, rs | output[i..(i + 7)] = input[(j - 7)..j] | NONE | NONE | Reverses the order of the bytes in rs. | Byte_reverse | ++--------+----------------------+--------------------------------------------------------------+------------------+--------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+ + +RVZbc Carry-less multiplication +------------------------------- + + ++--------+---------------------+------------------------------------------------------------------------------------------+------------------+--------------------+------------------------------------------------------------------------+--------------------------------------+ +| Name | Format | Pseudocode | Invalid_values | Exception_raised | Description | Op Name | ++========+=====================+==========================================================================================+==================+====================+========================================================================+======================================+ +| CLMUL | clmul rd, rs1, rs2 | foreach (i from 1 to xlen by 1) { | NONE | NONE | clmul produces the lower half of the 2.XLEN carry-less product. | Carry-less multiplication Operations | +| | | output = if ((rs2 >> i) & 1) then output ^ (rs1 << i); else output; | | | | | +| | | } | | | | | ++--------+---------------------+------------------------------------------------------------------------------------------+------------------+--------------------+------------------------------------------------------------------------+--------------------------------------+ +| CLMULH | clmulh rd, rs1, rs2 | foreach (i from 1 to xlen by 1) { | NONE | NONE | clmulh produces the upper half of the 2.XLEN carry-less product. | Carry-less multiplication Operations | +| | | output = if ((rs2_val >> i) & 1) then output ^ (rs1_val >> (xlen - i)) else output | | | | | +| | | } | | | | | ++--------+---------------------+------------------------------------------------------------------------------------------+------------------+--------------------+------------------------------------------------------------------------+--------------------------------------+ +| CLMULR | clmulr rd, rs1, rs2 | foreach (i from 0 to (xlen - 1) by 1) { | NONE | NONE | clmulr produces bits 2.XLEN-2:XLEN-1 of the 2.XLEN carry-less product. | Carry-less multiplication Operations | +| | | output = if ((rs2_val >> i) & 1) then output ^ (rs1_val >> (xlen - i - 1)) else output | | | | | +| | | } | | | | | ++--------+---------------------+------------------------------------------------------------------------------------------+------------------+--------------------+------------------------------------------------------------------------+--------------------------------------+ + RVZbs Single bit Instructions ----------------------------- @@ -298,33 +377,33 @@ RVZbs Single bit Instructions | BSETI | bseti rd, rs1, shamt | X(rd) = X(rs1) | (1 << (shamt & (XLEN - 1))) | NONE | NONE | This instruction returns rs1 with a single bit set at the index specified in shamt. The index is read from the lower log2(XLEN) bits of shamt. For RV32, the encodings corresponding to shamt[5]=1 are reserved. | Single_bit_Operations | +--------+----------------------+------------------------------------------------+------------------+--------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------+ -RV32Zicond Integer Conditional Instructions -------------------------------------------- - - -+-----------+------------------------+----------------------------------------+------------------+--------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------+ -| Name | Format | Pseudocode | Invalid_values | Exception_raised | Description | Op Name | -+===========+========================+========================================+==================+====================+======================================================================================================================================================================================================================================================+================================+ -| CZERO.EQZ | czero.eqz rd, rs1, rs2 | if (x[rs2] == 0) x[rd] = 0 else x[rs1] | NONE | NONE | This instruction behaves as if there is a conditional branch dependent on rs2 being equal to zero, wherein it branches to code that writes a 0 into rd when the equivalence is true, and otherwise falls through to code that moves rs1 into rd. | Integer Conditional Operations | -+-----------+------------------------+----------------------------------------+------------------+--------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------+ -| CZERO.NEZ | czero.nez rd, rs1, rs2 | if (x[rs2] != 0) x[rd] = 0 else x[rs1] | NONE | NONE | This instruction behaves as if there is a conditional branch dependent on rs2 being not equal to zero, wherein it branches to code that writes a 0 into rd when the equivalence is true, and otherwise falls through to code that moves rs1 into rd. | Integer Conditional Operations | -+-----------+------------------------+----------------------------------------+------------------+--------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------+ - - -+--------+----------+--------------+------------------+--------------------+---------------+-----------+ -| Name | Format | Pseudocode | Invalid_values | Exception_raised | Description | Op Name | -+========+==========+==============+==================+====================+===============+===========+ -+--------+----------+--------------+------------------+--------------------+---------------+-----------+ - - -+--------+----------+--------------+------------------+--------------------+---------------+-----------+ -| Name | Format | Pseudocode | Invalid_values | Exception_raised | Description | Op Name | -+========+==========+==============+==================+====================+===============+===========+ -+--------+----------+--------------+------------------+--------------------+---------------+-----------+ - - -+--------+----------+--------------+------------------+--------------------+---------------+-----------+ -| Name | Format | Pseudocode | Invalid_values | Exception_raised | Description | Op Name | -+========+==========+==============+==================+====================+===============+===========+ -+--------+----------+--------------+------------------+--------------------+---------------+-----------+ +RV32Zcb Code Size Reduction Instructions +---------------------------------------- + + ++----------+-----------------------+------------------------------------------------------+------------------+----------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------+ +| Name | Format | Pseudocode | Invalid_values | Exception_raised | Description | Op Name | ++==========+=======================+======================================================+==================+============================================================================+==============================================================================================================================================================================================================================================================================================+================================+ +| C.ZEXT.B | c.zext.b rd' | x[8 + rd'] = zext(x[8 + rd'][7:0]) | NONE | NONE | This instruction takes a single source/destination operand. It zero-extends the least-significant byte of the operand by inserting zeros into all of the bits more significant than 7. | Code Size Reduction Operations | ++----------+-----------------------+------------------------------------------------------+------------------+----------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------+ +| C.SEXT.B | c.sext.b rd' | x[8 + rd'] = sext(x[8 + rd'][7:0]) | NONE | NONE | This instruction takes a single source/destination operand. It sign-extends the least-significant byte in the operand by copying the most-significant bit in the byte (i.e., bit 7) to all of the more-significant bits. It also requires Bit-Manipulation (Zbb) extension support. | Code Size Reduction Operations | ++----------+-----------------------+------------------------------------------------------+------------------+----------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------+ +| C.ZEXT.H | c.zext.h rd' | x[8 + rd'] = zext(x[8 + rd'][15:0]) | NONE | NONE | This instruction takes a single source/destination operand. It zero-extends the least-significant halfword of the operand by inserting zeros into all of the bits more significant than 15. It also requires Bit-Manipulation (Zbb) extension support. | Code Size Reduction Operations | ++----------+-----------------------+------------------------------------------------------+------------------+----------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------+ +| C.SEXT.H | c.sext.h rd' | x[8 + rd'] = sext(x[8 + rd'][15:0]) | NONE | NONE | This instruction takes a single source/destination operand. It sign-extends the least-significant halfword in the operand by copying the most-significant bit in the halfword (i.e., bit 15) to all of the more-significant bits. It also requires Bit-Manipulation (Zbb) extension support. | Code Size Reduction Operations | ++----------+-----------------------+------------------------------------------------------+------------------+----------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------+ +| C.NOT | c.not rd' | x[8 + rd'] = x[8 + rd'] ^ -1 | NONE | NONE | This instruction takes the one’s complement of rd'/rs1' and writes the result to the same register. | Code Size Reduction Operations | ++----------+-----------------------+------------------------------------------------------+------------------+----------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------+ +| C.MUL | c.mul rd', rs2' | x[8 + rd'] = (x[8 + rd'] * x[8 + rs2'])[31:0] | NONE | NONE | performs a 32-bit × 32-bit multiplication and places the lower 32 bits in the destination register (Both rd' and rs2' treated as signed numbers). It also requires M extension support. | Code Size Reduction Operations | ++----------+-----------------------+------------------------------------------------------+------------------+----------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------+ +| C.LHU | c.lhu rd', uimm(rs1') | x[8+rd'] = zext(M[x[8+rs1'] + zext(uimm[1])][15:0]) | NONE | an exception raised if the memory address isn't aligned (2-byte boundary). | This instruction loads a halfword from the memory address formed by adding rs1' to the zero extended immediate uimm. The resulting halfword is zero extended and is written to rd'. | Code Size Reduction Operations | ++----------+-----------------------+------------------------------------------------------+------------------+----------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------+ +| C.LH | c.lh rd', uimm(rs1') | x[8+rd'] = sext(M[x[8+rs1'] + zext(uimm[1])][15:0]) | NONE | an exception raised if the memory address isn't aligned (2-byte boundary). | This instruction loads a halfword from the memory address formed by adding rs1' to the zero extended immediate uimm. The resulting halfword is sign extended and is written to rd'. | Code Size Reduction Operations | ++----------+-----------------------+------------------------------------------------------+------------------+----------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------+ +| C.LBU | c.lbu rd', uimm(rs1') | x[8+rd'] = zext(M[x[8+rs1'] + zext(uimm[1:0])][7:0]) | NONE | NONE | This instruction loads a byte from the memory address formed by adding rs1' to the zero extended immediate uimm. The resulting byte is zero extended and is written to rd'. | Code Size Reduction Operations | ++----------+-----------------------+------------------------------------------------------+------------------+----------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------+ +| C.SH | c.sh rs2', uimm(rs1') | M[x[8+rs1'] + zext(uimm[1])][15:0] = x[8+rs2'] | NONE | an exception raised if the memory address isn't aligned (2-byte boundary). | This instruction stores the least significant halfword of rs2' to the memory address formed by adding rs1' to the zero extended immediate uimm. | Code Size Reduction Operations | ++----------+-----------------------+------------------------------------------------------+------------------+----------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------+ +| C.SB | c.sb rs2', uimm(rs1') | M[x[8+rs1'] + zext(uimm[1:0])][7:0] = x[8+rs2'] | NONE | NONE | This instruction stores the least significant byte of rs2' to the memory address formed by adding rs1' to the zero extended immediate uimm. | Code Size Reduction Operations | ++----------+-----------------------+------------------------------------------------------+------------------+----------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------+ diff --git a/config/gen_from_riscv_config/requirements.txt b/config/gen_from_riscv_config/requirements.txt index caebb85f4c..f97f9c9699 100644 --- a/config/gen_from_riscv_config/requirements.txt +++ b/config/gen_from_riscv_config/requirements.txt @@ -3,4 +3,4 @@ pyyaml mdutils restructuredtext-lint rstcloth -regex +regex \ No newline at end of file diff --git a/config/gen_from_riscv_config/scripts/libs/csr_updater.py b/config/gen_from_riscv_config/scripts/libs/csr_updater.py index d8b6ba5205..03c3388078 100644 --- a/config/gen_from_riscv_config/scripts/libs/csr_updater.py +++ b/config/gen_from_riscv_config/scripts/libs/csr_updater.py @@ -13,7 +13,8 @@ # limitations under the License. # # Original Author: Oukalrazqou Abdessamii -""" Module is used to update csr based on yaml file called csr updater""" +""" Module is used to update csr based on yaml file called csr updater """ +import re import yaml @@ -28,13 +29,14 @@ def csr_recursive_update(original_dict, csr_update): """ for key, value in csr_update.items(): if key in original_dict.keys(): - print(key) if isinstance(value, dict): csr_recursive_update(original_dict[key], value) elif isinstance(value, bool): if isinstance(original_dict[key], dict): for k in original_dict[key]: + print(k) if isinstance(original_dict[key][k], dict): + for sub_key in original_dict[key][k]: original_dict[key][k][sub_key] = value else: @@ -85,7 +87,7 @@ def remove_keys_recursive(dictionary): else: if v.get(exclude_key) == cond: keys_to_remove.append(k) - remove_keys_recursive(v) + remove_keys_recursive(v) for k in keys_to_remove: dictionary.pop(k) diff --git a/config/gen_from_riscv_config/scripts/libs/isa_updater.py b/config/gen_from_riscv_config/scripts/libs/isa_updater.py index 06a0e0d9c6..aea4245910 100644 --- a/config/gen_from_riscv_config/scripts/libs/isa_updater.py +++ b/config/gen_from_riscv_config/scripts/libs/isa_updater.py @@ -14,7 +14,7 @@ # # Original Author: Oukalrazqou Abdessamii -""" Module is used to update isa based on yaml file called isa updater""" +""" Module is used to update isa based on yaml file called isa updater """ import re diff --git a/config/gen_from_riscv_config/scripts/libs/utils.py b/config/gen_from_riscv_config/scripts/libs/utils.py index 39621589d2..92cb450dbd 100644 --- a/config/gen_from_riscv_config/scripts/libs/utils.py +++ b/config/gen_from_riscv_config/scripts/libs/utils.py @@ -102,11 +102,19 @@ class Field: """field class""" def __init__( - self, name, bitlegal, bitmask, bitmsb, bitlsb, bitWidth, fieldDesc, fieldaccess + self, + name, + bitlegal, + fieldreset, + bitmsb, + bitlsb, + bitWidth, + fieldDesc, + fieldaccess, ): self.name = name self.bitlegal = bitlegal - self.bitmask = bitmask + self.fieldreset = fieldreset self.bitmsb = bitmsb self.bitlsb = bitlsb self.bitWidth = bitWidth @@ -226,7 +234,11 @@ def returnAsString(self): for i, _ in enumerate(regNameList): if regRV32List[i] | regRV64List[i]: summary_table.append( - [regAddressList[i], str(regNameList[i]), str(regDescrList[i])] + [ + regAddressList[i], + str(regNameList[i]).upper(), + str(regDescrList[i]), + ] ) r.table(header=["Address", "Register Name", "Description"], data=summary_table) @@ -234,7 +246,7 @@ def returnAsString(self): for reg in registerlist: if reg.RV32 | reg.RV64: reg_table = [] - r.h2(reg.name) + r.h2(reg.name.upper()) r.newline() r.field("Address", (reg.address)) if reg.resetValue: @@ -252,15 +264,18 @@ def returnAsString(self): bits = f"[{field.bitmsb}:{field.bitlsb}]" _line = [ bits, - field.name, + field.name.upper(), field.bitlegal, - field.bitmask, + field.fieldreset, field.fieldaccess, ] _line.append(field.fieldDesc) reg_table.append(_line) - _headers = ["Bits", "Field Name", "Legal Values", "Mask", "Access"] + _headers = ["Bits", "Field Name", "Legal Values", "Reset", "Type"] _headers.append("Description") + reg_table = sorted( + reg_table, key=lambda x: int(x[0].strip("[]").split(":")[0]) + ) # table of the register r.table(header=_headers, data=reg_table) return r.data @@ -306,31 +321,31 @@ def returnAsString(self): r.table(header=["Subset Name", "Name", "Description"], data=summary_table) for reg in self.Instructionlist: reg_table = [] - _headers = [ - "Name", - "Format", - "Pseudocode", - "Invalid_values", - "Exception_raised", - "Description", - "Op Name", - ] if len(reg.Name) > 0: + _headers = [ + "Name", + "Format", + "Pseudocode", + "Invalid_values", + "Exception_raised", + "Description", + "Op Name", + ] r.h2(reg.key) r.newline() - for fieldIndex in list(range(len(reg.Name))): - _line = [ - reg.Name[fieldIndex], - reg.Format[fieldIndex], - reg.pseudocode[fieldIndex], - reg.invalid_values[fieldIndex], - reg.exception_raised[fieldIndex], - reg.Description[fieldIndex], - ] - _line.append(reg.OperationName[fieldIndex]) - reg_table.append(_line) + for fieldIndex in list(range(len(reg.Name))): + _line = [ + reg.Name[fieldIndex], + reg.Format[fieldIndex], + reg.pseudocode[fieldIndex], + reg.invalid_values[fieldIndex], + reg.exception_raised[fieldIndex], + reg.Description[fieldIndex], + ] + _line.append(reg.OperationName[fieldIndex]) + reg_table.append(_line) # table of the register - r.table(header=_headers, data=reg_table) + r.table(header=_headers, data=reg_table) return r.data @@ -416,6 +431,7 @@ def returnAsString(self): ).replace("\n", " ") reg_table.append(reg.Description[fieldIndex]) reg_table.append(reg.OperationName[fieldIndex]) + self.mdFile.new_table( columns=len(headers), rows=len(reg.Description) + 1, @@ -438,6 +454,13 @@ def __init__(self, name): self.suffix = ".md" self.mdFile = MdUtils(file_name="none", title="") + def parse_bits(self, bits): + if ":" in bits: + msb, lsb = map(int, bits.strip("[]").split(":")[0]) + else: + msb = lsb = int(bits.strip("[]").split(":")[0]) + return msb, lsb + def returnAsString(self): registerlist = sorted(self.registerList, key=lambda reg: reg.address) regNameList = [reg.name for reg in registerlist if reg.RV32 | reg.RV64] @@ -465,7 +488,7 @@ def returnAsString(self): rows.extend( [ regAddressList[i], - f"[{regNameList[i]}](#{regNameList[i]})", + f"[{regNameList[i].upper()}](#{regNameList[i].upper()})", str(regDescrList[i]), ] ) @@ -479,34 +502,45 @@ def returnAsString(self): self.mdFile.new_header(level=3, title="Registers Description") for reg in registerlist: if reg.RV64 | reg.RV32: - headers = ["Bits", "Field Name", "Legal Values", "Mask", "Access"] - headers.append("Description") self.returnMdRegDesc( reg.name, reg.address, reg.resetValue, reg.desc, reg.access ) reg_table = [] + _line = [] for field in reg.field: if field.bitWidth == 1: # only one bit -> no range needed bits = f"{field.bitlsb}" else: bits = f"[{field.bitmsb}:{field.bitlsb}]" - reg_table.append(bits) - reg_table.append(field.name) - reg_table.append(field.bitlegal) - reg_table.append(field.bitmask) - reg_table.append(field.fieldaccess) - reg_table.append(field.fieldDesc) + reg_table.append( + [ + bits, + field.name.upper(), + field.bitlegal, + field.fieldreset, + field.fieldaccess, + field.fieldDesc, + ] + ) + _headers = ["Bits", "Field Name", "Legal Values", "Reset", "Type"] + _headers.append("Description") + reg_table = sorted( + reg_table, key=lambda x: int(x[0].strip("[]").split(":")[0]) + ) + reg_table_flattened = [ + item for sublist in reg_table for item in sublist + ] self.mdFile.new_table( - columns=len(headers), - rows=len(reg.field) + 1, - text=headers + reg_table, + columns=len(_headers), + rows=len(reg_table) + 1, + text=_headers + reg_table_flattened, text_align="left", ) return self.mdFile.file_data_text def returnMdRegDesc(self, name, address, resetValue, desc, access): - self.mdFile.new_header(level=4, title=name) + self.mdFile.new_header(level=4, title=name.upper()) self.mdFile.new_line("---") self.mdFile.new_line("**Address** " + str(address)) if resetValue: @@ -553,18 +587,19 @@ def returnRegister( ) bitmsb = int(registerElem.get("rv32", "")[item].get("msb", "")) bitlsb = int(registerElem.get("rv32", "")[item].get("lsb", "")) - fieldaccess = ( - registerElem.get("rv32", "")[item] - .get("shadow_type", "") - .upper() + fieldreset = hex( + int(resetValue, 16) >> (bitlsb) & ((1 << ((bitWidth))) - 1) ) + fieldaccess = "" legal = registerElem.get("rv32", "")[item].get("type", None) if legal is None: bitlegal = "" - bitmask = "" + fieldaccess = "WARL" + fieldDesc = fieldDesc else: warl = re.findall(pattern_warl, str(legal.keys())) if warl: + fieldaccess = warl[0].upper() legal_2 = ( registerElem.get("rv32", "")[item] .get("type", None) @@ -579,22 +614,19 @@ def returnRegister( pattern, str(legal_2["legal"][0]) ) if matches: - legal_value = matches.group(3) - mask = matches.group(4) - bitmask = mask + legal_value = matches.group(2) bitlegal = legal_value elif isinstance(legal_2, list): pattern = r"\s*((?:0x)?[0-9A-Fa-f]+)\s*(.)\s*((?:0x)?[0-9A-Fa-f]+)\s*" matches = re.search(pattern, legal_2[0]) if matches: - legal_value = matches.group(1) - mask = matches.group(3) - bitmask = mask + legal_value = ( + f"[{matches.group(1)} , {matches.group(3)}]" + ) + bitlegal = legal_value else: - mask = 0 legal_value = hex(legal_2) - bitmask = mask bitlegal = legal_value pattern = r"((\D+)\d+(.*))-\d+" match = re.match(pattern, regName) @@ -608,28 +640,41 @@ def returnRegister( ) else: fieldName = item + f = Field( + fieldName, + bitlegal, + fieldreset, + bitmsb, + bitlsb, + bitWidth, + fieldDesc, + fieldaccess, + ) + field.append(f) elif isinstance(item, list): for item_ in item: fieldName = f"Reserved_{item_[0]}" bitlsb = item_[0] bitmsb = item_[len(item_) - 1] legal = "" - fieldaccess = "Reserved" + fieldaccess = "WPRI" bitWidth = int(item_[len(item_) - 1]) - int(item_[0]) + 1 - fieldDesc = "Reserved" + fieldDesc = "RESERVED" bitlegal = legal - bitmask = "" - f = Field( - fieldName, - bitlegal, - bitmask, - bitmsb, - bitlsb, - bitWidth, - fieldDesc, - fieldaccess, - ) - field.append(f) + fieldreset = hex( + int(resetValue, 16) >> (bitlsb) & ((1 << ((bitWidth))) - 1) + ) + f = Field( + fieldName, + bitlegal, + fieldreset, + bitmsb, + bitlsb, + bitWidth, + fieldDesc, + fieldaccess, + ) + field.append(f) elif len(fieldList) == 0: pattern = r"(\D+)\[(\d+)\-\d+\](.*)" match = re.match(pattern, regName) @@ -653,12 +698,15 @@ def returnRegister( bitmsb = registerElem.get("rv32", None).get("msb", None) bitlsb = registerElem.get("rv32", None).get("lsb", None) legal = registerElem.get("rv32", "").get("type", None) + fieldaccess = "" if legal is None: bitlegal = "" bitmask = "" + fieldaccess = "RO" else: warl = re.findall(pattern_warl, str(legal.keys())) if warl: + fieldaccess = warl[0].upper() legal_2 = ( registerElem.get("rv32", "") .get("type", None) @@ -671,7 +719,9 @@ def returnRegister( pattern = r"([\w\[\]:]+\s*\w+\s*)(\[\s*((?:0x)?[0-9A-Fa-f]+)\s*\D+\s*(?:((?:0x)?[0-9A-Fa-f]+))?\s*])" matches = re.search(pattern, str(legal_2["legal"][0])) if matches: - legal_value = matches.group(3) + legal_value = ( + f"[{matches.group(3)} , {matches.group(4)}]" + ) mask = matches.group(4) bitmask = mask bitlegal = legal_value @@ -679,15 +729,17 @@ def returnRegister( pattern = r"([0-9A-Fa-f]+).*([0-9A-Fa-f]+)" matches = re.search(pattern, legal_2[0]) if matches: - legal_value = matches.group(1) + legal_value = ( + f"[{matches.group(1)} , {matches.group(2)}]" + ) mask = matches.group(2) bitmask = mask - bitlegal = hex(legal_value) + bitlegal = legal_value else: bitmask = 0 - bitlegal = hex(legal_2) - fieldaccess = registerElem.get("rv32", "").get("shadow_type", "").upper() + bitlegal = "0x" + hex(legal_2)[2:].zfill(int(size / 4)) fieldDesc = regDesc + fieldreset = "0x" + hex(int(resetValue, 16))[2:].zfill(int(size / 4)) if bitlsb is None: bitlsb = 0 if bitmsb is None: @@ -698,7 +750,7 @@ def returnRegister( f = Field( fieldName, bitlegal, - bitmask, + fieldreset, bitmsb, bitlsb, bitWidth, diff --git a/config/gen_from_riscv_config/scripts/riscv_config_gen.py b/config/gen_from_riscv_config/scripts/riscv_config_gen.py index f7e8c5e495..2b7a2dc20b 100644 --- a/config/gen_from_riscv_config/scripts/riscv_config_gen.py +++ b/config/gen_from_riscv_config/scripts/riscv_config_gen.py @@ -30,7 +30,7 @@ parser = argparse.ArgumentParser(description="ipxact2rst") parser.add_argument("-s", "--srcFile", help="yaml input file") parser.add_argument("-d", "--destDir", help="write generated file to dir") - parser.add_argument("-m", "--modif", help="ISA Formatter if existe") + parser.add_argument("-m", "--modif", help="ISA /CSR Formatter if exist") parser.add_argument("-i", "--temp", help="Full ISA Template") parser.add_argument("-t", "--target", help="Specifiy Config Name") args, unknown_args = parser.parse_known_args() diff --git a/config/gen_from_riscv_config/templates/isa_template.yaml b/config/gen_from_riscv_config/templates/isa_template.yaml index c531116c10..db8e52de7a 100644 --- a/config/gen_from_riscv_config/templates/isa_template.yaml +++ b/config/gen_from_riscv_config/templates/isa_template.yaml @@ -18,7 +18,7 @@ RV32Zcb Code Size Reduction Instructions: zeros into all of the bits more significant than 7. Pseudocode: x[8 + rd'] = zext(x[8 + rd'][7:0]) Invalid_Values: NONE - Exception raised: NONE + Exception_Raised: NONE C.SEXT.B: Format: c.sext.b rd' Description: > @@ -29,7 +29,7 @@ RV32Zcb Code Size Reduction Instructions: support. Pseudocode: x[8 + rd'] = sext(x[8 + rd'][7:0]) Invalid_Values: NONE - Exception raised: NONE + Exception_Raised: NONE C.ZEXT.H: Format: c.zext.h rd' Description: > @@ -39,7 +39,7 @@ RV32Zcb Code Size Reduction Instructions: Bit-Manipulation (Zbb) extension support. Pseudocode: x[8 + rd'] = zext(x[8 + rd'][15:0]) Invalid_Values: NONE - Exception raised: NONE + Exception_Raised: NONE C.SEXT.H: Format: c.sext.h rd' Description: > @@ -50,7 +50,7 @@ RV32Zcb Code Size Reduction Instructions: support. Pseudocode: x[8 + rd'] = sext(x[8 + rd'][15:0]) Invalid_Values: NONE - Exception raised: NONE + Exception_Raised: NONE C.NOT: Format: c.not rd' Description: > @@ -58,7 +58,7 @@ RV32Zcb Code Size Reduction Instructions: the result to the same register. Pseudocode: x[8 + rd'] = x[8 + rd'] ^ -1 Invalid_Values: NONE - Exception raised: NONE + Exception_Raised: NONE C.MUL: Format: c.mul rd', rs2' Description: > @@ -67,7 +67,7 @@ RV32Zcb Code Size Reduction Instructions: numbers). It also requires M extension support. Pseudocode: x[8 + rd'] = (x[8 + rd'] * x[8 + rs2'])[31:0] Invalid_Values: NONE - Exception raised: NONE + Exception_Raised: NONE C.LHU: Format: c.lhu rd', uimm(rs1') Description: > @@ -76,7 +76,7 @@ RV32Zcb Code Size Reduction Instructions: is zero extended and is written to rd'. Pseudocode: x[8+rd'] = zext(M[x[8+rs1'] + zext(uimm[1])][15:0]) Invalid_Values: NONE - Exception raised: an exception raised if the memory address isn't aligned + Exception_Raised: an exception raised if the memory address isn't aligned (2-byte boundary). C.LH: Format: c.lh rd', uimm(rs1') @@ -86,7 +86,7 @@ RV32Zcb Code Size Reduction Instructions: is sign extended and is written to rd'. Pseudocode: x[8+rd'] = sext(M[x[8+rs1'] + zext(uimm[1])][15:0]) Invalid_Values: NONE - Exception raised: an exception raised if the memory address isn't aligned + Exception_Raised: an exception raised if the memory address isn't aligned (2-byte boundary). C.LBU: Format: c.lbu rd', uimm(rs1') @@ -96,7 +96,7 @@ RV32Zcb Code Size Reduction Instructions: zero extended and is written to rd'. Pseudocode: x[8+rd'] = zext(M[x[8+rs1'] + zext(uimm[1:0])][7:0]) Invalid_Values: NONE - Exception raised: NONE + Exception_Raised: NONE C.SH: Format: c.sh rs2', uimm(rs1') Description: > @@ -105,7 +105,7 @@ RV32Zcb Code Size Reduction Instructions: uimm. Pseudocode: M[x[8+rs1'] + zext(uimm[1])][15:0] = x[8+rs2'] Invalid_Values: NONE - Exception raised: an exception raised if the memory address isn't aligned + Exception_Raised: an exception raised if the memory address isn't aligned (2-byte boundary). C.SB: Format: c.sb rs2', uimm(rs1') @@ -115,7 +115,7 @@ RV32Zcb Code Size Reduction Instructions: uimm. Pseudocode: M[x[8+rs1'] + zext(uimm[1:0])][7:0] = x[8+rs2'] Invalid_Values: NONE - Exception raised: NONE + Exception_Raised: NONE RV32A Atomic Instructions: Description: > The standard atomic instruction extension is denoted by instruction @@ -908,7 +908,11 @@ RVZbs Single bit Instructions: Invalid_Values: NONE Exception_Raised: NONE RVZbc Carry-less multiplication: - Subset_Name: Zicb + Description : | + Carry-less multiplication is the multiplication in the polynomial ring over GF(2). + clmul produces the lower half of the carry-less product and clmulh produces the upper half of the 2✕XLEN carry-less product. + clmulr produces bits 2✕XLEN−2:XLEN-1 of the 2✕XLEN carry-less product. + Subset_Name: Zbc Instructions: Carry-less multiplication Operations: CLMUL: @@ -1264,3 +1268,166 @@ RV32I Base Integer Instructions: Pseudocode: x[8 + rd'] = sext(x[8 + rd'][7:0]) Invalid_Values: NONE Exception_Raised: NONE +RVZbb Basic bit-manipulation: + Description : | + The bit-manipulation (bitmanip) extension collection is comprised of several component extensions to the base RISC-V architecture that are intended to provide some combination of code size reduction, performance improvement, and energy reduction. + While the instructions are intended to have general use, some instructions are more useful in some domains than others. Hence, several smaller bitmanip extensions are provided. Each of these smaller extensions is grouped by common function and use case, and each has its own Zb*-extension name. + Subset_Name : Zbb + Instructions : + Logical_with_negate: + ANDN: + Format: andn rd, rs1, rs2 + Description: Performs bitwise AND operation between rs1 and bitwise inversion of rs2. + Pseudocode: X(rd) = X(rs1) & ~X(rs2) + Invalid_Values: NONE + Exception_Raised: NONE + ORN: + Format: orn rd, rs1, rs2 + Description: Performs bitwise OR operation between rs1 and bitwise inversion of rs2. + Pseudocode: X(rd) = X(rs1) | ~X(rs2) + Invalid_Values: NONE + Exception_Raised: NONE + XNOR: + Format: xnor rd, rs1, rs2 + Description: Performs bitwise XOR operation between rs1 and rs2, then complements the result. + Pseudocode: X(rd) = ~(X(rs1) ^ X(rs2)) + Invalid_Values: NONE + Exception_Raised: NONE + Count_leading_trailing_zero_bits: + CLZ : + Format: clz rd, rs + Description: Counts leading zero bits in rs. + Pseudocode: if [x[i]] == 1 then return(i) else return -1 + Invalid_Values: NONE + Exception_Raised: NONE + CTZ : + Format: ctz rd, rs + Description: Counts trailing zero bits in rs. + Pseudocode: if [x[i]] == 1 then return(i) else return xlen; + Invalid_Values: NONE + Exception_Raised: NONE + CLZW: + Format: clzw rd, rs + Description: Counts leading zero bits in the least-significant word of rs. + Pseudocode: if [x[i]] == 1 then return(i) else return -1 + Invalid_Values: NONE + Exception_Raised: NONE + CTZW: + Format: ctzw rd, rs + Description: Counts trailing zero bits in the least-significant word of rs. + Pseudocode: if [x[i]] == 1 then return(i) else return 32; + Invalid_Values: NONE + Exception_Raised: NONE + + Count_population: + CPOP: + Format: cpop rd, rs + Description: Counts set bits in rs. + Pseudocode: if rs[i] == 1 then bitcount = bitcount + 1 else () + Invalid_Values: NONE + Exception_Raised: NONE + CPOPW: + Format: cpopw rd, rs + Description: Counts set bits in the least-significant word of rs. + Pseudocode: if rs[i] == 0b1 then bitcount = bitcount + 1 else () + Invalid_Values: NONE + Exception_Raised: NONE + Integer_minimum_maximum: + MAX: + Format: max rd, rs1, rs2 + Description: Returns the larger of two signed integers. + Pseudocode: if rs1_val <_s rs2_val then rs2_val else rs1_val + Invalid_Values: NONE + Exception_Raised: NONE + MAXU: + Format: maxu rd, rs1, rs2 + Description: Returns the larger of two unsigned integers. + Pseudocode: if rs1_val <_u rs2_val then rs2_val else rs1_val + Invalid_Values: NONE + Exception_Raised: NONE + MIN: + Format: min rd, rs1, rs2 + Description: Returns the smaller of two signed integers. + Pseudocode: if rs1_val <_s rs2_val then rs1_val else rs2_val + Invalid_Values: NONE + Exception_Raised: NONE + MINU: + Format: minu rd, rs1, rs2 + Description: Returns the smaller of two unsigned integers. + Pseudocode: if rs1_val <_u rs2_val then rs1_val else rs2_val + Invalid_Values: NONE + Exception_Raised: NONE + Sign_and_zero_extension: + SEXT.B: + Format: sext.b rd, rs + Description: Sign-extends the least-significant byte in the source to XLEN. + Pseudocode: X(rd) = EXTS(X(rs)[7..0]) + Invalid_Values: NONE + Exception_Raised: NONE + SEXT.H: + Format: sext.h rd, rs + Description: Sign-extends the least-significant halfword in rs to XLEN. + Pseudocode: X(rd) = EXTS(X(rs)[15..0]) + Invalid_Values: NONE + Exception_Raised: NONE + ZEXT.H: + Format: zext.h rd, rs + Description: Zero-extends the least-significant halfword of the source to XLEN. + Pseudocode: X(rd) = EXTZ(X(rs)[15..0]) + Invalid_Values: NONE + Exception_Raised: NONE + Bitwise_rotation: + ROL: + Format: rol rd, rs1, rs2 + Description: Performs a rotate left of rs1 by the amount in least-significant log2(XLEN) bits of rs2. + Pseudocode: (X(rs1) << log2(XLEN)) | (X(rs1) >> (xlen - log2(XLEN))) + Invalid_Values: NONE + Exception_Raised: NONE + ROR: + Format: ror rd, rs1, rs2 + Description: Performs a rotate right of rs1 by the amount in least-significant log2(XLEN) bits of rs2. + Pseudocode: (X(rs1) >> log2(XLEN)) | (X(rs1) << (xlen - log2(XLEN))) + Invalid_Values: NONE + Exception_Raised: NONE + RORI: + Format: rori rd, rs1, shamt + Description: Performs a rotate right of rs1 by the amount in least-significant log2(XLEN) bits of shamt. + Pseudocode: (X(rs1) >> log2(XLEN)) | (X(rs1) << (xlen - log2(XLEN))) + Invalid_Values: NONE + Exception_Raised: NONE + + ROLW: + Format: rolw rd, rs1, rs2 + Description: Performs a rotate left on the least-significant word of rs1 by the amount in least-significant 5 bits of rs2. + Pseudocode: EXTS((rs1 << X(rs2)[4..0]) | (rs1 >> (32 - X(rs2)[4..0]))) + Invalid_Values: NONE + Exception_Raised: NONE + RORIW: + Format: roriw rd, rs1, shamt + Description: Performs a rotate right on the least-significant word of rs1 by the amount in least-significant log2(XLEN) bits of shamt. + Pseudocode: (rs1_data >> shamt[4..0]) | (rs1_data << (32 - shamt[4..0])) + Invalid_Values: NONE + Exception_Raised: NONE + RORW: + Format: rorw rd, rs1, rs2 + Description: Performs a rotate right on the least-significant word of rs1 by the amount in least-significant 5 bits of rs2. + Pseudocode: (rs1 >> X(rs2)[4..0]) | (rs1 << (32 - X(rs2)[4..0])) + Invalid_Values: NONE + Exception_Raised: NONE + + OR_Combine: + ORC.b: + Format: orc.b rd, rs + Description: Sets the bits of each byte in rd to all zeros if no bit within the respective byte of rs is set, or to all ones if any bit within the respective byte of rs is set. + Pseudocode: if { input[(i + 7)..i] == 0 then 0b00000000 else 0b11111111 + Invalid_Values: NONE + Exception_Raised: NONE + + Byte_reverse: + REV8: + Format: rev8 rd, rs + Description: Reverses the order of the bytes in rs. + Pseudocode: output[i..(i + 7)] = input[(j - 7)..j] + Invalid_Values: NONE + Exception_Raised: NONE + diff --git a/config/gen_from_riscv_config/updaters/cv32a65x/csr_updater.yaml b/config/gen_from_riscv_config/updaters/cv32a65x/csr_updater.yaml index 2f966a7f5b..132d09dc7d 100644 --- a/config/gen_from_riscv_config/updaters/cv32a65x/csr_updater.yaml +++ b/config/gen_from_riscv_config/updaters/cv32a65x/csr_updater.yaml @@ -5,14 +5,24 @@ misa: - reset-val: 123475 -mcycle: - reset-val: 123475 -mvendorid: - description: '' -misa: - rv32: - mxl: - shadow_type: '' -pmp : - reset-val: 123475 + reset-val: 0x40001106 + +mcountinhibit: + rv32 : + accessible : false +pmpaddr0: + reset-val: 0x0 +# Range control +pmpaddr : + range: 8 +pmpcfg : + range : 2 + # Exclude mode +exclude : + key : priv_mode + cond : S +exclude : + key : priv_mode + cond : U + + diff --git a/config/gen_from_riscv_config/updaters/cv32a65x/isa_updater.yaml b/config/gen_from_riscv_config/updaters/cv32a65x/isa_updater.yaml index 5a9164ba8e..d54552faa4 100644 --- a/config/gen_from_riscv_config/updaters/cv32a65x/isa_updater.yaml +++ b/config/gen_from_riscv_config/updaters/cv32a65x/isa_updater.yaml @@ -3,16 +3,14 @@ # SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1 # Author: Abdessamii Oukalrazqou -Zicond : True -m0 : True + # Enable and disable extension +Zicond : False -I : True +Zcb : True Zcmp : False -RV32I Base Integer Instructions: - Instructions : - Integer_Register_Immediate_Operations: - ADDI: - Format: addi +Zbb : False + + diff --git a/config/riscv-config/Makefile b/config/riscv-config/Makefile index bc4b676af6..b2fb44d563 100644 --- a/config/riscv-config/Makefile +++ b/config/riscv-config/Makefile @@ -42,5 +42,8 @@ $(RVCONFIG_OUTPUTS): $(RVCONFIG_INPUTS) Makefile -cspec $(SPEC_DIR)/custom_spec.yaml \ -pspec $(SPEC_DIR)/platform_spec.yaml -clean: - $(RM) $(OUTPUT_FILES) $(RVCONFIG_OUTPUTS) +clean: distclean + $(RM) $(OUTPUT_FILES) + +distclean: + $(RM) run.log $(RVCONFIG_OUTPUTS) diff --git a/core/Flist.cva6 b/core/Flist.cva6 index e39026e8ed..71f9f42d38 100644 --- a/core/Flist.cva6 +++ b/core/Flist.cva6 @@ -180,8 +180,10 @@ ${CVA6_REPO_DIR}/core/pmp/src/pmp_entry.sv // Tracer (behavioral code, not RTL) ${CVA6_REPO_DIR}/common/local/util/instr_tracer.sv ${CVA6_REPO_DIR}/common/local/util/tc_sram_wrapper.sv +${CVA6_REPO_DIR}/common/local/util/tc_sram_wrapper_cache_techno.sv ${CVA6_REPO_DIR}/vendor/pulp-platform/tech_cells_generic/src/rtl/tc_sram.sv ${CVA6_REPO_DIR}/common/local/util/sram.sv +${CVA6_REPO_DIR}/common/local/util/sram_cache.sv // MMU ${CVA6_REPO_DIR}/core/cva6_mmu/cva6_mmu.sv diff --git a/core/Flist.cva6_gate b/core/Flist.cva6_gate index 55cc6c32dd..4b743fa19c 100644 --- a/core/Flist.cva6_gate +++ b/core/Flist.cva6_gate @@ -9,6 +9,10 @@ # +incdir+${CVA6_REPO_DIR}/core/include/ ++incdir+${CVA6_REPO_DIR}/vendor/pulp-platform/common_cells/include/ ++incdir+${CVA6_REPO_DIR}/vendor/pulp-platform/common_cells/src/ ++incdir+${CVA6_REPO_DIR}/vendor/pulp-platform/axi/include/ ++incdir+${CVA6_REPO_DIR}/common/local/util/ ${CVA6_REPO_DIR}/core/include/config_pkg.sv ${CVA6_REPO_DIR}/core/include/${TARGET_CFG}_config_pkg.sv @@ -16,17 +20,54 @@ ${CVA6_REPO_DIR}/core/include/riscv_pkg.sv ${CVA6_REPO_DIR}/core/include/ariane_pkg.sv ${CVA6_REPO_DIR}/vendor/pulp-platform/axi/src/axi_pkg.sv -${CVA6_REPO_DIR}/core/include/cvxif_pkg.sv - +// Packages ${CVA6_REPO_DIR}/core/include/wt_cache_pkg.sv ${CVA6_REPO_DIR}/core/include/std_cache_pkg.sv ${CVA6_REPO_DIR}/core/include/instr_tracer_pkg.sv ${CVA6_REPO_DIR}/core/include/build_config_pkg.sv +//CVXIF +${CVA6_REPO_DIR}/core/include/cvxif_pkg.sv +${CVA6_REPO_DIR}/core/cvxif_example/include/cvxif_instr_pkg.sv +${CVA6_REPO_DIR}/core/cvxif_fu.sv +${CVA6_REPO_DIR}/core/cvxif_example/cvxif_example_coprocessor.sv +${CVA6_REPO_DIR}/core/cvxif_example/instr_decoder.sv +${CVA6_REPO_DIR}/core/cva6_fifo_v3.sv + + +// Common Cells +${CVA6_REPO_DIR}/vendor/pulp-platform/common_cells/src/cf_math_pkg.sv +${CVA6_REPO_DIR}/vendor/pulp-platform/common_cells/src/fifo_v3.sv +${CVA6_REPO_DIR}/vendor/pulp-platform/common_cells/src/lfsr.sv +${CVA6_REPO_DIR}/vendor/pulp-platform/common_cells/src/lfsr_8bit.sv +${CVA6_REPO_DIR}/vendor/pulp-platform/common_cells/src/stream_arbiter.sv +${CVA6_REPO_DIR}/vendor/pulp-platform/common_cells/src/stream_arbiter_flushable.sv +${CVA6_REPO_DIR}/vendor/pulp-platform/common_cells/src/stream_mux.sv +${CVA6_REPO_DIR}/vendor/pulp-platform/common_cells/src/stream_demux.sv +${CVA6_REPO_DIR}/vendor/pulp-platform/common_cells/src/lzc.sv +${CVA6_REPO_DIR}/vendor/pulp-platform/common_cells/src/rr_arb_tree.sv +${CVA6_REPO_DIR}/vendor/pulp-platform/common_cells/src/shift_reg.sv +${CVA6_REPO_DIR}/vendor/pulp-platform/common_cells/src/unread.sv +${CVA6_REPO_DIR}/vendor/pulp-platform/common_cells/src/popcount.sv +${CVA6_REPO_DIR}/vendor/pulp-platform/common_cells/src/exp_backoff.sv + +// Common Cells for example coprocessor +${CVA6_REPO_DIR}/vendor/pulp-platform/common_cells/src/counter.sv +${CVA6_REPO_DIR}/vendor/pulp-platform/common_cells/src/delta_counter.sv + +${CVA6_REPO_DIR}/core/cache_subsystem/axi_adapter.sv + ${LIB_VERILOG} -${CVA6_REPO_DIR}/pd/synth/cva6_${TARGET_CFG}_synth_modified.v +${CVA6_REPO_DIR}/pd/synth/cva6_${TARGET_CFG}_synth.v +# Dedicated to black box in caches, cv32a65x only ${CVA6_REPO_DIR}/pd/synth/tc_sram_wrapper_256_64_00000008_00000001_00000001_none_0.sv +${CVA6_REPO_DIR}/pd/synth/hpdcache_sram_wbyteenable_1rw_00000007_00000040_00000080.sv +${CVA6_REPO_DIR}/pd/synth/hpdcache_sram_1rw_00000006_0000001a_00000040.sv + ${CVA6_REPO_DIR}/common/local/util/tc_sram_wrapper.sv +${CVA6_REPO_DIR}/common/local/util/tc_sram_wrapper_cache_techno.sv + ${CVA6_REPO_DIR}/vendor/pulp-platform/tech_cells_generic/src/rtl/tc_sram.sv ${CVA6_REPO_DIR}/common/local/util/sram.sv +${CVA6_REPO_DIR}/common/local/util/sram_cache.sv diff --git a/core/cache_subsystem/cva6_icache.sv b/core/cache_subsystem/cva6_icache.sv index e3f539afa1..d97fed369a 100644 --- a/core/cache_subsystem/cva6_icache.sv +++ b/core/cache_subsystem/cva6_icache.sv @@ -457,10 +457,12 @@ module cva6_icache for (genvar i = 0; i < CVA6Cfg.ICACHE_SET_ASSOC; i++) begin : gen_sram // Tag RAM - sram #( + sram_cache #( // tag + valid bit - .DATA_WIDTH(CVA6Cfg.ICACHE_TAG_WIDTH + 1), - .NUM_WORDS (ICACHE_NUM_WORDS) + .DATA_WIDTH (CVA6Cfg.ICACHE_TAG_WIDTH + 1), + .BYTE_ACCESS(0), + .TECHNO_CUT (CVA6Cfg.TechnoCut), + .NUM_WORDS (ICACHE_NUM_WORDS) ) tag_sram ( .clk_i (clk_i), .rst_ni (rst_ni), @@ -480,11 +482,13 @@ module cva6_icache assign vld_rdata[i] = cl_tag_valid_rdata[i][CVA6Cfg.ICACHE_TAG_WIDTH]; // Data RAM - sram #( - .USER_WIDTH(CVA6Cfg.ICACHE_USER_LINE_WIDTH), - .DATA_WIDTH(CVA6Cfg.ICACHE_LINE_WIDTH), - .USER_EN (CVA6Cfg.FETCH_USER_EN), - .NUM_WORDS (ICACHE_NUM_WORDS) + sram_cache #( + .USER_WIDTH (CVA6Cfg.ICACHE_USER_LINE_WIDTH), + .DATA_WIDTH (CVA6Cfg.ICACHE_LINE_WIDTH), + .USER_EN (CVA6Cfg.FETCH_USER_EN), + .BYTE_ACCESS(0), + .TECHNO_CUT (CVA6Cfg.TechnoCut), + .NUM_WORDS (ICACHE_NUM_WORDS) ) data_sram ( .clk_i (clk_i), .rst_ni (rst_ni), diff --git a/core/cache_subsystem/wt_dcache_mem.sv b/core/cache_subsystem/wt_dcache_mem.sv index f801defd63..e20320de24 100644 --- a/core/cache_subsystem/wt_dcache_mem.sv +++ b/core/cache_subsystem/wt_dcache_mem.sv @@ -305,11 +305,13 @@ module wt_dcache_mem for (genvar k = 0; k < DCACHE_NUM_BANKS; k++) begin : gen_data_banks // Data RAM - sram #( - .USER_WIDTH(CVA6Cfg.DCACHE_SET_ASSOC * CVA6Cfg.DCACHE_USER_WIDTH), - .DATA_WIDTH(CVA6Cfg.DCACHE_SET_ASSOC * CVA6Cfg.XLEN), - .USER_EN (CVA6Cfg.DATA_USER_EN), - .NUM_WORDS (CVA6Cfg.DCACHE_NUM_WORDS) + sram_cache #( + .USER_WIDTH (CVA6Cfg.DCACHE_SET_ASSOC * CVA6Cfg.DCACHE_USER_WIDTH), + .DATA_WIDTH (CVA6Cfg.DCACHE_SET_ASSOC * CVA6Cfg.XLEN), + .USER_EN (CVA6Cfg.DATA_USER_EN), + .BYTE_ACCESS(1), + .TECHNO_CUT (CVA6Cfg.TechnoCut), + .NUM_WORDS (CVA6Cfg.DCACHE_NUM_WORDS) ) i_data_sram ( .clk_i (clk_i), .rst_ni (rst_ni), @@ -330,10 +332,12 @@ module wt_dcache_mem assign rd_vld_bits_o[i] = vld_tag_rdata[i][CVA6Cfg.DCACHE_TAG_WIDTH]; // Tag RAM - sram #( + sram_cache #( // tag + valid bit - .DATA_WIDTH(CVA6Cfg.DCACHE_TAG_WIDTH + 1), - .NUM_WORDS (CVA6Cfg.DCACHE_NUM_WORDS) + .DATA_WIDTH (CVA6Cfg.DCACHE_TAG_WIDTH + 1), + .BYTE_ACCESS(0), + .TECHNO_CUT (CVA6Cfg.TechnoCut), + .NUM_WORDS (CVA6Cfg.DCACHE_NUM_WORDS) ) i_tag_sram ( .clk_i (clk_i), .rst_ni (rst_ni), diff --git a/core/include/build_config_pkg.sv b/core/include/build_config_pkg.sv index c31f0e11f9..e9e6fccfe3 100644 --- a/core/include/build_config_pkg.sv +++ b/core/include/build_config_pkg.sv @@ -42,6 +42,7 @@ package build_config_pkg; cfg.VMID_WIDTH = (CVA6Cfg.XLEN == 64) ? 14 : 1; cfg.FpgaEn = CVA6Cfg.FpgaEn; + cfg.TechnoCut = CVA6Cfg.TechnoCut; cfg.NrCommitPorts = CVA6Cfg.NrCommitPorts; cfg.NrLoadPipeRegs = CVA6Cfg.NrLoadPipeRegs; cfg.NrStorePipeRegs = CVA6Cfg.NrStorePipeRegs; diff --git a/core/include/config_pkg.sv b/core/include/config_pkg.sv index 3b590736b4..119293b4c6 100644 --- a/core/include/config_pkg.sv +++ b/core/include/config_pkg.sv @@ -162,6 +162,8 @@ package config_pkg; int unsigned FetchUserWidth; // Is FPGA optimization of CV32A6 bit FpgaEn; + // Is Techno Cut instanciated + bit TechnoCut; // Number of commit ports int unsigned NrCommitPorts; // Load cycle latency number @@ -202,6 +204,7 @@ package config_pkg; int unsigned VMID_WIDTH; bit FpgaEn; + bit TechnoCut; /// Number of commit ports, i.e., maximum number of instructions that the /// core can retire per cycle. It can be beneficial to have more commit /// ports than issue ports, for the scoreboard to empty out in case one diff --git a/core/include/cv32a60x_config_pkg.sv b/core/include/cv32a60x_config_pkg.sv index 2989daa775..1845844ad1 100644 --- a/core/include/cv32a60x_config_pkg.sv +++ b/core/include/cv32a60x_config_pkg.sv @@ -77,6 +77,7 @@ package cva6_config_pkg; localparam config_pkg::cva6_user_cfg_t cva6_cfg = '{ XLEN: unsigned'(CVA6ConfigXlen), FpgaEn: bit'(CVA6ConfigFpgaEn), + TechnoCut: bit'(0), NrCommitPorts: unsigned'(CVA6ConfigNrCommitPorts), AxiAddrWidth: unsigned'(CVA6ConfigAxiAddrWidth), AxiDataWidth: unsigned'(CVA6ConfigAxiDataWidth), diff --git a/core/include/cv32a65x_config_pkg.sv b/core/include/cv32a65x_config_pkg.sv index acffa590b9..d00b0c8f10 100644 --- a/core/include/cv32a65x_config_pkg.sv +++ b/core/include/cv32a65x_config_pkg.sv @@ -25,6 +25,7 @@ package cva6_config_pkg; localparam config_pkg::cva6_user_cfg_t cva6_cfg = '{ XLEN: unsigned'(CVA6ConfigXlen), FpgaEn: bit'(0), + TechnoCut: bit'(1), NrCommitPorts: unsigned'(1), AxiAddrWidth: unsigned'(CVA6ConfigAxiAddrWidth), AxiDataWidth: unsigned'(CVA6ConfigAxiDataWidth), @@ -80,13 +81,13 @@ package cva6_config_pkg; IcacheSetAssoc: unsigned'(2), IcacheLineWidth: unsigned'(128), DCacheType: config_pkg::HPDCACHE, - DcacheByteSize: unsigned'(32768), - DcacheSetAssoc: unsigned'(8), + DcacheByteSize: unsigned'(2028), + DcacheSetAssoc: unsigned'(2), DcacheLineWidth: unsigned'(128), - DataUserEn: unsigned'(0), + DataUserEn: unsigned'(1), WtDcacheWbufDepth: int'(2), FetchUserWidth: unsigned'(32), - FetchUserEn: unsigned'(0), + FetchUserEn: unsigned'(1), InstrTlbEntries: int'(2), DataTlbEntries: int'(2), UseSharedTlb: bit'(1), diff --git a/core/include/cv32a6_embedded_config_pkg.sv b/core/include/cv32a6_embedded_config_pkg.sv index 8956923d62..adb9e987ac 100644 --- a/core/include/cv32a6_embedded_config_pkg.sv +++ b/core/include/cv32a6_embedded_config_pkg.sv @@ -76,6 +76,7 @@ package cva6_config_pkg; localparam config_pkg::cva6_user_cfg_t cva6_cfg = '{ XLEN: unsigned'(CVA6ConfigXlen), FpgaEn: bit'(CVA6ConfigFpgaEn), + TechnoCut: bit'(0), NrCommitPorts: unsigned'(CVA6ConfigNrCommitPorts), AxiAddrWidth: unsigned'(CVA6ConfigAxiAddrWidth), AxiDataWidth: unsigned'(CVA6ConfigAxiDataWidth), diff --git a/core/include/cv32a6_ima_sv32_fpga_config_pkg.sv b/core/include/cv32a6_ima_sv32_fpga_config_pkg.sv index 6d2543fe2b..c41e880c0a 100644 --- a/core/include/cv32a6_ima_sv32_fpga_config_pkg.sv +++ b/core/include/cv32a6_ima_sv32_fpga_config_pkg.sv @@ -77,6 +77,7 @@ package cva6_config_pkg; localparam config_pkg::cva6_user_cfg_t cva6_cfg = '{ XLEN: unsigned'(CVA6ConfigXlen), FpgaEn: bit'(CVA6ConfigFpgaEn), + TechnoCut: bit'(0), NrCommitPorts: unsigned'(CVA6ConfigNrCommitPorts), AxiAddrWidth: unsigned'(CVA6ConfigAxiAddrWidth), AxiDataWidth: unsigned'(CVA6ConfigAxiDataWidth), diff --git a/core/include/cv32a6_imac_sv0_config_pkg.sv b/core/include/cv32a6_imac_sv0_config_pkg.sv index 34e2977012..a8a609f940 100644 --- a/core/include/cv32a6_imac_sv0_config_pkg.sv +++ b/core/include/cv32a6_imac_sv0_config_pkg.sv @@ -77,6 +77,7 @@ package cva6_config_pkg; localparam config_pkg::cva6_user_cfg_t cva6_cfg = '{ XLEN: unsigned'(CVA6ConfigXlen), FpgaEn: bit'(CVA6ConfigFpgaEn), + TechnoCut: bit'(0), NrCommitPorts: unsigned'(CVA6ConfigNrCommitPorts), AxiAddrWidth: unsigned'(CVA6ConfigAxiAddrWidth), AxiDataWidth: unsigned'(CVA6ConfigAxiDataWidth), diff --git a/core/include/cv32a6_imac_sv32_config_pkg.sv b/core/include/cv32a6_imac_sv32_config_pkg.sv index 17c098ffcb..d8931d65a0 100644 --- a/core/include/cv32a6_imac_sv32_config_pkg.sv +++ b/core/include/cv32a6_imac_sv32_config_pkg.sv @@ -77,6 +77,7 @@ package cva6_config_pkg; localparam config_pkg::cva6_user_cfg_t cva6_cfg = '{ XLEN: unsigned'(CVA6ConfigXlen), FpgaEn: bit'(CVA6ConfigFpgaEn), + TechnoCut: bit'(0), NrCommitPorts: unsigned'(CVA6ConfigNrCommitPorts), AxiAddrWidth: unsigned'(CVA6ConfigAxiAddrWidth), AxiDataWidth: unsigned'(CVA6ConfigAxiDataWidth), diff --git a/core/include/cv32a6_imafc_sv32_config_pkg.sv b/core/include/cv32a6_imafc_sv32_config_pkg.sv index 17b646d758..4f8e63c072 100644 --- a/core/include/cv32a6_imafc_sv32_config_pkg.sv +++ b/core/include/cv32a6_imafc_sv32_config_pkg.sv @@ -77,6 +77,7 @@ package cva6_config_pkg; localparam config_pkg::cva6_user_cfg_t cva6_cfg = '{ XLEN: unsigned'(CVA6ConfigXlen), FpgaEn: bit'(CVA6ConfigFpgaEn), + TechnoCut: bit'(0), NrCommitPorts: unsigned'(CVA6ConfigNrCommitPorts), AxiAddrWidth: unsigned'(CVA6ConfigAxiAddrWidth), AxiDataWidth: unsigned'(CVA6ConfigAxiDataWidth), diff --git a/core/include/cv64a6_imadfcv_sv39_polara_config_pkg.sv b/core/include/cv64a6_imadfcv_sv39_polara_config_pkg.sv index b060a62ee4..233b85f317 100644 --- a/core/include/cv64a6_imadfcv_sv39_polara_config_pkg.sv +++ b/core/include/cv64a6_imadfcv_sv39_polara_config_pkg.sv @@ -77,6 +77,7 @@ package cva6_config_pkg; localparam config_pkg::cva6_user_cfg_t cva6_cfg = '{ XLEN: unsigned'(CVA6ConfigXlen), FpgaEn: bit'(CVA6ConfigFpgaEn), + TechnoCut: bit'(0), NrCommitPorts: unsigned'(CVA6ConfigNrCommitPorts), AxiAddrWidth: unsigned'(CVA6ConfigAxiAddrWidth), AxiDataWidth: unsigned'(CVA6ConfigAxiDataWidth), diff --git a/core/include/cv64a6_imafdc_sv39_config_pkg.sv b/core/include/cv64a6_imafdc_sv39_config_pkg.sv index 7fe5382642..32bf8cc963 100644 --- a/core/include/cv64a6_imafdc_sv39_config_pkg.sv +++ b/core/include/cv64a6_imafdc_sv39_config_pkg.sv @@ -77,6 +77,7 @@ package cva6_config_pkg; localparam config_pkg::cva6_user_cfg_t cva6_cfg = '{ XLEN: unsigned'(CVA6ConfigXlen), FpgaEn: bit'(CVA6ConfigFpgaEn), + TechnoCut: bit'(0), NrCommitPorts: unsigned'(CVA6ConfigNrCommitPorts), AxiAddrWidth: unsigned'(CVA6ConfigAxiAddrWidth), AxiDataWidth: unsigned'(CVA6ConfigAxiDataWidth), diff --git a/core/include/cv64a6_imafdc_sv39_hpdcache_config_pkg.sv b/core/include/cv64a6_imafdc_sv39_hpdcache_config_pkg.sv index 5035dafd12..c5874cd5f8 100644 --- a/core/include/cv64a6_imafdc_sv39_hpdcache_config_pkg.sv +++ b/core/include/cv64a6_imafdc_sv39_hpdcache_config_pkg.sv @@ -84,6 +84,7 @@ package cva6_config_pkg; localparam config_pkg::cva6_user_cfg_t cva6_cfg = '{ XLEN: unsigned'(CVA6ConfigXlen), FpgaEn: bit'(CVA6ConfigFpgaEn), + TechnoCut: bit'(0), NrCommitPorts: unsigned'(CVA6ConfigNrCommitPorts), AxiAddrWidth: unsigned'(CVA6ConfigAxiAddrWidth), AxiDataWidth: unsigned'(CVA6ConfigAxiDataWidth), diff --git a/core/include/cv64a6_imafdc_sv39_openpiton_config_pkg.sv b/core/include/cv64a6_imafdc_sv39_openpiton_config_pkg.sv index 68af62733d..431b862ea1 100644 --- a/core/include/cv64a6_imafdc_sv39_openpiton_config_pkg.sv +++ b/core/include/cv64a6_imafdc_sv39_openpiton_config_pkg.sv @@ -77,6 +77,7 @@ package cva6_config_pkg; localparam config_pkg::cva6_user_cfg_t cva6_cfg = '{ XLEN: unsigned'(CVA6ConfigXlen), FpgaEn: bit'(CVA6ConfigFpgaEn), + TechnoCut: bit'(0), NrCommitPorts: unsigned'(CVA6ConfigNrCommitPorts), AxiAddrWidth: unsigned'(CVA6ConfigAxiAddrWidth), AxiDataWidth: unsigned'(CVA6ConfigAxiDataWidth), diff --git a/core/include/cv64a6_imafdc_sv39_wb_config_pkg.sv b/core/include/cv64a6_imafdc_sv39_wb_config_pkg.sv index ff16818f72..cd24267261 100644 --- a/core/include/cv64a6_imafdc_sv39_wb_config_pkg.sv +++ b/core/include/cv64a6_imafdc_sv39_wb_config_pkg.sv @@ -77,6 +77,7 @@ package cva6_config_pkg; localparam config_pkg::cva6_user_cfg_t cva6_cfg = '{ XLEN: unsigned'(CVA6ConfigXlen), FpgaEn: bit'(CVA6ConfigFpgaEn), + TechnoCut: bit'(0), NrCommitPorts: unsigned'(CVA6ConfigNrCommitPorts), AxiAddrWidth: unsigned'(CVA6ConfigAxiAddrWidth), AxiDataWidth: unsigned'(CVA6ConfigAxiDataWidth), diff --git a/core/include/cv64a6_imafdch_sv39_config_pkg.sv b/core/include/cv64a6_imafdch_sv39_config_pkg.sv index eefe47dcb4..41e00edeb3 100644 --- a/core/include/cv64a6_imafdch_sv39_config_pkg.sv +++ b/core/include/cv64a6_imafdch_sv39_config_pkg.sv @@ -77,6 +77,7 @@ package cva6_config_pkg; localparam config_pkg::cva6_user_cfg_t cva6_cfg = '{ XLEN: unsigned'(CVA6ConfigXlen), FpgaEn: bit'(CVA6ConfigFpgaEn), + TechnoCut: bit'(0), NrCommitPorts: unsigned'(CVA6ConfigNrCommitPorts), AxiAddrWidth: unsigned'(CVA6ConfigAxiAddrWidth), AxiDataWidth: unsigned'(CVA6ConfigAxiDataWidth), diff --git a/core/include/cv64a6_imafdch_sv39_wb_config_pkg.sv b/core/include/cv64a6_imafdch_sv39_wb_config_pkg.sv index 1807fcf9c9..5a685c9171 100644 --- a/core/include/cv64a6_imafdch_sv39_wb_config_pkg.sv +++ b/core/include/cv64a6_imafdch_sv39_wb_config_pkg.sv @@ -77,6 +77,7 @@ package cva6_config_pkg; localparam config_pkg::cva6_user_cfg_t cva6_cfg = '{ XLEN: unsigned'(CVA6ConfigXlen), FpgaEn: bit'(CVA6ConfigFpgaEn), + TechnoCut: bit'(CVA6ConfigTechnoCut), NrCommitPorts: unsigned'(CVA6ConfigNrCommitPorts), AxiAddrWidth: unsigned'(CVA6ConfigAxiAddrWidth), AxiDataWidth: unsigned'(CVA6ConfigAxiDataWidth), diff --git a/core/include/cv64a6_imafdcv_sv39_config_pkg.sv b/core/include/cv64a6_imafdcv_sv39_config_pkg.sv index a22ce62bc1..066414588d 100644 --- a/core/include/cv64a6_imafdcv_sv39_config_pkg.sv +++ b/core/include/cv64a6_imafdcv_sv39_config_pkg.sv @@ -77,6 +77,7 @@ package cva6_config_pkg; localparam config_pkg::cva6_user_cfg_t cva6_cfg = '{ XLEN: unsigned'(CVA6ConfigXlen), FpgaEn: bit'(CVA6ConfigFpgaEn), + TechnoCut: bit'(0), NrCommitPorts: unsigned'(CVA6ConfigNrCommitPorts), AxiAddrWidth: unsigned'(CVA6ConfigAxiAddrWidth), AxiDataWidth: unsigned'(CVA6ConfigAxiDataWidth), diff --git a/core/include/cv64a6_mmu_config_pkg.sv b/core/include/cv64a6_mmu_config_pkg.sv index 1d9a2639de..00950df843 100644 --- a/core/include/cv64a6_mmu_config_pkg.sv +++ b/core/include/cv64a6_mmu_config_pkg.sv @@ -29,6 +29,7 @@ package cva6_config_pkg; localparam config_pkg::cva6_user_cfg_t cva6_cfg = '{ XLEN: unsigned'(CVA6ConfigXlen), FpgaEn: bit'(0), + TechnoCut: bit'(0), NrCommitPorts: unsigned'(CVA6ConfigNrCommitPorts), AxiAddrWidth: unsigned'(CVA6ConfigAxiAddrWidth), AxiDataWidth: unsigned'(CVA6ConfigAxiDataWidth), diff --git a/corev_apu/tb/ariane_gate_tb.sv b/corev_apu/tb/ariane_gate_tb.sv new file mode 100644 index 0000000000..615d2bcf30 --- /dev/null +++ b/corev_apu/tb/ariane_gate_tb.sv @@ -0,0 +1,480 @@ +// Copyright 2024 Thales DIS France SAS +// +// Licensed under the Solderpad Hardware Licence, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// SPDX-License-Identifier: Apache-2.0 WITH SHL-2.0 +// You may obtain a copy of the License at https://solderpad.org/licenses/ +// +// Original Author: Guillaume Chauvon - Thales +// + +import uvm_pkg::*; + +`include "axi/assign.svh" +`include "rvfi_types.svh" + +`ifdef VERILATOR +`include "custom_uvm_macros.svh" +`else +`include "uvm_macros.svh" +`endif + +`define MAIN_MEM(P) i_sram.gen_cut[0].i_tc_sram_wrapper.i_tc_sram.init_val[(``P``)] +`define USER_MEM(P) i_sram.gen_cut[0].gen_mem_user.i_tc_sram_wrapper_user.i_tc_sram.init_val[(``P``)] + +`timescale 1ns/1ns + +import "DPI-C" function void read_elf(input string filename); +import "DPI-C" function byte get_section(output longint address, output longint len); +import "DPI-C" context function read_section_sv(input longint address, inout byte buffer[]); +import "DPI-C" function string getenv(input string env_name); + +module ariane_gate_tb; + + // cva6 configuration + localparam config_pkg::cva6_cfg_t CVA6Cfg = build_config_pkg::build_config(cva6_config_pkg::cva6_cfg); + static uvm_cmdline_processor uvcl = uvm_cmdline_processor::get_inst(); + + localparam int unsigned AXI_USER_WIDTH = CVA6Cfg.AxiUserWidth; + localparam int unsigned AXI_USER_EN = CVA6Cfg.AXI_USER_EN; + localparam int unsigned AXI_ADDRESS_WIDTH = 64; + localparam int unsigned AXI_DATA_WIDTH = 64; + + + localparam NrSlaves = 1; + localparam NB_PERIPHERALS = 3; + localparam IdWidthSlave = ariane_axi_soc::IdWidth + $clog2(NrSlaves); + + localparam NUM_WORDS = 2**16; + int unsigned CLOCK_PERIOD = 20ns; + logic clk_i; + logic rst_ni; + + longint unsigned cycles; + longint unsigned max_cycles; + + logic [31:0] exit_o; + localparam [7:0] hart_id = '0; + + // RVFI + localparam type rvfi_instr_t = `RVFI_INSTR_T(CVA6Cfg); + localparam type rvfi_csr_elmt_t = `RVFI_CSR_ELMT_T(CVA6Cfg); + localparam type rvfi_csr_t = `RVFI_CSR_T(CVA6Cfg, rvfi_csr_elmt_t); + + // RVFI PROBES + localparam type rvfi_probes_instr_t = `RVFI_PROBES_INSTR_T(CVA6Cfg); + localparam type rvfi_probes_csr_t = `RVFI_PROBES_CSR_T(CVA6Cfg); + localparam type rvfi_probes_t = struct packed { + logic csr; + rvfi_probes_instr_t instr; + }; + + string binary = ""; + + + typedef enum int unsigned { + DRAM = 0, + UART = 1, + ROM = 2 + } axi_slaves_t; + + AXI_BUS #( + .AXI_ADDR_WIDTH ( AXI_ADDRESS_WIDTH ), + .AXI_DATA_WIDTH ( AXI_DATA_WIDTH ), + .AXI_ID_WIDTH ( ariane_axi_soc::IdWidth ), + .AXI_USER_WIDTH ( AXI_USER_WIDTH ) + ) slave[NrSlaves-1:0](); + + AXI_BUS #( + .AXI_ADDR_WIDTH ( AXI_ADDRESS_WIDTH ), + .AXI_DATA_WIDTH ( AXI_DATA_WIDTH ), + .AXI_ID_WIDTH ( IdWidthSlave ), + .AXI_USER_WIDTH ( AXI_USER_WIDTH ) + ) master[NB_PERIPHERALS-1:0](); + + // --------------- + // Core + // --------------- + ariane_axi::req_t axi_ariane_req; + ariane_axi::resp_t axi_ariane_resp; + rvfi_probes_t rvfi_probes; + rvfi_csr_t rvfi_csr; + rvfi_instr_t [CVA6Cfg.NrCommitPorts-1:0] rvfi_instr; + + ariane #( + .CVA6Cfg ( CVA6Cfg ), + .rvfi_probes_instr_t ( rvfi_probes_instr_t ), + .rvfi_probes_csr_t ( rvfi_probes_csr_t ), + .rvfi_probes_t ( rvfi_probes_t ), + .noc_req_t ( ariane_axi::req_t ), + .noc_resp_t ( ariane_axi::resp_t ) + ) i_ariane ( + .clk_i ( clk_i ), + .rst_ni ( rst_ni ), + .boot_addr_i ( ariane_soc::ROMBase), // start fetching from ROM + .hart_id_i ( {56'h0, hart_id} ), + .irq_i ( 2'b00 /*irqs*/ ), + .ipi_i ( 1'b0 /*ipi*/ ), + .time_irq_i ( 1'b0 /*timer_irq*/ ), + .debug_req_i ( 1'b0 ), + .rvfi_probes_o ( rvfi_probes ), + .noc_req_o ( axi_ariane_req ), + .noc_resp_i ( axi_ariane_resp ) + ); + + `AXI_ASSIGN_FROM_REQ(slave[0], axi_ariane_req) + `AXI_ASSIGN_TO_RESP(axi_ariane_resp, slave[0]) + // ------------- + // Simulation Helper Functions + // ------------- + // check for response errors + always_ff @(posedge clk_i) begin : p_assert + if (axi_ariane_req.r_ready && + axi_ariane_resp.r_valid && + axi_ariane_resp.r.resp inside {axi_pkg::RESP_DECERR, axi_pkg::RESP_SLVERR}) begin + $warning("R Response Errored"); + end + if (axi_ariane_req.b_ready && + axi_ariane_resp.b_valid && + axi_ariane_resp.b.resp inside {axi_pkg::RESP_DECERR, axi_pkg::RESP_SLVERR}) begin + $warning("B Response Errored"); + end + end + + cva6_rvfi #( + .CVA6Cfg (CVA6Cfg), + .rvfi_instr_t(rvfi_instr_t), + .rvfi_csr_t(rvfi_csr_t), + .rvfi_probes_instr_t(rvfi_probes_instr_t), + .rvfi_probes_csr_t(rvfi_probes_csr_t), + .rvfi_probes_t(rvfi_probes_t) + ) i_cva6_rvfi ( + .clk_i (clk_i), + .rst_ni (rst_ni), + .rvfi_probes_i(rvfi_probes), + .rvfi_instr_o(rvfi_instr), + .rvfi_csr_o(rvfi_csr) + ); + + rvfi_tracer #( + .CVA6Cfg(CVA6Cfg), + .rvfi_instr_t(rvfi_instr_t), + .rvfi_csr_t(rvfi_csr_t), + // + .HART_ID(hart_id), + .DEBUG_START(0), + .DEBUG_STOP(0) + ) i_rvfi_tracer ( + .clk_i(clk_i), + .rst_ni(rst_ni), + .rvfi_i(rvfi_instr), + .rvfi_csr_i(rvfi_csr), + .end_of_test_o(rvfi_exit) + ); + + assign exit_o = rvfi_exit; + + + // ------------------------------ + // Memory + Exclusive Access + // ------------------------------ + + logic req; + logic we; + logic [AXI_ADDRESS_WIDTH-1:0] addr; + logic [AXI_DATA_WIDTH/8-1:0] be; + logic [AXI_DATA_WIDTH-1:0] wdata; + logic [AXI_DATA_WIDTH-1:0] rdata; + logic [AXI_USER_WIDTH-1:0] wuser; + logic [AXI_USER_WIDTH-1:0] ruser; + + axi2mem #( + .AXI_ID_WIDTH ( IdWidthSlave ), + .AXI_ADDR_WIDTH ( AXI_ADDRESS_WIDTH ), + .AXI_DATA_WIDTH ( AXI_DATA_WIDTH ), + .AXI_USER_WIDTH ( AXI_USER_WIDTH ) + ) i_axi2mem ( + .clk_i ( clk_i ), + .rst_ni ( rst_ni ), + .slave ( master[DRAM] ), // dram_delayed ? + .req_o ( req ), + .we_o ( we ), + .addr_o ( addr ), + .be_o ( be ), + .user_o ( wuser ), + .data_o ( wdata ), + .user_i ( ruser ), + .data_i ( rdata ) + ); + + sram #( + .DATA_WIDTH ( AXI_DATA_WIDTH ), + .USER_WIDTH ( AXI_USER_WIDTH ), + .USER_EN ( AXI_USER_EN ), + `ifdef VERILATOR + .SIM_INIT ( "none" ), + `else + .SIM_INIT ( "zeros" ), + `endif + .NUM_WORDS ( NUM_WORDS ) + ) i_sram ( + .clk_i ( clk_i ), + .rst_ni ( rst_ni ), + .req_i ( req ), + .we_i ( we ), + .addr_i ( addr[$clog2(NUM_WORDS)-1+$clog2(AXI_DATA_WIDTH/8):$clog2(AXI_DATA_WIDTH/8)] ), + .wuser_i ( wuser ), + .wdata_i ( wdata ), + .be_i ( be ), + .ruser_o ( ruser ), + .rdata_o ( rdata ) + ); + + // --------------- + // ROM + // --------------- + logic rom_req; + logic [AXI_ADDRESS_WIDTH-1:0] rom_addr; + logic [AXI_DATA_WIDTH-1:0] rom_rdata; + + axi2mem #( + .AXI_ID_WIDTH ( IdWidthSlave ), + .AXI_ADDR_WIDTH ( AXI_ADDRESS_WIDTH ), + .AXI_DATA_WIDTH ( AXI_DATA_WIDTH ), + .AXI_USER_WIDTH ( AXI_USER_WIDTH ) + ) i_axi2rom ( + .clk_i ( clk_i ), + .rst_ni ( rst_ni ), + .slave ( master[ROM] ), + .req_o ( rom_req ), + .we_o ( ), + .addr_o ( rom_addr ), + .be_o ( ), + .user_o ( ), + .data_o ( ), + .user_i ( '0 ), + .data_i ( rom_rdata ) + ); + + bootrom i_bootrom ( + .clk_i ( clk_i ), + .req_i ( rom_req ), + .addr_i ( rom_addr ), + .rdata_o ( rom_rdata ) + ); + + // --------------- + // AXI Xbar + // --------------- + + axi_pkg::xbar_rule_64_t [NB_PERIPHERALS-1:0] addr_map; + + assign addr_map = '{ + '{ idx: ROM, start_addr: ariane_soc::ROMBase, end_addr: ariane_soc::ROMBase + ariane_soc::ROMLength }, + '{ idx: UART, start_addr: ariane_soc::UARTBase, end_addr: ariane_soc::UARTBase + ariane_soc::UARTLength }, + '{ idx: DRAM, start_addr: ariane_soc::DRAMBase, end_addr: ariane_soc::DRAMBase + ariane_soc::DRAMLength } + }; + + localparam axi_pkg::xbar_cfg_t AXI_XBAR_CFG = '{ + NoSlvPorts: unsigned'(NrSlaves), + NoMstPorts: unsigned'(NB_PERIPHERALS), + MaxMstTrans: unsigned'(1), // Probably requires update + MaxSlvTrans: unsigned'(1), // Probably requires update + FallThrough: 1'b0, + LatencyMode: axi_pkg::NO_LATENCY, + AxiIdWidthSlvPorts: unsigned'(ariane_axi_soc::IdWidth), + AxiIdUsedSlvPorts: unsigned'(ariane_axi_soc::IdWidth), + UniqueIds: 1'b0, + AxiAddrWidth: unsigned'(AXI_ADDRESS_WIDTH), + AxiDataWidth: unsigned'(AXI_DATA_WIDTH), + NoAddrRules: unsigned'(NB_PERIPHERALS) + }; + + axi_xbar_intf #( + .AXI_USER_WIDTH ( AXI_USER_WIDTH ), + .Cfg ( AXI_XBAR_CFG ), + .rule_t ( axi_pkg::xbar_rule_64_t ) + ) i_axi_xbar ( + .clk_i ( clk_i ), + .rst_ni ( rst_ni ), + .test_i ( '0 ), + .slv_ports ( slave ), + .mst_ports ( master ), + .addr_map_i ( addr_map ), + .en_default_mst_port_i ( '0 ), + .default_mst_port_i ( '0 ) + ); + + + + // --------------- + // 2. UART + // --------------- + logic uart_penable; + logic uart_pwrite; + logic [31:0] uart_paddr; + logic uart_psel; + logic [31:0] uart_pwdata; + logic [31:0] uart_prdata; + logic uart_pready; + logic uart_pslverr; + + axi2apb_64_32 #( + .AXI4_ADDRESS_WIDTH ( AXI_ADDRESS_WIDTH ), + .AXI4_RDATA_WIDTH ( AXI_DATA_WIDTH ), + .AXI4_WDATA_WIDTH ( AXI_DATA_WIDTH ), + .AXI4_ID_WIDTH ( IdWidthSlave ), + .AXI4_USER_WIDTH ( AXI_USER_WIDTH ), + .BUFF_DEPTH_SLAVE ( 2 ), + .APB_ADDR_WIDTH ( 32 ) + ) i_axi2apb_64_32_uart ( + .ACLK ( clk_i ), + .ARESETn ( rst_ni ), + .test_en_i ( 1'b0 ), + .AWID_i ( master[UART].aw_id ), + .AWADDR_i ( master[UART].aw_addr ), + .AWLEN_i ( master[UART].aw_len ), + .AWSIZE_i ( master[UART].aw_size ), + .AWBURST_i ( master[UART].aw_burst ), + .AWLOCK_i ( master[UART].aw_lock ), + .AWCACHE_i ( master[UART].aw_cache ), + .AWPROT_i ( master[UART].aw_prot ), + .AWREGION_i( master[UART].aw_region ), + .AWUSER_i ( master[UART].aw_user ), + .AWQOS_i ( master[UART].aw_qos ), + .AWVALID_i ( master[UART].aw_valid ), + .AWREADY_o ( master[UART].aw_ready ), + .WDATA_i ( master[UART].w_data ), + .WSTRB_i ( master[UART].w_strb ), + .WLAST_i ( master[UART].w_last ), + .WUSER_i ( master[UART].w_user ), + .WVALID_i ( master[UART].w_valid ), + .WREADY_o ( master[UART].w_ready ), + .BID_o ( master[UART].b_id ), + .BRESP_o ( master[UART].b_resp ), + .BVALID_o ( master[UART].b_valid ), + .BUSER_o ( master[UART].b_user ), + .BREADY_i ( master[UART].b_ready ), + .ARID_i ( master[UART].ar_id ), + .ARADDR_i ( master[UART].ar_addr ), + .ARLEN_i ( master[UART].ar_len ), + .ARSIZE_i ( master[UART].ar_size ), + .ARBURST_i ( master[UART].ar_burst ), + .ARLOCK_i ( master[UART].ar_lock ), + .ARCACHE_i ( master[UART].ar_cache ), + .ARPROT_i ( master[UART].ar_prot ), + .ARREGION_i( master[UART].ar_region ), + .ARUSER_i ( master[UART].ar_user ), + .ARQOS_i ( master[UART].ar_qos ), + .ARVALID_i ( master[UART].ar_valid ), + .ARREADY_o ( master[UART].ar_ready ), + .RID_o ( master[UART].r_id ), + .RDATA_o ( master[UART].r_data ), + .RRESP_o ( master[UART].r_resp ), + .RLAST_o ( master[UART].r_last ), + .RUSER_o ( master[UART].r_user ), + .RVALID_o ( master[UART].r_valid ), + .RREADY_i ( master[UART].r_ready ), + .PENABLE ( uart_penable ), + .PWRITE ( uart_pwrite ), + .PADDR ( uart_paddr ), + .PSEL ( uart_psel ), + .PWDATA ( uart_pwdata ), + .PRDATA ( uart_prdata ), + .PREADY ( uart_pready ), + .PSLVERR ( uart_pslverr ) + ); + + mock_uart i_mock_uart ( + .clk_i ( clk_i ), + .rst_ni ( rst_ni ), + .penable_i ( uart_penable ), + .pwrite_i ( uart_pwrite ), + .paddr_i ( uart_paddr ), + .psel_i ( uart_psel ), + .pwdata_i ( uart_pwdata ), + .prdata_o ( uart_prdata ), + .pready_o ( uart_pready ), + .pslverr_o ( uart_pslverr ) + ); + + + + + // Clock process + initial begin + + string SIMU_PERIOD = {getenv("SIMU_PERIOD"),"ns"}; + if (SIMU_PERIOD != "ns") + CLOCK_PERIOD = SIMU_PERIOD.atoi(); + + clk_i = 1'b0; + rst_ni = 1'b0; + repeat(8) + #(CLOCK_PERIOD/2) clk_i = ~clk_i; + rst_ni = 1'b1; + forever begin + #(CLOCK_PERIOD/2) clk_i = 1'b1; + #(CLOCK_PERIOD/2) clk_i = 1'b0; + + //if (cycles > max_cycles) + // $fatal(1, "Simulation reached maximum cycle count of %d", max_cycles); + + cycles++; + end + end + + + initial begin + forever begin + + wait (exit_o[0]); + + if ((exit_o >> 1)) begin + `uvm_error( "Core Test", $sformatf("*** FAILED *** (tohost = %0d)", (exit_o >> 1))) + end else begin + `uvm_info( "Core Test", $sformatf("*** SUCCESS *** (tohost = %0d)", (exit_o >> 1)), UVM_LOW) + end + + $finish(); + end + end + + // for faster simulation we can directly preload the ELF + // Note that we are loosing the capabilities to use risc-fesvr though + initial begin + automatic logic [7:0][7:0] mem_row; + longint address, len; + byte buffer[]; + void'(uvcl.get_arg_value("+elf_file=", binary)); + + if (binary != "") begin + `uvm_info( "Core Test", $sformatf("Preloading ELF: %s", binary), UVM_LOW) + + void'(read_elf(binary)); + // wait with preloading, otherwise randomization will overwrite the existing value + wait(clk_i); + + // while there are more sections to process + while (get_section(address, len)) begin + automatic int num_words = (len+7)/8; + `uvm_info( "Core Test", $sformatf("Loading Address: %x, Length: %x", address, len),UVM_LOW) + buffer = new [num_words*8]; + void'(read_section_sv(address, buffer)); + // preload memories + // 64-bit + for (int i = 0; i < num_words; i++) begin + mem_row = '0; + for (int j = 0; j < 8; j++) begin + mem_row[j] = buffer[i*8 + j]; + end + if (address[31:0] < 'h84000000) begin + `MAIN_MEM((address[23:0] >> 3) + i) = mem_row; + end else begin + `USER_MEM((address[23:0] >> 3) + i) = mem_row; + end + end + end + end + end +endmodule diff --git a/corev_apu/tb/ariane_tb.cpp b/corev_apu/tb/ariane_tb.cpp index 565f210663..8de0c5b20f 100644 --- a/corev_apu/tb/ariane_tb.cpp +++ b/corev_apu/tb/ariane_tb.cpp @@ -333,9 +333,11 @@ int main(int argc, char **argv) { #if (VERILATOR_VERSION_INTEGER >= 5000000) // Verilator v5: Use rootp pointer and .data() accessor. #define MEM top->rootp->ariane_testharness__DOT__i_sram__DOT__gen_cut__BRA__0__KET____DOT__i_tc_sram_wrapper__DOT__i_tc_sram__DOT__sram.m_storage +#define MEM_USER top->rootp->ariane_testharness__DOT__i_sram__DOT__gen_cut__BRA__0__KET____DOT__gen_mem_user__DOT__i_tc_sram_wrapper_user__DOT__i_tc_sram__DOT__sram.m_storage #else // Verilator v4 #define MEM top->ariane_testharness__DOT__i_sram__DOT__gen_cut__BRA__0__KET____DOT__i_tc_sram_wrapper__DOT__i_tc_sram__DOT__sram +#define MEM_USER top->ariane_testharness__DOT__i_sram__DOT__gen_cut__BRA__0__KET____DOT__gen_mem_user__DOT__i_tc_sram_wrapper_user__DOT__i_tc_sram__DOT__sram #endif long long addr; long long len; @@ -345,6 +347,12 @@ int main(int argc, char **argv) { { if (addr == 0x80000000) read_section_void(addr, (void *) MEM , mem_size); + if (addr == 0x84000000) + try { + read_section_void(addr, (void *) MEM_USER , mem_size); + } catch (...){ + std::cerr << "No user memory instanciated ...\n"; + } } while (!dtm->done() && !jtag->done() && !(top->exit_o & 0x1)) { diff --git a/corev_apu/tb/ariane_tb.sv b/corev_apu/tb/ariane_tb.sv index 5e03e65175..d45d7673ee 100644 --- a/corev_apu/tb/ariane_tb.sv +++ b/corev_apu/tb/ariane_tb.sv @@ -21,7 +21,7 @@ import uvm_pkg::*; `include "rvfi_types.svh" `define MAIN_MEM(P) dut.i_sram.gen_cut[0].i_tc_sram_wrapper.i_tc_sram.init_val[(``P``)] -// `define USER_MEM(P) dut.i_sram.gen_cut[0].gen_mem.gen_mem_user.i_tc_sram_wrapper_user.i_tc_sram.init_val[(``P``)] +`define USER_MEM(P) dut.i_sram.gen_cut[0].gen_mem_user.i_tc_sram_wrapper_user.i_tc_sram.init_val[(``P``)] `ifndef READ_ELF_T `define READ_ELF_T @@ -140,7 +140,7 @@ module ariane_tb; // while there are more sections to process while (get_section(address, len)) begin automatic int num_words = (len+7)/8; - `uvm_info( "Core Test", $sformatf("Loading Address: %x, Length: %x", address, len), UVM_LOW) + `uvm_info( "Core Test", $sformatf("Loading Address: %x, Length: %x", address, len), UVM_NONE) buffer = new [num_words*8]; void'(read_section_sv(address, buffer)); // preload memories @@ -152,10 +152,14 @@ module ariane_tb; end load_address = (address[23:0] >> 3) + i; if (load_address != last_load_address) begin - `MAIN_MEM(load_address) = mem_row; + if (address[31:0] < 'h84000000) begin + `MAIN_MEM(load_address) = mem_row; + end else begin + `USER_MEM(load_address) = mem_row; + end last_load_address = load_address; end else begin - `uvm_info( "Debug info", $sformatf(" Address: %x Already Loaded! ELF file might have less than 64 bits granularity on segments.", load_address), UVM_LOW) + `uvm_info( "Debug info", $sformatf(" Address: %x Already Loaded! ELF file might have less than 64 bits granularity on segments.", load_address), UVM_NONE) end end diff --git a/pd/synth/.gitignore b/pd/synth/.gitignore index 9f9e8d922e..2f847184a4 100644 --- a/pd/synth/.gitignore +++ b/pd/synth/.gitignore @@ -5,4 +5,7 @@ alib-52 command.tcl command_read.tcl default.svf -ariane +cva6_* +Flist.* +pes.bat +simv* diff --git a/pd/synth/Makefile b/pd/synth/Makefile index d66ceee647..c56c6e4282 100644 --- a/pd/synth/Makefile +++ b/pd/synth/Makefile @@ -8,18 +8,18 @@ # Original Author: Jean-Roch COULON - Thales # -DESIGN_NAME = cva6 +DESIGN_NAME ?= cva6 PERIOD ?= 17 FOUNDRY_PATH ?= -TECH_NAME ?= +LOCAL_LIB_PATH ?=/shares/common/tools/RAMs/ TARGET_LIBRARY_FILES = $(TECH_NAME).db INPUT_DELAY ?= 0.46 OUTPUT_DELAY ?= 0.11 DC_SHELL_PATH ?= /opt/synopsys/syn/Q-2019.12/bin/ NAND2_AREA ?= 1120 -TARGET ?= cv64a6_imafdc_sv39 +TARGET ?= cv32a65x -EXPORT_LIST=SNPSLMD_QUEUE=TRUE TECH_NAME=$(TECH_NAME) DESIGN_NAME=$(DESIGN_NAME) TARGET=$(TARGET) TERM=vt100 PERIOD=$(PERIOD) FOUNDRY_PATH=$(FOUNDRY_PATH) TARGET_LIBRARY_FILES=$(TARGET_LIBRARY_FILES) INPUT_DELAY=$(INPUT_DELAY) OUTPUT_DELAY=$(OUTPUT_DELAY) +EXPORT_LIST=SNPSLMD_QUEUE=TRUE TECH_NAME=$(TECH_NAME) DESIGN_NAME=$(DESIGN_NAME) TARGET=$(TARGET) TERM=vt100 PERIOD=$(PERIOD) FOUNDRY_PATH=$(FOUNDRY_PATH) LOCAL_LIB_PATH=$(LOCAL_LIB_PATH) TARGET_LIBRARY_FILES=$(TARGET_LIBRARY_FILES) INPUT_DELAY=$(INPUT_DELAY) OUTPUT_DELAY=$(OUTPUT_DELAY) ifndef FOUNDRY_PATH $(error "Please provide FOUNDRY techno") @@ -28,18 +28,40 @@ ifndef TECH_NAME $(error "Please provide TECH_NAME techno") endif +# Create Flist with good compilation order for synthesis +# - config_pkg.sv +# - hpdcache_params_pkg.sv before hdpcache_pkg.sv +# - pkg before rtl pre_cva6_synth: - grep "CVA6_REPO_DIR\}" ../../core/Flist.cva6|grep -v "instr_tracer"|grep -v "incdir" > Flist.cva6_synth - sed -i "s/^/analyze -f sverilog -lib ariane_lib /" Flist.cva6_synth + grep "{\w*}" ../../core/Flist.cva6|grep -v "instr_tracer"|grep -v "incdir"|grep -v "hpdcache.Flist" > Flist.cva6_synth + grep "{\w*}" ../../core/cache_subsystem/hpdcache/rtl/hpdcache.Flist|grep -v "incdir" >> Flist.cva6_synth + grep "hpdcache_pkg.sv" Flist.cva6_synth > hpdcache_pkg.tmp + grep "_pkg.sv" Flist.cva6_synth | grep -v "hpdcache_pkg.sv" > packages.tmp + grep -v "hpdcache_pkg.sv" Flist.cva6_synth | grep -v "HPDCACHE_TARGET_CFG" | grep -v "_pkg.sv" > rtl.tmp + cat packages.tmp > Flist.cva6_synth + cat hpdcache_pkg.tmp >> Flist.cva6_synth + cat rtl.tmp >> Flist.cva6_synth + sed -i "s/^/analyze -f sverilog -lib ariane_lib -define HPDCACHE_ASSERT_OFF /" Flist.cva6_synth + sed -i -e 's/behav/blackbox/g' Flist.cva6_synth +# Deprecated cva6_synth: pre_cva6_synth @echo $(PERIOD) @export $(EXPORT_LIST); $(DC_SHELL_PATH)/dc_shell -f ./cva6_synth.tcl -output synthesis_batch.log - python scripts/gate_analysis.py '$(DESIGN_NAME)_$(TARGET)/reports/$(PERIOD)/$(DESIGN_NAME)_$(TECH_NAME)_synth_area.rpt' $(NAND2_AREA) + python scripts/gate_analysis.py '$(DESIGN_NAME)_$(TARGET)/$(PERIOD)/reports/$(DESIGN_NAME)_$(TECH_NAME)_synth_area.rpt' $(NAND2_AREA) mv $(DESIGN_NAME)_synth.v $(DESIGN_NAME)_$(TARGET)_synth.v mv $(DESIGN_NAME)_synth.v.sdf $(DESIGN_NAME)_$(TARGET)_synth.v.sdf - sed -n -e '/module tc_sram_wrapper_256_64_00000008_00000001_00000001_none_0/,/endmodule/!p' $(DESIGN_NAME)_$(TARGET)_synth.v > $(DESIGN_NAME)_$(TARGET)_synth_modified.v - sed -i 's/cva6_ /cva6 /g' $(DESIGN_NAME)_$(TARGET)_synth_modified.v + sed -i 's/cva6_ /cva6 /g' $(DESIGN_NAME)_$(TARGET)_synth.v + echo $(NAND2_AREA) > $(DESIGN_NAME)_$(TARGET)/nand2area.txt + +# Supported for cv32a65x +rm_synth: pre_cva6_synth + @echo $(PERIOD) + cp Flist.cva6_synth ../../$(SYNTH_FLOW_NAME)/synth/ + CVA6_REPO_DIR=$(CVA6_REPO_DIR) make -C ../../$(SYNTH_FLOW_NAME)/synth/ platform_synth_topo + sed -i -n -e '/module hpdcache_sram_wbyteenable_1rw_00000007_00000040_00000080/,/endmodule/!p' $(DESIGN_NAME)_$(TARGET)_synth.v + sed -i -n -e '/module hpdcache_sram_1rw_00000006_0000001a_00000040/,/endmodule/!p' $(DESIGN_NAME)_$(TARGET)_synth.v + echo $(NAND2_AREA) > $(DESIGN_NAME)_$(TARGET)/nand2area.txt cva6_read: @export $(EXPORT_LIST); $(DC_SHELL_PATH)/dc_shell -f cva6_read.tcl -gui diff --git a/pd/synth/hpdcache_sram_1rw_00000006_0000001a_00000040.sv b/pd/synth/hpdcache_sram_1rw_00000006_0000001a_00000040.sv new file mode 100644 index 0000000000..138cfdea5e --- /dev/null +++ b/pd/synth/hpdcache_sram_1rw_00000006_0000001a_00000040.sv @@ -0,0 +1,60 @@ +/* + * Copyright 2023 CEA* + * *Commissariat a l'Energie Atomique et aux Energies Alternatives (CEA) + * + * SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1 + * + * Licensed under the Solderpad Hardware License v 2.1 (the “License”); you + * may not use this file except in compliance with the License, or, at your + * option, the Apache License version 2.0. You may obtain a copy of the + * License at + * + * https://solderpad.org/licenses/SHL-2.1/ + * + * Unless required by applicable law or agreed to in writing, any work + * distributed under the License is distributed on an “AS IS” BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +/* + * Authors : Cesar Fuguet + * Creation Date : March, 2020 + * Description : SRAM behavioral model + * History : + */ +module hpdcache_sram_1rw_00000006_0000001a_00000040 +#( + parameter int unsigned ADDR_SIZE = 6, + parameter int unsigned DATA_SIZE = 26, + parameter int unsigned DEPTH = 2**ADDR_SIZE +) +( + input logic clk, + input logic rst_n, + input logic cs, + input logic we, + input logic [ADDR_SIZE-1:0] addr, + input logic [DATA_SIZE-1:0] wdata, + output logic [DATA_SIZE-1:0] rdata +); + + /* + * Internal memory array declaration + */ + typedef logic [DATA_SIZE-1:0] mem_t [DEPTH]; + mem_t mem; + + /* + * Process to update or read the memory array + */ + always_ff @(posedge clk) + begin : mem_update_ff + if (cs == 1'b1) begin + if (we == 1'b1) begin + mem[addr] <= wdata; + end + rdata <= mem[addr]; + end + end : mem_update_ff +endmodule : hpdcache_sram_1rw_00000006_0000001a_00000040 diff --git a/pd/synth/hpdcache_sram_wbyteenable_1rw_00000007_00000040_00000080.sv b/pd/synth/hpdcache_sram_wbyteenable_1rw_00000007_00000040_00000080.sv new file mode 100644 index 0000000000..cd294ca955 --- /dev/null +++ b/pd/synth/hpdcache_sram_wbyteenable_1rw_00000007_00000040_00000080.sv @@ -0,0 +1,64 @@ +/* + * Copyright 2023 CEA* + * *Commissariat a l'Energie Atomique et aux Energies Alternatives (CEA) + * + * SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1 + * + * Licensed under the Solderpad Hardware License v 2.1 (the “License”); you + * may not use this file except in compliance with the License, or, at your + * option, the Apache License version 2.0. You may obtain a copy of the + * License at + * + * https://solderpad.org/licenses/SHL-2.1/ + * + * Unless required by applicable law or agreed to in writing, any work + * distributed under the License is distributed on an “AS IS” BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +/* + * Authors : Cesar Fuguet + * Creation Date : March, 2020 + * Description : Behavioral model of a 1RW SRAM with write byte enable + * History : + */ +module hpdcache_sram_wbyteenable_1rw_00000007_00000040_00000080 + +#( + parameter int unsigned ADDR_SIZE = 7, + parameter int unsigned DATA_SIZE = 64, + parameter int unsigned DEPTH = 2**ADDR_SIZE +) +( + input logic clk, + input logic rst_n, + input logic cs, + input logic we, + input logic [ADDR_SIZE-1:0] addr, + input logic [DATA_SIZE-1:0] wdata, + input logic [DATA_SIZE/8-1:0] wbyteenable, + output logic [DATA_SIZE-1:0] rdata +); + + /* + * Internal memory array declaration + */ + typedef logic [DATA_SIZE-1:0] mem_t [DEPTH]; + mem_t mem; + + /* + * Process to update or read the memory array + */ + always_ff @(posedge clk) + begin : mem_update_ff + if (cs == 1'b1) begin + if (we == 1'b1) begin + for (int i = 0; i < DATA_SIZE/8; i++) begin + if (wbyteenable[i]) mem[addr][i*8 +: 8] <= wdata[i*8 +: 8]; + end + end + rdata <= mem[addr]; + end + end : mem_update_ff +endmodule : hpdcache_sram_wbyteenable_1rw_00000007_00000040_00000080 diff --git a/pd/synth/scripts/dc_setup.tcl b/pd/synth/scripts/dc_setup.tcl index a80d4bd690..fa73a6cb49 100644 --- a/pd/synth/scripts/dc_setup.tcl +++ b/pd/synth/scripts/dc_setup.tcl @@ -18,6 +18,7 @@ set FOUNDRY_PATH [getenv FOUNDRY_PATH]; set TARGET_LIBRARY_FILES [getenv TARGET_LIBRARY_FILES]; set INPUT_DELAY [getenv INPUT_DELAY]; set OUTPUT_DELAY [getenv OUTPUT_DELAY]; +set LOCAL_LIB_PATH [getenv LOCAL_LIB_PATH]; set ADDITIONAL_LINK_LIB_FILES " ";# Extra link logical libraries not included in TARGET_LIBRARY_FILES diff --git a/pd/synth/scripts/dc_setup_filenames.tcl b/pd/synth/scripts/dc_setup_filenames.tcl index 7d8d93edd1..3d98b1a229 100644 --- a/pd/synth/scripts/dc_setup_filenames.tcl +++ b/pd/synth/scripts/dc_setup_filenames.tcl @@ -18,11 +18,17 @@ puts "RM-Info: Running script [info script]\n" ################################################################################# set INPUTS_DIR ${DESIGN_NAME}_${TARGET}/inputs/ -set REPORTS_DIR ${DESIGN_NAME}_${TARGET}/reports/${PERIOD}/ -set OUTPUTS_DIR ${DESIGN_NAME}_${TARGET}/outputs/${PERIOD}/ +set REPORTS_DIR ${DESIGN_NAME}_${TARGET}/${PERIOD}/reports/ +set OUTPUTS_DIR ${DESIGN_NAME}_${TARGET}/${PERIOD}/outputs/ +set RESULTS_DIR ${DESIGN_NAME}_${TARGET}/${PERIOD}/netlist/ + +set SCENARIO mode_norm_ws0_wc_125 + file mkdir ${INPUTS_DIR} file mkdir ${REPORTS_DIR} file mkdir ${OUTPUTS_DIR} +file mkdir ${RESULTS_DIR} + ############### # Input Files # @@ -55,15 +61,16 @@ set DCRM_FINAL_POWER_REPORT ${REPORTS_DIR}/${DESIGN_ # Output Files # ################ -set DCRM_AUTOREAD_RTL_SCRIPT ${OUTPUTS_DIR}/${DESIGN_NAME}_${TECH}.autoread_rtl.tcl -set DCRM_ELABORATED_DESIGN_DDC_OUTPUT_FILE ${OUTPUTS_DIR}/${DESIGN_NAME}_${TECH}.elab.ddc -set DCRM_COMPILE_ULTRA_DDC_OUTPUT_FILE ${OUTPUTS_DIR}/${DESIGN_NAME}_${TECH}.compile_ultra.ddc -set DCRM_FINAL_DDC_OUTPUT_FILE ${OUTPUTS_DIR}/${DESIGN_NAME}_${TECH}_synth.ddc -set DCRM_FINAL_VERILOG_OUTPUT_FILE ${OUTPUTS_DIR}/${DESIGN_NAME}_${TECH}_synth.v -set DCRM_FINAL_SDC_OUTPUT_FILE ${OUTPUTS_DIR}/${DESIGN_NAME}_${TECH}_synth.sdc -set DCRM_FINAL_SPEF_OUTPUT_FILE ${OUTPUTS_DIR}/${DESIGN_NAME}_${TECH}_synth.spef -set DCRM_FINAL_FSDB_OUTPUT_FILE ${OUTPUTS_DIR}/${DESIGN_NAME}_${TECH}_synth.fsdb -set DCRM_FINAL_VCD_OUTPUT_FILE ${OUTPUTS_DIR}/${DESIGN_NAME}_${TECH}_synth.vcd +set DCRM_AUTOREAD_RTL_SCRIPT ${RESULTS_DIR}/${DESIGN_NAME}_${TARGET}_${TECH}.autoread_rtl.tcl +set DCRM_ELABORATED_DESIGN_DDC_OUTPUT_FILE ${RESULTS_DIR}/${DESIGN_NAME}_${TARGET}_${TECH}.elab.ddc +set DCRM_COMPILE_ULTRA_DDC_OUTPUT_FILE ${RESULTS_DIR}/${DESIGN_NAME}_${TARGET}_${TECH}.compile_ultra.ddc +set DCRM_FINAL_DDC_OUTPUT_FILE ${RESULTS_DIR}/${DESIGN_NAME}_${TARGET}_${TECH}_synth.ddc +set DCRM_FINAL_VERILOG_OUTPUT_FILE ${RESULTS_DIR}/${DESIGN_NAME}_${TARGET}_${TECH}_synth.v +set DCRM_FINAL_SDC_OUTPUT_FILE ${RESULTS_DIR}/${DESIGN_NAME}_${TARGET}_${TECH}_synth.${SCENARIO}.sdc +set DCRM_FINAL_SPEF_OUTPUT_FILE ${RESULTS_DIR}/${DESIGN_NAME}_${TARGET}_${TECH}_synth.${SCENARIO}.spef +set DCRM_FINAL_FSDB_OUTPUT_FILE ${OUTPUTS_DIR}/${DESIGN_NAME}_${TARGET}_${TECH}_synth.fsdb +set DCRM_FINAL_VCD_OUTPUT_FILE ${OUTPUTS_DIR}/${DESIGN_NAME}_${TARGET}_${TECH}_synth.vcd +set DCRM_FINAL_SDF_OUTPUT_FILE ${RESULTS_DIR}/${DESIGN_NAME}_${TARGET}_${TECH}_synth.${SCENARIO}.sdf puts "RM-Info: Completed script [info script]\n" diff --git a/spyglass/reference_summary.rpt b/spyglass/reference_summary.rpt index 881f01c48d..3f38f4311d 100644 --- a/spyglass/reference_summary.rpt +++ b/spyglass/reference_summary.rpt @@ -58,6 +58,8 @@ INFO HdlLibDuCheck_03 1 Reports that 'hdllibdu' is not required +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Severity Rule Name Count Short Help =============================================================================== +ERROR SYNTH_5251 1 This gets flagged for out-of-range for + Part-Select Operations. ERROR SYNTH_5273 1 Number of bits for net/variable exceeds the mthresh value WARNING SYNTH_12605 1 Used Priority/Unique Type case/if diff --git a/util/init_gate.do b/util/init_gate.do new file mode 100644 index 0000000000..b64ba17ab9 --- /dev/null +++ b/util/init_gate.do @@ -0,0 +1 @@ +fsdbDumpvars 0 "ariane_gate_tb" +all +trace_process diff --git a/vendor/patches/riscv/riscv-config/0001-enable-implied-B-ext.patch b/vendor/patches/riscv/riscv-config/0001-enable-implied-B-ext.patch new file mode 100644 index 0000000000..142a0caf0b --- /dev/null +++ b/vendor/patches/riscv/riscv-config/0001-enable-implied-B-ext.patch @@ -0,0 +1,18 @@ +diff --git a/vendor/riscv/riscv-config/riscv_config/isa_validator.py b/vendor/riscv/riscv-config/riscv_config/isa_validator.py +index 94f7412ae..9655258b3 100644 +--- a/vendor/riscv/riscv-config/riscv_config/isa_validator.py ++++ b/vendor/riscv/riscv-config/riscv_config/isa_validator.py +@@ -60,7 +60,12 @@ def get_extension_list(isa): + elif a1 == a2 and a3 > a4: + err = True + err_list.append( f"Within the Z{a1.lower()} category extension {zext_list[i]} must occur after {zext_list[i+1]}") +- ++ if 'B' not in extension_list and (set(['Zba', 'Zbb', 'Zbs']) & set(extension_list) == set(['Zba', 'Zbb', 'Zbs'])): ++ # Insert 'B' at correct location: after any of its predecessors in canonical ordering. ++ # At least 'I' or 'E' must be present by definition. ++ B_preds = canonical_ordering[:canonical_ordering.find('B')] ++ lastpred_B_idx = max([pos for pos, char in enumerate(standard_isa) if char in list(B_preds)]) ++ extension_list.insert(lastpred_B_idx + 1, 'B') + if 'I' not in extension_list and 'E' not in extension_list: + err_list.append( 'Either of I or E base extensions need to be present in the ISA string') + err = True diff --git a/vendor/patches/riscv/riscv-config/0002-add-mstatus-UBE-bit.patch b/vendor/patches/riscv/riscv-config/0002-add-mstatus-UBE-bit.patch new file mode 100644 index 0000000000..ffd992c2fb --- /dev/null +++ b/vendor/patches/riscv/riscv-config/0002-add-mstatus-UBE-bit.patch @@ -0,0 +1,54 @@ +diff --git a/vendor/riscv/riscv-config/riscv_config/schemas/schema_isa.yaml b/vendor/riscv/riscv-config/riscv_config/schemas/schema_isa.yaml +index 981ee6247..a972efb14 100644 +--- a/vendor/riscv/riscv-config/riscv_config/schemas/schema_isa.yaml ++++ b/vendor/riscv/riscv-config/riscv_config/schemas/schema_isa.yaml +@@ -636,6 +636,24 @@ hart_schema: + - 0:1 + default: {implemented: false} + check_with: s_check ++ ube: ++ type: dict ++ schema: ++ description: { type: string, default: control the endianness of memory accesses other than instruction fetches for user mode} ++ shadow: {type: string, default: , nullable: True} ++ shadow_type: {type: string, default: rw, nullable: True, allowed: ['rw','ro']} ++ msb: {type: integer, default: 6, allowed: [6]} ++ lsb: {type: integer, default: 6, allowed: [6]} ++ implemented: {type: boolean, default: true} ++ type: ++ type: dict ++ oneof: ++ - schema: { warl: *ref_warl } ++ - schema: {ro_constant: {type: integer, max: 0 , min : 0}} ++ - schema: { wlrl: *ref_wlrl } ++ default: {ro_constant: 0} ++ default: {implemented: false} ++ check_with: u_check + mpie: + type: dict + schema: +@@ -1049,6 +1067,24 @@ hart_schema: + - 0:1 + default: {implemented: false} + check_with: s_check ++ ube: ++ type: dict ++ schema: ++ description: { type: string, default: control the endianness of memory accesses other than instruction fetches for user mode} ++ shadow: {type: string, default: , nullable: True} ++ shadow_type: {type: string, default: rw, nullable: True, allowed: ['rw','ro']} ++ msb: {type: integer, default: 6, allowed: [6]} ++ lsb: {type: integer, default: 6, allowed: [6]} ++ implemented: {type: boolean, default: true} ++ type: ++ type: dict ++ oneof: ++ - schema: { warl: *ref_warl } ++ - schema: {ro_constant: {type: integer, max: 0 , min : 0}} ++ - schema: { wlrl: *ref_wlrl } ++ default: {ro_constant: 0} ++ default: {implemented: false} ++ check_with: u_check + mpie: + type: dict + schema: diff --git a/vendor/patches/riscv/riscv-config/0003-add-mtval-roconst0-schema.patch b/vendor/patches/riscv/riscv-config/0003-add-mtval-roconst0-schema.patch new file mode 100644 index 0000000000..c91750c9da --- /dev/null +++ b/vendor/patches/riscv/riscv-config/0003-add-mtval-roconst0-schema.patch @@ -0,0 +1,15 @@ +diff --git a/vendor/riscv/riscv-config/riscv_config/schemas/schema_isa.yaml b/vendor/riscv/riscv-config/riscv_config/schemas/schema_isa.yaml +index a972efb14..a7536375f 100644 +--- a/vendor/riscv/riscv-config/riscv_config/schemas/schema_isa.yaml ++++ b/vendor/riscv/riscv-config/riscv_config/schemas/schema_isa.yaml +@@ -3594,7 +3594,9 @@ hart_schema: + lsb: {type: integer, default: 0, allowed: [0]} + type: + type: dict +- schema: { warl: *ref_warl } ++ oneof: ++ - schema: { ro_constant: {type: integer, default: 0x0, allowed: [0x0]}} ++ - schema: { warl: *ref_warl } + default: + warl: + dependency_fields: [] diff --git a/vendor/riscv/riscv-config/riscv_config/isa_validator.py b/vendor/riscv/riscv-config/riscv_config/isa_validator.py index 94f7412ae3..9655258b3b 100644 --- a/vendor/riscv/riscv-config/riscv_config/isa_validator.py +++ b/vendor/riscv/riscv-config/riscv_config/isa_validator.py @@ -60,7 +60,12 @@ def get_extension_list(isa): elif a1 == a2 and a3 > a4: err = True err_list.append( f"Within the Z{a1.lower()} category extension {zext_list[i]} must occur after {zext_list[i+1]}") - + if 'B' not in extension_list and (set(['Zba', 'Zbb', 'Zbs']) & set(extension_list) == set(['Zba', 'Zbb', 'Zbs'])): + # Insert 'B' at correct location: after any of its predecessors in canonical ordering. + # At least 'I' or 'E' must be present by definition. + B_preds = canonical_ordering[:canonical_ordering.find('B')] + lastpred_B_idx = max([pos for pos, char in enumerate(standard_isa) if char in list(B_preds)]) + extension_list.insert(lastpred_B_idx + 1, 'B') if 'I' not in extension_list and 'E' not in extension_list: err_list.append( 'Either of I or E base extensions need to be present in the ISA string') err = True diff --git a/vendor/riscv/riscv-config/riscv_config/schemas/schema_isa.yaml b/vendor/riscv/riscv-config/riscv_config/schemas/schema_isa.yaml index 981ee62472..a7536375f5 100644 --- a/vendor/riscv/riscv-config/riscv_config/schemas/schema_isa.yaml +++ b/vendor/riscv/riscv-config/riscv_config/schemas/schema_isa.yaml @@ -636,6 +636,24 @@ hart_schema: - 0:1 default: {implemented: false} check_with: s_check + ube: + type: dict + schema: + description: { type: string, default: control the endianness of memory accesses other than instruction fetches for user mode} + shadow: {type: string, default: , nullable: True} + shadow_type: {type: string, default: rw, nullable: True, allowed: ['rw','ro']} + msb: {type: integer, default: 6, allowed: [6]} + lsb: {type: integer, default: 6, allowed: [6]} + implemented: {type: boolean, default: true} + type: + type: dict + oneof: + - schema: { warl: *ref_warl } + - schema: {ro_constant: {type: integer, max: 0 , min : 0}} + - schema: { wlrl: *ref_wlrl } + default: {ro_constant: 0} + default: {implemented: false} + check_with: u_check mpie: type: dict schema: @@ -1049,6 +1067,24 @@ hart_schema: - 0:1 default: {implemented: false} check_with: s_check + ube: + type: dict + schema: + description: { type: string, default: control the endianness of memory accesses other than instruction fetches for user mode} + shadow: {type: string, default: , nullable: True} + shadow_type: {type: string, default: rw, nullable: True, allowed: ['rw','ro']} + msb: {type: integer, default: 6, allowed: [6]} + lsb: {type: integer, default: 6, allowed: [6]} + implemented: {type: boolean, default: true} + type: + type: dict + oneof: + - schema: { warl: *ref_warl } + - schema: {ro_constant: {type: integer, max: 0 , min : 0}} + - schema: { wlrl: *ref_wlrl } + default: {ro_constant: 0} + default: {implemented: false} + check_with: u_check mpie: type: dict schema: @@ -3558,7 +3594,9 @@ hart_schema: lsb: {type: integer, default: 0, allowed: [0]} type: type: dict - schema: { warl: *ref_warl } + oneof: + - schema: { ro_constant: {type: integer, default: 0x0, allowed: [0x0]}} + - schema: { warl: *ref_warl } default: warl: dependency_fields: [] diff --git a/verif/sim/Makefile b/verif/sim/Makefile index c2e8615272..7a9d7d333a 100644 --- a/verif/sim/Makefile +++ b/verif/sim/Makefile @@ -32,8 +32,9 @@ FLIST_TB := $(CVA6_TB_DIR)/Flist.cva6_tb # target takes one of the following cva6 hardware configuration: # cv64a6_imafdc_sv39, cv32a6_imac_sv0, cv32a6_imac_sv32, cv32a6_imafc_sv32 target ?= cv64a6_imafdc_sv39 -FLIST_CORE := $(if $(gate), $(CVA6_REPO_DIR)/core/Flist.cva6_gate,$(CVA6_REPO_DIR)/core/Flist.cva6) - +FLIST_CORE = $(if $(gate),$(CVA6_REPO_DIR)/core/Flist.cva6_gate,$(CVA6_REPO_DIR)/core/Flist.cva6) +th_top_level := $(if $(gate),ariane_gate_tb,ariane_tb) +do_file := $(if $(gate),init_gate,init_testharness) TRACE_FAST ?= TRACE_COMPACT ?= VERDI ?= @@ -246,6 +247,7 @@ vcs_uvm_comp: -f $(FLIST_CORE) -f $(FLIST_TB) \ -f $(CVA6_UVMT_DIR)/uvmt_cva6.flist \ $(cov-comp-opt) +define+UNSUPPORTED_WITH+ $(isscomp_opts)\ + -ignore initializer_driver_checks \ -top uvmt_cva6_tb vcs_uvm_run: vcs_uvm_comp @@ -323,8 +325,8 @@ vcs_clean_all: # testharness specific commands, variables ############################################################################### vcs-testharness: - make -C $(path_var) vcs_build target=$(target) defines=$(subst +define+,,$(isscomp_opts))$(if $(spike-tandem),SPIKE_TANDEM=1) - $(path_var)/work-vcs/simv $(if $(VERDI), -verdi -do $(path_var)/util/init_testharness.do,) +permissive \ + make -C $(path_var) vcs_build target=$(target) gate=$(gate) top_level=$(th_top_level) flist=$(FLIST_CORE) defines=$(subst +define+,,$(isscomp_opts))$(if $(spike-tandem),SPIKE_TANDEM=1) + $(path_var)/work-vcs/simv $(if $(VERDI), -verdi -do $(path_var)/util/$(do_file).do,) +permissive \ +permissive-off $(COMMON_RUN_ARGS) # If present, move default waveform files to log directory. # Keep track of target in waveform file name. diff --git a/verif/sim/cov-exclude-mod.lst b/verif/sim/cov-exclude-mod.lst index d0a40835b9..81ff71d789 100644 --- a/verif/sim/cov-exclude-mod.lst +++ b/verif/sim/cov-exclude-mod.lst @@ -13,3 +13,4 @@ -tree uvmt_cva6_tb.cva6_dut_wrap.cva6_tb_wrapper_i.i_cva6.genblk6.i_cva6_rvfi_combi -tree uvmt_cva6_tb.cva6_dut_wrap.cva6_tb_wrapper_i.i_cva6.i_cva6_rvfi_probes -tree uvmt_cva6_tb.cva6_dut_wrap.cva6_tb_wrapper_i.i_cva6.i_frontend.i_instr_queue.i_unread_* +-tree uvmt_cva6_tb.cva6_dut_wrap.cva6_tb_wrapper_i.i_cva6.gen_cache_hpd.i_cache_subsystem diff --git a/verif/sim/cva6.yaml b/verif/sim/cva6.yaml index b266a5a47b..219781391d 100644 --- a/verif/sim/cva6.yaml +++ b/verif/sim/cva6.yaml @@ -45,7 +45,14 @@ tool_path: SPIKE_PATH tb_path: TB_PATH cmd: > - make vcs-uvm target= gate=1 cov=${cov} variant= elf= tool_path= isscomp_opts= issrun_opts= isspostrun_opts= log= + make vcs-testharness target= gate=1 cov=${cov} variant= elf= path_var= tool_path= isscomp_opts= issrun_opts= isspostrun_opts= log= + +- iss: vcs-gate-tb + path_var: RTL_PATH + tool_path: SPIKE_PATH + tb_path: TB_PATH + cmd: > + make vcs-testharness target= th_top_level=ariane_gate_tb do_file=init_gate cov=${cov} variant= elf= path_var= tool_path= isscomp_opts= issrun_opts= isspostrun_opts= log= - iss: vcs-uvm path_var: RTL_PATH diff --git a/verif/sim/link.ld b/verif/sim/link.ld index ad50f56e2e..d064469c6b 100644 --- a/verif/sim/link.ld +++ b/verif/sim/link.ld @@ -19,17 +19,48 @@ ENTRY(_start) SECTIONS { . = 0x80000000; + _start_text = .; .text.init : { *(.text.init) } . = ALIGN(0x1000); .tohost : { *(.tohost) } . = ALIGN(0x1000); .text : { *(.text) } . = ALIGN(0x1000); + .text.startup : { *(.text.startup) } + . = ALIGN(0x1000); + _end_text = .; + . = ALIGN(0x1000); + .rodata : { *(.rodata*)} + . = ALIGN(0x8); + . = ALIGN(0x1000); .page_table : { *(.page_table) } .user_stack : { *(.user_stack) } .kernel_data : { *(.kernel_data) } .kernel_stack : { *(.kernel_stack) } .data : { *(.data) } + .sdata : { + __global_pointer$ = . + 0x800; + *(.srodata.cst16) *(.srodata.cst8) *(.srodata.cst4) *(.srodata.cst2) *(.srodata*) + *(.sdata .sdata.* .gnu.linkonce.s.*) + } + + /* bss segment */ +/* .sbss : { + *(.sbss .sbss.* .gnu.linkonce.sb.*) + *(.scommon) + }*/ .bss : { *(.bss) } + .tdata : + { + _tdata_begin = .; + *(.tdata) + _tdata_end = .; + } + .tbss : + { + *(.tbss) + _tbss_end = .; + } + _end = .; } diff --git a/verif/tb/uvmt/cva6_tb_wrapper.sv b/verif/tb/uvmt/cva6_tb_wrapper.sv index 79987b2530..e1d60de852 100644 --- a/verif/tb/uvmt/cva6_tb_wrapper.sv +++ b/verif/tb/uvmt/cva6_tb_wrapper.sv @@ -299,8 +299,12 @@ module cva6_tb_wrapper import uvmt_cva6_pkg::*; #( end load_address = (address[23:0] >> 3) + i; if (load_address != last_load_address) begin - `MAIN_MEM(load_address) = mem_row; - last_load_address = load_address; + if (address[31:0] < 'h84000000) begin + `MAIN_MEM(load_address) = mem_row; + end else begin + `USER_MEM(load_address) = mem_row; + end + last_load_address = load_address; end else begin `uvm_info( "Debug info", $sformatf(" Address: %x Already Loaded! ELF file might have less than 64 bits granularity on segments.", load_address), UVM_LOW) end