Saturday 5 December 2015

fpga - VHDL - How does a process run concurrent with other processes and components while it executes sequentially?


Just as the title says, how does this occur? I'm trying to wrap my head around processes vs components and I don't understand how this mechanism works. This may not be a proper question so please help me formulate it to be more specific, but I just really need to understand this concept to keep moving forward in my design.


For example:


count: process (x)

variable cnt : integer := -1;
begin
cnt:=cnt+1;

if (cnt > '9') then
cnt:=0;
OVERFLOW <= '1';
endif;
end process;


I understand that the if statement is dependent on the previous increment statement. I also understand why order is important (logically it makes sense - I check condition after updating), but what doesn't make sense to me is without any kind of clocking or other sequential mechanism, how does OVERFLOW (which is a signal in this example, not shown) get it's value updated concurrently with all the other signals in the design when it depends on cnt being updated first? Furthermore, any other signals which have implied processes associated with OVERFLOW are assigned concurrently, making them dependent on cnt by proxy as well.



Answer



Signals are always evaluated in a concurrent way. Variables are really just a convenience for making calculations or used as helpers in loops or generates. In general, they contain combinatorial evaluations or are used as iterators. In that sense they produce synthesis, but the sequentiality in their assignment is not synthesized per se, they will never make a signal change more than once in a single pass of a process (signals retain the last value assigned to them in a process).


This phrase that I use "single pass of a process" sounds very academic, and does not properly convey its relationship with hardware (hardware in this context being basically logic gates and flip flops). The process is evaluated when any signal in its sensitivity list changes. What this means in hardware is that the inputs to a combinatorial block changed, therefore it may be possible that the output or outputs of this block change as well. A signal may be assigned multiple times in a process, but this is only a way to code priority in evaluations (in describing how the combinatorial block works), not actual changes in the outputs in sequential manner. That is why it is said that the signals retain the last assignment in a process.


The best way to understand all this is to see how digital blocks that you can see in a schematic are coded in vhdl (or the language of your preference). When you get the hang of it, and start using variables as 'helpers', you'll see why they are what they are, why they are not the same as signals, and why the sequentiality in their assignment inside processes is not synthesized as such.


No comments:

Post a Comment

arduino - Can I use TI&#39;s cc2541 BLE as micro controller to perform operations/ processing instead of ATmega328P AU to save cost?

I am using arduino pro mini (which contains Atmega328p AU ) along with cc2541(HM-10) to process and transfer data over BLE to smartphone. I...