Count clock
写了半天不对,才注意到是十六进制的 - -
另外安装了vivado 哈哈哈哈,可以看看写的到底对不对
之前好多程序在 hdlbits 可以正确运行 但是 vivado 编译不通过。
module clock(input clk,input reset,input ena,output reg pm,output reg[7:0] hh,output reg[7:0] mm,output reg[7:0] ss); wire [2:0]ena_clock;assign ena_clock[0]= ss==8'h59;assign ena_clock[1]= mm==8'h59 && ss==8'h59;assign ena_clock[2]= hh==8'h12 && mm==8'h59 && ss==8'h59;always@(posedge clk)beginif (reset){hh,mm,ss,pm} <= {8'h12,8'h0,8'h0,1'b0};else beginif(ena)beginif (hh==8'h11 && ena_clock[1]) pm <= !pm;if (ena_clock[0]) ss <= 8'h0; else if (ss[3:0]<8'h9)ss <= ss+1; else beginss[3:0] <= 4'b0;ss[7:4] <= ss[7:4]+1;endif (ena_clock[1]) mm <= 8'h0; else if (mm[3:0]<8'h9) mm <= mm + ena_clock[0];else beginif (ena_clock[0])beginmm[3:0] <= 4'b0;mm[7:4] <= mm[7:4]+ena_clock[0];endendif (ena_clock[2]) hh <= 8'h1; else if (hh[3:0]<8'h9)hh<= hh+ena_clock[1];else beginif (ena_clock[1])beginhh[3:0] <= 4'b0;hh[7:4] <= hh[7:4]+ena_clock[1];endend// if (ena_clock[1]) mm <= 8'h0; else mm <= mm+ena_clock[0];// if (ena_clock[2]) hh <= 8'h1; else hh <= hh+ena_clock[1];endendend
endmodule