我想实现一个通用的位滑模块。下面是我想为 4 和 8 做的一个例子。我不知道如何编写代码,所以我可以传递一些通用的 N 并且代码将使用 for 循环或其他东西自动生成。
---- 4-bitslip
bits_slipped <=
bits_in(3 downto 0) when tap_sel = "00" else
bits_in(2 downto 0) & bits_in(3) when tap_sel = "01" else
bits_in(1 downto 0) & bits_in(3 downto 2) when tap_sel = "10" else
bits_in(0) & bits_in(3 downto 1) when tap_sel = "11";
-- 8-bitslip
bits_slipped <=
bits_in(7 downto 0) when tap_sel = "000" else
bits_in(6 downto 0) & bits_in(7) when tap_sel = "001" else
bits_in(5 downto 0) & bits_in(7 downto 6) when tap_sel = "010" else
bits_in(4 downto 0) & bits_in(7 downto 5) when tap_sel = "011" else
bits_in(3 downto 0) & bits_in(7 downto 4) when tap_sel = "100" else
bits_in(2 downto 0) & bits_in(7 downto 3) when tap_sel = "101" else
bits_in(1 downto 0) & bits_in(7 downto 2) when tap_sel = "110" else
bits_in(0) & bits_in(7 downto 1) when tap_sel = "111";
-- N-bitslip ????