예제 #1
0
		/// \brief Clone an instance.
		/// \param inIntancePtr A pointer to the instance to be cloned.
		/// \param inCloneInstanceName The name of the clone.
		/// \details Clone an instance and its configuration. This function does not clone the 
		/// 	instance pins. Instance pins are handled when cloning nets, in function cloneNet.
		InstanceSharedPtr cloneInstance(InstanceSharedPtr inIntancePtr,
			const string& inCloneInstanceName) {

			// Clone inInstancePtr
			InstanceSharedPtr inInstanceClonePtr = Factory::newInstancePtr(inCloneInstanceName,
				inIntancePtr->getType(), inIntancePtr->getTile(), inIntancePtr->getSite(),
				inIntancePtr->getBonding());

			// Begin clone inIntance configuration
			// Get a begin iterator to inIntance config
			ConfigMap::const_iterator instanceConfigBegin = inIntancePtr->configBegin();
			// Get an end iterator to inIntance config
			ConfigMap::const_iterator instanceConfigEnd = inIntancePtr->configEnd();
			// Configuration map
			ConfigMap configMap;

			// Iterate over all configuration
			while(instanceConfigBegin != instanceConfigEnd) {

				// Get current setting
				const string setting = instanceConfigBegin->first;
				// Get current configuration
				const Config config = instanceConfigBegin->second;
				// Add (setting,configuration) to configuration map
				configMap.setConfig(setting, config);
				// Move to the next configuration
				instanceConfigBegin++;

			}

			// Add configurations to instance clone
			inInstanceClonePtr->addConfigs(configMap);
			// End clone inInstance configuration

			// Return cloned instance
			return inInstanceClonePtr;
		}
예제 #2
0
		/// \brief Clone a net.
		/// \param inNetPtr A pointer to the net to be cloned.
		/// \param inNetCloneName The name of the clone.
		/// \param inModuleInstanceName The module instance name.
		/// \details Clone a net, its configuration, its sources, sinks and pips. For pips, the
		/// 	routethrough instances are droppped and not cloned.
		NetSharedPtr cloneNet(NetSharedPtr inNetPtr, const string& inNetCloneName,
			const string& inModuleInstanceName) {

			// Clone inNetPtr
			NetSharedPtr inNetClonePtr = Factory::newNetPtr(inNetCloneName, inNetPtr->getNetType());

			// Begin clone inNetPtr configuration
			// Get a begin iterator to net config
			ConfigMap::const_iterator netConfigBegin = inNetPtr->configBegin();
			// Get an end iterator to net config
			ConfigMap::const_iterator netConfigEnd = inNetPtr->configEnd();
			// Configuration map
			ConfigMap configMap;

			// Iterate over all configuration
			while(netConfigBegin != netConfigEnd) {

				// Get current setting
				const string setting = netConfigBegin->first;
				// Get current configuration
				const Config config = netConfigBegin->second;
				// Add (setting,configuration) to configuration map
				configMap.setConfig(setting, config);
				// Move to the next configuration
				netConfigBegin++;

			}

			// Add configurations to net clone
			inNetClonePtr->addConfigs(configMap);
			// End clone inNetPtr configuration

			// Begin clone inNetPtr sources
			// Get a begin iterator to net sources
			InstancePinSharedPtrConstIterator inNetSourcesBegin = inNetPtr->sourcesBegin();
			// Get an end iterator to net sources
			InstancePinSharedPtrConstIterator inNetSourcesEnd = inNetPtr->sourcesEnd();

			// Iterate over all source pins
			while(inNetSourcesBegin != inNetSourcesEnd) {

				// Get pointer to current net pin
				InstancePinSharedPtr instPinPtr = *inNetSourcesBegin;
				// Get net pin reference instance
				InstanceSharedPtr pinInstPtr = instPinPtr->getInstancePtr().lock();
				// Find the cloned instance that correspond to the pin reference instance
				InstanceSharedPtrIterator pinInstPtrCloneItr = mDesignPtr->findInstance(
					inModuleInstanceName + sHierarchySeparator + pinInstPtr->getName());
				// Clone source pin
				InstancePinSharedPtr instPinPtrClone 
					= Factory::newInstancePinPtr(*pinInstPtrCloneItr, instPinPtr->getPinName());
				// Add pin clone to the net clone
				inNetClonePtr->addSource(instPinPtrClone);
				// Move to next source
				inNetSourcesBegin++;

			}
			// End clone inNetPtr sources

			// Begin clone inNetPtr sinks
			// Get a begin iterator to net sinks
			InstancePinSharedPtrConstIterator inNetSinksBegin = inNetPtr->sinksBegin();
			// Get an end iterator to net sinks
			InstancePinSharedPtrConstIterator inNetSinksEnd = inNetPtr->sinksEnd();

			// Iterate over all sink pins
			while(inNetSinksBegin != inNetSinksEnd) {

				// Get pointer to current net pin
				InstancePinSharedPtr instPinPtr = *inNetSinksBegin;
				// Get net pin reference instance
				InstanceSharedPtr pinInstPtr = instPinPtr->getInstancePtr().lock();
				// Find the cloned instance that correspond to the pin reference instance
				InstanceSharedPtrIterator pinInstPtrCloneItr = mDesignPtr->findInstance(
					inModuleInstanceName + sHierarchySeparator + pinInstPtr->getName());
				// Clone sink pin
				InstancePinSharedPtr instPinPtrClone 
					= Factory::newInstancePinPtr(*pinInstPtrCloneItr, instPinPtr->getPinName());
				// Add pin clone to the net clone
				inNetClonePtr->addSink(instPinPtrClone);
				// Move to next sink
				inNetSinksBegin++;

			}
			// End clone inNetPtr sinks

			// Begin clone inNetPtr pips
			// Get a begin iterator to net pips
			PipConstIterator inNetPipsBegin = inNetPtr->pipsBegin();
			// Get an end iterator to net pips
			PipConstIterator inNetPipsEnd = inNetPtr->pipsEnd();

			// Iterate over all pips
			while(inNetPipsBegin != inNetPipsEnd) {

				// Get a pointer to the current pip
				Pip pipPtr = *inNetPipsBegin;
				/// \todo We are dropping routethrough instances.
				// Clone the pip
				Pip pipClone = Factory::newPip(pipPtr.getTileName(), pipPtr.getSourceWireName(),
					pipPtr.getSinkWireName(), pipPtr.getDirection());
				// Add pip clone to cloned net
				inNetClonePtr->addPip(pipClone);
				// Move to next pip
				inNetPipsBegin++;

			}
			// End clone inNetPtr pips

			// Return cloned net
			return inNetClonePtr;
		}