PageRenderTime 56ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/Backup/Component.cs

#
C# | 806 lines | 623 code | 124 blank | 59 comment | 65 complexity | ff033fca2c8005f73a09f6fd3e8bc73b MD5 | raw file
  1. using System;
  2. namespace RapidHDL
  3. {
  4. /// <summary>
  5. /// Summary description for Component.
  6. /// </summary>
  7. public class Component
  8. {
  9. Component oParentComponent;
  10. int iHirarchyLevel;
  11. string sComponentTypeId;
  12. RapidHardware oRapidHardware;
  13. string sName;
  14. double dCombinationalDelay;
  15. System.Collections.Hashtable oNodeVectors;
  16. System.Collections.Hashtable oComponents;
  17. System.Collections.Hashtable oSinkNodeVectors;
  18. System.Collections.Hashtable oSourceNodeVectors;
  19. System.Collections.Hashtable oPassThroughNodeVectors;
  20. internal System.Collections.ArrayList InputNodeVectors;
  21. internal System.Collections.ArrayList OutputNodeVectors;
  22. internal System.Collections.ArrayList ConnectionOnlyNodeVectors;
  23. internal System.Collections.ArrayList RedundantNodeVectors;
  24. SimulationState eSimulationStateOutput;
  25. ComponentVerilog oComponentVerilog;
  26. EventNode oEventNodeStabilize;
  27. protected bool IsComponentWellFormed;
  28. protected bool IsComponentCheckingForWellFormed;
  29. bool bRegisteredComponent;
  30. public Component(Component poParentComponent, string psName)
  31. {
  32. Initialize();
  33. oParentComponent = poParentComponent;
  34. oRapidHardware = oParentComponent.RapidHardware;
  35. sName = psName;
  36. oParentComponent.Components.Add(psName,this);
  37. iHirarchyLevel = oParentComponent.HirarchyLevel + 1;
  38. }
  39. public Component(RapidHardware poRapidHardware, string psName)
  40. {
  41. Initialize();
  42. oRapidHardware = poRapidHardware;
  43. sName = psName;
  44. oParentComponent = null;
  45. iHirarchyLevel = 1;
  46. }
  47. private void Initialize()
  48. {
  49. dCombinationalDelay = 0;
  50. oNodeVectors = new System.Collections.Hashtable();
  51. oComponents = new System.Collections.Hashtable();
  52. oSinkNodeVectors = new System.Collections.Hashtable();
  53. oSourceNodeVectors = new System.Collections.Hashtable();
  54. oPassThroughNodeVectors = new System.Collections.Hashtable();
  55. oComponentVerilog = new ComponentVerilog(this);
  56. eSimulationStateOutput = SimulationState.Stable;
  57. bRegisteredComponent = false;
  58. IsComponentWellFormed = false;
  59. IsComponentCheckingForWellFormed = false;
  60. sComponentTypeId = this.GetType().ToString();
  61. sComponentTypeId = sComponentTypeId.Replace(".","");
  62. }
  63. public NodeVector CreateNodeVector(string psName, int piSize)
  64. {
  65. return new NodeVector(this,psName, piSize);
  66. }
  67. public NodeVector CreateNodeVector(string psName, int piSize, NodeFlowType peNodeFlowType)
  68. {
  69. return new NodeVector(this,psName, piSize,peNodeFlowType);
  70. }
  71. public virtual string GenerateVerilog()
  72. {
  73. return "";
  74. }
  75. public double CombinationalDelay
  76. {
  77. get{return dCombinationalDelay;}
  78. set{dCombinationalDelay = value;}
  79. }
  80. public SimulationState SimulationStateInput
  81. {
  82. get
  83. {
  84. foreach(NodeVector oNodeVector in oSinkNodeVectors.Values)
  85. {
  86. foreach(Node oNode in oNodeVector.Nodes)
  87. {
  88. if (oNode.Net.SimulationStateOutput == SimulationState.Unstable)
  89. {
  90. SimulationTraceLog("This component's input node is unstable",oNode);
  91. return SimulationState.Unstable;
  92. }
  93. }
  94. }
  95. SimulationTraceLog("This component's inputs are stable",null);
  96. return SimulationState.Stable;
  97. }
  98. }
  99. public SimulationState SimulationStateOutput
  100. {
  101. get{return eSimulationStateOutput;}
  102. }
  103. public RapidHardware RapidHardware
  104. {
  105. get{return oRapidHardware;}
  106. }
  107. public System.Collections.Hashtable NodeVectors
  108. {
  109. get {return oNodeVectors;}
  110. }
  111. public System.Collections.Hashtable SinkNodeVectors
  112. {
  113. get {return oSinkNodeVectors;}
  114. }
  115. public System.Collections.Hashtable SourceNodeVectors
  116. {
  117. get {return oSourceNodeVectors;}
  118. }
  119. public System.Collections.Hashtable PassthroughNodeVectors
  120. {
  121. get {return oPassThroughNodeVectors;}
  122. }
  123. public ComponentVerilog ComponentVerilog
  124. {
  125. get {return oComponentVerilog;}
  126. }
  127. public int HirarchyLevel
  128. {
  129. get {return iHirarchyLevel;}
  130. }
  131. public virtual bool RegisteredComponent
  132. {
  133. get {return bRegisteredComponent;}
  134. }
  135. public System.Collections.Hashtable Components
  136. {
  137. get {return oComponents;}
  138. }
  139. public string Name
  140. {
  141. get{return sName;}
  142. }
  143. public string HirarchicalName
  144. {
  145. get
  146. {
  147. if (oParentComponent == null)
  148. return Name;
  149. else
  150. return oParentComponent.HirarchicalName + "." + Name;
  151. }
  152. }
  153. public virtual void GenerateStructure()
  154. {
  155. }
  156. public void BaseGenerateStructure()
  157. {
  158. GenerateStructure();
  159. foreach(Component oComponent in oComponents.Values)
  160. {
  161. oComponent.BaseGenerateStructure();
  162. }
  163. }
  164. public void SimulationDestabilizeComponent()
  165. {
  166. // if component output is already unstable...
  167. // we only need to cancel any scheduled stabilization event
  168. if (eSimulationStateOutput == SimulationState.Unstable)
  169. {
  170. SimulationTraceLog("SimulationDestabilizeComponent already unstable",null);
  171. // cancel stabilization event
  172. if (oEventNodeStabilize != null)
  173. oRapidHardware.Simulation.Clock.UnlinkNode(oEventNodeStabilize);
  174. oEventNodeStabilize = null;
  175. return;
  176. }
  177. SimulationTraceLog("SimulationDestabilizeComponent NOT already unstable",null);
  178. // otherwise, we were a stable component
  179. // we need to alert nets driven by compoenet
  180. // that the net inputs are now unstable
  181. eSimulationStateOutput = SimulationState.Unstable;
  182. foreach(NodeVector oNodeVector in oSourceNodeVectors.Values)
  183. {
  184. int i = 1;
  185. foreach(Node oNode in oNodeVector.Nodes)
  186. {
  187. SimulationTraceLog("Destabilize Node Net, loop " + i.ToString() + " of " + oNodeVectors.Count.ToString() ,oNode);
  188. oNode.Net.SimulationDestabilizeNet();
  189. }
  190. }
  191. }
  192. public void SimulationStabilizeComponent()
  193. {
  194. SimulationTraceLog("SimulationStabilizeComponent",null);
  195. // should never call this when node is already stable
  196. System.Diagnostics.Debug.Assert(eSimulationStateOutput != SimulationState.Stable);
  197. // check to see if the inputs are all stable
  198. if (this.SimulationStateInput != SimulationState.Stable)
  199. {
  200. return; // unstable inputs mean unstable net
  201. }
  202. // if there is no propagation delay, immediately stabilize output too
  203. // but, if there is a propagation delay, schedule stabilization event on clock
  204. if (dCombinationalDelay == 0)
  205. {
  206. SimulationTraceLog("Stabilization With No Combinational Delay",null);
  207. SimulationStabilizeComponentOutputEvent(0);
  208. }
  209. else
  210. {
  211. SimulationTraceLog("Schedule Stabilization AFTER Combinational Delay",null);
  212. if (oEventNodeStabilize != null)
  213. oRapidHardware.Simulation.Clock.UnlinkNode(oEventNodeStabilize);
  214. oEventNodeStabilize = oRapidHardware.Simulation.Clock.ScheduleClockEvent(dCombinationalDelay,new Clock.ClockEvent(this.SimulationStabilizeComponentOutputEvent));
  215. }
  216. }
  217. public virtual void CalculateOutput()
  218. {
  219. }
  220. private void BaseCalculateOutput()
  221. {
  222. foreach(NodeVector oNodeVector in oSourceNodeVectors.Values)
  223. {
  224. SimulationTraceLog("Start CalcluateOutput {" + oNodeVector.Name + " = '" + oNodeVector.NodeVectorAsString + "'}",null);
  225. }
  226. CalculateOutput();
  227. foreach(NodeVector oNodeVector in oSourceNodeVectors.Values)
  228. {
  229. SimulationTraceLog("Finished CalcluateOutput {" + oNodeVector.Name + " = '" + oNodeVector.NodeVectorAsString + "'}",null);
  230. }
  231. }
  232. public void SimulationStabilizeComponentOutputEvent(long plTimeNow)
  233. {
  234. SimulationTraceLog("SimulationSabilizeComponentOutputEvent at time " + plTimeNow.ToString() + "/" + oRapidHardware.Simulation.Clock.TimeNow.ToString() ,null);
  235. // if this happens, there is a fundamental scheduling problem
  236. System.Diagnostics.Debug.Assert((oEventNodeStabilize == null & plTimeNow == 0 | plTimeNow != 0),"Phantom EventNodeStabilize event scheduled in component!");
  237. // should never call this event if node is already stable
  238. System.Diagnostics.Debug.Assert(eSimulationStateOutput != SimulationState.Stable,"Net stabilization event called when compoent is already stable!");
  239. BaseCalculateOutput();
  240. SimulationTraceLog("Output state marked stable",null);
  241. eSimulationStateOutput = SimulationState.Stable;
  242. foreach(NodeVector oNodeVector in oSourceNodeVectors.Values)
  243. {
  244. int i = 1;
  245. foreach(Node oNode in oNodeVector.Nodes)
  246. {
  247. SimulationTraceLog("Stabilize Node's Net, loop " + i.ToString() + " of " + oNodeVectors.Count.ToString() ,oNode);
  248. oNode.Net.SimulationStabilizeNet();
  249. i++;
  250. }
  251. }
  252. }
  253. protected virtual Component TestBuildStructure(Component poTopComponent, string psTestName)
  254. {
  255. return null;
  256. }
  257. protected virtual string TestComponent(Clock poClock, Component poTestComponent, string psTestName)
  258. {
  259. return "";
  260. }
  261. public string BaseTestComponent(RapidHardware poRapidHardware, string psTestName)
  262. {
  263. string sResult;
  264. poRapidHardware.Simulation.Clock.Reset();
  265. Component oComponent = TestBuildStructure(poRapidHardware.Structure.TopLevelComponent,psTestName);
  266. if (oComponent == null)
  267. return "";
  268. oComponent.BaseGenerateStructure();
  269. if (!oComponent.SortStructure())
  270. return "";
  271. if (!oComponent.ValidateWellFormedComponent())
  272. return "";
  273. sResult = TestComponent(poRapidHardware.Simulation.Clock,oComponent,psTestName);
  274. poRapidHardware.Structure.TopLevelComponent.Components.Remove(oComponent.Name);
  275. return sResult;
  276. }
  277. private void SimulationTraceLog(string psLogEntry, Node poNode)
  278. {
  279. string sLogEntry = "Component: {" + this.HirarchicalName + "}";
  280. if (poNode != null)
  281. sLogEntry += " {Node: " + poNode.Name + " = '" + poNode.NodeState.ToString() + "'}";
  282. sLogEntry += " " + psLogEntry;
  283. oRapidHardware.InternalLog.Log(LogType.SimulationTrace,sLogEntry);
  284. }
  285. public virtual bool TransformStructureToVerilog()
  286. {
  287. ComponentVerilog.VerilogTraceLog("No override of TransforStructureToVerilog in derrived component");
  288. ComponentVerilog.WriteVerilogText("// Component Did Not Write Any Custom Verilog");
  289. return true;
  290. }
  291. internal Component ParentComponent
  292. {
  293. get{return oParentComponent;}
  294. }
  295. public bool BaseTransformStructureToVerilog()
  296. {
  297. foreach(Component oComponent in oComponents.Values)
  298. {
  299. if (!oComponent.BaseTransformStructureToVerilog())
  300. return false;
  301. }
  302. oComponentVerilog.VerilogTraceLog("Starting VerilogTransform");
  303. return oComponentVerilog.TransformStructureToVerilog();
  304. }
  305. public bool IsTestComponentSameOrChild(Component poTestComponent)
  306. {
  307. int iTestHirarchyLevel;
  308. Component oTestParentComponent;
  309. iTestHirarchyLevel = poTestComponent.HirarchyLevel;
  310. oTestParentComponent = poTestComponent;
  311. while(iTestHirarchyLevel > iHirarchyLevel)
  312. {
  313. iTestHirarchyLevel--;
  314. oTestParentComponent = oTestParentComponent.ParentComponent;
  315. }
  316. return (oTestParentComponent == this);
  317. }
  318. public ComponentRelationship GetComponentRelationship(Component poComponent)
  319. {
  320. ComponentRelationship eComponentRelationship;
  321. if(poComponent == this)
  322. return ComponentRelationship.ThisComponent;
  323. if (poComponent.HirarchyLevel == this.HirarchyLevel)
  324. {
  325. return ComponentRelationship.CousinComponent;
  326. }
  327. if (poComponent.HirarchyLevel > this.HirarchyLevel)
  328. {
  329. eComponentRelationship = poComponent.GetComponentRelationship(this.ParentComponent);
  330. if (eComponentRelationship == ComponentRelationship.ThisComponent)
  331. return ComponentRelationship.ChildComponent;
  332. else
  333. return ComponentRelationship.CousinComponent;
  334. }
  335. else
  336. {
  337. eComponentRelationship = this.GetComponentRelationship(poComponent.ParentComponent);
  338. if (eComponentRelationship == ComponentRelationship.ThisComponent)
  339. return ComponentRelationship.ParentComponent;
  340. else
  341. return ComponentRelationship.CousinComponent;
  342. }
  343. }
  344. internal bool SortStructure()
  345. {
  346. bool bIsNodeFloating;
  347. // necessary
  348. // sort node vectors based on flow type
  349. foreach(NodeVector oNodeVector in oNodeVectors.Values)
  350. {
  351. if(oNodeVector.NodeFlowType == NodeFlowType.Source)
  352. {
  353. oSourceNodeVectors.Add(oNodeVector.Name,oNodeVector);
  354. }
  355. else
  356. {
  357. if(oNodeVector.NodeFlowType == NodeFlowType.Sink)
  358. {
  359. oSinkNodeVectors.Add(oNodeVector.Name,oNodeVector);
  360. // check for floating sink nodes
  361. // floating node is one without a source
  362. // and that doesn't flow to level 2 of hirarchy
  363. foreach(Node oNode in oNodeVector.Nodes)
  364. {
  365. if (oNode.Net.SourceNodes.Count == 0)
  366. {
  367. if(oNode.ParentNodeVector.ParentComponent.HirarchyLevel > 2)
  368. {
  369. bIsNodeFloating = true;
  370. foreach(Node oPassNode in oNode.Net.PassthroughNodes)
  371. {
  372. if(oPassNode.ParentNodeVector.ParentComponent.HirarchyLevel <= 2)
  373. {
  374. bIsNodeFloating = false;
  375. continue;
  376. }
  377. }
  378. if (bIsNodeFloating)
  379. {
  380. System.Diagnostics.Debug.Fail("Sink Node " + oNode.HirarchicalName + " is floating, with no source.");
  381. return false;
  382. }
  383. }
  384. }
  385. }
  386. }
  387. else
  388. {
  389. oPassThroughNodeVectors.Add(oNodeVector.Name,oNodeVector);
  390. // check for floating passthrough nodes
  391. // should have a sink or soruce, at least
  392. foreach(Node oNode in oNodeVector.Nodes)
  393. {
  394. if (oNode.Net.SinkNodes.Count == 0 && oNode.Net.SourceNodes.Count == 0)
  395. {
  396. System.Diagnostics.Debug.Fail("Sink Node " + oNode.HirarchicalName + " is floating, with no source or sink.");
  397. return false;
  398. }
  399. }
  400. }
  401. }
  402. }
  403. foreach(Component oComponent in oComponents.Values)
  404. {
  405. if (oComponent.SortStructure() == false)
  406. return false;
  407. }
  408. return true;
  409. }
  410. public bool ValidateWellFormedComponent()
  411. {
  412. foreach(Component oComponent in oComponents.Values)
  413. {
  414. oComponent.ValidateWellFormedComponent();
  415. }
  416. return RecurseCheckWellFormedComponent();
  417. // loop to the bottom of the component hirarchy
  418. // and trace paths in each component
  419. }
  420. protected bool RecurseCheckWellFormedComponent()
  421. {
  422. if (IsComponentCheckingForWellFormed)
  423. {
  424. System.Diagnostics.Debug.Fail(this.HirarchicalName + " is not in a wellformed configuration.");
  425. return false;
  426. }
  427. if (IsComponentWellFormed)
  428. return true;
  429. IsComponentCheckingForWellFormed = true;
  430. foreach(NodeVector oNodeVector in oSourceNodeVectors.Values)
  431. {
  432. foreach(Node oNode in oNodeVector.Nodes)
  433. {
  434. foreach(Node oSinkNode in oNode.Net.SinkNodes)
  435. {
  436. Component oComponent = oSinkNode.ParentNodeVector.ParentComponent;
  437. if (oComponent.RegisteredComponent == false)
  438. {
  439. if (oComponent.RecurseCheckWellFormedComponent() == false)
  440. return false;
  441. }
  442. }
  443. }
  444. }
  445. IsComponentCheckingForWellFormed = false;
  446. return true;
  447. }
  448. public string ComponentTypeId
  449. {
  450. get
  451. {
  452. return sComponentTypeId;
  453. }
  454. set{sComponentTypeId = value;}
  455. }
  456. public void PrepareVerilogStructure()
  457. {
  458. foreach(Component oComponent in oComponents.Values)
  459. {
  460. oComponent.PrepareVerilogStructure();
  461. SpliceConnectingVectors(oComponent);
  462. }
  463. ComponentVerilog.VerilogTraceLog("************* Start Preperation of Verilog Structure ***************");
  464. InputNodeVectors = new System.Collections.ArrayList();
  465. OutputNodeVectors = new System.Collections.ArrayList();
  466. ConnectionOnlyNodeVectors = new System.Collections.ArrayList();
  467. RedundantNodeVectors = new System.Collections.ArrayList();
  468. foreach(NodeVector oNodeVector in oSourceNodeVectors.Values)
  469. {
  470. StructureNodeVector(oNodeVector);
  471. }
  472. foreach(NodeVector oNodeVector in oSinkNodeVectors.Values)
  473. {
  474. StructureNodeVector(oNodeVector);
  475. }
  476. foreach(NodeVector oNodeVector in oPassThroughNodeVectors.Values)
  477. {
  478. StructureNodeVector(oNodeVector);
  479. }
  480. ComponentVerilog.VerilogTraceLog("************* End Preperation of Verilog Structure ***************");
  481. }
  482. private void SpliceConnectingVectors(Component poComponent)
  483. {
  484. string sNodeVectorName;
  485. NodeVector oNewNodeVector;
  486. System.Collections.ArrayList oComponentLevelNetNodes;
  487. ComponentVerilog.VerilogTraceLog("----- Start Splice In of Any Needed Routing Nodes --------");
  488. foreach(NodeVector oNodeVector in poComponent.InputNodeVectors)
  489. {
  490. // scan the nodes in the vector
  491. // and make sure that it is connected to a node in the parent
  492. // if not connected, then duplicate the entire vector in the parent and continue
  493. foreach(Node oNode in oNodeVector.Nodes)
  494. {
  495. oComponentLevelNetNodes = oNode.Net.SelectNodes(this);
  496. if (oComponentLevelNetNodes.Count == 0)
  497. {
  498. ComponentVerilog.VerilogTraceLog("Child input node has no counterpart in parent",oNode);
  499. sNodeVectorName = GetUniqueNodeVectorName(poComponent.Name + "_" + oNodeVector.Name);
  500. oNewNodeVector = CreateNodeVector(sNodeVectorName,oNodeVector.Size);
  501. oNewNodeVector.Nodes = oNodeVector.Nodes;
  502. oPassThroughNodeVectors.Add(oNewNodeVector.Name,oNewNodeVector);
  503. ComponentVerilog.VerilogTraceLog("created new vector to link with node",oNewNodeVector,oNode);
  504. break;
  505. }
  506. }
  507. }
  508. foreach(NodeVector oNodeVector in poComponent.OutputNodeVectors)
  509. {
  510. foreach(Node oNode in oNodeVector.Nodes)
  511. {
  512. oComponentLevelNetNodes = oNode.Net.SelectNodes(this);
  513. if (oComponentLevelNetNodes.Count == 0)
  514. {
  515. ComponentVerilog.VerilogTraceLog("Child output node has no counterpart in parent",oNode);
  516. sNodeVectorName = GetUniqueNodeVectorName(poComponent.Name + "_" + oNodeVector.Name);
  517. oNewNodeVector = CreateNodeVector(sNodeVectorName,oNodeVector.Size);
  518. oPassThroughNodeVectors.Add(oNewNodeVector.Name,oNewNodeVector);
  519. oNewNodeVector.Nodes = oNodeVector.Nodes;
  520. ComponentVerilog.VerilogTraceLog("Created new vector to link with node.",oNewNodeVector,oNode);
  521. break;
  522. }
  523. }
  524. }
  525. ComponentVerilog.VerilogTraceLog("----- End Splice In of Any Needed Routing Nodes --------");
  526. }
  527. private void StructureNodeVector(NodeVector poNodeVector)
  528. {
  529. NodeStructure eNodeStructure;
  530. eNodeStructure = poNodeVector.OrganizeNodeStructure();
  531. switch(eNodeStructure)
  532. {
  533. case NodeStructure.Connection:
  534. ComponentVerilog.VerilogTraceLog("NodeVector classified as Connection",poNodeVector);
  535. ConnectionOnlyNodeVectors.Add(poNodeVector);
  536. break;
  537. case NodeStructure.Input:
  538. ComponentVerilog.VerilogTraceLog("NodeVector classified as Input",poNodeVector);
  539. InputNodeVectors.Add(poNodeVector);
  540. break;
  541. case NodeStructure.Output:
  542. ComponentVerilog.VerilogTraceLog("NodeVector classified as Output",poNodeVector);
  543. OutputNodeVectors.Add(poNodeVector);
  544. break;
  545. case NodeStructure.Redundant:
  546. ComponentVerilog.VerilogTraceLog("NodeVector classified as Redundant",poNodeVector);
  547. RedundantNodeVectors.Add(poNodeVector);
  548. break;
  549. case NodeStructure.Mixed:
  550. ComponentVerilog.VerilogTraceLog("NodeVector classified as Mixed... Splitting",poNodeVector);
  551. SplitMixedNodeVector(poNodeVector);
  552. break;
  553. }
  554. }
  555. private void SplitMixedNodeVector(NodeVector poNodeVector)
  556. {
  557. Node oTempNode;
  558. int iConnectionNodes = 0;
  559. int iOutputNodes = 0;
  560. int iInputNodes = 0;
  561. string sNodeVectorName;
  562. NodeVector oConnectionNodeVector = null;
  563. NodeVector oInputNodeVector = null;
  564. NodeVector oOutputNodeVector = null;
  565. foreach(Node oNode in poNodeVector.Nodes)
  566. {
  567. switch(oNode.NodeStructure)
  568. {
  569. case NodeStructure.Connection:
  570. iConnectionNodes++;
  571. break;
  572. case NodeStructure.Input:
  573. iInputNodes++;
  574. break;
  575. case NodeStructure.Output:
  576. iOutputNodes++;
  577. break;
  578. }
  579. }
  580. if (iConnectionNodes > 0)
  581. {
  582. sNodeVectorName = GetUniqueNodeVectorName(poNodeVector.Name + "_c");
  583. oConnectionNodeVector = this.CreateNodeVector(sNodeVectorName,iConnectionNodes);
  584. ConnectionOnlyNodeVectors.Add(oConnectionNodeVector);
  585. oConnectionNodeVector.NodeStructure = NodeStructure.Connection;
  586. ComponentVerilog.VerilogTraceLog("Created A Split Connection NodeVector",oConnectionNodeVector);
  587. }
  588. if (iInputNodes > 0)
  589. {
  590. sNodeVectorName = GetUniqueNodeVectorName(poNodeVector.Name + "_i");
  591. oInputNodeVector = this.CreateNodeVector(sNodeVectorName,iInputNodes);
  592. InputNodeVectors.Add(oInputNodeVector);
  593. oInputNodeVector.NodeStructure = NodeStructure.Input;
  594. ComponentVerilog.VerilogTraceLog("Created A Split Input NodeVector",oInputNodeVector);
  595. }
  596. if (iOutputNodes > 0)
  597. {
  598. sNodeVectorName = GetUniqueNodeVectorName(poNodeVector.Name + "_o");
  599. oOutputNodeVector = this.CreateNodeVector(sNodeVectorName,iOutputNodes);
  600. oConnectionNodeVector.NodeStructure = NodeStructure.Output;
  601. OutputNodeVectors.Add(oOutputNodeVector);
  602. ComponentVerilog.VerilogTraceLog("Created A Split Output NodeVector",oOutputNodeVector);
  603. }
  604. iConnectionNodes = 0;
  605. iInputNodes = 0;
  606. iOutputNodes = 0;
  607. ComponentVerilog.VerilogTraceLog("Making NodeVector Redundant",poNodeVector);
  608. foreach(Node oNode in poNodeVector.Nodes)
  609. {
  610. switch(oNode.NodeStructure)
  611. {
  612. case NodeStructure.Connection:
  613. ComponentVerilog.VerilogTraceLog("Connecting this node to new Split Connection NodeVector",oNode);
  614. oTempNode = (Node)oConnectionNodeVector.Nodes[iConnectionNodes];
  615. oTempNode.NodeStructure = NodeStructure.Connection;
  616. oNode.Net.Connect(oTempNode.Net);
  617. iConnectionNodes++;
  618. break;
  619. case NodeStructure.Input:
  620. ComponentVerilog.VerilogTraceLog("Connecting this node to new Split Input NodeVector",oNode);
  621. oTempNode = (Node)oInputNodeVector.Nodes[iInputNodes];
  622. oTempNode.NodeStructure = NodeStructure.Input;
  623. oNode.Net.Connect(oTempNode.Net);
  624. iInputNodes++;
  625. break;
  626. case NodeStructure.Output:
  627. ComponentVerilog.VerilogTraceLog("Connecting this node to new Split Output NodeVector",oNode);
  628. oTempNode = (Node)oConnectionNodeVector.Nodes[iOutputNodes];
  629. oTempNode.NodeStructure = NodeStructure.Output;
  630. oNode.Net.Connect(oTempNode.Net);
  631. iOutputNodes++;
  632. break;
  633. }
  634. oNode.NodeStructure = NodeStructure.Redundant;
  635. }
  636. /*if (iConnectionNodes > 0)
  637. {
  638. StructureNodeVector(oConnectionNodeVector);
  639. }
  640. if (iInputNodes > 0)
  641. {
  642. StructureNodeVector(oInputNodeVector);
  643. }
  644. if (iOutputNodes > 0)
  645. {
  646. StructureNodeVector(oOutputNodeVector);
  647. }*/
  648. poNodeVector.NodeStructure = NodeStructure.Redundant;
  649. RedundantNodeVectors.Add(poNodeVector);
  650. }
  651. private string GetUniqueNodeVectorName(string psName)
  652. {
  653. string sName = psName;
  654. int iSuffix = 0;
  655. while(oNodeVectors.ContainsKey(sName))
  656. {
  657. sName = psName + iSuffix.ToString();
  658. }
  659. return sName;
  660. }
  661. /*public void ParseNetStructure()
  662. {
  663. foreach(Component oComponent in oComponents.Values)
  664. oComponent.ParseNetStructure();
  665. ComponentVerilog.VerilogTraceLog("***************** Start Parsing Net Structure For Verilog ****************");
  666. foreach(NodeVector oNodeVector in oSinkNodeVectors.Values)
  667. oNodeVector.ParseNetStructure();
  668. foreach(NodeVector oNodeVector in oSourceNodeVectors.Values)
  669. oNodeVector.ParseNetStructure();
  670. foreach(NodeVector oNodeVector in oPassThroughNodeVectors.Values)
  671. oNodeVector.ParseNetStructure();
  672. ComponentVerilog.VerilogTraceLog("***************** Finished Parsing Net Structure For Verilog ****************");
  673. }*/
  674. }
  675. }