FPGA Center



WITH

"With" expression is used to chose concurrent conditional statements.

  with selection_expression select
           value <= statement when choice ,
                           statement  when choice,
                           statement  when others;

Unlike "with" statment, concurrent operations can be done with "case" statement. All options with choices are processed at the same time.

EXAMPLE (4 to 2 Encoder):

A "4 to 2 Encoder" is designed in this example.

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;

entity encoder is
     Port (  D_in    : in  STD_LOGIC_VECTOR (3 downto 0);
                 D_out : out  STD_LOGIC_VECTOR (1 downto 0));
end encoder;

architecture Behavioral of encoder is
begin
    with
  D_in select
              D_out <= "00" when "0001",
                                "01" when "0010",
                                "10" when "0100",
                                "11" when "1000",
                                "ZZ" when others;
end Behavioral;

After simulation on ModelSim, we get the plot below:

1

 

 

                                                                                                           

    

                                                                                                                                    

 

                                                                                                                                                                                                                                                                   

Home | Fpga | VHDL | VHDL Dictionary | Digital Design | Simulation | PCB | Examples | Contact Us
Copyright © 2010 - 2013 FPGAcenter. All Rights Reserved.