public Result AddResult(CircuitMap circuitMap, Jam jam, int bitNumber) { Tracer.Assert(CircuitMap.IsPrimitive(jam.CircuitSymbol.Circuit)); SymbolMap map = this.AddSymbol(circuitMap, (CircuitSymbol)jam.CircuitSymbol); return(map.AddResult(circuitMap, jam, bitNumber)); }
public Parameter AddParameter(Result result, CircuitMap circuitMap, Jam jam, int bitNumber) { Tracer.Assert(circuitMap.Circuit == jam.CircuitSymbol.LogicalCircuit && jam.CircuitSymbol == this.key.CircuitSymbol); JamKey jamKey = new JamKey(jam, bitNumber); Parameter parameter; if (this.parameters.TryGetValue(jamKey, out parameter)) { if (parameter.Result != result) { if (!parameter.Result.IsTriState || !result.IsTriState) { CircuitGlyph symbol = jam.CircuitSymbol; throw new CircuitException(Cause.UserError, Properties.Resources.ErrorManyResults(jam.Pin.Name, symbol.Circuit.Notation + symbol.Point.ToString()) ); } parameter.Result.Link(result); } } else { parameter = new Parameter(result, circuitMap, jam, bitNumber); this.parameters.Add(jamKey, parameter); result.Add(parameter); } return(parameter); }
public Result Result(Jam jam, int bitNumber) { if (this.results.TryGetValue(new JamKey(jam, bitNumber), out Result resut)) { return(resut); } return(null); }
public Result AddResult(CircuitMap circuitMap, Jam jam, int bitNumber) { Tracer.Assert(circuitMap.Circuit == jam.CircuitSymbol.LogicalCircuit && jam.CircuitSymbol == this.key.CircuitSymbol); Result result = new Result(circuitMap, jam, bitNumber); this.results.Add(new JamKey(jam, bitNumber), result); return(result); }
public Parameter Parameter(Jam jam, int bitNumber) { if (this.parameters.TryGetValue(new JamKey(jam, bitNumber), out Parameter parameter)) { return(parameter); } return(null); }
public IEnumerable <Connection> SelectByOutput(Jam outputJam) { if (this.outputs.TryGetValue(outputJam, out Dictionary <Jam, Connection> inputs)) { return(inputs.Values); } return(Enumerable.Empty <Connection>()); }
protected StateIndex(CircuitMap circuitMap, Jam jam, int bitNumber) { Tracer.Assert(circuitMap.Circuit == jam.CircuitSymbol.LogicalCircuit); Tracer.Assert(jam.IsValid(bitNumber)); this.CircuitMap = circuitMap; this.Jam = jam; this.BitNumber = bitNumber; }
public JamBit(CircuitMap map, Jam jam, int bit) { Tracer.Assert(map.Circuit == jam.CircuitSymbol.LogicalCircuit); Tracer.Assert(0 <= bit && bit < jam.Pin.BitWidth); this.map = map; this.jam = jam; this.bit = bit; }
public Result(CircuitMap circuitMap, Jam jam, int bitNumber) : base(circuitMap, jam, bitNumber) { Tracer.Assert(jam.Pin.PinType == PinType.Output); this.Parameters = new List <Parameter>(); if (jam.Pin.Circuit is Gate gate && (gate.GateType == GateType.TriState1 || gate.GateType == GateType.TriState2)) { this.TriStateGroup = new HashSet <Result> { this }; } }
private Jam CreateJam(BasePin pin) { if (pin is Pin) { LogicalCircuit logicalCircuit = (LogicalCircuit)this.Circuit; CircuitSymbol pinSymbol = logicalCircuit.CircuitProject.CircuitSymbolSet.SelectByCircuit(pin).First(); Jam innerJam = pinSymbol.Jams().First(); return(new LogicalJamItem(pin, this, innerJam)); } return(new JamItem(pin, this)); }
public Connection Connect(Jam inputJam, Jam outputJam) { Connection connection; Dictionary <Jam, Connection> inputs; if (this.outputs.TryGetValue(outputJam, out inputs)) { if (inputs.TryGetValue(inputJam, out connection)) { return(connection); } } else { inputs = new Dictionary <Jam, Connection>(); this.outputs.Add(outputJam, inputs); } connection = new Connection(inputJam, outputJam); inputs.Add(inputJam, connection); return(connection); }
public LogicalJamItem(BasePin pin, CircuitGlyph symbol, Jam innerJam) : base(pin, symbol) { Tracer.Assert(innerJam != null && innerJam.CircuitSymbol.LogicalCircuit == symbol.Circuit); this.innerJam = innerJam; }
public bool IsConnected(CircuitMap map, Jam jam, int bit) { return(!this.jamConnected.Add(new JamBit(map, jam, bit))); }
public JamBit(CircuitMap circuitMap, Jam jam, int bit) { this.Map = circuitMap; this.Jam = jam; this.Bit = bit; }
public Parameter(Result result, CircuitMap circuitMap, Jam jam, int bitNumber) : base(circuitMap, jam, bitNumber) { Tracer.Assert(jam.Pin.PinType == PinType.Input); this.Result = result; }
public JamKey(Jam jam, int bitNumber) { Tracer.Assert(jam.IsValid(bitNumber)); this.Jam = jam; this.BitNumber = bitNumber; }
public IEnumerable <Parameter> AllParameters(Jam jam) => this.parameters.Where(p => p.Key.Jam == jam).OrderBy(p => p.Key.BitNumber).Select(p => p.Value);