- module bcd_counter(
- rst,
- clk,
- qout
- );
- input rst;
- input clk;
- output[7:0] qout;
- reg [3:0] low;
- reg [3:0] high;
- assign qout ={high,low};
- always @(posdage clk)
- if(rst)
- begin
- dc <= 1'b0;
- low <= 4'h0;
- high <= 4'h0;
- end
- else
- begin
- case(low)
- 0,1,2,3,4,5,6,7,8:
- low <= low+4'h1;
- 9:
- begin
- low <= 4'h0;
- case(high)
- 0,1,2,3,4,5,6,7,8:
- high <= high+4'h1;
- 9:
- high <= 0;
- endcase
- end
- endcase
- end
- end module
復制代碼 |