(总)4位计数器源程序与testbench测试程序.docVIP

  • 85
  • 0
  • 约3.01千字
  • 约 4页
  • 2017-04-07 发布于重庆
  • 举报

(总)4位计数器源程序与testbench测试程序.doc

(总)4位计数器源程序与testbench测试程序

1、简单4位计数器程序: module count4(clk,cnt); input clk; output reg[3:0]cnt=4b0; always @(posedge clk) begin cnt=cnt+1; end endmodule 测试程序: `timescale 1 ns/10 ps module test_count4(); reg clk=0; wire [3:0]cnt; count4 i1(.clk(clk),.cnt(cnt)); always #10 clk=~clk; initial begin $monitor($time,,,clk=%d cnt=%d,clk,cnt); #400 $stop; end endmodule 仿真波形: 2、异步清零4位计数器源程序 module count4_reset(clk,rst,cnt); input clk,rst; output reg[3:0]cnt=4b0; always @(posedge clk or negedge rst) begin if(!rst) cnt=4b0;

文档评论(0)

1亿VIP精品文档

相关文档