回复 2# A1985
要真的源文件和testbench文件吗?module asser
(
clk, reset,a,b,
count
);
input clk,reset,a,b;
output [3:0] count;
reg [3:0]count_reg;
assign count =count_reg;
always @(clk)
begin
if (reset)
count_reg<= 0;
else if (a)
count_reg<= count + 1;
else if (b)
count_reg<= count - 1;
end
endmodule
testbench文件
`timescale 1ns/1ps
module test ;
reg a,b,clk,reset;
initial
begin
reset = 0;
# 300 reset = 1;
forever
#5 clk=!clk;
end
initial
reset= 0;
#300
reset =1;
end
initial
begin
a= 0;
b= 0;
#800
a = 1;
#800
b = 1;
end
initial begin
$fsdbDumpfile("wave.fsdb");
$fsdbDumpvars;
# 6000000 $finish;
end
asser u_asser (
.clk(clk),
.reset(reset),
.a(a),
.b(b),
.count()
) ;
endmodule;
|