Commit 957b69f0 by SergeyDegtyar

Update testbenches for MACC and FSMs

parent a5b30e54
...@@ -31,21 +31,35 @@ module testbench; ...@@ -31,21 +31,35 @@ module testbench;
); );
initial begin initial begin
rst <= 0;
#5
rst <= 1; rst <= 1;
#5 #5
a <= 1; rst <= 0;
b <= 0; end
#50
a <= 0; initial begin
b <= 0; a <= 0;
#50 repeat (20000) #3 a = !a;
a <= 0; end
b <= 1;
#50 initial begin
a <= 1; b <= 0;
b <= 1; repeat (20000) #4 b = !b;
end
assert g0_test(.clk(clk), .A(g0));
assert g1_test(.clk(clk), .A(g1));
endmodule
module assert(input clk, input A);
always @(posedge clk)
begin
//#1;
if (A == 1'bZ)
begin
$display("ASSERTION FAILED in %m:",$time," ",A);
//$finish;
end
end end
endmodule endmodule
...@@ -31,21 +31,35 @@ module testbench; ...@@ -31,21 +31,35 @@ module testbench;
); );
initial begin initial begin
rst <= 0;
#5
rst <= 1; rst <= 1;
#5 #5
a <= 1; rst <= 0;
b <= 0; end
#50
a <= 0; initial begin
b <= 0; a <= 0;
#50 repeat (20000) #3 a = !a;
a <= 0; end
b <= 1;
#50 initial begin
a <= 1; b <= 0;
b <= 1; repeat (20000) #4 b = !b;
end
assert g0_test(.clk(clk), .A(g0));
assert g1_test(.clk(clk), .A(g1));
endmodule
module assert(input clk, input A);
always @(posedge clk)
begin
//#1;
if (A == 1'bZ)
begin
$display("ASSERTION FAILED in %m:",$time," ",A);
//$finish;
end
end end
endmodule endmodule
...@@ -71,7 +71,7 @@ fsm u_fsm ( .clock(clk), ...@@ -71,7 +71,7 @@ fsm u_fsm ( .clock(clk),
assign g0 = g[0]; assign g0 = g[0];
assign g1 = g[1]; assign g1 = g[1];
assign a = r[0]; assign r[0] = a;
assign b = r[1]; assign r[1] = b;
endmodule endmodule
...@@ -35,10 +35,12 @@ module testbench; ...@@ -35,10 +35,12 @@ module testbench;
); );
initial begin initial begin
rst <= 0; rst <= 0;
#5 #5
rst <= 1; rst <= 1;
#5 #5
rst <= 0;
#5
a <= 4'b1111; a <= 4'b1111;
b <= 4'b1010; b <= 4'b1010;
c <= 4'b1011; c <= 4'b1011;
...@@ -56,4 +58,21 @@ module testbench; ...@@ -56,4 +58,21 @@ module testbench;
c <= 4'b0000; c <= 4'b0000;
end end
assert x_test(.clk(clk), .A(x));
assert y_test(.clk(clk), .A(y));
assert z_test(.clk(clk), .A(z));
endmodule
module assert(input clk, input [4:0] A);
always @(posedge clk)
begin
//#1;
if (A == 4'b0000)
begin
$display("ASSERTION FAILED in %m:",$time," ",A);
//$finish;
end
end
endmodule endmodule
...@@ -19,6 +19,7 @@ module testbench; ...@@ -19,6 +19,7 @@ module testbench;
reg [17:0] dinB; reg [17:0] dinB;
reg carryin; reg carryin;
reg rst; reg rst;
wire [47:0] p;
top uut ( top uut (
.p (p), .p (p),
...@@ -50,5 +51,26 @@ module testbench; ...@@ -50,5 +51,26 @@ module testbench;
dinB <= 0; dinB <= 0;
carryin <= 0; carryin <= 0;
end end
assert macc_test(.clk(clk), .A(dinA), .B(dinB), .C(carryin), .P(p));
endmodule
module assert(input clk, input [24:0] A, input [17:0] B, input C, input [47:0] P);
reg [47:0] p;
always @(posedge clk)
begin
//#1;
@(posedge clk);
@(posedge clk);
@(posedge clk);
@(posedge clk);
assign p = (A * B) + C;
if (P != p)
begin
$display("ASSERTION FAILED in %m:",$time," ",P," ",p);
//$finish;
end
end
endmodule endmodule
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment