public override void visit(Component obj) { DesignEntity de = obj; CodeGenerator.Logger.WriteDebug( "SpiceVisitor::visit({0})", obj.Name); // create a signal container for this component var siginfo_obj = new Spice.SignalContainer() { name = de.Name, gmeid = de.Impl.ID }; ObjectSiginfoMap.Add(de, siginfo_obj); var siginfo_parent = this.siginfo_obj; if (de.Parent != null && ObjectSiginfoMap.ContainsKey(de.Parent)) { siginfo_parent = ObjectSiginfoMap[de.Parent] as Spice.SignalContainer; } siginfo_parent.signals.Add(siginfo_obj); var spiceObjs = obj.Impl.Children.SPICEModelCollection; var spiceObj = CyPhyBuildVisitor.GetSpiceModel(obj, spiceObjs); if (spiceObj == null) // no spice model in this component, skip from generating { return; } GenerateSpice(de, spiceObj); }
private void GenerateSpiceCode(TestBench TestBench_obj) { var circuit = new Spice.Circuit() { name = TestBench_obj.Name }; var siginfo = new Spice.SignalContainer() { name = TestBench_obj.Name, objectToNetId = new Dictionary <CyPhy2SchematicInterpreter.IDs, string>() }; // now traverse the object network with Spice Visitor to build the spice and siginfo object network TestBench_obj.accept(new SpiceVisitor(Traceability, mgaIdToDomainIDs, this) { circuit_obj = circuit, siginfo_obj = siginfo, mode = this.mode }); String spiceTemplateFile = Path.Combine(this.mainParameters.OutputDirectory, "schema.cir.template"); circuit.Serialize(spiceTemplateFile); String siginfoFile = Path.Combine(this.mainParameters.OutputDirectory, "siginfo.json"); siginfo.Serialize(siginfoFile); }
public override void visit(Component obj) { CodeGenerator.Logger.WriteDebug( "SpiceVisitor::visit({0})", obj.Name); // create a signal container for this component var siginfo_obj = new Spice.SignalContainer() { name = obj.Name, gmeid = obj.Impl.ID }; ObjectSiginfoMap.Add(obj, siginfo_obj); var siginfo_parent = this.siginfo_obj; if (obj.Parent != null && ObjectSiginfoMap.ContainsKey(obj.Parent)) { siginfo_parent = ObjectSiginfoMap[obj.Parent] as Spice.SignalContainer; } siginfo_parent.signals.Add(siginfo_obj); var nodes = circuit_obj.nodes; var spiceObj = obj.Impl.Children.SPICEModelCollection.FirstOrDefault(); if (spiceObj == null) // no spice model in this component, skip from generating { return; } var spiceType = GetSpiceType(obj); if (Grounds.Any(spiceType.Item2.Contains)) // is a ground node skip it { return; } var node = new Spice.Node(); node.name = obj.Name; node.type = spiceType.Item1; node.classType = spiceType.Item2; // error checking if (node.type == (char)0) { CodeGenerator.Logger.WriteWarning("Missing Spice Type for component {0}", obj.Name); } if (node.type == 'X' && node.classType == "") { CodeGenerator.Logger.WriteWarning("Missing Subcircuit Type for component {0}, should be X.<subckt-type>", obj.Name); } if (node.classType != "" && !circuit_obj.subcircuits.ContainsKey(node.classType)) { circuit_obj.subcircuits.Add(node.classType, obj.SpiceLib); } foreach (var par in spiceObj.Children.SPICEModelParameterCollection) { if (node.parameters.ContainsKey(par.Name)) { CodeGenerator.Logger.WriteError("Duplicate Parameter: {0}: in Component <a href=\"mga:{2}\">{1}</a>", par.Name, obj.Name, obj.Impl.ID); } else { node.parameters.Add(par.Name, par.Attributes.Value); } } nodes.Add(node); ComponentNodeMap[obj] = node; }
public override void visit(ComponentAssembly obj) { CodeGenerator.Logger.WriteDebug( "SpiceVisitor::visit({0})", obj.Name); // create a signal container for this assembly var siginfo_obj = new Spice.SignalContainer() { name = obj.Name, gmeid = obj.Impl.ID }; ObjectSiginfoMap.Add(obj, siginfo_obj); var siginfo_parent = this.siginfo_obj; if (obj.Parent != null && ObjectSiginfoMap.ContainsKey(obj.Parent)) { siginfo_parent = ObjectSiginfoMap[obj.Parent] as Spice.SignalContainer; } siginfo_parent.signals.Add(siginfo_obj); }
private void GenerateSpiceCode(TestBench TestBench_obj) { var circuit = new Spice.Circuit() { name = TestBench_obj.Name }; var siginfo = new Spice.SignalContainer() { name = TestBench_obj.Name }; // now traverse the object network with Spice Visitor to build the spice and siginfo object network TestBench_obj.accept(new SpiceVisitor() { circuit_obj = circuit, siginfo_obj = siginfo, mode = this.mode }); String spiceFile = Path.Combine(this.mainParameters.OutputDirectory, "schema.cir"); circuit.Serialize(spiceFile); String siginfoFile = Path.Combine(this.mainParameters.OutputDirectory, "siginfo.json"); siginfo.Serialize(siginfoFile); }