题解 | #优先编码器电路①#
优先编码器电路①
https://www.nowcoder.com/practice/0594ed5303ad48a19aed90bc48839d00
`timescale 1ns/1ns module encoder_0( input [8:0] I_n , output wire [3:0] Y_n ); assign Y_n = (I_n[8] == 0) ? 4'd6 : (I_n[8:7] == 2'b10) ? 4'd7 : (I_n[8:6] == 3'b110) ? 4'd8 : (I_n[8:5] == 4'b1110) ? 4'd9 : (I_n[8:4] == 5'b11110) ? 4'd10 : (I_n[8:3] == 6'b111110) ? 4'd11 : (I_n[8:2] == 7'b1111110) ? 4'd12 : (I_n[8:1] == 8'b11111110) ? 4'd13 : (I_n[8:0] == 9'b111111110) ? 4'd14 : 4'd15; endmodule