java/ch/wlkl/processor/Store.java
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ch.wlkl.processor;
/**
*
* @author walter
*/
public class Store extends Gate {
public final Gate iSet, iVal;
public final String name;
public static Store[] newArray(int sz, Gate gSet) {
Store[] r = new Store[sz];
for (int i = 0; i < r.length; i++) {
r[i] = new Store("", gSet, new GateOr());
}
return r;
}
public static Store[] newArray(int sz, Gate gSet, Gate[] iVal) {
Store[] r = new Store[sz];
for (int i = 0; i < r.length; i++) {
r[i] = new Store("", gSet, iVal[i]);
}
return r;
}
public Store(String nm, Gate s, Gate v) {
iSet = s;
iVal = v;
name = nm;
s.addOut(this);
v.addOut(this);
update();
}
public void update() {
if (! iSet.get())
return;
if (val == iVal.get())
return;
val = iVal.get();
propagate();
}
}