简体   繁体   English

VHDL中的过程可重入吗?

[英]Is process in VHDL reentrant?

Is it possible two or more sequential run for a process in VHDL ? VHDL的流程是否可以连续运行两个或多个?

What will happen if another event happen (on sensitivity signal list) while the sequential execution of a process is not completed ? 如果未完成过程的顺序执行而又发生另一事件(在灵敏度信号列表上),将会发生什么?

Is it possible or my VHDL model in mind for process is completely wrong? 是否有可能或者我将VHDL模型记入过程中是完全错误的?

No event will ever occur while a process is running! 进程运行时不会发生任何事件!

When a process is woken by an event, it runs to completion ("end process") or an explicit "wait" statement, and goes to sleep. 当某个进程被事件唤醒时,它会运行到完成(“结束进程”)或显式的“ wait”语句,然后进入睡眠状态。 This takes, notionally, ZERO time. 从概念上讲,这需要零时间。 Which means that if you have loops in your process, they are effectively unrolled completely, and when you synthesise, you will generate enough hardware to run EVERY iteration in parallel. 这意味着,如果您的流程中存在循环,则循环将完全展开,并且在您进行综合时,您将生成足够的硬件来并行运行每个迭代。 Also, any procedures, functions etc, take zero time - unless they contained an explicit "wait" statement (in which case the process suspends at the "wait", as if the procedure had been inlined). 同样,任何过程,函数等都需要零时间-除非它们包含显式的“ wait”语句(在这种情况下,过程在“ wait”处挂起,就像过程已被内联一样)。

Throughout this process, all signals have the value they originally had when the process woke up, and any signal assignments are stored up, to happen later. 在整个过程中,所有信号都具有其在唤醒过程中所具有的原始值,并且所有信号分配都被存储起来,以备以后使用。 (Variables update immediately; later statements in the process see the new value). (变量将立即更新;过程中的后续语句将看到新值)。

When the process suspends (at "wait" or "end process"), nothing happens until ALL the other processes also suspend. 当进程挂起时(“等待”或“结束进程”),在所有其他进程也挂起之前,什么也不会发生。 (But remember they all take zero time!). (但请记住,它们都需要零时间!)。 If a process suspends at "end process" it will restart from the beginning when its sensitivity list wakes it up. 如果某个进程在“结束进程”中挂起,则当其敏感度列表将其唤醒时,它将从头开始重启。 If it suspends at an explicit "wait", that "wait" will specify an event or future time, which will restart it after the "Wait". 如果它在显式的“等待”中挂起,则该“等待”将指定一个事件或将来的时间,它将在“等待”之后重新启动它。 (NOTES: 1 : do not mix the sensitivity list and Wait styles in the same process! 2: Wait Until some event is synthesisable (though some tools may object) ; Wait for some time is simulation only) (注:1:不要在同一过程中混合使用灵敏度列表和等待样式!2:等待直到某些事件可综合(尽管某些工具可能会反对);等待一段时间仅是模拟)

THEN all the signal assignments are performed. 然后执行所有信号分配。 Since all processes are asleep, this eliminates all race conditions and timing hazards. 由于所有过程都处于睡眠状态,因此消除了所有比赛条件和计时危险。 Some of these assignments (like '1' to a clock) will cause events to be scheduled on processes sensitive to them. 其中一些分配(例如时钟为“ 1”)将导致事件在对它们敏感的进程上进行调度。

After all the signal assignments are done, the time steps forward one infinitely short tick (called a delta cycle), and then all the processes with scheduled events are woken. 完成所有信号分配后,时间将向前移动一个无限短的滴答声(称为增量周期),然后唤醒所有具有计划事件的进程。

This continues until a delta cycle occurs in which NO new events are scheduled, and finally the simulation can advance by a real time step. 这一直持续到发生增量周期(在该周期中未安排任何新事件),最后模拟可以实时进行。

Thus 从而

process(clk)
begin
if rising_edge(clk) then
   A <= B;
   B <= A;
end if;
end process;

is hazard-free in VHDL. 在VHDL中是无害的。

If you ever need to use Verilog, be aware that some of this happens differently there, and you cannot rely on the same level of predictability in simulation results. 如果您需要使用Verilog,请注意,其中某些情况会以不同的方式发生,并且您不能在模拟结果中依赖相同级别的可预测性。


In synthesis, of course, we generate hardware which will take some real time to execute this process. 当然,综合而言,我们生成的硬件将需要一些实时时间才能执行此过程。 However, the synthesis and back-end tools (place and route) guarantee to either obey this model faithfully, or fail and report why they failed. 但是,综合和后端工具(布局和布线)保证可以忠实地遵循此模型,或者失败并报告失败的原因。 For example, they will add up all the real delays and verify that the sum is less than your specified clock period. 例如,他们将累加所有实际延迟,并验证总和小于您指定的时钟周期。 (Unless you have set the clock speed too high!). (除非您将时钟速度设置得太高!)。

So the upshot is, as long as the tools report success (and you are setting the timing constraints like clock speed correctly) you can pretend the above "zero time" model is true, and the real hardware behaviour will match the simulation. 因此,结果是,只要工具报告成功(并且您正确设置了时钟速度等时序约束),您就可以假装上述“零时间”模型为真,并且实际的硬件行为将与仿真相匹配。 Guaranteed, barring tool bugs! 保证,禁止工具错误!

When starting out using VHDL (or any other HDL for that matter), it is hugely important to discard all notions of sequential code, and instead focus on the flow of data through the hardware. 当开始使用VHDL(或其他任何HDL)时,丢弃所有顺序代码的概念,而是专注于通过硬件的数据流,这一点非常重要。 In hardware, everything is inherently parallel (everything happens simultaneously), but uses constantly changing data (input signals) to calculate constantly changing results (output signals)! 在硬件中,所有事物本质上都是并行的(一切同时发生),但是使用不断变化的数据(输入信号)来计算不断变化的结果(输出信号)!

Without going into more advanced topics such as variables, wait commands etc., everything within a process happens simultaneously. 在不涉及变量,等待命令等更高级的主题的情况下,流程中的所有内容都会同时发生。 If conflicting things occur within the same process (multiple writes to the same signal), the last statement in the process wins, which is often where confusion about "sequential" code in VHDL comes from. 如果在同一进程中发生冲突(多次写入同一信号),则该进程中的最后一条语句将获胜,这通常是对VHDL中“顺序”代码产生混淆的地方。

This works due to the way that values are assigned to signals. 这是由于将值分配给信号的方式而起作用。 When assigning a value to a signal, the value of the signal does not immediately change! 为信号分配值时,信号的值不会立即改变! Instead, the assigned value is remembered and will be committed as the actual signal value later (in preparation for the next delta cycle, which is effectively the next quantum of time). 取而代之的是,将记住分配的值,并在以后将其提交为实际信号值(为下一个增量周期做准备,这实际上是下一个时间量)。

Since the next delta cycle will not begin until all processes from the previous delta cycle have completed, signal values will only change when no process is running. 由于下一个增量周期要等到上一个增量周期的所有进程完成后才能开始,因此信号值仅在没有进程在运行时才会更改。 Once all signals have changed, the next delta cycle begins and any process sensitive to one of the changed signals will be executed. 一旦所有信号都已更改,下一个增量周期就会开始,任何对更改后的信号之一敏感的过程都将执行。

If a process is sensitive to a signal it also writes, you have what is known as a combinatorial loop, eg, a gate where the output feeds an input. 如果某个过程对它也会写入的信号敏感,那么您将拥有所谓的组合循环,例如,输出将输出馈入输入的门。 This is (almost) always an error in your circuit, and will usually cause simulators to enter an infinite delta-cycle loop. 这(几乎)总是电路中的错误,并且通常会导致模拟器进入无限增量循环。

That's all I'll write for now, as Brian Drummond's answer just popped up as I was writing this, but feel free to leave a comment and I'll add some more details. 这就是我现在要写的全部内容,因为在撰写本文时,Brian Drummond的答案刚刚弹出,但是请随时发表评论,我将添加更多详细信息。

流程一旦开始运行(由于事件),它将在允许任何其他事件触发其他事件之前运行至完成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM