示例#1
0
        public void Remove_BufferIsPassThroughBuffer_NotRemoveBuffer()
        {
            var hostModule = CreateHostModule("test_module");
            var builder    = new InstanceBuilder(DummyNetlist, hostModule.Name);

            _instanceRepository.Add(builder.New("x_buf", "inst1").Add("i", "w1").Add("o", "w5").Build());
            _instanceRepository.Add(builder.New("an2", "inst2").Add("a", "w3").Add("b", "w2").Add("z", "w4").Build());

            _target.Remove(DummyNetlist, "x_buf", "i", "o");

            var result = _instanceRepository.GetByModuleName(DummyNetlist, "x_buf");

            Assert.That(result, Has.Exactly(1).Matches <Instance>(i => i.InstanceName == "inst1"));
        }
        public void Remove(string netlist, string moduleName, string outputPort)
        {
            var instances = _instanceRepository.GetByModuleName(netlist, moduleName);

            foreach (var instance in instances)
            {
                if (instance.GetWire(outputPort).IsNullOrEmpty())
                {
                    _instanceRepository.Remove(instance);
                }
            }
        }
        public void Replace(string netlist, string gateToReplace, string newGate, PortsMapping portsMapping)
        {
            if (_moduleRepository.Exists(netlist, gateToReplace))
            {
                throw new InvalidOperationException("can replace only library gates");
            }

            var instances = _instanceRepository.GetByModuleName(netlist, gateToReplace);

            _instanceMutator.Take(instances)
            .MutateModuleName(newGate)
            .ReplacePorts(portsMapping);

            _instanceRepository.UpdateMany(instances);
        }
示例#4
0
        public void Replace_LibraryGateWithoutMapping_ReplaceLibraryGate()
        {
            // oai22 inst056453  ( .b2(n37), .b1(i3), .a2(n36), .a1(i1), .zn(o) );
            const string moduleToReplace = "oai22";
            const string newModule       = "oai22new";

            _target.Replace(DummyNetlist, moduleToReplace, newModule, new PortsMapping());

            var result = _instanceRepository.GetByModuleName(DummyNetlist, moduleToReplace).ToList();

            Assert.That(result, Is.Empty);

            result = _instanceRepository.GetByModuleName(DummyNetlist, newModule).ToList();
            Assert.That(result, Has.Count.EqualTo(1));
            Assert.That(result[0].Net, Has.Exactly(1).Matches <PortWirePair>(pwp => pwp.Port == "b2" & pwp.Wire == "n37"));
            Assert.That(result[0].Net, Has.Exactly(1).Matches <PortWirePair>(pwp => pwp.Port == "b1" & pwp.Wire == "i3"));
            Assert.That(result[0].Net, Has.Exactly(1).Matches <PortWirePair>(pwp => pwp.Port == "a2" & pwp.Wire == "n36"));
            Assert.That(result[0].Net, Has.Exactly(1).Matches <PortWirePair>(pwp => pwp.Port == "a1" & pwp.Wire == "i1"));
            Assert.That(result[0].Net, Has.Exactly(1).Matches <PortWirePair>(pwp => pwp.Port == "zn" & pwp.Wire == "o"));
        }