【问题标题】:How can I generate a "tick" inside a process in VHDL?如何在 VHDL 的进程中生成“滴答”?
【发布时间】:2015-12-11 01:31:38
【问题描述】:

我正在用 VHDL 编写一个指定的 UART 组件。

send: process(send_start)
    variable bit_index : integer range 0 to 2 := 0;
begin
    if (falling_edge(send_start)) then
        if (start = '0' and transceiver_start = '1') then
            bit_index := 0;
        end if;

        transceiver_start <= '1';
        if (bit_index = 0) then
            temp_data <= data.RE;
            bit_index := 1;
            transceiver_start <= '0';
            delay_counter <= 0;
        elsif (bit_index = 1) then
            temp_data <= data.IM;
            bit_index := 2;
            transceiver_start <= '0';
        end if;
    end if;
end process;

transceiver_start 信号的下降沿触发子组件运行。我想触发它​​两次,但我不知道如何生成第二个下降沿。

我考虑过使用并发进程,它基本上会在delay_counter 达到某个限制后将transceiver_start 信号重置为高状态。因此,我可以再次将其置于send 进程中以生成下降沿。但是,这使我对delay_counter 信号有两个驱动过程,并且我读到具有解析函数并不是合成的好习惯(此代码需要可合成。)

bit_index = 1 时有什么方法可以让我生成下降沿?

【问题讨论】:

    标签: vhdl fpga hdl


    【解决方案1】:

    FPGA 器件和相关综合工具针对同步逻辑进行了优化, 因此,时钟触发进程执行的 VHDL。使用特定的信号 触发流程执行,如问题代码中一样,因此不符合 缩进的FPGA和VHDL设计方法。

    相反,使用内部时钟来触发进程执行,通常是上升 时钟的边缘。然后,流程内的实际更新可以取决于 检测到控制信号的变化,可以是send_start

    process (clock) is
    begin
      if rising_edge(clock) then
        send_start_prev <= send_start;  -- Previous for edge detection
        if ((send_start = '0') and (send_start_prev = '1')) then  -- Falling edge of send_start
          ...  -- More code
        end if;
      end if;
    end process;
    

    对于条件流程代码的重新运行,例如基于bit_index = 1,流程内容可以更新如下:

        send_start_prev <= send_start;  -- Previous for edge detection
        rerun_request   <= '0';  -- Default no rerun
        if ((send_start = '0') and (send_start_prev = '1')) or  -- Falling edge of send_start
           (rerun_request = '1') then  -- Rerun request
          if bit_index = 1 then
            rerun_request <= '1';
          end if;
          ...  -- More code
        end if;
    

    【讨论】:

      猜你喜欢
      • 2019-11-04
      • 1970-01-01
      • 2020-09-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-04
      • 1970-01-01
      • 2015-05-14
      相关资源
      最近更新 更多