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.

different ways to implement mux

Status
Not open for further replies.

mr_vasanth

Member level 5
Member level 5
Joined
Mar 12, 2007
Messages
86
Helped
5
Reputation
10
Reaction score
7
Trophy points
1,288
Location
Bangalore, India, India
Visit site
Activity points
1,906
Method1:
Code:
assign y = sel ? a : b;

Method2:
Code:
case sel
1'b0: y = b;
1'b1: y = a;
endcase

Method3:
Code:
if (sel)
y = a;
else
y = b;


What is the difference between the implementation of mux using these three different methods ?
How do these methods treat 'x' and 'z' on sel input ?

After synthesis, will all these three methods produce same netlist ?
 

Hi,

Using conditional operator, there will be an issue with select lines if they are x or z.
But when you use if else for implementing the mux, then x in select line then it will execute else condition.

For beter understanding, just implement the design and run the simulation once. Always a case block should have default statement in it.

Thanks,
Vivek.S
 

Found the difference between if-else and ternary/conditional operator based mux implementation.

1. if-else
during simulation, if the sel line is 'x' then the output y will be b.

2. ternary/conditional operator
during simulation, if the sel line is 'x' then the output y will be 'x'.

Coding Guideline: Never use “if-else” statement in combinatorial logic. Instead, use ternary/conditional “?” operator.

can someone explain how the case statement based mux will behave if the sel is 'x' ?
 

Found the difference between if-else and ternary/conditional operator based mux implementation.

1. if-else
during simulation, if the sel line is 'x' then the output y will be b.

2. ternary/conditional operator
during simulation, if the sel line is 'x' then the output y will be 'x'.

Coding Guideline: Never use “if-else” statement in combinatorial logic. Instead, use ternary/conditional “?” operator.

can someone explain how the case statement based mux will behave if the sel is 'x' ?

The case statement will output your default value. That is why you need a default.

If sel = x, a=1 and b=1 then the ternary will deliver an x even though hardware will deliver a 1. That is not good. You should also distinguish between glitching and glitchless muxes.


John Eaton
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top