| 
 | 
module cnt_999 
    ( 
    input                   rst_n, 
    input                   clk, 
 
    output  wire    [11:0]  cnt 
    ); 
 
reg     [3:0]   cnt0; 
reg     [3:0]   cnt1; 
reg     [3:0]   cnt2; 
always @ (posedge clk or negedge) 
begin 
    if (rst_n == 1'b0) 
        cnt0 <= 4'd0; 
    else if (cnt0[3:0] >= 4'd9) 
        cnt0 <= 4'd0; 
    else 
        cnt0 <= cnt0 + 4'd1; 
end 
 
always @ (posedge clk or negedge) 
begin 
    if (rst_n == 1'b0) 
        cnt1 <= 4'd0; 
    else if (cnt0[3:0] >= 4'd9) 
    begin 
        if (cnt1[3:0] >= 4'd9) 
            cnt1 <= 4'd0; 
        else 
            cnt1 <= cnt1 + 4'd1; 
    end 
    else ; 
end 
 
always @ (posedge clk or negedge) 
begin 
    if (rst_n == 1'b0) 
        cnt1 <= 4'd0; 
    else if ((cnt0[3:0] >= 4'd9) && (cnt1[3:0] >= 4'd9)) 
    begin 
        if (cnt2[3:0] >= 4'd9) 
            cnt2 <= 4'd0; 
        else 
            cnt2 <= cnt2 + 4'd1; 
    end 
    else ; 
end 
 
assign cnt = {cnt2,cnt1,cnt0}; 
 
endmodule 
 
不知道这样是不是可以? |   
 
 
 
 |