Commit c19afcd5 authored by Ille, Ondrej, Ing.'s avatar Ille, Ondrej, Ing.

Merge branch '239-regmap-gen-saturation-fix' into 'master'

Resolve "Regmap gen saturation fix."

Closes #239

See merge request illeondr/CAN_FD_IP_Core!192
parents 5f40b1f7 4af0927e
Pipeline #5793 failed with stages
in 61 minutes and 32 seconds
Subproject commit 1f02df14b17d36da110e1e8ca30b34923a24046b
Subproject commit 24f6fe411be6ed81ce4ab27d2dfeadaca425d999
......@@ -64,6 +64,7 @@
--------------------------------------------------------------------------------
-- Revision History:
-- 3.11.2018 Created file
-- 8.01.2019 Added data saturation upon address overflow.
--------------------------------------------------------------------------------
Library ieee;
......@@ -133,7 +134,11 @@ architecture rtl of data_mux is
-- Data output from data mux (before masking)
signal sel_data : std_logic_vector(data_out_width - 1 downto 0);
-- Data output from data mux (after masking)
-- Data after saturation. Saturated data return all zeroes when address overflow
-- and read beyond last address of register block occurs.
signal saturated_data : std_logic_vector(data_out_width - 1 downto 0);
-- Data output from data mux (after masking and saturation)
signal masked_data : std_logic_vector(data_out_width - 1 downto 0);
-- Internal data select converted to natural to avoid ugly code in
......@@ -145,7 +150,7 @@ architecture rtl of data_mux is
-- Saturated value of internal index.
signal index_sat : natural range 0 to INDEX_MAX;
begin
---------------------------------------------------------------------------
......@@ -153,6 +158,7 @@ begin
---------------------------------------------------------------------------
index <= to_integer(unsigned(data_selector));
---------------------------------------------------------------------------
-- Data selector saturation, we need to saturate data selector in case
-- we don't have 2^N inputs. Address conversion of n bit vector to index
......@@ -160,8 +166,7 @@ begin
-- modulo is not effective, modulo by non 2^N number results in extra
-- shitty logic...
---------------------------------------------------------------------------
index_sat <= index when (index <= INDEX_MAX)
else
index_sat <= index when (index <= INDEX_MAX) else
INDEX_MAX;
......@@ -173,11 +178,21 @@ begin
end generate data_mux_gen;
---------------------------------------------------------------------------
-- Data saturation
---------------------------------------------------------------------------
data_saturation_gen : for i in 0 to data_out_width - 1 generate
saturated_data(i) <= sel_data(i) when (index <= INDEX_MAX)
else
'0';
end generate data_saturation_gen;
---------------------------------------------------------------------------
-- Data masking
---------------------------------------------------------------------------
data_mask_gen : for i in 0 to data_out_width - 1 generate
masked_data(i) <= sel_data(i) and data_mask_n(i);
masked_data(i) <= saturated_data(i) and data_mask_n(i);
end generate data_mask_gen;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment