forked from TimRudy/ice-chips-verilog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path74147.v
32 lines (27 loc) · 895 Bytes
/
74147.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// 10-line to 4-line priority encoder
module ttl_74147 #(parameter WIDTH_IN = 9, WIDTH_OUT = 4, DELAY_RISE = 0, DELAY_FALL = 0)
(
input [WIDTH_IN-1:0] A_bar,
output [WIDTH_OUT-1:0] Y_bar
);
//------------------------------------------------//
reg [WIDTH_OUT-1:0] computed;
always @(*)
begin
casez (A_bar)
9'b0????????: computed = 4'b1001; // highest priority (inverted)
9'b10???????: computed = 4'b1000;
9'b110??????: computed = 4'b0111;
9'b1110?????: computed = 4'b0110;
9'b11110????: computed = 4'b0101;
9'b111110???: computed = 4'b0100;
9'b1111110??: computed = 4'b0011;
9'b11111110?: computed = 4'b0010;
9'b111111110: computed = 4'b0001;
9'b111111111: computed = 4'b0000;
default: computed = 4'b0000;
endcase
end
//------------------------------------------------//
assign #(DELAY_RISE, DELAY_FALL) Y_bar = ~computed;
endmodule