加减计数器
题目描述
请编写一个十进制计数器模块,当mode信号为1,计数器输出信号递增,当mode信号为0,计数器输出信号递减。每次到达0,给出指示信号zero。
模块的接口信号图如下:
`timescale 1ns/1nsmodule count_module(input clk,input rst_n,input mode,output reg [3:0]number,output reg zero);reg[3:0] num;always@(posedge clk or negedge rst_n)beginif(!rst_n)num <= 4'd0;else if(mode == 1'd1)beginif(num == 4'd9)num <= 4'd0;elsenum <= num + 1'b1;endelse if(mode =