Priorityencoder Typ1

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

module priorityEncoder(d0,d1,d2,d3,y1,y0,v);

input d0,d1,d2,d3;
output y1,y0,v;

or(v,d0,d1,d2,d3);
/*
y1 = d0'.d1';
y0 = d0' . (d1 + d2')
*/
wire d0n,d1n,d2n;
wire w;
not(d0n, d0);
not(d1n, d1);
not(d2n,d2);

and(y1,d0n,d1n);
or(w,d1,d2n);
and(y0,d0n,w);

endmodule

module stimulus;
reg d0,d1,d2,d3;
wire y1,y0,v;
priorityEncoder pe (d0,d1,d2,d3,y1,y0,v);

initial
begin
#0 d0=1;d1=1'bx;
#10 d0=0;d1=1;d2=1'bx;
#10 d0=0;d1=0;d2=1;d3=1'bx;
#10 d0=0;d1=0;d2=0;d3=1;

end
initial
begin
$display("d0\td1\td2\td3\t\ty1\ty0\tv");
$monitor("%d\t%d\t%d\t%d\t\t%d\t%d\t%d",d0,d1,d2,d3,y1,y0,v);
end

endmodule

You might also like