contr.v

来自「交通灯。1)当乡村公路无车时」· Verilog 代码 · 共 41 行

V
41
字号
module contr(lod,clk,aqm,aqc,numm,numc,rst,c,light);
input[7:0] aqm,aqc;
output[7:0] numm,numc;
output[5:0] light;
input clk,c,rst;
output lod;
reg[7:0] numm,numc;
reg[1:0] qc;
reg[5:0] light;
reg m;
reg lod;
always @(negedge clk )
begin
lod=1;
if(aqm==0 || aqc==0)lod=0;
end
always @(negedge clk or negedge rst )
begin 
      if(!rst)begin light='b001100;numm='b00100101;numc='b00100101;qc=1;end 
      else
      case(qc)
      0:begin if(aqm==0 || aqc==0) begin light='b001100;numm='b00100101;numc='b00100101;qc=1;end end
      1:begin
        if(aqm==0 || aqc==0) 
              begin if(c==1)begin numm='b00000101;light='b010100;qc=qc+1;numc='b00000101;end
                     else begin numm='b00000000;numc='b00000000;light='b001100;qc=1;m=1;end
              end
        end
      2:begin
           if(aqm==0 || aqc==0)
             begin  if(c==1)begin numm='b00100001;numc='b00010110;light='b100001;qc=qc+1;end
               else begin numm='b00000000;numc='b00000000;qc=3;end
             end
         end
      3:begin if(c==0 && numm>'b00000101) begin numm='b00000101;numc='b00000101;light='b100010;qc=0; end
              if(c==1&&(aqm==0||aqc==0)) begin numc='b00000101;numm='b00000101;light='b100010;qc=0;end
        end
      default:qc=0;
        endcase
end   
endmodule

⌨️ 快捷键说明

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