74 typedef std::map<std::string, bool> StringToBoolMap;
75 StringToBoolMap protectedCells;
76 StringToBoolMap protectedLibraries;
80 DesignSharedPtrVector designs;
81 rootPtr->getDesigns(designs);
82 DesignSharedPtrVector::iterator dp = designs.begin();
83 DesignSharedPtrVector::iterator de = designs.end();
89 std::string cellRefName = designPtr->getCellRefName();
90 std::string libraryRefName = designPtr->getLibraryRefName();
91 std::cout <<
" Protecting design \"" << designName <<
"\" (cell \"" << cellRefName
92 <<
"\", library \"" << libraryRefName <<
"\")" << std::endl;
93 protectedCells[libraryRefName +
":" + cellRefName] =
true;
94 protectedLibraries[libraryRefName] =
true;
99 boost::regex regexVendorLibraries(
"^(VhdlGenLib|virtex|virtexr|unilib)$",
100 boost::regex_constants::icase);
103 typedef std::vector<LibrarySharedPtr> LibrarySharedPtrVector;
104 LibrarySharedPtrVector libraries;
105 rootPtr->getLibraries(libraries);
106 LibrarySharedPtrVector::iterator lp = libraries.begin();
107 LibrarySharedPtrVector::iterator le = libraries.end();
116 if(boost::regex_search(libraryName, regexVendorLibraries))
continue;
119 typedef std::vector<CellSharedPtr> CellSharedPtrVector;
120 CellSharedPtrVector cells;
121 libraryPtr->getCells(cells);
122 CellSharedPtrVector::iterator cp = cells.begin();
123 CellSharedPtrVector::iterator ce = cells.end();
129 typedef std::vector<ViewSharedPtr> ViewSharedPtrVector;
130 ViewSharedPtrVector views;
131 cellPtr->getViews(views);
132 ViewSharedPtrVector::iterator vp = views.begin();
133 ViewSharedPtrVector::iterator ve = views.end();
138 if(viewName ==
"syn_black_box") {
139 protectedLibraries[libraryName] =
true;
140 protectedCells[libraryName +
":" + cellName] =
true;
146 bool libraryIsProtected = protectedLibraries.count(libraryName) > 0;
147 if(!libraryIsProtected) {
149 = libraryIsProtected ? libraryName :
obfuscate(libraryName);
150 libraryPtr->setName(obfuscatedLibraryName);
151 libraryPtr->setOriginalName(
"");
152 log <<
"library " << libraryName <<
"=> " << obfuscatedLibraryName << std::endl;
171 bool cellIsProtected = protectedCells.count(libraryName +
":" + cellName) > 0;
172 if(cellIsProtected ==
false) {
174 cellPtr->setName(obfuscatedCellName);
175 cellPtr->setOriginalName(
"");
176 log <<
"cell " << cellName <<
" => " << obfuscatedCellName << std::endl;
178 log <<
"cell " << cellName <<
" => " << cellName << std::endl;
182 typedef std::vector<ViewSharedPtr> ViewSharedPtrVector;
183 ViewSharedPtrVector views;
184 cellPtr->getViews(views);
185 ViewSharedPtrVector::iterator vp = views.begin();
186 ViewSharedPtrVector::iterator ve = views.end();
195 if(cellIsProtected ==
false) {
197 viewPtr->setName(obfuscatedViewName);
198 viewPtr->setOriginalName(
"");
199 log <<
" view " << viewName <<
" => " << obfuscatedViewName << std::endl;
201 log <<
" view " << viewName <<
" => " << viewName << std::endl;
206 PortSharedPtrVector ports;
207 viewPtr->getPorts(ports);
208 PortSharedPtrVector::iterator pp = ports.begin();
209 PortSharedPtrVector::iterator pe = ports.end();
218 if(cellIsProtected ==
false) {
220 portPtr->setName(obfuscatedPortName);
221 std::string originalName = portPtr->getOriginalName();
224 boost::regex re(
".*([\\(\\[].+[\\)\\]])");
225 if(boost::regex_match(originalName, what, re, boost::match_default)) {
230 originalName = newName;
232 portPtr->setOriginalName(originalName);
233 log <<
" port " << portName <<
" => " << obfuscatedPortName
236 log <<
" port " << portName <<
" => " << portName << std::endl;
243 InstanceSharedPtrVector instances;
244 viewPtr->getInstances(instances);
245 InstanceSharedPtrVector::iterator ip = instances.begin();
246 InstanceSharedPtrVector::iterator ie = instances.end();
257 instancePtr->setName(obfuscatedInstanceName);
258 instancePtr->setOriginalName(
"");
259 log <<
" instance " << instanceName <<
" => " << obfuscatedInstanceName
266 NetSharedPtrVector nets;
267 viewPtr->getNets(nets);
268 NetSharedPtrVector::iterator np = nets.begin();
269 NetSharedPtrVector::iterator ne = nets.end();
279 netPtr->setName(obfuscatedNetName);
280 netPtr->setOriginalName(
"");
281 log <<
" net " << netName <<
" => " << obfuscatedNetName << std::endl;
285 PortSharedPtrVector ports;
286 netPtr->getConnectedPorts(ports,
false);
287 PortSharedPtrVector::iterator pp = ports.begin();
288 PortSharedPtrVector::iterator pe = ports.end();
295 switch(compositionType) {
297 parentPortName = portPtr->getName();
298 if(parentPortName == portName)
break;
299 portPtr->setName(parentPortName);
305 const PortSharedPtr& vectorPtr = portPtr->getParentCollection();
306 parentPortName = vectorPtr->getName();
307 if(parentPortName == portName)
break;
308 vectorPtr->setName(parentPortName);
314 std::cerr <<
"ERROR: Unsupported composition type "
315 << compositionType <<
" in " << __FILE__ <<
" line "
316 << __LINE__ << std::endl;
void log(const char *fmt,...)
boost::shared_ptr< Instance > InstanceSharedPtr
std::vector< InstanceSharedPtr > InstanceSharedPtrVector
Vector of Instance shared pointers.
std::vector< DesignSharedPtr > DesignSharedPtrVector
Vector of Design shared pointers.
boost::shared_ptr< Design > DesignSharedPtr
CompositionType
Defines possible Composition types.
boost::shared_ptr< Net > NetSharedPtr
boost::shared_ptr< Library > LibrarySharedPtr
std::string obfuscate(const std::string &inIdentifier)
boost::uint32_t mIdentifierCount
std::vector< NetSharedPtr > NetSharedPtrVector
Vector of Net shared pointers.
boost::shared_ptr< View > ViewSharedPtr
boost::shared_ptr< Cell > CellSharedPtr
boost::shared_ptr< Port > PortSharedPtr
std::vector< PortSharedPtr > PortSharedPtrVector
Vector of Port shared pointers.