Continue to Site

# What do 'If-Else' statements synthesize to?

Status
Not open for further replies.

#### GeekWizard

##### Full Member level 1
I know that the switch case statements synthesize to Multiplexers.

What do 'If-Else' or 'If-ElseIf' statements synthesize to?

Thank you.

#### Iouri

it is really depends what you are trying to impliment. also keep in mind when you are implimeting state mashine you are using case statement, but it is not implimentig as MUX. You can use Simplfy to see RTL model of your design

Regards,

#### neo_chip

##### Member level 1
when you code for a combinational circuits........... if-else statments mostly synthesize to mux

But Iouri siad it really depends on what you are trying to implement.............

#### GeekWizard

##### Full Member level 1
I am trying to comprehend a VHDL code.

I believe it is a sequential circuit as the code consists of nested if-else statements in a 'process' as follows:-

//
process (list-of-parameters)
begin

if (condition) then
statements

elseif (condition) then
if (condition) then
statements
else (condition) then
statements

elseif (condition) then
.
.
.

and so on......

end if;
end process;
//

What would the synthesized structure look like?

Pardon my ignorance but I'm new to this.

Thnak you.

#### Iouri

I am not sure why do you need this. Because, ferstiveal inside FPGA it will come down LUT, ALUT, LE depends what famaly/vendor you are using
Second, all vendor have coding style guideline, where you picking up statement according to the logical function you are trying to impliment
Thirdly syntezis tools like Simplify or Leonardo offers you ability to see how you code implimets.
For example if take regular MUX we can use to discribe:
1. IF then, elsif statements
2. Selective signal assigment out <= in1 when else in2 when ....
3. Case statement
As you can see I pointed there are ways of implimeting MUX (might be more I not an expert), but bottom line is it will take exact the same amount of recourses and will do exact the same function. But coding style is totally different

Good luck!!! Regards,

Iouri

#### Gunship

##### Member level 2
In VHDL, if-then-else produces a piority encoder. The case statement
produces a simple mux.

Gunship

### GeekWizard

Points: 2

#### sarath51

##### Full Member level 2
a priority encoder

#### tkbits

##### Full Member level 5
if-elseif with a clock event synthesizes to a register, or circuits with register components. (For example, shift registers and counters.)

if-elseif without a clock event and missing assignments for some cases - synthesizes to a latch.

if-elseif without a clock event and an assignment for every case - reduces to Boolean logic.

The following code (where f is defined in every case)
Code:
if a = '1'  then
f <= w;
elseif b = '1' then
f <= x;
elseif c = '1' then
f <= y;
else
f <= z;
end if;
reduces to
Code:
  f <= (a and w) or
((not a) and b and x) or
((not a) and (not b) and c and y) or
((not a) and (not b) and (not c) and z);

### GeekWizard

Points: 2

#### pahol

##### Junior Member level 2
It is up to your code.
Most of combination circuit should be priority multiplexer.
But for DFF, maybe enable of DFF or reset or etc.

#### snake_eyes

##### Member level 3
Theoratically all the above discussions are correct. But as I said "theoratically"...
If you are using a decent sysnthesis tool, it will optimise the logic in a very good way. So you may see some part of the logic implemented as mux and some may be as preority encoder.
The tool basically goes through the nested if tatements and generatlly tries to put the circuit to optimise timing. In this process, it uses all the combinations of MUX and encoder or even simple gates to ensure that the logic has minimum delay.
hence if you see the end design spitted out of synthesis tool; be ready for a shock!!

#### jetset

##### Full Member level 3

Status
Not open for further replies.