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_BufferConnectedToOutputPort_RemoveBuffer() { var hostModule = CreateHostModule("test_module"); var builder = new InstanceBuilder(DummyNetlist, hostModule.Name); _instanceRepository.Add(builder.New("x_buf", "inst1").Add("i", "out").Add("o", "w4").Build()); _instanceRepository.Add(builder.New("an2", "inst2").Add("a", "w1").Add("b", "w2").Add("z", "out").Build()); _target.Remove(DummyNetlist, "x_buf", "i", "o"); var result = _instanceRepository.GetByModuleName(DummyNetlist, "x_buf").ToList(); Assert.That(result, Is.Empty); result = _instanceRepository.GetByModuleName(DummyNetlist, "an2").ToList(); Assert.That(result[0].Net, Has.Exactly(1).Matches <PortWirePair>(pwp => pwp.Port == "z" && pwp.Wire == "w4")); }
public void Remove_OneHostModule_RemoveOpenOutputInstances() { _netlistRepository.Add(new Netlist(DummyNetlist)); _moduleRepository.Add(new Module(DummyNetlist, "m1")); var instanceBuilder = new InstanceBuilder(DummyNetlist, "m1"); _instanceRepository.Add(instanceBuilder.New("an2", "inst1").Add("a", "w").Build()); _instanceRepository.Add(instanceBuilder.New("b1", "inst2").Add("a", "w1").Build()); _instanceRepository.Add(instanceBuilder.New("b1", "inst3").Add("a", "w1").Add("z", null).Build()); _instanceRepository.Add(instanceBuilder.New("b1", "inst4").Add("a", "w1").Add("z", "").Build()); _instanceRepository.Add(instanceBuilder.New("b1", "inst5").Add("a", "w1").Add("z", "w2").Build()); _target.Remove(DummyNetlist, "b1", "z"); var instances = _instanceRepository.GetBy(DummyNetlist).ToList(); Assert.That(instances, Has.Count.EqualTo(2)); Assert.That(instances, Has.Exactly(1).Matches <Instance>(i => i.InstanceName == "inst1")); Assert.That(instances, Has.Exactly(1).Matches <Instance>(i => i.InstanceName == "inst5")); }
public void BuildInstanceDeclaration_InstanceWithNet_BuildWithNet() { var instanceBuilder = new InstanceBuilder("netlist", "hostModule"); var instance = instanceBuilder.New("an2", "inst1").Add("a", "w1").Add("\\xc(f", "w2").Build(); _target.BuildInstanceDeclaration(instance); var result = _target.GetResult().Trim(); Assert.That(result, Is.EqualTo("an2 inst1 ( .a ( w1 ) , .\\xc(f ( w2 ) );")); }
public void Remove_ExtraModule_RemoveBufferAndNotRewireOutsideHostModule() { var hostModule = CreateHostModule("test_module"); var builder = new InstanceBuilder(DummyNetlist, hostModule.Name); _instanceRepository.Add(builder.New("x_buf", "inst1").Add("i", "i1").Add("o", "out").Build()); _instanceRepository.Add(builder.New("an2", "inst2").Add("a", "i1").Add("b", "w2").Add("z", "zout").Build()); var hostModule2 = CreateHostModule("test_module_2"); builder = new InstanceBuilder(DummyNetlist, hostModule2.Name); _instanceRepository.Add(builder.New("an2", "inst2").Add("a", "i1").Add("b", "w2").Add("z", "zout").Build()); _target.Remove(DummyNetlist, "x_buf", "i", "o"); var result = _instanceRepository.GetByHostModule(DummyNetlist, hostModule2.Name).ToList(); Assert.That(result, Has.Count.EqualTo(1)); Assert.That(result[0].Net, Has.Exactly(1).Matches <PortWirePair>(pwp => pwp.Port == "a" && pwp.Wire == "i1")); Assert.That(result[0].Net, Has.Exactly(1).Matches <PortWirePair>(pwp => pwp.Port == "b" && pwp.Wire == "w2")); Assert.That(result[0].Net, Has.Exactly(1).Matches <PortWirePair>(pwp => pwp.Port == "z" && pwp.Wire == "zout")); }
public void Remove_NetlistMoreThanOneHostModule_RemoveFromAllHostModules() { _netlistRepository.Add(new Netlist(DummyNetlist)); _moduleRepository.Add(new Module(DummyNetlist, "m1")); _moduleRepository.Add(new Module(DummyNetlist, "m2")); var instanceBuilder = new InstanceBuilder(DummyNetlist, "m1"); _instanceRepository.Add(instanceBuilder.New("b1", "inst2").Add("a", "w1").Build()); instanceBuilder = new InstanceBuilder(DummyNetlist, "m2"); _instanceRepository.Add(instanceBuilder.New("b1", "inst4").Add("a", "w1").Add("z", "").Build()); _target.Remove(DummyNetlist, "b1", "z"); var instances = _instanceRepository.GetBy(DummyNetlist).ToList(); Assert.That(instances, Is.Empty); }