Esempio n. 1
0
        private void CreatePins(Memory memory)
        {
            Tracer.Assert(!this.CircuitProject.DevicePinSet.SelectByCircuit(memory).Any());
            // The order of creation of the pins is essential for expansion algorithm.

            DevicePin address = this.CircuitProject.DevicePinSet.Create(memory, PinType.Input, memory.AddressBitWidth);

            address.PinSide     = PinSide.Left;
            address.Name        = Properties.Resources.MemoryAddressPinName;
            address.JamNotation = Properties.Resources.MemoryAddressPinNotation;
            DevicePin data = this.CircuitProject.DevicePinSet.Create(memory, PinType.Output, memory.DataBitWidth);

            data.PinSide     = PinSide.Right;
            data.Name        = Properties.Resources.MemoryDataPinName;
            data.JamNotation = Properties.Resources.MemoryDataPinNotation;
            if (memory.Writable)
            {
                DevicePin dataIn = this.CircuitProject.DevicePinSet.Create(memory, PinType.Input, memory.DataBitWidth);
                dataIn.PinSide     = PinSide.Left;
                dataIn.Name        = Properties.Resources.MemoryDataInPinName;
                dataIn.JamNotation = Properties.Resources.MemoryDataPinNotation;
                DevicePin write = this.CircuitProject.DevicePinSet.Create(memory, PinType.Input, 1);
                write.PinSide     = PinSide.Bottom;
                write.Name        = Properties.Resources.MemoryWritePinName(memory.WriteOn1 ? Properties.Resources.WriteOn1 : Properties.Resources.WriteOn0);
                write.JamNotation = Properties.Resources.MemoryWritePinNotation;
                memory.SetPins(address, data, dataIn, write);
                MemorySet.UpdateWritePinName(memory);
            }
            else
            {
                memory.SetPins(address, data);
            }
        }
        private void CreateDevicePin(CircuitButton button)
        {
            DevicePin pin = this.CircuitProject.DevicePinSet.Create(button, PinType.Output, 1);

            pin.PinSide  = button.PinSide;
            pin.Inverted = button.Inverted;
        }
Esempio n. 3
0
        public int Compare(BasePin x, BasePin y)
        {
            Tracer.Assert(x.GetType() == y.GetType());
            DevicePin dp1 = x as DevicePin;

            if (dp1 != null)
            {
                DevicePin dp2 = (DevicePin)y;
                return(dp1.Order - dp2.Order);
            }
            else
            {
                CircuitSymbolSet symbolSet = x.CircuitProject.CircuitSymbolSet;
                Tracer.Assert(symbolSet == y.CircuitProject.CircuitSymbolSet);
                CircuitSymbol s1 = symbolSet.SelectByCircuit(x).FirstOrDefault();
                CircuitSymbol s2 = symbolSet.SelectByCircuit(y).FirstOrDefault();
                if (s1 != null && s2 != null)
                {
                    int d = s1.Y - s2.Y;
                    if (d == 0)
                    {
                        d = s1.X - s2.X;
                        if (d == 0)
                        {
                            return(StringComparer.Ordinal.Compare(x.Name, y.Name));
                        }
                    }
                    return(d);
                }
                return(StringComparer.Ordinal.Compare(x.Name, y.Name));
            }
        }
        private void CreateDevicePins(GraphicsArray graphicsArray)
        {
            Tracer.Assert(!this.CircuitProject.DevicePinSet.SelectByCircuit(graphicsArray).Any());
            // The order of creation of the pins is essential for expansion algorithm.

            DevicePin address = this.CircuitProject.DevicePinSet.Create(graphicsArray, PinType.Input, graphicsArray.AddressBitWidth);

            address.PinSide = PinSide.Left;
            address.Name    = Properties.Resources.MemoryAddressPinName;
            DevicePin data = this.CircuitProject.DevicePinSet.Create(graphicsArray, PinType.Output, graphicsArray.DataBitWidth);

            data.PinSide = PinSide.Right;
            data.Name    = Properties.Resources.MemoryDataPinName;

            DevicePin dataIn = this.CircuitProject.DevicePinSet.Create(graphicsArray, PinType.Input, graphicsArray.DataBitWidth);

            dataIn.PinSide = PinSide.Left;
            dataIn.Name    = Properties.Resources.MemoryDataInPinName;
            DevicePin write = this.CircuitProject.DevicePinSet.Create(graphicsArray, PinType.Input, 1);

            write.PinSide = PinSide.Bottom;
            write.Name    = Properties.Resources.MemoryWritePinName(graphicsArray.WriteOn1 ? Properties.Resources.WriteOn1 : Properties.Resources.WriteOn0);
            graphicsArray.SetPins(address, data, dataIn, write);
            GraphicsArraySet.UpdateWritePinName(graphicsArray);
        }
Esempio n. 5
0
        public void UpdatePins()
        {
            this.CircuitProject.DevicePinSet.DeleteAllPins(this);
            int rows    = this.Rows;
            int columns = this.Columns;
            int colors  = this.Colors;

            if (this.MatrixType == LedMatrixType.Individual)
            {
                int bitWidth = columns * colors;
                for (int i = 0; i < rows; i++)
                {
                    DevicePin pin = this.CircuitProject.DevicePinSet.Create(this, PinType.Input, bitWidth);
                    pin.Name = Properties.Resources.LedMatrixRowIndividual(i + 1);
                }
            }
            else                 //this.MatrixType == LedMatrixType.Selector
            {
                Tracer.Assert(this.MatrixType == LedMatrixType.Selector);
                for (int i = 0; i < columns; i++)
                {
                    DevicePin pin = this.CircuitProject.DevicePinSet.Create(this, PinType.Input, colors);
                    pin.Name    = Properties.Resources.LedMatrixColumnSelector(i + 1);
                    pin.PinSide = PinSide.Top;
                }
                for (int i = 0; i < rows; i++)
                {
                    DevicePin pin = this.CircuitProject.DevicePinSet.Create(this, PinType.Input, 1);
                    pin.Name = Properties.Resources.LedMatrixRowSelector(i + 1);
                }
            }
        }
Esempio n. 6
0
 private static void SetName(DevicePin pin, int firstBit, int pinWidth)
 {
     if (pinWidth == 1)
     {
         pin.Name = Properties.Resources.SplitterThin1PinName(firstBit);
     }
     else
     {
         pin.Name = Properties.Resources.SplitterThin2PinName(firstBit, firstBit + pinWidth - 1);
     }
 }
Esempio n. 7
0
        public DevicePin Create(Circuit circuit, PinType pinType, int bitWidth)
        {
            PinSide   pinSide = BasePin.DefaultSide((circuit is Pin circuitPin) ? (circuitPin.PinType == PinType.Input ? PinType.Output : PinType.Input) : pinType);
            DevicePin pin     = this.CreateItem(Guid.NewGuid(), circuit, bitWidth, pinType, pinSide, false,
                                                this.UniqueName(BasePin.DefaultName(pinType), circuit),
                                                DevicePinData.NoteField.Field.DefaultValue, DevicePinData.JamNotationField.Field.DefaultValue
                                                );

            pin.Order = this.order++;
            return(pin);
        }
Esempio n. 8
0
        internal void SetPins(DevicePin addressPin, DevicePin dataPin)
        {
            Tracer.Assert(!this.Writable);
            Tracer.Assert(this.AddressPin == null);
            Tracer.Assert(addressPin != null && dataPin != null);

            this.AddressPin = addressPin;
            this.DataOutPin = dataPin;

            Tracer.Assert(addressPin.BitWidth == this.AddressBitWidth);
            Tracer.Assert(dataPin.BitWidth == this.DataBitWidth);
        }
Esempio n. 9
0
        private void CreateDevicePin(Pin pin)
        {
            PinType pinType = pin.PinType;

            if (pinType != PinType.None)
            {
                DevicePin devicePin = this.CircuitProject.DevicePinSet.Create(
                    pin, PinType.None, pin.BitWidth
                    );
                devicePin.Inverted = pin.Inverted;
            }
        }
Esempio n. 10
0
        internal void SetPins(DevicePin addressPin, DevicePin dataOutPin, DevicePin dataInPin, DevicePin writePin)
        {
            Tracer.Assert(this.AddressPin == null);
            Tracer.Assert(addressPin != null && dataOutPin != null && dataInPin != null && writePin != null);

            this.AddressPin = addressPin;
            this.DataOutPin = dataOutPin;
            this.DataInPin  = dataInPin;
            this.WritePin   = writePin;

            Tracer.Assert(addressPin.BitWidth == this.AddressBitWidth);
            Tracer.Assert(dataInPin.BitWidth == dataOutPin.BitWidth && dataOutPin.BitWidth == this.DataBitWidth);
            Tracer.Assert(writePin.BitWidth == 1);
        }
Esempio n. 11
0
        private void GenerateTriStatePins(Gate gate)
        {
            Tracer.Assert(gate.GateType == GateType.TriState1 || gate.GateType == GateType.TriState2);

            DevicePin pinX = this.CircuitProject.DevicePinSet.Create(gate, PinType.Input, 1);

            pinX.Name = Properties.Resources.PinInName;

            DevicePin pinE = this.CircuitProject.DevicePinSet.Create(gate, PinType.Input, 1);

            pinE.Name    = Properties.Resources.PinEnableName;
            pinE.PinSide = (gate.GateType == GateType.TriState1) ? PinSide.Bottom : PinSide.Top;

            DevicePin pin = this.CircuitProject.DevicePinSet.Create(gate, PinType.Output, 1);

            pin.Inverted = false;
            pin.Name     = Properties.Resources.PinOutName;
        }
Esempio n. 12
0
        private void CreatePins(Splitter splitter)
        {
            // The order of creation of the pins is essential for expansion algorithm (CircuitMap.Connect).
            // The wide pin should go first and then thin pins starting from lower bits to higher
            Tracer.Assert(!this.CircuitProject.DevicePinSet.SelectByCircuit(splitter).Any());
            if (splitter.PinCount < 2)
            {
                splitter.PinCount = 2;
            }
            if (splitter.BitWidth < splitter.PinCount)
            {
                splitter.BitWidth = splitter.PinCount;
            }
            DevicePin pin = this.CircuitProject.DevicePinSet.Create(splitter, PinType.None, splitter.BitWidth);

            pin.Name = Properties.Resources.SplitterWidePinName;
            PinSide pinSide;

            if (splitter.Clockwise)
            {
                pinSide     = PinSide.Right;
                pin.PinSide = PinSide.Left;
            }
            else
            {
                pinSide     = PinSide.Left;
                pin.PinSide = PinSide.Right;
            }
            int pinWidth = splitter.BitWidth / splitter.PinCount;
            int rem      = splitter.BitWidth % splitter.PinCount;

            for (int i = 0; i < rem; i++)
            {
                pin         = this.CircuitProject.DevicePinSet.Create(splitter, PinType.None, pinWidth + 1);
                pin.PinSide = pinSide;
                SplitterSet.SetName(pin, i * (pinWidth + 1), pinWidth + 1);
            }
            for (int i = rem; i < splitter.PinCount; i++)
            {
                pin         = this.CircuitProject.DevicePinSet.Create(splitter, PinType.None, pinWidth);
                pin.PinSide = pinSide;
                SplitterSet.SetName(pin, i * pinWidth + rem, pinWidth);
            }
        }
Esempio n. 13
0
 private void GeneratePins(Gate gate, int inputCount, bool invertedOutput)
 {
     if (inputCount == 1)
     {
         DevicePin pin = this.CircuitProject.DevicePinSet.Create(gate, PinType.Input, 1);
         pin.Name = Properties.Resources.PinInName;
     }
     else
     {
         for (int i = 0; i < inputCount; i++)
         {
             DevicePin pin = this.CircuitProject.DevicePinSet.Create(gate, PinType.Input, 1);
             pin.Name = Properties.Resources.PinName(Properties.Resources.PinInName, i + 1);
         }
     }
     if (GateSet.HasOutput(gate.GateType))
     {
         DevicePin pin = this.CircuitProject.DevicePinSet.Create(gate, PinType.Output, 1);
         pin.Inverted = invertedOutput;
         pin.Name     = Properties.Resources.PinOutName;
     }
 }
Esempio n. 14
0
        private void GenerateSevenSegmentIndicatorPins(Gate gate)
        {
            string prefix = "Led7Pin";
            int    name   = 1;

            for (int i = 0; i < 4; i++)
            {
                DevicePin pin = this.CircuitProject.DevicePinSet.Create(gate, PinType.Input, 1);
                pin.Name = Properties.Resources.ResourceManager.GetString(prefix + name);
                name++;
            }
            for (int i = 0; i < 3; i++)
            {
                DevicePin pin = this.CircuitProject.DevicePinSet.Create(gate, PinType.Input, 1);
                pin.Name    = Properties.Resources.ResourceManager.GetString(prefix + name);
                pin.PinSide = PinSide.Right;
                name++;
            }
            DevicePin pinDot = this.CircuitProject.DevicePinSet.Create(gate, PinType.Input, 1);

            pinDot.Name    = Properties.Resources.ResourceManager.GetString(prefix + name);
            pinDot.PinSide = PinSide.Right;
        }
Esempio n. 15
0
        private void CreateDevicePin(Constant constant)
        {
            DevicePin pin = this.CircuitProject.DevicePinSet.Create(constant, PinType.Output, constant.BitWidth);

            pin.PinSide = constant.PinSide;
        }
Esempio n. 16
0
        private void CreateDevicePin(Sensor sensor)
        {
            DevicePin pin = this.CircuitProject.DevicePinSet.Create(sensor, PinType.Output, sensor.BitWidth);

            pin.PinSide = sensor.PinSide;
        }
Esempio n. 17
0
        private void CreateDevicePin(Sound sound)
        {
            DevicePin pin = this.CircuitProject.DevicePinSet.Create(sound, PinType.Input, 1);

            pin.PinSide = sound.PinSide;
        }