//===========================
// ex5.7 F(a,b,c,d,e) circuit
module EX10_4( a ,b, c, d, e, F);
input a ,b, c ,d ,e; // 1位元輸入
output reg F ; // Output 1位元輸出
always@ ( a ,b, c, d, e) begin
case ({a,b,c,d,e})
5'b0_0000: F=1'b0;
5'b0_0001: F=1'b1;
5'b0_0010: F=1'b0;
5'b0_0011: F=1'b1;
5'b0_0100: F=1'b0;
5'b0_0101: F=1'b1;
5'b0_0110: F=1'b0;
5'b0_0111: F=1'b1;
5'b0_1000: F=1'b1;
5'b0_1001: F=1'b0;
5'b0_1010: F=1'b0;
5'b0_1011: F=1'b1;
5'b0_1100: F=1'b1;
5'b0_1101: F=1'b0;
5'b0_1110: F=1'b0;
5'b0_1111: F=1'b0;
5'b1_0000: F=1'b0;
5'b1_0001: F=1'b1;
5'b1_0010: F=1'b0;
5'b1_0011: F=1'b1;
5'b1_0100: F=1'b0;
5'b1_0101: F=1'b1;
5'b1_0110: F=1'b0;
5'b1_0111: F=1'b1;
5'b1_1000: F=1'b1;
5'b1_1001: F=1'b0;
5'b1_1010: F=1'b0;
5'b1_1011: F=1'b1;
5'b1_1100: F=1'b1;
5'b1_1101: F=1'b0;
5'b1_1110: F=1'b0;
5'b1_1111: F=1'b0;
endcase
end
endmodule
//===========================
// 時間單位 100ns, 時間精確度100 ps
`timescale 100ns/100ps
module Test_bench;
// Inputs
reg a ,b, c ,d ,e ;
// Outputs
wire F ;
// Instantiate the Unit Under Test (UUT)
// Ch5.3 F(a,b,c,d) circuit
EX10_4 UUT (
.a(a),
.b(b),
.c(c),
.d(d),
.e(e),
.F(F)
);
initial begin
$monitor( a ,b, c, d,e, F);
//Apply inputs
a=1'b0; b=1'b0; c=1'b0; d=1'b0; e=1'b0;
#100;
{a,b,c,d,e}=5'b0_0001;
#100;
{a,b,c,d,e}=5'b0_0010;
#100;
{a,b,c,d,e}=5'b0_0011;
#100;
{a,b,c,d,e}=5'b0_0100;
#100;
{a,b,c,d,e}=5'b0_0101;
#100;
{a,b,c,d,e}=5'b0_0110;
#100;
{a,b,c,d,e}=5'b0_0111;
#100;
{a,b,c,d,e}=5'b0_1000;
#100;
{a,b,c,d,e}=5'b0_1001;
#100;
{a,b,c,d,e}=5'b0_1010;
#100;
{a,b,c,d,e}=5'b0_1011;
#100;
{a,b,c,d,e}=5'b0_1100;
#100;
{a,b,c,d,e}=5'b0_1101;
#100;
{a,b,c,d,e}=5'b0_1110;
#100;
{a,b,c,d,e}=5'b0_1111;
#100;
a=1'b1; b=1'b0; c=1'b0; d=1'b0; e=1'b0;
#100;
{a,b,c,d,e}=5'b1_0001;
#100;
{a,b,c,d,e}=5'b1_0010;
#100;
{a,b,c,d,e}=5'b1_0011;
#100;
{a,b,c,d,e}=5'b1_0100;
#100;
{a,b,c,d,e}=5'b1_0101;
#100;
{a,b,c,d,e}=5'b1_0110;
#100;
{a,b,c,d,e}=5'b1_0111;
#100;
{a,b,c,d,e}=5'b1_1000;
#100;
{a,b,c,d,e}=5'b1_1001;
#100;
{a,b,c,d,e}=5'b1_1010;
#100;
{a,b,c,d,e}=5'b1_1011;
#100;
{a,b,c,d,e}=5'b1_1100;
#100;
{a,b,c,d,e}=5'b1_1101;
#100;
{a,b,c,d,e}=5'b1_1110;
#100;
{a,b,c,d,e}=5'b1_1111;
#100;
end
initial begin
#3300 $stop;
end
endmodule
//===========================
沒有留言:
張貼留言