微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 嵌入式设计讨论 > FPGA,CPLD和ASIC > 求助一段verilog的计时程序 想公用比较器

求助一段verilog的计时程序 想公用比较器

时间:10-02 整理:3721RD 点击:
自己写了一段公用比较器实现记得时间差的程序,但是仿真结果不多,下载到硬件测量结果也不对,求高手帮忙
//计时程序2012/3/1
   
   module huoju_caiji(
   
    input  s01,ter02,ter03,                   //输入点火信号
    input  clk,              
    input  rst,                              //复位信号
    output   [31:0] deltat1,
    output   [31:0] deltat2);                  //输出时间差
   
    reg [31:0] count;
    reg [31:0] count1;
    reg [31:0] count2;        //计数计一小时D693A400
    reg [31:0] count3;
    reg [31:0] tempt1;
    reg [31:0] tempt2;
   
    reg flag1;
    reg flag2;
    reg flag3;
    reg i;
   
     //基准计时时间
  always @ (posedge clk or negedge rst)
     begin
       if(!rst)
         begin
            count<=32’d0;end
        else
          begin  count<=count+1'b1; end
          end
         
         //开始计时时间1结束时间2
   always @ (posedge s01   or posedge ter02 or negedge rst )
      begin
        if(!rst)
          begin
            count1<=32'd0;
            flag1<=1'b0;
             count2<=32'd0;
             flag2<=1'b0;
             i<=1'b0;
          end
           else if(s01||ter02==1'b1)
          begin
                i<=i+1'b1;
   
   
          end
  case(i)
     1'b0:begin
                count2<=count;
                flag2<=1'b1;
            end
    1'b1:begin
     
    count1<=count;  
    flag1<=1'b1;
    end
        endcase
  end
   
   
  
          //结束计时时间3
    always @ (posedge ter03 or negedge rst )
      begin
        if(!rst)
          begin
            count3<=32'd0;
             flag3<=1'b0;
            
          end
         else
          begin
            count3<=count;  
            flag3<=1'b1;
          end
       end   
   
   
    always @ (posedge clk or negedge rst)
        begin
           if(!rst)
             begin
                tempt1<=32'd0;
                tempt2<=32'd0;
             end
  else if({flag2,flag3}==2'b11)
   begin   
         case({flag2,flag3})
    2'b01: begin tempt1<=32'd0;
      tempt2<=(count3-count1);
      end
    2'b10: begin tempt1<=(count2-count1);
      tempt2<=32'd0;
      
      end
    2'b11: begin tempt1<=(count2-count1);
      tempt2<=(count3-count1);
     
      end
    default  begin tempt1<=32'd0;
       tempt2<=32'd0;
      
       end
   endcase
         end
         end
         
      
           assign    deltat1=tempt1;
           assign    deltat2=tempt2;
            
endmodule

有知道的希望联系我呵呵,先谢谢啦额呵呵 不常在论坛又看到的联系不胜感激

s01,ter02,ter03
这是1个开始信号,2个结束信号?仿真都不对,连综合下载的必要都没有

上一篇:求MBISTArchitect!
下一篇:QUARTUS下RAM问题

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top