コード例 #1
0
            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));
            }
コード例 #2
0
            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);
            }
コード例 #3
0
 public Result Result(Jam jam, int bitNumber)
 {
     if (this.results.TryGetValue(new JamKey(jam, bitNumber), out Result resut))
     {
         return(resut);
     }
     return(null);
 }
コード例 #4
0
            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);
            }
コード例 #5
0
 public Parameter Parameter(Jam jam, int bitNumber)
 {
     if (this.parameters.TryGetValue(new JamKey(jam, bitNumber), out Parameter parameter))
     {
         return(parameter);
     }
     return(null);
 }
コード例 #6
0
 public IEnumerable <Connection> SelectByOutput(Jam outputJam)
 {
     if (this.outputs.TryGetValue(outputJam, out Dictionary <Jam, Connection> inputs))
     {
         return(inputs.Values);
     }
     return(Enumerable.Empty <Connection>());
 }
コード例 #7
0
 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;
 }
コード例 #8
0
 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;
 }
コード例 #9
0
 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
         };
     }
 }
コード例 #10
0
 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));
 }
コード例 #11
0
            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);
            }
コード例 #12
0
 public LogicalJamItem(BasePin pin, CircuitGlyph symbol, Jam innerJam) : base(pin, symbol)
 {
     Tracer.Assert(innerJam != null && innerJam.CircuitSymbol.LogicalCircuit == symbol.Circuit);
     this.innerJam = innerJam;
 }
コード例 #13
0
 public bool IsConnected(CircuitMap map, Jam jam, int bit)
 {
     return(!this.jamConnected.Add(new JamBit(map, jam, bit)));
 }
コード例 #14
0
 public JamBit(CircuitMap circuitMap, Jam jam, int bit)
 {
     this.Map = circuitMap;
     this.Jam = jam;
     this.Bit = bit;
 }
コード例 #15
0
 public Parameter(Result result, CircuitMap circuitMap, Jam jam, int bitNumber) : base(circuitMap, jam, bitNumber)
 {
     Tracer.Assert(jam.Pin.PinType == PinType.Input);
     this.Result = result;
 }
コード例 #16
0
 public JamKey(Jam jam, int bitNumber)
 {
     Tracer.Assert(jam.IsValid(bitNumber));
     this.Jam       = jam;
     this.BitNumber = bitNumber;
 }
コード例 #17
0
 public IEnumerable <Parameter> AllParameters(Jam jam) => this.parameters.Where(p => p.Key.Jam == jam).OrderBy(p => p.Key.BitNumber).Select(p => p.Value);