赞
踩
https://github.com/zsylov/verliog-study/blob/master/2019.5.6%E8%AE%A1%E6%95%B0%E5%99%A8.md
用verilog实现一个4bit二进制计数器。
====
a) 异步复位
b) 同步复位
input clk, rst_n;
output [3:0] o_cnt;
```verilog
`timescale 1ns/1ps
module Syn_counter(
input clk,rst_n,
output[3:0] o_cnt
);
reg [3:0] o_cnt_r;
always @ (posedge clk)
if(!rst_n)
o_cnt_r <= 4'b0000;
else if(o_cnt_r == 4'b1111) o_cnt_r <= 4'b0000;
else
o_cnt_r <= o_cnt_r + 1'b1;
assign o_cnt =o_cnt_r;
endmodule
`timescale 1ns/1ps
module aSyn_counter(
input clk,rst_n,
output[3:0
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。