移动每个时钟事件和时钟= 1(VHDL)

时间:2015-01-07 11:13:21

标签: vhdl clock bit-shift

此代码会在n1n2的条件下,在每个clk'event and clk=1上移动sh=1su=0。问题是,第一个上升沿发生了转换,下一个上升沿不会再发生转变,任何人都知道如何让它连续转移?感谢。

ENTITY register_divider IS
  port( st , clk :in std_logic ; 
    num : in std_logic_vector (15 downto 0);

    qu : out std_logic_vector(7 downto 0);
    re : out std_logic_vector (7 downto 0);
    n1r : out std_logic_vector ( 8 downto 0 );
    counter : in std_logic_vector ( 3 downto 0);
    Sh, su, Ld: in std_logic ;
    n1c: in std_logic_vector ( 8 downto 0 )
  );
END ENTITY register_divider;

--
ARCHITECTURE rtl OF register_divider IS
BEGIN  

    process(clk)
        variable n1 : std_logic_vector ( 8 downto 0);
        variable n2 : std_logic_vector ( 7 downto 0) ;
    begin

        n2 := num(7 downto 0);
        n1 := '0' & num(15 downto 8); 

        if (clk'event and clk = '1' ) then
             n1r <= n1 ; 
             if ( sh='1' and su = '0') then 
                n1 := n1(7 downto 0) & n2(7);
                n2 := n2(6 downto 0) & '0';
             end if ;

             if  ( su = '1' and su = '1') then 
                n2(0) := '1';
                n1 := n1c ;
             end if ; 
        end if ; 

        qu <= n2 ;
        re <= n1(7 downto 0);
    end process;
 END ARCHITECTURE rtl;

1 个答案:

答案 0 :(得分:0)

作为Brian的mentioned,你的代码正在按你的意愿移动,但是,问题是它也在每个周期加载/设置寄存器,基本上撤消你想要的。每个周期(无条件地)加载/设置寄存器n1n2,而不是在声明适当的信号时加载条件(Ld可能?)