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.

[SOLVED] mux problem-unexpected undifined state

Status
Not open for further replies.

madalin1990

Full Member level 2
Joined
Apr 4, 2012
Messages
124
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,298
Activity points
2,090
I have a problem with this simple 3 to 1 mux:
Code:
module MUX3TO1(IN0,IN1,IN2,SEL,OUT);
  input [23:0] IN0,IN1,IN2;
  input [1:0] SEL;
  output reg [23:0] OUT;  
  
  always @(SEL or IN0 or IN1 or IN2)
       case( SEL )
 00:OUT <= IN0;
 01:OUT <= IN1;
 10:OUT <= IN2;
 default: OUT<=24'bx;
     endcase
     
 endmodule

I wrote a simple testbench:
Code:
module TB_MUX3_TO_1();
  
  reg [23:0] IN0,IN1,IN2;
  reg [1:0] SEL;
  wire [23:0] OUT;
  
  initial begin
    $display ("time\t IN0 IN1 IN2 SEL OUT ") ;
     $monitor ("%g\t   %b   %b   %b    %b      %b  ",
                $time,IN0,IN1,IN2,SEL,OUT);
IN0 = 24'b000000000000000000000011; //3               
IN1 = 24'b000000000000000000000101; //5
IN2 = 24'b000000000000000000000111; //7               
SEL = 2'b00; 
#5 IN2 = 24'b000000000000000000000101; //5 
#2 SEL = 2'b01; 
#5 IN0 = 24'b000000000000000000000100; //4
#4 IN1 = 24'b000000000000000000000110;//6
#2 SEL = 2'b10;
#4 IN1 = 24'b000000000000000000000111;//7
#10 SEL = 2'b00;
end


MUX3TO1 U_MUX3TO1  (
IN0,
IN1,
IN2,
SEL,
OUT);

 endmodule

It is working fine except when sel=10,because instead of directing in2 to out,it enters the undefined state.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top