首页 文章

写入后跟在VHDL过程中读取

提问于
浏览
0

以下代码用于VHDL中的一个非常简单的程序 .

entity ent is
    port(
        clk: in std_logic;
        out_value: out std_logic;
    );
end entity ent;

architecture ent_arch of ent is
    signal counter: std_logic_vector(3 downto 0);
begin
    process(clk)
    begin
        if rising_edge(clk) then
            counter <= counter + 1;
            if counter = 10 then
                counter <= (others => '0') ;
            end if;
        end if;
    end process;
end ent_arch;

想象一下counter = 9,我们输入if语句(如果rising_edge(clk)) . 第一个语句计数器<=计数器1将10分配给计数器 . 我的问题是“在这个入口处或下一个入口处是否if状态(如果计数器= 10)评估为真?". In other words "对于此过程的这个比较,由于前面的陈述,计数器= 10? “

非常感谢您的回答!

1 回答

  • 0

    信号分配总是延迟 . 您未使用 after 关键字明确指定延迟,因此分配会延迟一个增量周期(与 after 0 fs 相同) . 这意味着,该语句右侧的表达式的值:

    counter <= counter + 1;
    

    将在 next 模拟循环开始时分配给 counter .

    但是,您的过程中的所有剩余语句都在 current 模拟循环中执行 . 因此,这个读取计数器值,

    if counter = 10 then
    

    仍然会使用旧值,这样,当计数器在时钟上升沿已经为10时,它将被重置 . 计数器从0到10计数 .

    至少有一个delta周期的延迟,很容易交换寄存器的内容:

    -- within declarative part of architecture
    signal reg_a, reg_b : std_logic;
    
    -- within architecture body
    process(clock)
    begin
      if rising_edge(clock) then
        reg_a <= reg_b;
        reg_b <= reg_a;  -- assign old value of reg_a ! 
      end if;
    end process;
    

相关问题