没有加使能控制端口,需要的话自己加好了
module cntr2
(
input clk,rst_n,
output [1 :0] o_cnt,
output o_cout
);
reg[2:0] r_cnt;
reg[2:0] w_cnt_nxt;
assign o_cnt=r_cnt[1:0];
assign o_cout=r_cnt[2];
always@(posedge clk or negedge rst_n) begin
if(!rst_n) begin
r_cnt<=3'd0;
end
else begin
r_cnt<=w_cnt_nxt;
end
end
always@(*) begin
w_cnt_nxt=r_cnt+3'd1;
end
module cntr2
(
input clk,rst_n,
output [1 :0] o_cnt,
output o_cout
);
reg[2:0] r_cnt;
reg[2:0] w_cnt_nxt;
assign o_cnt=r_cnt[1:0];
assign o_cout=r_cnt[2];
always@(posedge clk or negedge rst_n) begin
if(!rst_n) begin
r_cnt<=3'd0;
end
else begin
r_cnt<=w_cnt_nxt;
end
end
always@(*) begin
w_cnt_nxt=r_cnt+3'd1;
end
