Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
21615 Discussions

VHDL DE2 board understanding Processes and Signals

Altera_Forum
Honored Contributor II
1,672 Views

So I wrote a program to turn on LEDS if SW, a switch, is '1' and off if '0'.  

 

entity StateLCD is port( SW : in std_logic_vector(0 downto 0); LEDG : out std_logic_vector(7 downto 0); LEDR : out std_logic_vector(7 downto 0)); end StateLCD; architecture StateLCD_Behaviour of StateLCD is SIGNAL LEDState: std_logic_vector(7 downto 0); begin process(SW) begin if(SW = "1") THEN LEDState <= "11111111"; else LEDState <= "00000000"; end if; LEDG <= LEDState; end process; end StateLCD_Behaviour;  

 

It works, but shouldn't it only work if I used variables instead of signals? With signals, It seems like the LEDS should be turning off when SW is '1' and turning on at '0' since signals only update at the end of a process. So I would be getting the opposite of the output I want? Where as variables would update immediately. Thanks for any help.
0 Kudos
8 Replies
Altera_Forum
Honored Contributor II
931 Views

Simple answer: Sensitivity lists are ignored in hardware synthesis. 

 

The bad with the present code is that a RTL simulation behaves different than the hardware.
0 Kudos
Altera_Forum
Honored Contributor II
931 Views

 

--- Quote Start ---  

So I wrote a program to turn on LEDS if SW, a switch, is '1' and off if '0'.  

 

entity StateLCD is port( SW : in std_logic_vector(0 downto 0); LEDG : out std_logic_vector(7 downto 0); LEDR : out std_logic_vector(7 downto 0)); end StateLCD; architecture StateLCD_Behaviour of StateLCD is SIGNAL LEDState: std_logic_vector(7 downto 0); begin process(SW) begin if(SW = "1") THEN LEDState <= "11111111"; else LEDState <= "00000000"; end if; LEDG <= LEDState; end process; end StateLCD_Behaviour; It works, but shouldn't it only work if I used variables instead of signals? With signals, It seems like the LEDS should be turning off when SW is '1' and turning on at '0' since signals only update at the end of a process. So I would be getting the opposite of the output I want? Where as variables would update immediately. Thanks for any help. 

--- Quote End ---  

 

 

 

Variable or signal will do since in both cases the assignment is fixed to same thing that depends only on switch state.
0 Kudos
Altera_Forum
Honored Contributor II
931 Views

your sensitivity list only takes care of "SW", which means your process is only executed when there is any change in SW. signals are updated at the end of process, with your code it means the LEDG is assigned with the existing(previous) value. 

 

anyway, if you want to tie signals to outputs, you don't need to put them inside process
0 Kudos
Altera_Forum
Honored Contributor II
931 Views

 

--- Quote Start ---  

your sensitivity list only takes care of "SW", which means your process is only executed when there is any change in SW. signals are updated at the end of process, with your code it means the LEDG is assigned with the existing(previous) value. 

--- Quote End ---  

As FvM explained, this statement is only true with a simulator. A synthesizer will ignore the sensitivity list, and the best way to simulate what the synthesizer actually does is this code:process(SW,LEDState) begin if(SW = "1") THEN LEDState <= "11111111"; else LEDState <= "00000000"; end if; LEDG <= LEDState; end process;I've changed the sensitivity list to contain all the signals that are read by the process. If you simulate this, when you change the switch state the process will be executed a first time, update LEDState, then run a second time and update LEDG. Then you get the same behaviour between the simulation and the synthesized code.
0 Kudos
Altera_Forum
Honored Contributor II
931 Views

Ok. i think i might have misunderstood some things. thanks for clearing things up.

0 Kudos
Altera_Forum
Honored Contributor II
931 Views

 

--- Quote Start ---  

As FvM explained, this statement is only true with a simulator. A synthesizer will ignore the sensitivity list, and the best way to simulate what the synthesizer actually does is this code 

--- Quote End ---  

 

 

 

Why does the synthesizer ignore the sensitivity list though? I don't quite get FvM explanation. Isn't what I'm doing hardware synthesis?
0 Kudos
Altera_Forum
Honored Contributor II
931 Views

 

--- Quote Start ---  

Why does the synthesizer ignore the sensitivity list though? I don't quite get FvM explanation. Isn't what I'm doing hardware synthesis? 

--- Quote End ---  

 

It didn't actually explain this point, just stated a fact. 

 

Sensitivity lists in asynchronous processes are primarly intended to optimize the operation of a simulator that interprets the HDL code. As a side effect, they work as a kind of software edge detection. Apparently this gives room for a misunderstanding that sensitivity lists can be used for this purpose in hardware design.  

 

But the hardware way of evaluating asynchronous HDL code is basically different. The synthesis tools translates it to combinational gate circuits that don't care for state changes, just propagate the combined input data as they are, either if they change every clock cycle or stay for hours. 

 

In other words, to answer your question, you should consider how HDL code is mapped to hardware elements.
0 Kudos
Altera_Forum
Honored Contributor II
931 Views

Sensitivity lists are ignored in hardware synthesis.

0 Kudos
Reply