OpenCores
URL https://opencores.org/ocsvn/sqmusic/sqmusic/trunk

Subversion Repositories sqmusic

[/] [sqmusic/] [trunk/] [sqm/] [sqm_pwm.v] - Diff between revs 4 and 6

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 4 Rev 6
Line 41... Line 41...
 
 
SQM_PWM_LOG dec( .din(din), .rep0(rep0), .rep1(rep1), .zero(zero) );
SQM_PWM_LOG dec( .din(din), .rep0(rep0), .rep1(rep1), .zero(zero) );
 
 
always @(posedge clk or negedge reset_n) begin
always @(posedge clk or negedge reset_n) begin
  if( !reset_n ) begin
  if( !reset_n ) begin
    count=0;
    count<=0;
    last0=0;
    last0<=0;
    last1=1;
    last1<=1;
  end
  end
  else
  else
    if( zero ) begin
    if( zero ) begin
      pwm=0;
      pwm  <=0;
      count=0;
      count<=0;
    end
    end
    else if( last0!=rep0 || last1!=rep1 ) begin
    else if( last0!=rep0 || last1!=rep1 ) begin
      last0 <= rep0;
      last0 <= rep0;
      last1 <= rep1;
      last1 <= rep1;
      count = 0;
      count <= 0;
      pwm=0;
      pwm   <=0;
    end
    end
    else if( last0==1 && last1==1 ) begin
    else if( last0==1 && last1==1 ) begin
      pwm=clk;
      pwm  <=clk;
      count=0;
      count<=0;
    end
    end
    else begin
    else begin
      if( pwm && count==last1-1 ) begin
      if( pwm && count==last1-1 ) begin
        count=0;
        count<=0;
        pwm=0;
        pwm  <=0;
      end
      end
      else if( !pwm && count==last0-1 ) begin
      else if( !pwm && count==last0-1 ) begin
        count=0;
        count<=0;
        pwm=1;
        pwm  <=1;
      end
      end
      else begin
      else begin
        count<=count+1;
        count<=count+1;
        pwm<=pwm;
        pwm<=pwm;
      end
      end

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.