Tuesday, August 20, 2013

Signal and Conditional Assignment Statements


Allows signals to be set to more than one value based on a condition. Both are concurrent assignment statements.

Select Signal Assignment :

Example 1. MUX2to1 ( 2 inputs (w1,w2),1 select line (s) and 1 output (f) ) and all ports are of std_logic type.
 WITH s SELECT  
 f <=     w1 WHEN '0',  
          w2 WHEN others;  

Example 2. MUX4is1 ( 4 input (w1,w2,w3,w4) , 2 select line (s) and 1 output (f) )
 WITH s SELECT  
 f <=     w1 WHEN "00",  
          w2 WHEN "01",  
          w3 WHEN "10",  
          w4 WHEN others;  

Conditional Signal Assignment

Example 1. MUX2to1 ( 2 inputs (w1,w2),1 select line (s) and 1 output (f) ) and all ports are of std_logic  type.
 f <=   w1 WHEN s='0' ELSE w2;  

Example 2. MUX4is1 ( 4 input (w1,w2,w3,w4) , 2 select line (s) ,and 1 output (f) )
 f <=     w1 WHEN s="00" ELSE  
          w2 WHEN s="01" ELSE  
          w3 WHEN s="10" ELSE  
          w4;  

Example 3. Comparator ( A,B are inputs and F_EQ, F_LT, F_GT, READY are outputs )
 F_EQ   <= '1' WHEN A=B ELSE '0';  
 F_LT   <= '1' WHEN A<B ELSE '0';   
 F_GT   <= '1' WHEN A>B ELSE '0';   
 READY  <= '1' WHEN (F_EQ='1' or F_LT='1' or F_GT='1') ELSE '0';  

No comments:

Post a Comment