`timescale 1ns / 1ps module plj(clk,clk_test,sw0,sw1,rst,out_wei,out_duan,miao); input clk,rst,clk_test,sw0,sw1; output reg[3:0] out_wei; output reg[7:0] out_duan; output reg miao; reg [27:0]count2; reg [3:0] ge,shi,bai,qian,p_10K,p_100K,p_M,p_10M,p_100M,s_ge,s_shi,s_bai,s_qian,s_10K,s_100K,s_M,s_10M,s_100M; reg flag=0; reg [19:0] saomiao=0; reg [3:0] duan; [email=always@(posedge]always@(posedge[/email] clk) begin if(!rst) begin count2<=0;flag<=0; end else begin count2<=count2+1; if(count2==50000000) begin flag<=1;miao<=1;end if(count2>=100000000)begin flag<=0;count2<=0;miao<=0;end end end
[email=always@(posedge]always@(posedge[/email] clk_test or negedge rst) begin if(!rst) begin ge<=0;shi<=0;bai<=0;qian<=0;p_10K<=0;p_100K<=0;p_M<=0;p_10M<=0;p_100M<=0; end else if(count2==60000000) begin ge<=0;shi<=0;bai<=0;qian<=0;p_10K<=0;p_100K<=0;p_M<=0;p_10M<=0;p_100M<=0;end else if(!flag) begin ge<=ge+1; if(ge==9) begin ge<=0;shi<=shi+1; if(shi==9) begin shi<=0;bai<=bai+1; if(bai==9) begin bai<=0;qian<=qian+1; if(qian==9) begin qian<=0;p_10K<=p_10K+1; if(p_10K==9) begin p_10K<=0;p_100K<=p_100K+1; if(p_100K==9) begin p_100K<=0;p_M<=p_M+1; if(p_M==9) begin p_M<=0;p_10M<=p_10M+1; if(p_10M==9) begin p_10M<=0;p_100M<=p_100M+1; end end end end end end end end end else begin ge<=ge;shi<=shi;bai<=bai;qian<=qian;p_10K<=p_10K;p_100K<=p_100K;p_M<=p_M;p_10M<=p_10M;p_100M<=p_100M; end end [email=always@(posedge]always@(posedge[/email] clk or negedge rst) begin if(!rst) saomiao<=0; else begin saomiao<=saomiao+1; if(saomiao==1000000) saomiao<=0; end end
[email=always@(posedge]always@(posedge[/email] clk or negedge rst) begin if(!rst) begin s_ge<=0;s_shi<=0;s_bai<=0;s_qian<=0;s_10K<=0;s_100K<=0;s_M<=0;s_10M<=0;s_100M<=0; end else if(count2==50000000) begin s_ge<=ge;s_shi<=shi;s_bai<=bai;s_qian<=qian;s_10K<=p_10K;s_100K<=p_100K;s_M<=p_M;s_10M<=p_10M;s_100M<=p_100M; end end
[email=always@(posedge]always@(posedge[/email] clk or negedge rst) begin if(!rst) begin case(saomiao) 0:begin out_wei<=4'b1000; duan<=0; end 250000:begin out_wei<=4'b0100; duan<=1; end 500000:begin out_wei<=4'b0010; duan<=2; end 750000:begin out_wei<=4'b0001; duan<=3; end endcase end
else if((sw1==0)&&(sw0==0)) begin case(saomiao) 0:begin out_wei<=4'b1000; duan<=s_ge; end 250000:begin out_wei<=4'b0100; duan<=s_shi; end 500000:begin out_wei<=4'b0010; duan<=s_bai; end 750000:begin out_wei<=4'b0001; duan<=s_qian; end default:begin out_wei<=out_wei; duan<=duan; end endcase end
else if((sw1==0)&&(sw0==1)) begin case(saomiao) 0:begin out_wei<=4'b1000; duan<=s_10K; end 250000:begin out_wei<=4'b0100; duan<=s_100K; end 500000:begin out_wei<=4'b0010; duan<=s_M; end 750000:begin out_wei<=4'b0001; duan<=s_10M; end default:begin out_wei<=out_wei; duan<=duan; end endcase end
else if((sw1==1)&&(sw0==1)) begin case(saomiao) 0:begin out_wei<=4'b1000; duan<=s_100M; end 250000:begin out_wei<=4'b0100; duan<=0; end 500000:begin out_wei<=4'b0010; duan<=0; end 750000:begin out_wei<=4'b0001; duan<=0; end default:begin out_wei<=out_wei; duan<=duan; end endcase end end