public void Clone_SourceNetlistExists_Clone() { _netlistRepository.Add(new Netlist(DummyNetlist)); _moduleRepository.Add(new Module(DummyNetlist, "m1")); _moduleRepository.Add(new Module(DummyNetlist, "m2")); _instanceRepository.Add(new Instance(DummyNetlist, "m1", "an2", "inst1")); _instanceRepository.Add(new Instance(DummyNetlist, "m1", "an2", "inst2")); _instanceRepository.Add(new Instance(DummyNetlist, "m2", "an3", "inst3")); _target.Clone(DummyNetlist, NewDummyNetlist); var netlist = _netlistRepository.Get(NewDummyNetlist); Assert.That(netlist, Is.Not.Null); var modules = _moduleRepository.GetAll(NewDummyNetlist).ToList(); Assert.That(modules, Has.Count.EqualTo(2)); Assert.That(modules, Has.Exactly(1).Matches <Module>(m => m.Name == "m1")); Assert.That(modules, Has.Exactly(1).Matches <Module>(m => m.Name == "m2")); var instances = _instanceRepository.GetBy(NewDummyNetlist).ToList(); Assert.That(instances, Has.Exactly(1).Matches <Instance>(i => i.InstanceName == "inst1")); Assert.That(instances, Has.Exactly(1).Matches <Instance>(i => i.InstanceName == "inst2")); Assert.That(instances, Has.Exactly(1).Matches <Instance>(i => i.InstanceName == "inst3")); }
public void Clone(string source, string newSource) { var netlist = _netlistRepository.Get(source); if (netlist == null) { throw new InvalidOperationException("source netlist does not exists"); } if (source == newSource) { return; } _netlistRemover.Remove(newSource); netlist.Source = newSource; _netlistRepository.Add(netlist); foreach (var module in _moduleRepository.GetAll(source)) { module.Netlist = newSource; _moduleRepository.Add(module); } foreach (var instance in _instanceRepository.GetBy(source)) { instance.Netlist = newSource; _instanceRepository.Add(instance); } }
public void Build(string source) { if (_netlistRepository.Exists(source)) { return; } var netlistFileReader = _netlistFileReaderProvider.GetReaderFor(source); var buildState = new BuildState { NetlistSource = source }; try { _netlistRepository.Add(new Netlist(source)); while ((buildState.CurrentStatementTrimmed = netlistFileReader.ReadTrimmedStatement()) != null) { _statementHandlersInvoker.Handle(buildState); } } catch (Exception e) { throw e; } finally { netlistFileReader.Close(); } _instancesTypeUpdater.UpdateInstancesType(source); }
public void SetUp() { _netlistRepository = Get <INetlistRepository>(); _moduleRepository = Get <IModuleRepository>(); _instanceRepository = Get <IInstanceRepository>(); _netlistRemover = Get <INetlistRemover>(); _target = Get <IBufferRemover>(); _netlistRepository.Add(new Netlist(DummyNetlist)); }
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 PortsToUpper_BothLibraryGatesAndNonLibraryGatesInstances_UppercasePortsOnlyForLibraryGatesInstances() { _netlistRepository.Add(new Netlist(DummyNetlist)); _moduleRepository.Add(new Module(DummyNetlist, "m1")); _moduleRepository.Add(new Module(DummyNetlist, "m2")); _instanceRepository.Add(new InstanceBuilder(DummyNetlist, "m1").New("an2", "inst1").Add("a", "w").Build()); _instanceRepository.Add(new InstanceBuilder(DummyNetlist, "m1").New("some-non-library-gate", "inst2", InstanceType.Module).Add("b", "w").Build()); _instanceRepository.Add(new InstanceBuilder(DummyNetlist, "m2").New("an2", "inst3").Add("c", "w").Build()); _target.PortsToUpper(DummyNetlist); var instances = _instanceRepository.GetBy(DummyNetlist).ToList(); Assert.That(instances, Has.Exactly(1).Matches <Instance>(i => i.InstanceName == "inst1" && i.Net[0].Port == "A")); Assert.That(instances, Has.Exactly(1).Matches <Instance>(i => i.InstanceName == "inst2" && i.Net[0].Port == "b")); Assert.That(instances, Has.Exactly(1).Matches <Instance>(i => i.InstanceName == "inst3" && i.Net[0].Port == "C")); }