题解 | 优先编码器Ⅰ
优先编码器Ⅰ
https://www.nowcoder.com/practice/a7068b8f4c824d6a9592f691990b21de
`timescale 1ns/1ns
module encoder_83(
input [7:0] I ,
input EI ,
output reg [2:0] Y ,
output reg GS ,
output reg EO
);
always @(*)begin
casex({EI,I})
9'b0_xxxx_xxxx : {Y,GS,EO} = 5'b000_0_0;
9'b1_0000_0000 : {Y,GS,EO} = 5'b000_0_1;
9'b1_1xxx_xxxx : {Y,GS,EO} = 5'b111_1_0;
9'b1_01xx_xxxx : {Y,GS,EO} = 5'b110_1_0;
9'b1_001x_xxxx : {Y,GS,EO} = 5'b101_1_0;
9'b1_0001_xxxx : {Y,GS,EO} = 5'b100_1_0;
9'b1_0000_1xxx : {Y,GS,EO} = 5'b011_1_0;
9'b1_0000_01xx : {Y,GS,EO} = 5'b010_1_0;
9'b1_0000_001x : {Y,GS,EO} = 5'b001_1_0;
9'b1_0000_0001 : {Y,GS,EO} = 5'b000_1_0;
endcase
end
endmodule
