home *** CD-ROM | disk | FTP | other *** search
- class FourBitBinaryCounter extends IntegratedCircuit {
- int Count;
-
- public FourBitBinaryCounter(Pin[][] var1, int var2, int var3) {
- super(var2, var3, 10, 7, 3, 1, 4, 5, 1, 4);
- super.IPin[0] = new InputPin("C", 1, 3, 2, 0, 0, 0, 0);
- super.OPin[0] = new OutputPin("A", 9, 2, -2, 0, 0, 0, 0);
- super.OPin[1] = new OutputPin("B", 9, 3, -2, 0, 0, 0, 0);
- super.OPin[2] = new OutputPin("C", 9, 4, -2, 0, 0, 0, 0);
- super.OPin[3] = new OutputPin("D", 9, 5, -2, 0, 0, 0, 0);
- super.ComponentName = "4-bit binary counter";
- super.ClassName = "FourBitBinaryCounter";
- ((ElectronicComponent)this).RegisterPins(var1, var2, var3);
- }
-
- public FourBitBinaryCounter(ElectronicComponent var1, int var2, int var3) {
- super(var1, var2, var3);
- }
-
- public ElectronicComponent Copy(int var1, int var2) {
- FourBitBinaryCounter var3 = new FourBitBinaryCounter(this, var1, var2);
- return var3;
- }
-
- public void SimulateLogic() {
- if (super.IPin[0].getOldLevel() == 0 && super.IPin[0].getLevel() == 5) {
- ++this.Count;
- if (this.Count < 0 || this.Count > 15) {
- this.Count = 0;
- }
- }
-
- if ((this.Count & 1) == 1) {
- super.OPin[0].setLevel(5);
- } else {
- super.OPin[0].setLevel(0);
- }
-
- if ((this.Count & 2) == 2) {
- super.OPin[1].setLevel(5);
- } else {
- super.OPin[1].setLevel(0);
- }
-
- if ((this.Count & 4) == 4) {
- super.OPin[2].setLevel(5);
- } else {
- super.OPin[2].setLevel(0);
- }
-
- if ((this.Count & 8) == 8) {
- super.OPin[3].setLevel(5);
- } else {
- super.OPin[3].setLevel(0);
- }
-
- super.IPin[0].OldLevel = super.IPin[0].getLevel();
- }
- }
-