From da0bd89c431b4b69ded7fb21dc3fbecf18f5b914 Mon Sep 17 00:00:00 2001 From: Benjamin Herrenschmidt Date: Wed, 16 Oct 2019 12:11:16 +1100 Subject: [PATCH] crhelpers: Constraint "crnum" integer This seems to save quite a few LUTs Signed-off-by: Benjamin Herrenschmidt --- crhelpers.vhdl | 11 +++++++---- execute1.vhdl | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/crhelpers.vhdl b/crhelpers.vhdl index f51110c..1e6160f 100644 --- a/crhelpers.vhdl +++ b/crhelpers.vhdl @@ -5,13 +5,16 @@ library work; use work.common.all; package crhelpers is - function fxm_to_num(fxm: std_ulogic_vector(7 downto 0)) return integer; - function num_to_fxm(num: integer) return std_ulogic_vector; + subtype crnum_t is integer range 0 to 7; + subtype crmask_t is std_ulogic_vector(7 downto 0); + + function fxm_to_num(fxm: crmask_t) return crnum_t; + function num_to_fxm(num: crnum_t) return crmask_t; end package crhelpers; package body crhelpers is - function fxm_to_num(fxm: std_ulogic_vector(7 downto 0)) return integer is + function fxm_to_num(fxm: crmask_t) return crnum_t is begin -- If multiple fields are set (undefined), match existing -- hardware by returning the first one. @@ -27,7 +30,7 @@ package body crhelpers is return 7; end; - function num_to_fxm(num: integer) return std_ulogic_vector is + function num_to_fxm(num: crnum_t) return crmask_t is begin case num is when 0 => diff --git a/execute1.vhdl b/execute1.vhdl index 002bdac..6d3a936 100644 --- a/execute1.vhdl +++ b/execute1.vhdl @@ -109,8 +109,8 @@ begin variable newcrf : std_ulogic_vector(3 downto 0); variable result_with_carry : std_ulogic_vector(64 downto 0); variable result_en : integer; - variable crnum : integer; - variable scrnum : integer; + variable crnum : crnum_t; + variable scrnum : crnum_t; variable lo, hi : integer; variable sh, mb, me : std_ulogic_vector(5 downto 0); variable sh32, mb32, me32 : std_ulogic_vector(4 downto 0); -- 2.30.2