以下代码均已通过Xilinx2014测试
1.8_3优先编码器
module PEn83(Y,I);
output [2:0]Y;
input [7:0]I;
or or1(Y[2],I[4],I[5],I[6],I[7]);
not not1(FI4,I[4]);
not not2(FI5,I[5]);
and and1(Tmp1,I[2],FI4,FI5);
and and2(Tmp2,I[3],FI4,FI5);
or or2(Y[1],Tmp1,Tmp2,I[6],I[7]);
and Pand1(P1,I[1],FI2,FI4,FI6);
and Pand2(P2,I[3],FI4,FI6);
and Pand3(P3,I[5],FI6);
or or3(Y[0],P1,P2,P3,I[7]);
endmodule
(2)仿真
module PEn83test;
wire [2:0]OutY;
wire [7:0]InI;
reg A,B,C,D,E,F,G,H;
assign InI={
A,B,C,D,E,F,G,H};
PEn83 MyPEn83(.Y(OutY),.I(InI));
initial
begin
A=0;B=0;C=0;D=0;E=0;F=0;G=0;H=1;#100;
A=0;B=0;C=0;D=0;E=0