import java.util.Properties;
import syncsim.SoftSyncPart;
import syncsim.Signal;
public class RegisterPart
extends SoftSyncPart {
private static final String PROP_BITWIDTH = "bitwidth";
private int bitWidth;
private Signal prevSignal;
public RegisterPart() {
}
public String in() {
return "in:" + bitWidth;
}
public String out() {
return "out:" + bitWidth;
}
public void initialize(String instanceName, Properties properties) {
super.initialize(instanceName, properties);
String s = properties.getProperty(PROP_BITWIDTH);
properties.remove(PROP_BITWIDTH);
if (s == null) {
throwMissingProperty(PROP_BITWIDTH);
}
try {
bitWidth = Integer.parseInt(s);
}
catch (NumberFormatException e) {
throwGeneralException("Property '" + PROP_BITWIDTH + "' is not a number.");
}
if (properties.size() > 0) {
throwUnknownProperties();
}
}
public void getOutput(Signal[] out) {
out[0] = prevSignal;
}
public void step(Signal[] in, Signal[] out) {
prevSignal = in[0];
getOutput(out);
}
public void update(Signal[] in, Signal[] out) {
getOutput(out);
}
}
|