Skip to content

Commit

Permalink
[package] add experimental match function
Browse files Browse the repository at this point in the history
  • Loading branch information
stnolting committed Dec 22, 2024
1 parent e8f06ea commit aa04eef
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions rtl/core/neorv32_package.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;

0 comments on commit aa04eef

Please # to comment.