请澄清VHDL中顺序执行和并发执行的概念

Please, clarify the concept of sequential and concurrent execution in VHDL

我在学校熟悉了一点 Verilog,现在,一年后,我买了一块 Basys 3 FPGA 板。我的目标是学习VHDL。

我一直在阅读一本名为 "Free Range VHDL" 的免费书籍,这对理解 VHDL 语言有很大帮助。我还搜索了包含 VHDL 代码的 github 存储库以供参考。

我最关心的是顺序执行和并发执行之间的区别。我明白这两个词的意思,但我仍然无法想象为什么我们可以使用 "process" 作为组合逻辑(即七段解码器)。我已经将我的七段解码器实现为并发语句的条件分配。 如果我使用进程和 switch 语句实现解码器,会有什么不同?当谈到组合逻辑时,我不理解进程顺序执行这个词。如果是时序机我就理解了——状态机

有人可以解释一下这个概念吗?

这是我的七段解码器代码:

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

entity hex_display_decoder is
    Port ( D: in STD_LOGIC_VECTOR (3 downto 0);
       SEG_OUT : out STD_LOGIC_VECTOR (6 downto 0));
end hex_display_decoder;

architecture dataflow of hex_display_decoder is
begin
  with D select
      SEG_OUT <=  "1000000" when "0000",
                  "1111001" when "0001",
                  "0100100" when "0010",
                  "0110000" when "0011",
                  "0011001" when "0100",
                  "0010010" when "0101",
                  "0000010" when "0110",
                  "1111000" when "0111",
                  "0000000" when "1000",
                  "0010000" when "1001",
                  "0001000" when "1010",
                  "0000011" when "1011",
                  "1000110" when "1100",
                  "0100001" when "1101",
                  "0000110" when "1110",
                  "0001110" when "1111",
                  "1111111" when others;
end dataflow;

谢谢,

杰克·赫拉迪克

My biggest concern is difference between sequential and concurrent execution. I understand the meaning of these two words but I still cannot imagine why we can use "process" for combinational logic (ex. seven segment decoder).

你混淆了两件事:

  • 逻辑类型,可以是顺序的或组合的。
  • 语句的执行顺序,可以是顺序的,也可以是并发的。

逻辑类型

逻辑设计中:

  • 一个组合电路是一个实现没有任何状态的纯逻辑功能的电路。组合电路中不需要时钟。
  • 时序电路是一种在每个时钟周期都会改变并在时钟周期之间记住其状态(使用触发器)的电路。

以下VHDL过程是组合的:

process(x, y) begin
    z <= x or y;
end process;

我们知道它是组合的,因为:

  • 它没有时钟。
  • 它的所有输入都在它的敏感列表中(process 关键字后的括号)。这意味着对这些输入中的任何一个进行更改都将导致重新评估流程。

以下 VHDL 过程是顺序的:

process(clk) begin
    if rising_edge(clk) then
        if rst = '1' then
            z <= '0';
        else
            z <= z xor y;
        end if;
    end if;
end process;

我们知道它是顺序的,因为:

  • 它只对其时钟的变化敏感 (clk)。
  • 它的输出只在时钟的上升沿改变值。
  • z的输出值取决于它之前的值(z在赋值的两边)。

执行模型

长话短说,VHDL中的流程执行如下:

  • 进程中的语句顺序执行(即在 其他按顺序)。
  • 进程 运行 并发 相对于彼此。

变相进程

所谓并发语句,本质上都是进程外的语句,其实都是伪装的进程。例如,这个并发信号分配(即分配给进程外的信号):

z <= x or y;

相当于这个过程:

process(x, y) begin
    z <= x or y;
end process;

也就是说,它等同于所有输入都在敏感列表中的进程中的相同分配。所谓等效,我的意思是 VHDL 标准 (IEEE 1076) 实际上通过等效过程定义了并发信号分配的行为。

这意味着,即使你不知道,你在 hex_display_decoder 中的这句话:

SEG_OUT <=  "1000000" when "0000",
            "1111001" when "0001",
            "0100100" when "0010",
            "0110000" when "0011",
            "0011001" when "0100",
            "0010010" when "0101",
            "0000010" when "0110",
            "1111000" when "0111",
            "0000000" when "1000",
            "0010000" when "1001",
            "0001000" when "1010",
            "0000011" when "1011",
            "1000110" when "1100",
            "0100001" when "1101",
            "0000110" when "1110",
            "0001110" when "1111",
            "1111111" when others;

已经是一个进程。

这反过来意味着

What would be the difference if I implemented the decoder using process and a switch statement?

None 完全没有。