3對8解碼器
增值表:
d2
|
d1
|
d0
|
y7
|
y6
|
y5
|
y4
|
y3
|
y2
|
y1
|
y0
|
0
|
0
|
0
|
1
|
1
|
1
|
1
|
1
|
1
|
1
|
0
|
0
|
0
|
1
|
1
|
1
|
1
|
1
|
1
|
1
|
0
|
1
|
0
|
1
|
0
|
1
|
1
|
1
|
1
|
1
|
0
|
1
|
1
|
0
|
1
|
1
|
1
|
1
|
1
|
1
|
0
|
1
|
1
|
1
|
1
|
0
|
0
|
1
|
1
|
1
|
0
|
1
|
1
|
1
|
1
|
1
|
0
|
1
|
1
|
1
|
0
|
1
|
1
|
1
|
1
|
1
|
1
|
1
|
0
|
1
|
0
|
1
|
1
|
1
|
1
|
1
|
1
|
1
|
1
|
1
|
0
|
1
|
1
|
1
|
1
|
1
|
1
|
1
|
(y0')'=y0=(d0'&d1'&d2')'
以此類推
行為描述:
y0在d0d1d2皆為0時為0 => assign y[0]=(!({d2,d1,d0}==3'd0));d為十進制
---------------------------------------------------------------
module deco3_8(d2,d1,d0,y);
input d2,d1,d0;
output [7:0] y;
assign y[0]=(({d2,d1,d0}==3'd0));
assign y[1]=(({d2,d1,d0}==3'd1));
assign y[2]=(({d2,d1,d0}==3'd2));
assign y[3]=(({d2,d1,d0}==3'd3));
assign y[4]=(({d2,d1,d0}==3'd4));
assign y[5]=(({d2,d1,d0}==3'd5));
assign y[6]=(({d2,d1,d0}==3'd6));
assign y[7]=(({d2,d1,d0}==3'd7));
endmodule
---------------------------------------------------------------
`timescale 1ns/100ps
`include"example.v"
module testdeco;
reg d2,d1,d0;
wire y;
deco3_8 U1(d2,d1,d0,y);
integer i;
initial
begin
for(i=0;i<=7;i=i+1)
begin
{d2,d1,d0}=i;
#10;
end
end
initial
begin
$dumpfile("test.vcd");
$dumpvars;
end
endmodule
沒有留言:
張貼留言
文章有誤或有問題麻煩您留言告知! 謝謝您~~