Interested In VHDL Training? Click Here

0 votes
in VHDL by (200 points)

In VHDL, what is with select, and what is the proper syntax?

3 Answers

0 votes
by (1.8k points)

VHDL With Select

Quick Syntax

with mux_sel select output <=
input1 when '0',
input2 when '1',
(others => '0') when others;

Purpose

The most common use for the with select statement is to a create a multiplexer, or MUX. The with is in reference to a select signal, which then determines the selection of the output signal, as the input options are then laid out given specific selects.

I usually never come across a with select statement. Frankly, the when else statement is so much easier to code, read, and maintain that it's used 99.9% of the time over with select.

Perhaps there is an advantage of with select, but I have never been able to come up with any. My recommendation is to use when else instead.

Best Practices

1. With select statements are great for creating a MUX.

2. Make sure that all of the select signal possibilities are covered. It's a good idea to also cover a when others as a catch all just in case.

3. When else is a better option since it's much easier to read for everyone.
0 votes
by (500 points)

Example :

signal selector : std_logic_vector ( 1 downto 0 ) ;
signal output : std_logic_vector( 3 downto 0 ) ;

with selector select
output <=
"0001" when "00" ,
"0010" when "01" ,
"0100" when "10" ,
"1000" when "11" ;
0 votes
by (500 points)

This is a concurrent conditional signal assignment statement. While the concurrent assignment "when-else" is a kind of if-else the assignment "with-select" is like a case statement. I think it has better readability when a choice is more than a few inputs.

with state select result <=
in0 when state_0,
in1 when state_1,
in2 when state_2,
in3 when others;

Want to improve your VHDL skills?

Click Here - Sign Up For VHDL Training

© 2022 by Hardware Coder. User contributions are licensed under cc by-sa 4.0 with attribution required. Attribution means a link to the question, answer, user, etc on this site.

This site is owned and operated by Hardware Coder in McKinney, Texas.

Send Us A Message
About Us

By using this site, you agree to the following:

Privacy Policy
Terms and Conditions
DMCA Policy
Earnings Disclaimer
Legal Disclaimer

...