From aa04eef81aea614c91a19111f819a10bae1b636e Mon Sep 17 00:00:00 2001 From: stnolting Date: Sun, 22 Dec 2024 17:58:36 +0100 Subject: [PATCH] [package] add experimental match function --- rtl/core/neorv32_package.vhd | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/rtl/core/neorv32_package.vhd b/rtl/core/neorv32_package.vhd index 5040d0f78..1e6b37f22 100644 --- a/rtl/core/neorv32_package.vhd +++ b/rtl/core/neorv32_package.vhd @@ -29,7 +29,7 @@ package neorv32_package is -- Architecture Constants ----------------------------------------------------------------- -- ------------------------------------------------------------------------------------------- - constant hw_version_c : std_ulogic_vector(31 downto 0) := x"01100707"; -- hardware version + constant hw_version_c : std_ulogic_vector(31 downto 0) := x"01100708"; -- hardware version constant archid_c : natural := 19; -- official RISC-V architecture ID constant XLEN : natural := 32; -- native data path width @@ -708,6 +708,7 @@ package neorv32_package is function replicate_f(input : std_ulogic; num : natural) return std_ulogic_vector; impure function mem32_init_f(init : mem32_t; depth : natural) return mem32_t; function print_version_f(version : std_ulogic_vector(31 downto 0)) return string; + function match_f(input : std_ulogic_vector; pattern : std_ulogic_vector) return boolean; -- ********************************************************************************************************** -- NEORV32 Processor Top Entity (component prototype) @@ -750,10 +751,10 @@ package neorv32_package is RISCV_ISA_Zksh : boolean := false; RISCV_ISA_Zxcfu : boolean := false; -- Tuning Options -- - CLOCK_GATING_EN : boolean := false; - FAST_MUL_EN : boolean := false; - FAST_SHIFT_EN : boolean := false; - REGFILE_HW_RST : boolean := false; + CPU_CLOCK_GATING_EN : boolean := false; + CPU_FAST_MUL_EN : boolean := false; + CPU_FAST_SHIFT_EN : boolean := false; + CPU_REGFILE_HW_RST : boolean := false; -- Physical Memory Protection (PMP) -- PMP_NUM_REGIONS : natural range 0 to 16 := 0; PMP_MIN_GRANULARITY : natural := 4; @@ -1174,4 +1175,23 @@ package body neorv32_package is return res_v; end function print_version_f; + -- Check if signal matches binary pattern (skip elements compared with '-') --------------- + -- ------------------------------------------------------------------------------------------- + function match_f(input : std_ulogic_vector; pattern : std_ulogic_vector) return boolean is + variable match_v : boolean; + begin + if (input'length /= pattern'length) then + report "[NEORV32] match_f: input and pattern have different sizes!" severity error; + return false; + else + match_v := true; + for i in input'length-1 downto 0 loop + if (pattern(i) = '1') or (pattern(i) = '0') then -- valid pattern value, skip everything else + match_v := match_v and boolean(pattern(i) = input(i)); + end if; + end loop; + return match_v; + end if; + end function match_f; + end neorv32_package;