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.

code for 4:1 mux in verilog?tell the difference

Status
Not open for further replies.

abhineet22

Advanced Member level 4
Joined
Jan 25, 2005
Messages
105
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,296
Location
bangalore
Activity points
1,017
verilog 4:1 mux

. Design a 4:1 mux in Verilog.

Multiple styles of coding. e.g.
Using if-else statements
if(sel_1 == 0 && sel_0 == 0) output = I0;
else if(sel_1 == 0 && sel_0 == 1) output = I1;
else if(sel_1 == 1 && sel_0 == 0) output = I2;
else if(sel_1 == 1 && sel_0 == 1) output = I3;

Using case statement

case ({sel_1, sel_0})
00 : output = I0;
01 : output = I1;
10 : output = I2;
11 : output = I3;
default : output = I0;
endcase

1What are the advantages / disadvantages of each coding style shown above?
2How Synthesis tool will give result for above codes?
3What happens if default statement is removed in case statement?
4What happens if combination 11 and default statement is removed?
 

verilog mux

1. one (if) has priority the other(case) has no
2. case have full/parallel concept
3. no impact to remove the default since the case is full case
4. possible mismatch in gatelevel and rtl simulation.
 

priority mux verilog

Hi, kxchorus,

During simulation phase, remove the default statement may cause the unknow to spread.

Good Luck
 

4:1 mux verilog

u can read synopsys sold documents about DC.
 

design a 4:1 mux in verilog

using assign is better, it will not cause sim/synt mismatch.
 

case verilog

If-else logic and case logic has different timing delay. Every possible condition should be outlined in combination logic block no matter if-else logic or case logic, Or else ,latch will be introduced.
 

4:1 verilog mux

hi,

if else can give you the priority type mux hardware while case statement will give you single mux.

with regards,
kul.
 

verilog if else simulate mux

Multiple styles of coding. e.g.
Using if-else statements
if(sel_1 == 0 && sel_0 == 0) output = I0;
else if(sel_1 == 0 && sel_0 == 1) output = I1;
else if(sel_1 == 1 && sel_0 == 0) output = I2;
else if(sel_1 == 1 && sel_0 == 1) output = I3;

Using case statement

case ({sel_1, sel_0})
00 : output = I0;
01 : output = I1;
10 : output = I2;
11 : output = I3;
default : output = I0;
endcase

1What are the advantages / disadvantages of each coding style shown above?
2How Synthesis tool will give result for above codes?
3What happens if default statement is removed in case statement?
4What happens if combination 11 and default statement is removed?


Here there is no difference between the two codes, the output is the same, as well the priority is not taken into consideration in the above logic, prioritycomes under different conditions, when the above control signals are different, what i mean to say is when one statement is used for different select signal and the other used for different select signal then priority comes under picture.

Here as u r mentioning all the the possibilities of the two signals that is 00, 01, 10, 11 then there is no difference, there is difference when u r using a full case and a parallel case

hope it is understandable

regards
 

4-1 mux and verilog

after DC synthesis, same result will be generated.

abhineet22 said:
. Design a 4:1 mux in Verilog.

Multiple styles of coding. e.g.
Using if-else statements
if(sel_1 == 0 && sel_0 == 0) output = I0;
else if(sel_1 == 0 && sel_0 == 1) output = I1;
else if(sel_1 == 1 && sel_0 == 0) output = I2;
else if(sel_1 == 1 && sel_0 == 1) output = I3;

Using case statement

case ({sel_1, sel_0})
00 : output = I0;
01 : output = I1;
10 : output = I2;
11 : output = I3;
default : output = I0;
endcase

1What are the advantages / disadvantages of each coding style shown above?
2How Synthesis tool will give result for above codes?
3What happens if default statement is removed in case statement?
4What happens if combination 11 and default statement is removed?
 

module MUX_4_1(
input [3:0]i,
input [1:0]s,
output o
);
assign o= (s[0]==0)?((s[1]==0)?i[0]:i[1]):((s[1]==0)?i[2]:i[3]);

endmodule
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top