I am confused about when a signal declared in an architecture must be inserted into the sensitivity list of a process.
Is there is a general law that can be followed in any situation?
I have real difficulties understanding when I have to include a signal in a process sensitivity list.
If a signal is in the sensitivity list of a process, the process will "wake up" and be evaluated whenever the value of that signal changes. If it is not in the sensitivity list, a signal can change, but a process will not be re-evaluated to determine what the new outputs should be.
The sensitivity list is where you list all the signals that you want to cause the code in the process to be evaluated whenever it changes state. For example, clock or master reset is often used in a sensitivity list. Whenever the reset or clock changes state, the code inside the process is executed.
In hardware description languages (HDL), sensitivity lists are used to indicate which events may trigger a VHDL process or (System)Verilog always statement. These trigger events are usually transitions of signals that are inputs of the process or always statement.
A process with a sensitivity list is a handy special case. First, only a process without wait statements can have a sensitivity list. Second, such a process is equivalent to a process without sensitivity list and with an additional wait statement as the last statement.
The "general law" is that
anything that your process needs to know about changes of needs to be in the sensitivity list.
For a typical synthesisable register with a synchronous reset:
process (clk) is begin if rising_edge(clk) then if reset = '1' then -- do reset things else -- read some signals, assign some outputs end if; end if; end process;
Only the clock needs to be in the list, as everything else is only looked at when the clock changes (due to the if rising_edge(clk)
statement.
If you need an asynchronous reset:
process (clk, reset) is begin if reset = '1' then -- do reset things elsif rising_edge(clk) then -- read some signals, assign some outputs end if; end process;
then the reset
signal must also be in the sensitivity list, as your design needs to check the value of it every time it changes, irrespective of what the clock is doing.
For combinatorial logic, I avoid using processes completely because of the problems keeping the sensitivity list up-to-date, and the potential for simulation then behaving differently to the synthesised code. This has been eased by the all
keyword in VHDL-2008, but I still haven't found myself wanting to write long complicated combinatorial logic such that a process would help.
If a signal is in the sensitivity list of a process, the process will "wake up" and be evaluated whenever the value of that signal changes. If it is not in the sensitivity list, a signal can change, but a process will not be re-evaluated to determine what the new outputs should be.
For Combinatorial Logic: Likely you want all your input signals to be included in the sensitivity list. If they are not included in the sensitivity list, then that will result in your output not changing even when that input signal changes. This is a common error (due to carelessness). Note that in VHDL 2008 you can use "all" keyword to automatically include all necessary signals in your process and avoid creating latches.
For Synchronous Logic: Likely you only want your clock (and maybe your reset) signal in the sensitivity list. This is because you are only concerned with the value of your signals (other than the clock) when your system clock has changed. This is because you are typically describing registers (composed of flip flops) which only allow changing their output value on a clock edge.
All of this can be confusing in the case of using HDL for synthesis because only a subset of the circuits you describe in VHDL can actually be implemented within a FPGA. For example, you can't have a primitive memory element that is sensitive to two independent clock edges, even though you could describe such a circuit by including two clocks in a sensitivity list.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With