You are on page 1of 1

PRIORITY ENCODER

module prienc(e0,e1,valid,d0,d1,d2,d3);
input d0,d1,d2,d3;
output e0,e1,valid;
wire y1,y2;
not g1(y1,d2);
and g2(y2,y1,d1);
or g3(e1,d3,y2);
or g4(e0,d3,d2);
or g5(valid,e0,d1,d0);
endmodule

#10 d0=1'b1;d1=1'b0;d2=1'b0;d3=1'b0;
#10 d0=1'bx;d1=1'b1;d2=1'b0;d3=1'b0;
#10 d0=1'bx;d1=1'bx;d2=1'b1;d3=1'b0;
#10 d0=1'bx;d1=1'bx;d2=1'bx;d3=1'b1;
initial
$monitor($time,"d0=%b,d1=%b,d2=%b,d3=%b,e0=%b,e1=%b,valid=%b\n",d0,d1,d2,d3,e0,e1,val
id);
initial #60 $stop;

You might also like