Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This piece of code should illustrate the difference b/w signals and variables. I inserted the processes directly into the testbench, so the code can be directly simulated with a HDL simulator of your choice.<br> After 10 ns the <code>start</code> event is fired and both processes are evaluated.<br> You should then see the expected result, namely <code>sig_out</code>going high after another 20 ns, whereas <code>var_out</code> should be high after only 10 ns.</p> <pre><code>library ieee; use ieee.std_logic_1164.all; entity sigvartest is end entity sigvartest; architecture behav of sigvartest is signal start : std_logic := '0'; -- event to start simulation signal x_sig : std_logic := '0'; -- signal tested in SIGPROCESS signal sig_out : std_logic := '0'; -- output of SIGPROCESS signal var_out : std_logic := '0'; -- output of VARPROCESS begin start &lt;= '0', '1' after 10 ns; -- pretty self-explanatory, start goes high after 10 ns SIGPROCESS: process(start) is begin if(rising_edge(start)) then x_sig &lt;= '1'; -- signal is scheduled to be assigned its new value, no immediate change! if(x_sig = '1') then sig_out &lt;= '1' after 10 ns; else sig_out &lt;= '1' after 20 ns; -- this part will execute end if; end if; end process; VARPROCESS: process(start) is variable x_var : std_logic := '0'; begin if(rising_edge(start)) then x_var := '1'; -- variable is assigned immediately if(x_var = '1') then var_out &lt;= '1' after 10 ns; -- this part will execute else var_out &lt;= '1' after 20 ns; end if; end if; end process; end architecture; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload