private Signal ScanSignal() { string name = ScanTextIdentifier(); Signal s; if (!system.TryLookupNamedSignal(name, out s)) { s = system.CreateNamedSignal(name); } return(s); }
private void ScanDefineArchitecture() { tokenizer.Match(TokenTypes.TextIdentifier, "architecture"); MathIdentifier architectureId = ScanEntityMathIdentifierOrLabel(true); MathIdentifier entityId = ScanEntityMathIdentifierOrLabel(true); IEntity entity = library.LookupEntity(entityId); tokenizer.Match("{"); IMathSystem originalSystem = system; IMathSystem tempSystem = Binder.CreateSystem(); system = tempSystem; while (tokenizer.LookaheadFistToken.Text != "}") { NextStatement(); } foreach (string input in entity.InputSignals) { tempSystem.PromoteAsInput(tempSystem.LookupNamedSignal(input)); } foreach (string output in entity.OutputSignals) { tempSystem.AddSignalTree(tempSystem.LookupNamedSignal(output), tempSystem.GetAllInputs(), true, false); } ReadOnlySignalSet leafs = tempSystem.GetAllLeafSignals(); foreach (Signal s in leafs) { Signal so; if (originalSystem.TryLookupNamedSignal(s.Label, out so) && so.Value != null) { s.PostNewValue(so.Value); } } Service <ISimulationMediator> .Instance.SimulateInstant(); system = originalSystem; tokenizer.Match("}"); tempSystem.RemoveUnusedObjects(); tempSystem.PublishToLibrary(architectureId, entity.EntityId); }