Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

What do 'If-Else' statements synthesize to?

Status
Not open for further replies.

GeekWizard

Full Member level 1
Full Member level 1
Joined
Oct 24, 2004
Messages
98
Helped
5
Reputation
10
Reaction score
2
Trophy points
1,288
Location
United Kingdom
Activity points
853
I know that the switch case statements synthesize to Multiplexers.

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

Thank you.
 

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,
 

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.............
 

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.
 

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
 

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

Gunship
 

    GeekWizard

    Points: 2
    Helpful Answer Positive Rating
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
    Helpful Answer Positive Rating
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.
 

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!! :)
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top