エンコーダとデコーダ
以下の真理値表を実現する。
A3 | A2 | A1 | A0 | F1 | F2 |
0 | 0 | 0 | 1 | 0 | 0 |
0 | 0 | 1 | 0 | 0 | 1 |
0 | 1 | 0 | 0 | 1 | 0 |
1 | 0 | 0 | 0 | 1 | 1 |
10進数の3~0に対応
(2)10→(10)2
HDL
module rei3_7(A,F);
input [3:0] A;
output [1:0] F;
function [1:0] ENC;
input [3:0] A;
begin
case(A)
4'b0001:ENC = 2'b00;
4'b0010:ENC = 2'b01;
4'b0100:ENC = 2'b10;
4'b1000:ENC = 2'b11;
default:ENC = 2'b11;
end
endfunction
assign F = ENC(A);
endmodule