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

Iouri

Advanced Member level 2
Joined
Aug 17, 2005
Messages
678
Helped
87
Reputation
174
Reaction score
8
Trophy points
1,298
Activity points
4,814
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
Joined
Jul 14, 2006
Messages
34
Helped
3
Reputation
6
Reaction score
0
Trophy points
1,286
Location
INDIA
Activity points
1,450
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
Joined
Oct 24, 2004
Messages
98
Helped
5
Reputation
10
Reaction score
2
Trophy points
1,288
Location
United Kingdom
Activity points
853
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

Advanced Member level 2
Joined
Aug 17, 2005
Messages
678
Helped
87
Reputation
174
Reaction score
8
Trophy points
1,298
Activity points
4,814
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
Joined
Dec 31, 2001
Messages
51
Helped
4
Reputation
8
Reaction score
1
Trophy points
1,288
Activity points
520
In VHDL, if-then-else produces a piority encoder. The case statement
produces a simple mux.

Gunship
 

    GeekWizard

    Points: 2
    Helpful Answer Positive Rating

tkbits

Full Member level 5
Joined
Dec 4, 2004
Messages
242
Helped
39
Reputation
78
Reaction score
2
Trophy points
1,298
Activity points
2,209
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

pahol

Junior Member level 2
Joined
Jun 20, 2003
Messages
20
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,281
Activity points
133
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
Joined
May 16, 2002
Messages
56
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,286
Activity points
307
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

Top