package signals;

public class Clock extends Signals
{
	private static final long serialVersionUID = 1L;
	
	private int nb_points = 100;
  
	public Clock(String name)
	{
		this.name = name;
		this.clock = true;
		this.widthUnit = 20;
		this.type = "clock";
	}
  
	public Clock(String name, int period)
	{
		init(name, period);
	}
  
	public Clock(String name, int period, int clockDomain, float ratio)
	{
		this.clockDomainId = clockDomain;
		this.ratio = ratio;
		init(name, period);
	}
  
	public void init(String name, int period)
	{
		setId();
		this.clockDomainId = this.id;
		this.name = name;
		this.clock = true;
		this.widthUnit = period;
		this.type = "clock";
    
	    boolean level = false;
	    for (int i = 0; i < nb_points; i++) // 200
	    {
	      if (level) 
	      {
	        this.wave[i] = 1;
	      }
	      if (!level) 
	      {
	        this.wave[i] = 0;
	      }
	      
	      level = !level;
	    }
	    
	    int pipo = 5;
	    pipo = pipo + 1;
  }
  
  public void generate(boolean beginOnRisingEdge)
  {
	  boolean level = false;
	  if (beginOnRisingEdge) 
	  {
		  for (int i = 0; i < 500; i++)
		  {
			  if (level) 
			  {
				  this.wave[i] = 0;
			  }
			  if (!level) 
			  {
				  this.wave[i] = 1;
			  }
			  level = !level;
		  }
	  } 
	  else 
	  {
		  for (int i = 0; i < 500; i++)
		  {
			  if (level) 
			  {
				  this.wave[i] = 1;
			  }
			  if (!level) 
			  {
				  this.wave[i] = 0;
			  }
			  level = !level;
		  }
	  }
  	}
}
