19 #include <boost/test/unit_test.hpp>
29 #include <boost/regex.hpp>
34 BOOST_AUTO_TEST_SUITE(
generic)
39 void operator ()(NetSharedPtr& inNetPtr)
const {
45 std::vector<PortSharedPtr> ports;
46 inNetPtr->getConnectedPorts(ports);
47 std::vector<PortSharedPtr>::const_iterator pp = ports.begin();
48 std::vector<PortSharedPtr>::const_iterator pe = ports.end();
50 const PortSharedPtr& portPtr = *pp++;
61 std::vector<PortReferenceSharedPtr> portReferences;
62 inNetPtr->getConnectedPortRefs(portReferences);
64 std::vector<PortReferenceSharedPtr>::const_iterator rp = portReferences.begin();
65 std::vector<PortReferenceSharedPtr>::const_iterator re = portReferences.end();
67 const PortReferenceSharedPtr& portRefPtr = *rp++;
68 const PortSharedPtr& portPtr = portRefPtr->getMaster();
77 BOOST_REQUIRE_EQUAL(sources, 1);
78 std::cerr <<
"Net " << inNetPtr->getName() <<
": "
79 << ports.size() <<
" ports, "
80 << portReferences.size() <<
" portRefs, "
81 << sources <<
" sources, "
91 std::stringstream generated;
92 std::stringstream parsed;
94 std::cout <<
"Generating " <<
"and.edf" <<
" ... ";
97 boost::shared_ptr<ObjectFactory> objectFactoryPtr(
new ObjectFactory());
101 rootPtr->setOriginalName(
"AND");
104 LibrarySharedPtr virtexLibraryPtr = objectFactoryPtr->newLibraryPtr(
"VIRTEX", rootPtr);
105 LibrarySharedPtr workLibraryPtr = objectFactoryPtr->newLibraryPtr(
"work", rootPtr);
108 CellSharedPtr lut2CellPtr = objectFactoryPtr->newCellPtr(
"LUT2", virtexLibraryPtr);
109 ViewSharedPtr lut2ViewPtr = objectFactoryPtr->newViewPtr(
"PRIM", lut2CellPtr);
118 CellSharedPtr andCellPtr = objectFactoryPtr->newCellPtr(
"and", workLibraryPtr,
120 ViewSharedPtr andViewPtr = objectFactoryPtr->newViewPtr(
"verilog", andCellPtr);
130 andViewPtr, lut2ViewPtr,
"o");
132 = objectFactoryPtr->newScalarPortReferencePtr(oZ0InstancePtr, lut2I0PortPtr);
134 = objectFactoryPtr->newScalarPortReferencePtr(oZ0InstancePtr, lut2I1PortPtr);
136 = objectFactoryPtr->newScalarPortReferencePtr(oZ0InstancePtr, lut2OPortPtr);
140 andI0PortPtr->connect(i0NetPtr);
141 oZ0I0PortReferencePtr->connect(i0NetPtr);
143 andI1PortPtr->connect(i1NetPtr);
144 oZ0I1PortReferencePtr->connect(i1NetPtr);
146 andOPortPtr->connect(oNetPtr);
147 oZ0OPortReferencePtr->connect(oNetPtr);
150 PropertySharedPtr initPropertyPtr = objectFactoryPtr->newPropertyPtr(
"INIT", oZ0InstancePtr,
152 (void) initPropertyPtr;
155 DesignSharedPtr designPtr = objectFactoryPtr->newDesignPtr(
"and", rootPtr,
"and",
"work",
159 PropertySharedPtr partPropertyPtr = objectFactoryPtr->newPropertyPtr(
"PART", designPtr,
161 partPropertyPtr->setOwner(
"Xilinx");
163 std::cout <<
"done." << std::endl;
177 for(std::vector<Error::StackFrameInfo>::const_iterator it = stack.begin();
178 it != stack.end(); it++) {
179 std::cerr <<
" " << (*it).getFunction() <<
"() [" << (*it).getFile() <<
":"
180 << (*it).getLine() <<
"]" << std::endl;
209 BOOST_CHECK_EQUAL(generated.str(), parsed.str());
213 BOOST_AUTO_TEST_SUITE_END()
220 (edif (rename and
"AND")
223 (keywordMap (keywordLevel 0))
226 (timeStamp 2010 8 30 21 51 32)
227 (author
"Synplicity, Inc.")
228 (program
"Synplify Pro" (version
"C-2009.06-SP1, mapper map450rcp1sp1, Build 037R"))
233 (technology (numberDefinition ))
234 (cell LUT2 (cellType GENERIC)
235 (view PRIM (viewType NETLIST)
237 (port I0 (direction INPUT))
238 (port I1 (direction INPUT))
239 (port O (direction OUTPUT))
246 (technology (numberDefinition ))
247 (cell (rename and
"AND") (cellType GENERIC)
248 (view verilog (viewType NETLIST)
250 (port i0 (direction INPUT))
251 (port i1 (direction INPUT))
252 (port o (direction OUTPUT))
255 (instance (rename oZ0
"o") (viewRef PRIM (cellRef LUT2 (libraryRef VIRTEX)))
256 (property INIT (
string "8"))
260 (portRef I0 (instanceRef oZ0))
264 (portRef I1 (instanceRef oZ0))
267 (portRef O (instanceRef oZ0))
274 (design (rename and
"AND") (cellRef and (libraryRef work))
275 (property PART (
string "xc5vlx30ff324-1") (owner
"Xilinx")))
static MessageTable * instance()
boost::shared_ptr< ScalarPort > ScalarPortSharedPtr
boost::shared_ptr< ScalarNet > ScalarNetSharedPtr
boost::shared_ptr< Net > NetSharedPtr
BOOST_AUTO_TEST_CASE(Om1UnitTest)
Unit test for the generic object model.
boost::shared_ptr< ScalarPortReference > ScalarPortReferenceSharedPtr
boost::shared_ptr< Design > DesignSharedPtr
The Error object thrown by different methods of EdifOM.
const std::vector< StackFrameInfo > & getStackTrace() const
boost::shared_ptr< Library > LibrarySharedPtr
boost::shared_ptr< PortReference > PortReferenceSharedPtr
const MessageId getErrorMessageId() const
boost::shared_ptr< View > ViewSharedPtr
boost::shared_ptr< Cell > CellSharedPtr
boost::shared_ptr< Port > PortSharedPtr
boost::shared_ptr< Property > PropertySharedPtr
boost::shared_ptr< SingleInstance > SingleInstanceSharedPtr
std::string getMessage(MessageId inId) const
boost::shared_ptr< Root > RootSharedPtr