有人可以帮我弄清楚为什么我的班次登记册不能正确旋转。我知道它不是开关输入,因为我用sw(15)切换sw(14)并且它仍然向左旋转但不是向右旋转。我认为这是实际编码中的内容,但我不确定是什么。
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
entity question2 is
Port (
led: buffer std_logic_vector (9 downto 0);
clk: in std_logic;
btnU: in std_logic;
btnD: in std_logic;
btnC: in std_logic;
sw: in std_logic_vector (15 downto 14)--------rotate prob. is not in switches
);
end question2;
architecture Behavioral of question2 is
constant active: std_logic :='1';
signal DataIn: std_logic_vector (9 downto 0):= "0000000001";
signal Load: std_logic := btnD;
signal Reset: std_logic := btnC;
signal Left: std_logic:= sw(15);
signal Right: std_logic:= sw(14);
signal DataOut: std_logic_vector (9 downto 0);
signal Clear: std_logic:= btnU;
signal speed_enable: std_logic;
begin
led<= DataOut;
SpeedControl: process (clk, Reset)
variable counter: integer range 0 to 10000000;
begin
speed_enable<=not active;
if Reset = Active then
counter:= 0;
elsif (rising_edge (clk)) then
counter := counter + 1;
if (counter=10000000) then
speed_enable<= Active;
counter:=0;
end if;
end if;
end process;
shiftregister: process(clk, clear)
begin
if rising_edge (clk) then
if clear= active or reset=active then
DataOut <= (others => '0');
elsif load = active then
DataOut <= DataIn ;
elsif Left = active and Right = not active then
if speed_enable = active then
DataOut <= DataOut(8 downto 0) & DataOut(9) ;
elsif Right = active and left = not active then
if speed_enable = active then
DataOut <= DataOut(0) & DataOut (9 downto 1) ;
else
dataout <= "0000000000";
end if;
end if;
end if;
end if;
end process;
end Behavioral;
答案 0 :(得分:1)
你还没有解决我在上一个问题上提到的所有问题。默认分配不是默认连接;当Left
输入发生变化时,Right
和sw
信号不会改变。
您应该将内部控制信号连接到led<= DataOut;
行正下方的输入,例如Left <= sw(15);
此外,当没有控制信号处于活动状态时dataout
应保持不变,不会将其自身重置为所有'0'
。您的加载,重置和清除按钮也不起作用。 speed_enable
仍在混合组合作业和时钟作业,不会合成。
DataIn
也可能是常量,因为无法修改它。
看起来你错过了end if;
时钟启用(你把它们粘在最后而不是它们应该的位置),这会导致不良行为。