并发和条件信号分配 (VHDL)

mah*_*ood 3 concurrency vhdl

In VHDL, there are two types for signal assignment:

concurrent   ---->    when...else
             ---->    select...when...else

sequential   ---->    if...else
             ---->    case...when
Run Code Online (Sandbox Code Playgroud)

Problem is that some say that when...else conditions are checked line by line (king of sequential) while select...when...else conditionals are checked once. See this reference for example.

I say that when..else is also a sequential assignment because you are checking line by line. In other words, I say that there no need to say if..else within a process is equivalent to when..else. Why they assume when..else is a concurrent assignment?

Jim*_*wis 5

您在问题中暗示的地方与并发赋值或顺序语句无关。它更多地与 if 和 case 之间的区别有关。在我们开始之前,让我们先了解一些等价物。并发条件赋值:

Y <= A when ASel = '1' else B when BSel = '1' else C ; 
Run Code Online (Sandbox Code Playgroud)

完全等同于具有以下代码的进程:

process(A, ASel, B, BSel, C) 
begin
  if ASel = '1' then
    Y <= A ;
  elsif BSel = '1' then 
    Y <= B ; 
  else 
    Y <= C ; 
  end if ;
end process ; 
Run Code Online (Sandbox Code Playgroud)

同样的并发选择分配:

With MuxSel select
  Y <= A when "00", B when "01", C when others ; 
Run Code Online (Sandbox Code Playgroud)

相当于具有以下内容的过程:

process(MuxSel, A, B , C) 
begin
  case MuxSel is 
    when "00" =>    Y <= A; 
    when "01" =>    Y <= B ; 
    when others =>  Y <= C ;
  end case ; 
end process ; 
Run Code Online (Sandbox Code Playgroud)

从编码的角度来看,上面的顺序形式比分配形式具有更多的编码能力,因为 case 和 if 允许代码块,其中分配形式只分配给一个信号。然而除此之外,它们具有相同的语言限制并产生相同的硬件(与综合工具一样)。此外,对于许多简单的硬件问题,分配表效果很好,并且是对问题的简明捕获。

因此,您的想法指向何处实际上归结为 if 和 case 之间的区别。如果语句(及其等效的条件赋值)在(或隐含在)中有多个“elsif”,则倾向于创建优先级逻辑或至少是级联逻辑。其中案例(及其等效的选定分配)往往非常适合多路复用器之类的东西,并且它们的逻辑结构往往更像是一种平衡的树结构。

有时工具会重构 if 语句以使其等效于 case 语句。同样对于某些目标(特别是基于 LUT 的逻辑,如 Xilinx 和 Altera),它们之间在硬件效率方面的差异直到有足够的“elsif”分支才显示出来。

使用 VHDL-2008,也允许在顺序代码中使用赋值形式。除了没有流程包装器之外,转换是相同的。