⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ntaxi.v

📁 出租车计价器
💻 V
字号:
module ntaxi(clk,reset,flag,ifw,c1,c2,c3,c4,m1,m2,w1,w2);
 input clk,reset,flag;
 output[3:0]c1,c2,c3,c4,m1,m2,w1,w2;
 output ifw;
 reg ifw;
 reg[3:0]t1,t2,t3,t4,c1,c2,c3,c4,m1,m2,w1,w2,tempf;
 reg[6:0]tempm;
 reg[5:0]tempt;
  always@(posedge clk)
 if(reset)
   begin
   {c4,c3,c2,c1}<=16'h0050;
   tempm<=7'b0000000;
   tempt<=6'b000000;
   tempf<=4'b0000;
   {t1,t2,t3,t4}<=16'h0200;
   {c1,c2,c3,c4,m1,m2,w1,w2}<=32'h05000000;
   end
 else
   begin
   if(!ifw)
     begin
     if(tempt<60)
     tempt<=tempt+1;
     end
   else
     begin
     if(tempf<10)
     tempf<=tempf+1;
     if(tempm<100)
     tempm<=tempm+1;
     end
   if(!ifw&&tempt==59)
     begin
     tempt<=6'b000000;
     if(w1==9)
       begin
       w1<=0;
       if(w2==9)
       w2<=0;
       else
       w2<=w2+1;
       end
     else
       w1<=w1+1;
     end 
    if(ifw&&tempm==99)
      begin
      tempm<=7'b0000000;
      if(m1==9)
        begin
        m1<=0;
        if(m2==9)
        m2<=0;
        else
        m2<=m2+1;
        end
     else
       m1<=m1+1;
     end 
    if(ifw&&tempf==9||!ifw&&tempt==59)
      begin
      tempf<=4'b0000;
      tempt<=6'b000000;
      if(t1==9)
        begin
        t1<=0;
        if(t2==9)
          begin 
          t2<=0;
          if(t3==9)
            begin 
            t3<=0;
            if(t4==9)
            t4<=0;
            else
            t4<=t4+1;
            end
          else
            t3<=t3+1;
          end
        else
            t2<=t2+1;
        end
     else
        t1<=t1+1;
     end 
    if(m2==4'b0000&&m1>=3||m2>=1)
    {c4,c3,c2,c1}<={t4,t3,t2,t1};
   end
 always @ (posedge flag)
 begin
 ifw<=!ifw;
 end
 endmodule


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -