package signals;

public class Clock extends Signals{

	private static final long serialVersionUID = 1L;

	
	public Clock(String name){ // No instantiation
		this.name=name;
		clock=true;
		widthUnit=20;
	}
	
	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=id;
		this.name=name;
		clock=true;
		widthUnit=period;
		
		boolean level = false;
		for (int i=0; i<200; i++){
			if (level) wave[i]=1;
			if (!level) wave[i]=0;
			level=!level;
		}
	}
	
	public void generate(boolean beginOnRisingEdge){
		boolean level = false;
		if (beginOnRisingEdge){
			for (int i=0; i<500; i++){
				if (level) wave[i]=0;
				if (!level) wave[i]=1;
				level=!level;
			}
		}
		else{
			for (int i=0; i<500; i++){
				if (level) wave[i]=1;
				if (!level) wave[i]=0;
				level=!level;
			}
		}
	}
}
