private bool ShouldCodeLabelBeEvaluated(CodeLabel label, int stage) { if (label.Stage == stage) { var scount = label.ScheduleCount; // Trace("should {0} {1}", label.OriginalGate, label.OriginalGate.GetType().Name); if (label.OriginalGate.Type == GateType.Input && scount > 0) { return(true); } else if (scount > 1) { return(true); } else { return(false); } } else { return(false); } }
private void AddToGateMap(IGate gate, CodeLabel label) { gate = gate.Simplify(); if (!_gatemap.ContainsKey(gate.ID)) { _gatemap.Add(gate.ID, label); } }
internal void SetLabel(int stage, CodeLabel label) { _labels[stage] = label; }
private CodeLabel AddCodeLabel(int stage, IGate g, bool makelabels) { CodeLabel label; var e = g; var labelkey = GetCodeLabelIdentifier(stage, g); if (makelabels) { e = MakeCodeLabels(stage, e); e = Gate.Simplify(e); } if (!_labels.ContainsKey(labelkey)) { // not found in table ... if (null != OnBeforeAddLabel) { // client may do something about it var r = OnBeforeAddLabel(stage, e); if (r != e) { if (_gatemap.TryGetValue(r.ID, out label)) { return(label); } else { throw new Exception("unexpected, gate not found."); } } } } if (!_labels.TryGetValue(labelkey, out label)) { if (null == label) { // construct a new label var labelindex = _lseed++; //var name = "u_" + stage + "_" + labelindex; var name = "_c" + labelindex; var newlabel = new CodeLabel(this, stage, labelindex, name, e); // Gate.TraceLabel(g, newlabel.Gate, stage + " create {0} ...", newlabel); // look for a reduced label. var r = newlabel.Gate; var lg = newlabel.Gate as LabelGate; if (null == lg) { var derivedkey = GetCodeLabelIdentifier(stage, r); if (!_labels.TryGetValue(derivedkey, out label)) { _labels[derivedkey] = newlabel; Gate.TraceLabel(g, newlabel.Gate, stage + " insert <" + derivedkey + ">"); AddToGateMap(r, label); } else { // forget newlabel = null; } } else { } if (null != newlabel) { label = newlabel; _labels[labelkey] = label; AddToGateMap(label.Gate, label); Gate.TraceLabel(g, newlabel.Gate, stage + " insert <" + labelkey + ">"); } AddToGateMap(e, label); } } AddToGateMap(g, label); return(label); }
public LabelGate(CodeLabel label) { Label = label; }
public void Queue(CodeLabel label) { _queue.Add(label); }
private bool ShouldCodeLabelBeEvaluated(CodeLabel label, int stage) { if (label.Stage == stage) { var scount = label.ScheduleCount; // Trace("should {0} {1}", label.OriginalGate, label.OriginalGate.GetType().Name); if (label.OriginalGate.Type == GateType.Input && scount > 0) { return true; } else if (scount > 1) { return true; } else { return false; } } else { return false; } }
private CodeLabel AddCodeLabel(int stage, IGate g, bool makelabels) { CodeLabel label; var e = g; var labelkey = GetCodeLabelIdentifier(stage, g); if (makelabels) { e = MakeCodeLabels(stage, e); e = Gate.Simplify(e); } if(!_labels.ContainsKey(labelkey)) { // not found in table ... if (null != OnBeforeAddLabel) { // client may do something about it var r = OnBeforeAddLabel(stage, e); if(r != e) { if(_gatemap.TryGetValue(r.ID, out label)) { return label; } else { throw new Exception("unexpected, gate not found."); } } } } if (!_labels.TryGetValue(labelkey, out label)) { if (null == label) { // construct a new label var labelindex = _lseed++; //var name = "u_" + stage + "_" + labelindex; var name = "_c" + labelindex; var newlabel = new CodeLabel(this, stage, labelindex, name, e); // Gate.TraceLabel(g, newlabel.Gate, stage + " create {0} ...", newlabel); // look for a reduced label. var r = newlabel.Gate; var lg = newlabel.Gate as LabelGate; if (null == lg) { var derivedkey = GetCodeLabelIdentifier(stage, r); if (!_labels.TryGetValue(derivedkey, out label)) { _labels[derivedkey] = newlabel; Gate.TraceLabel(g, newlabel.Gate, stage + " insert <" + derivedkey + ">"); AddToGateMap(r, label); } else { // forget newlabel = null; } } else { } if (null != newlabel) { label = newlabel; _labels[labelkey] = label; AddToGateMap(label.Gate, label); Gate.TraceLabel(g, newlabel.Gate, stage + " insert <" + labelkey + ">"); } AddToGateMap(e, label); } } AddToGateMap(g, label); return label; }