これが私の問題です。組み合わせロジックを使用して、16 ビットの左/右論理/算術シフト コンポーネントを最初から設計する必要があります (std_logic_vector と std_logic を使用する場合を除く)。
ここに私が持っているものがあります:
library ieee;
use ieee.std_logic_1164.all;
entity Shift16 is
port
(
-- Input ports
I : in std_logic_vector(15 downto 0);
Shift : in std_logic_vector(3 downto 0);
-- Sel(1) == 0 -> Logical ; Sel(0) == Left
Sel : in std_logic_vector(1 downto 0);
-- Output ports
O : out std_logic_vector(15 downto 0)
);
end Shift16;
architecture Struct of Shift16 is
component Mux16to1 is
port (I : in std_logic_vector(15 downto 0);
S : in std_logic_vector(3 downto 0);
O : out std_logic);
end component;
component Mux2to1_16 is
port
( A, B : in std_logic_vector(15 downto 0); S : in std_logic;
Q : out std_logic_vector(15 downto 0) );
end component;
signal OLeft, ORight : std_logic_vector(15 downto 0);
signal PadVal : std_logic;
type gen_signal is array (15 downto 0) of std_logic_vector(15 downto 0);
signal leftPad, rightPad : gen_signal;
begin
process (I, Sel)
begin
if (Sel(0) = '0') then -- logical
PadVal <= '0';
else
PadVal <= I(15); -- aritmetic
end if;
for j in 15 downto 0 loop
for k in j downto 0 loop
leftPad(j, k) <= I(15-j);
rightPad(j, k) <= PadVal;
end loop;
for k in 15 downto j+1 loop
leftPad(j, k) <= PadVal;
rightPad(j, k) <= I(15-j);
end loop;
end loop;
end process;
muxarr_left_shift: for index in 15 downto 0 generate
begin
mux: Mux16to1 port map (leftPad(index), Shift, OLeft(index));
end generate;
muxarr_right_shift: for index in 15 downto 0 generate
begin
mux: Mux16to1 port map (rightPad(index), Shift, ORight(index));
end generate;
OutputMux: Mux2to1_16 port map (ORight, OLeft, Sel(1), O);
end Struct;
コンポーネントは、Mux
まさに私のカスタム バージョンです。
私の最初のアイデアは、16 個の 16 対 1 の Mux を使用し、それらを配線して、シフト量がそれぞれの選択になるようにすることでした。これは非常に高速ですが、何らかの理由でコードがコンパイルされません。
私もこれを複雑にしすぎていると思います.
コンパイルエラーは次のとおりです。Error (10382): VHDL error at Shl16.vhd(52): index of object of array type gen_signal must have 1 dimensions