1
对矢量中的每个位执行端口映射的最佳方式是什么?假设我有一个代表一系列按钮的向量,并且希望使用一个跳动模块来消除每个按钮,我应该怎么做?矢量中每个位的VHDL映射
现在我有以下的,但我相信应该有更好的方式
entity ButtonDebouncer is
Port (
clock : in std_logic;
buttons : in std_logic_vector(0 to 5);
--{ more stuff }
);
end ButtonDebouncer;
architecture Behavioral of ButtonDebouncer is
signal bufferedButtons : std_logic_vector(0 to 5) := (others => '0');
begin
c1: entity debounce port map (Clock, buttons(0), bufferedButtons(0));
c2: entity debounce port map (Clock, buttons(1), bufferedButtons(1));
c3: entity debounce port map (Clock, buttons(2), bufferedButtons(2));
c4: entity debounce port map (Clock, buttons(3), bufferedButtons(3));
c5: entity debounce port map (Clock, buttons(4), bufferedButtons(4));
c6: entity debounce port map (Clock, buttons(5), bufferedButtons(5));
--{ Do stuff with debounced buttons }
end Behavioral;
你甚至可以用'buttons'range'更换'0〜5'架构,避免了神奇的硬编码值,使意图明显。 –
太棒了,我不知道'生成' – Jableader