`timescale 1 ns/1 ns
module EX_108 (a, f);
input [2:0] a;
output [3:0] f;
wire [3:0] f;
assign f[3] = (~a[2] & ~a[1] & ~a[0]) |
(~a[2] & ~a[1] & a[0]) |
( a[2] & a[1] & a[0]);
assign f[2] = (~a[2] & a[1] & ~a[0]) |
( a[2] & ~a[1] & ~a[0]) |
( a[2] & a[1] & a[0]);
assign f[1] = (~a[2] & ~a[1] & a[0]) |
(~a[2] & a[1] & ~a[0]) |
( a[2] & a[1] & a[0]);
assign f[0] = (~a[2] & ~a[1] & ~a[0]) |
( a[2] & ~a[1] & a[0]);
endmodule
/*
true_table
a f
000 1001
001 1010
010 0110
011 0000
100 0100
101 0001
110 0000
111 1110
*/
`timescale 100ns/1 ns
module testbench;
reg [2:0] a;
wire [3:0] f;
EX_108 UUT(
.a(a),
.f(f) );
initial
begin
a = 3'b000; // Time = 0
#20; // Time = 20
a = 3'b001;
#20; // Time = 40
a = 3'b010;
#20; // Time = 60
a = 3'b011;
#20; // Time = 80
a = 3'b100;
#20; // Time = 100
a = 3'b101;
#20; // Time = 120
a = 3'b110;
#20; // Time = 140
a = 3'b111;
end
endmodule
沒有留言:
張貼留言