 package signals;
 
 public class Clock extends Signals
 {
   private static final long serialVersionUID = 1L;
   
   public Clock(String name)
   {
     this.name = name;
     this.clock = true;
     this.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 = this.id;
     this.name = name;
     this.clock = true;
     this.widthUnit = period;
     
     boolean level = false;
     for (int i = 0; i < 200; i++) {
       if (level) this.wave[i] = 1;
       if (!level) this.wave[i] = 0;
       level = !level;
     }
   }
   
   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;
       }
     }
   }
 }





