OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
HDLGenerator::Module Class Reference

#include <HDLGenerator.hh>

Inheritance diagram for HDLGenerator::Module:
Inheritance graph
Collaboration diagram for HDLGenerator::Module:
Collaboration graph

Public Member Functions

 Module (std::string name)
 
 Module (ipxact::ModuleInfo info, int id)
 
void set_header ()
 
void set_prefix (std::string prefix)
 
Moduleoperator<< (Behaviour &rhs)
 
Moduleoperator<< (Behaviour &&rhs)
 
Moduleoperator<< (Port &&port)
 
Moduleoperator<< (Parameter &&param)
 
Moduleoperator<< (IntegerConstant &&constant)
 
Moduleoperator<< (BinaryConstant &&constant)
 
Moduleoperator<< (Wire &&wire)
 
Moduleoperator<< (Register &&reg)
 
Moduleoperator<< (Register &reg)
 
Moduleoperator<< (Option &&opt)
 
Moduleoperator<< (Module &&rhs)
 
Moduleoperator<< (Module &rhs)
 
void build () final
 
void appendToHeader (const std::string &line)
 
virtual bool isRegister (const std::string &name) final
 
virtual bool isConstant (const std::string &name) final
 
virtual bool isVariable (const std::string &name) final
 
void registerVariable (const std::shared_ptr< Variable > var)
 
Width width (const std::string &name) final
 
WireType wireType (const std::string &name) final
 
void reads (const std::string &var) final
 
void writes (const std::string &var) final
 
void declare (std::ostream &stream, Language lang, int level)
 
void instantiate (std::ostream &stream, Language lang, int level)
 
void implement (std::ostream &stream, Language lang, int level=0)
 
bool hasOption (const std::string &var) final
 
RegistergetRegister (const std::string &var) final
 
- Public Member Functions inherited from HDLGenerator::Generatable
 Generatable (std::string name)
 
virtual ~Generatable ()=default
 
virtual void reads (const LHSValue &var)
 
int integerWidth (const std::string &name)
 
virtual Width width ()
 
virtual WireType wireType () const
 
virtual void hdl (std::ostream &stream, Language lang, int indent)
 
virtual void hdl (std::ostream &stream, Language lang)
 
virtual void implementAll (std::ostream &stream, Language lang)
 
virtual void implementAll (std::ostream &stream, Language lang, int indent)
 
template<typename Func >
void forAll (Func func)
 
template<typename Type , typename Func >
void forAll (Func func)
 
template<class Type >
bool parentIs ()
 
template<class Type >
Type * parentType ()
 
void pushComponent (std::shared_ptr< Generatable > c)
 
template<class Component >
void addComponent (Component c)
 
const std::string & name () const noexcept
 
void setParent (Generatable *parent) noexcept
 
Generatableparent () const noexcept
 

Private Member Functions

void clear ()
 

Private Attributes

int id_ = 0
 
std::string prefix_
 
std::unordered_set< std::string > options_
 
std::vector< std::string > headerComment_
 
std::vector< Parameterparameters_
 
std::vector< Portports_
 
std::vector< IntegerConstantconstants_
 
std::vector< BinaryConstantbinaryConstants_
 
std::vector< std::shared_ptr< Wire > > wires_
 
std::vector< Registerregisters_
 
std::vector< std::shared_ptr< Variable > > variables_
 
std::vector< std::shared_ptr< Behaviour > > behaviours_
 
std::vector< Modulemodules_
 

Detailed Description

Entity/module.

Definition at line 1164 of file HDLGenerator.hh.

Constructor & Destructor Documentation

◆ Module() [1/2]

HDLGenerator::Module::Module ( std::string  name)
inline

Definition at line 1166 of file HDLGenerator.hh.

1167 set_header();
1168 }
const std::string & name() const noexcept
Generatable(std::string name)

References set_header().

Here is the call graph for this function:

◆ Module() [2/2]

HDLGenerator::Module::Module ( ipxact::ModuleInfo  info,
int  id 
)
inline

Definition at line 1170 of file HDLGenerator.hh.

1170 : Generatable(info.name),
1171 prefix_(info.name) {
1172 set_header();
1173 id_ = id;
1174 for (auto&& p : info.parameters) {
1175 parameters_.emplace_back(Parameter{p.name, p.value});
1176 }
1177 for (auto&& p : info.ports) {
1178 Direction dir = p.direction == "in" ?
1180 if (p.vector) {
1181 *this << Port(p.name, dir, p.left + "+1");
1182 } else {
1183 *this << Port(p.name, dir);
1184 }
1185 }
1186 }
std::vector< Parameter > parameters_
std::string name
Definition IPXact.hh:54

References id_, HDLGenerator::In, HDLGenerator::Generatable::name(), HDLGenerator::Out, ipxact::ModuleInfo::parameters, parameters_, ipxact::ModuleInfo::ports, and set_header().

Here is the call graph for this function:

Member Function Documentation

◆ appendToHeader()

void HDLGenerator::Module::appendToHeader ( const std::string &  line)
inline

Definition at line 1278 of file HDLGenerator.hh.

1278 {
1279 headerComment_.emplace_back(line);
1280 }
std::vector< std::string > headerComment_

References headerComment_.

Referenced by FUGen::createFUHeaderComment().

◆ build()

void HDLGenerator::Module::build ( )
inlinefinalvirtual

Reimplemented from HDLGenerator::Generatable.

Definition at line 1271 of file HDLGenerator.hh.

1271 {
1272 for (auto&& b : behaviours_) {
1273 b->setParent(this);
1274 b->build();
1275 }
1276 }
std::vector< std::shared_ptr< Behaviour > > behaviours_

References behaviours_.

Referenced by implement().

◆ clear()

void HDLGenerator::Module::clear ( )
inlineprivate

Definition at line 1674 of file HDLGenerator.hh.

1674 {
1675 // clear variables.
1676 variables_.clear();
1677 // Remove duplicate registers.
1678 registers_.erase(std::unique(registers_.begin(), registers_.end(),
1679 [](Register l, Register r) {
1680 return l.name() == r.name();
1681 }),
1682 registers_.end());
1683 }
std::vector< std::shared_ptr< Variable > > variables_
std::vector< Register > registers_

References registers_, and variables_.

Referenced by implement().

◆ declare()

void HDLGenerator::Module::declare ( std::ostream &  stream,
Language  lang,
int  level 
)
inline

Definition at line 1383 of file HDLGenerator.hh.

1383 {
1384 if (lang == Language::VHDL) {
1385 stream << StringTools::indent(level) << "component "
1386 << name() << " is\n";
1387 // - Generics
1388 if (!parameters_.empty()) {
1389 std::string separator = "";
1390 stream << StringTools::indent(level + 1) << "generic (\n";
1391 for (auto&& parameter : parameters_) {
1392 stream << separator << StringTools::indent(level + 2);
1393 parameter.declare(stream, lang);
1394 separator = ";\n";
1395 }
1396 stream << ");\n";
1397 }
1398 // - Ports
1399 if (!ports_.empty()) {
1400 std::string separator = "";
1401 stream << StringTools::indent(level + 1) << "port (\n";
1402 for (auto&& port : ports_) {
1403 stream << separator << StringTools::indent(level + 2);
1404 port.declare(stream, lang);
1405 separator = ";\n";
1406 }
1407 stream << ");\n";
1408 }
1409 stream << StringTools::indent(level) << "end component "
1410 << name() << ";\n";
1411 } else if (lang == Language::Verilog) {
1412 // no declaration for verilog.
1413 } else {
1414 throw std::runtime_error(__PRETTY_FUNCTION__);
1415 }
1416 }
std::vector< Port > ports_
static std::string indent(int level)

References StringTools::indent(), HDLGenerator::Generatable::name(), parameters_, ports_, HDLGenerator::Verilog, and HDLGenerator::VHDL.

Here is the call graph for this function:

◆ getRegister()

Register & HDLGenerator::Module::getRegister ( const std::string &  var)
inlinefinalvirtual

Reimplemented from HDLGenerator::Generatable.

Definition at line 1664 of file HDLGenerator.hh.

1664 {
1665 for (auto&& r : registers_) {
1666 if (r.name() == var) {
1667 return r;
1668 }
1669 }
1670 throw std::runtime_error("Couldn't find register '" + var + "'");
1671 }

References registers_.

◆ hasOption()

bool HDLGenerator::Module::hasOption ( const std::string &  var)
inlinefinalvirtual

Reimplemented from HDLGenerator::Generatable.

Definition at line 1659 of file HDLGenerator.hh.

1659 {
1660 return std::find(options_.begin(), options_.end(), var) !=
1661 options_.end();
1662 }
std::unordered_set< std::string > options_

References options_.

◆ implement()

void HDLGenerator::Module::implement ( std::ostream &  stream,
Language  lang,
int  level = 0 
)
inline

Definition at line 1481 of file HDLGenerator.hh.

1481 {
1482 clear();
1483 build();
1484 if (lang == Language::VHDL) {
1485 std::string ident = StringTools::indent(level);
1486 // Header comment
1487 for (auto&& line : headerComment_) {
1488 stream << ident << "-- " << line << "\n";
1489 }
1490 // Libraries
1491 stream << ident << "\n"
1492 << ident << "library ieee;\n"
1493 << ident << "use ieee.std_logic_1164.all;\n"
1494 << ident << "use ieee.numeric_std.all;\n"
1495 << ident << "use ieee.std_logic_misc.all;\n"
1496 // Entity
1497 << ident << "\n"
1498 << ident << "entity " << name() << " is\n";
1499 // - Generics
1500 if (!parameters_.empty()) {
1501 std::string separator = "";
1502 stream << StringTools::indent(level + 1) << "generic (\n";
1503 for (auto&& parameter : parameters_) {
1504 stream << separator;
1505 parameter.declare(stream, lang, level + 2);
1506 separator = ";\n";
1507 }
1508 stream << ");\n";
1509 }
1510 // - Ports
1511 if (!ports_.empty()) {
1512 std::string separator = "";
1513 stream << StringTools::indent(level + 1) << "port (\n";
1514 for (auto&& port : ports_) {
1515 stream << separator;
1516 port.declare(stream, lang, level + 2);
1517 separator = ";\n";
1518 }
1519 stream << ");\n";
1520 }
1521 stream << ident << "end entity " << name() << ";\n"
1522 // Architecture
1523 << ident << "\n"
1524 << ident << "architecture rtl of "
1525 << name() << " is\n";
1526 // constants
1527 if (!constants_.empty() || !binaryConstants_.empty()) {
1528 stream << "\n";
1529 }
1530 for (auto&& c : constants_) {
1531 c.declare(stream, lang, level + 1);
1532 }
1533 for (auto&& c : binaryConstants_) {
1534 c.declare(stream, lang, level + 1);
1535 }
1536 // wires
1537 if (!wires_.empty()) {
1538 stream << "\n";
1539 }
1540 for (auto&& w : wires_) {
1541 w->declare(stream, lang, level + 1);
1542 }
1543 // registers
1544 if (!registers_.empty()) {
1545 stream << "\n";
1546 }
1547 for (auto&& r : registers_) {
1548 r.declare(stream, lang, level + 1);
1549 }
1550 // declare components
1551 std::vector<std::string> declared;
1552 for (auto&& m : modules_) {
1553 if (std::find(declared.begin(), declared.end(),
1554 m.name()) != declared.end()) {
1555 continue;
1556 }
1557 stream << "\n";
1558 m.declare(stream, lang, level + 1);
1559 declared.emplace_back(m.name());
1560 }
1561 stream << StringTools::indent(level) << "\nbegin\n\n";
1562 // instantiate components
1563 for (auto&& m : modules_) {
1564 m.instantiate(stream, lang, level + 1);
1565 stream << "\n";
1566 }
1567 // actual behavioural code
1568 for (auto&& b : behaviours_) {
1569 b->behaviour(stream, lang, level + 1);
1570 }
1571 stream << "\n";
1572 stream << StringTools::indent(level)
1573 << "end architecture rtl;\n\n";
1574
1575 } else if (lang == Language::Verilog) {
1576 // Header comment
1577 stream << StringTools::indent(level) << "/*\n";
1578 for (auto&& line : headerComment_) {
1579 stream << StringTools::indent(level)
1580 << " * " << line << "\n";
1581 }
1582 stream << StringTools::indent(level) << " */\n";
1583 // Module
1584 stream << StringTools::indent(level) << "\n";
1585 stream << StringTools::indent(level) << "module " << name();
1586 // - Parameters
1587 if (!parameters_.empty()) {
1588 std::string separator = "";
1589 stream << " #(\n";
1590 for (auto&& parameter : parameters_) {
1591 stream << separator;
1592 parameter.declare(stream, lang, level + 2);
1593 separator = ",\n";
1594 }
1595 stream << ")";
1596 }
1597 // - Ports
1598 if (!ports_.empty()) {
1599 std::string separator = "";
1600 stream << " (\n";
1601 for (auto&& port : ports_) {
1602 stream << separator;
1603 port.declare(stream, lang, level + 2);
1604 separator = ",\n";
1605 }
1606 stream << ")";
1607 }
1608 // end module interface
1609 stream << ";\n";
1610 // constants
1611 if (!constants_.empty() || !binaryConstants_.empty()) {
1612 stream << "\n";
1613 }
1614 for (auto&& c : constants_) {
1615 c.declare(stream, lang, level + 1);
1616 }
1617 for (auto&& c : binaryConstants_) {
1618 c.declare(stream, lang, level + 1);
1619 }
1620 // wires
1621 if (!wires_.empty()) {
1622 stream << "\n";
1623 }
1624 for (auto&& w : wires_) {
1625 w->declare(stream, lang, level + 1);
1626 }
1627 // variables
1628 if (!variables_.empty()) {
1629 stream << "\n";
1630 for (auto&& v : variables_) {
1631 v->declare(stream, lang, level + 1);
1632 }
1633 }
1634 // registers
1635 if (!registers_.empty()) {
1636 stream << "\n";
1637 }
1638 for (auto&& r : registers_) {
1639 r.declare(stream, lang, level + 1);
1640 }
1641 // instantiate stuff
1642 for (auto&& m : modules_) {
1643 stream << "\n";
1644 m.instantiate(stream, lang, level + 1);
1645 }
1646 // actual code
1647 stream << "\n";
1648 for (auto&& b : behaviours_) {
1649 b->behaviour(stream, lang, level + 1);
1650 }
1651 // end module
1652 stream << "\n";
1653 stream << StringTools::indent(level) << "endmodule\n\n";
1654 } else {
1655 throw std::runtime_error(__PRETTY_FUNCTION__);
1656 }
1657 }
std::vector< Module > modules_
std::vector< BinaryConstant > binaryConstants_
std::vector< IntegerConstant > constants_
std::vector< std::shared_ptr< Wire > > wires_

References behaviours_, binaryConstants_, build(), clear(), constants_, headerComment_, StringTools::indent(), modules_, HDLGenerator::Generatable::name(), parameters_, ports_, registers_, variables_, HDLGenerator::Verilog, HDLGenerator::VHDL, and wires_.

Referenced by FUGen::createImplementationFiles().

Here is the call graph for this function:

◆ instantiate()

void HDLGenerator::Module::instantiate ( std::ostream &  stream,
Language  lang,
int  level 
)
inline

Definition at line 1418 of file HDLGenerator.hh.

1418 {
1419 std::string instance = prefix_ + "_" + std::to_string(id_);
1420 if (lang == Language::VHDL) {
1421 stream << StringTools::indent(level)
1422 << instance << " : " << name() << "\n";
1423 if (parameters_.size() > 0) {
1424 stream << StringTools::indent(level + 1) << "generic map (\n";
1425
1426 std::string separator = "";
1427 for (auto&& p : parameters_) {
1428 stream << separator
1429 << StringTools::indent(level + 2)
1430 << p.name() << " => " << p.strValue();
1431 separator = ",\n";
1432 }
1433 stream << ")\n";
1434 }
1435 std::string separator = "";
1436 stream << StringTools::indent(level + 1) << "port map (\n";
1437 for (auto&& p : ports_) {
1438 stream << separator << StringTools::indent(level + 2)
1439 << p.name() << " => ";
1440 if (p.name() == "clk" || p.name() == "rstx" ||
1441 p.name() == "glock_in") {
1442 stream << p.name();
1443 } else {
1444 stream << instance << "_" << p.name();
1445 }
1446 separator = ",\n";
1447 }
1448 stream << ");\n";
1449 } else if (lang == Language::Verilog) {
1450 stream << StringTools::indent(level) << name() << " ";
1451 if (parameters_.size() > 0) {
1452 stream << "#(";
1453 std::string separator = "";
1454 for (auto&& p : parameters_) {
1455 stream << separator;
1456 stream << "." << p.name() << "(" << p.strValue() << ")";
1457 separator = ", ";
1458 }
1459 stream << ") ";
1460 }
1461 std::string separator = "";
1462 stream << instance << " (\n";
1463 for (auto&& p : ports_) {
1464 stream << separator;
1465 stream << StringTools::indent(level + 2) << "." << p.name()
1466 << "(";
1467 if (p.name() == "clk" || p.name() == "rstx" ||
1468 p.name() == "glock_in") {
1469 stream << p.name() << ")";
1470 } else {
1471 stream << instance << "_" << name() << ")";
1472 }
1473 separator = ",\n";
1474 }
1475 stream << ");\n";
1476 } else {
1477 throw std::runtime_error(__PRETTY_FUNCTION__);
1478 }
1479 }

References id_, StringTools::indent(), HDLGenerator::Generatable::name(), parameters_, ports_, prefix_, HDLGenerator::Verilog, and HDLGenerator::VHDL.

Here is the call graph for this function:

◆ isConstant()

virtual bool HDLGenerator::Module::isConstant ( const std::string &  name)
inlinefinalvirtual

Reimplemented from HDLGenerator::Generatable.

Definition at line 1291 of file HDLGenerator.hh.

1291 {
1292 for (auto&& r : constants_) {
1293 if (r.name() == name) {
1294 return true;
1295 }
1296 }
1297 for (auto&& r : binaryConstants_) {
1298 if (r.name() == name) {
1299 return true;
1300 }
1301 }
1302 return false;
1303 }

References binaryConstants_, constants_, and HDLGenerator::Generatable::name().

Here is the call graph for this function:

◆ isRegister()

virtual bool HDLGenerator::Module::isRegister ( const std::string &  name)
inlinefinalvirtual

Reimplemented from HDLGenerator::Generatable.

Definition at line 1282 of file HDLGenerator.hh.

1282 {
1283 for (auto&& r : registers_) {
1284 if (r.name() == name) {
1285 return true;
1286 }
1287 }
1288 return false;
1289 }

References HDLGenerator::Generatable::name(), and registers_.

Here is the call graph for this function:

◆ isVariable()

virtual bool HDLGenerator::Module::isVariable ( const std::string &  name)
inlinefinalvirtual

Reimplemented from HDLGenerator::Generatable.

Definition at line 1305 of file HDLGenerator.hh.

1305 {
1306 for (auto&& v : variables_) {
1307 if (v->name() == name) {
1308 return true;
1309 }
1310 }
1311 return false;
1312 }

References HDLGenerator::Generatable::name(), and variables_.

Here is the call graph for this function:

◆ operator<<() [1/12]

Module & HDLGenerator::Module::operator<< ( Behaviour &&  rhs)
inline

Definition at line 1216 of file HDLGenerator.hh.

1216 {
1217 behaviours_.emplace_back(new Behaviour(rhs));
1218 return *this;
1219 }

References behaviours_.

◆ operator<<() [2/12]

Module & HDLGenerator::Module::operator<< ( Behaviour rhs)
inline

Definition at line 1211 of file HDLGenerator.hh.

1211 {
1212 behaviours_.emplace_back(new Behaviour(rhs));
1213 return *this;
1214 }

References behaviours_.

◆ operator<<() [3/12]

Module & HDLGenerator::Module::operator<< ( BinaryConstant &&  constant)
inline

Definition at line 1236 of file HDLGenerator.hh.

1236 {
1237 binaryConstants_.emplace_back(constant);
1238 return *this;
1239 }

References binaryConstants_.

◆ operator<<() [4/12]

Module & HDLGenerator::Module::operator<< ( IntegerConstant &&  constant)
inline

Definition at line 1231 of file HDLGenerator.hh.

1231 {
1232 constants_.emplace_back(constant);
1233 return *this;
1234 }

References constants_.

◆ operator<<() [5/12]

Module & HDLGenerator::Module::operator<< ( Module &&  rhs)
inline

Definition at line 1261 of file HDLGenerator.hh.

1261 {
1262 modules_.emplace_back(rhs);
1263 return *this;
1264 }

References modules_.

◆ operator<<() [6/12]

Module & HDLGenerator::Module::operator<< ( Module rhs)
inline

Definition at line 1266 of file HDLGenerator.hh.

1266 {
1267 modules_.emplace_back(rhs);
1268 return *this;
1269 }

References modules_.

◆ operator<<() [7/12]

Module & HDLGenerator::Module::operator<< ( Option &&  opt)
inline

Definition at line 1256 of file HDLGenerator.hh.

1256 {
1257 options_.emplace(opt.name());
1258 return *this;
1259 }

References options_.

◆ operator<<() [8/12]

Module & HDLGenerator::Module::operator<< ( Parameter &&  param)
inline

Definition at line 1226 of file HDLGenerator.hh.

1226 {
1227 parameters_.emplace_back(param);
1228 return *this;
1229 }

References parameters_.

◆ operator<<() [9/12]

Module & HDLGenerator::Module::operator<< ( Port &&  port)
inline

Definition at line 1221 of file HDLGenerator.hh.

1221 {
1222 ports_.push_back(port);
1223 return *this;
1224 }

References ports_.

◆ operator<<() [10/12]

Module & HDLGenerator::Module::operator<< ( Register &&  reg)
inline

Definition at line 1246 of file HDLGenerator.hh.

1246 {
1247 registers_.emplace_back(reg);
1248 return *this;
1249 }

References registers_.

◆ operator<<() [11/12]

Module & HDLGenerator::Module::operator<< ( Register reg)
inline

Definition at line 1251 of file HDLGenerator.hh.

1251 {
1252 registers_.emplace_back(reg);
1253 return *this;
1254 }

References registers_.

◆ operator<<() [12/12]

Module & HDLGenerator::Module::operator<< ( Wire &&  wire)
inline

Definition at line 1241 of file HDLGenerator.hh.

1241 {
1242 wires_.emplace_back(new Wire(wire));
1243 return *this;
1244 }

References wires_.

◆ reads()

void HDLGenerator::Module::reads ( const std::string &  var)
inlinefinalvirtual

Reimplemented from HDLGenerator::Generatable.

Definition at line 1379 of file HDLGenerator.hh.

1379{ (void)var; }

◆ registerVariable()

void HDLGenerator::Module::registerVariable ( const std::shared_ptr< Variable var)
inline

Definition at line 1314 of file HDLGenerator.hh.

1314 {
1315 for (auto&& v : variables_) {
1316 if (v->name() == var->name()) {
1317 throw std::runtime_error("tried to register variable " +
1318 var->name() + " multiple times");
1319 }
1320 }
1321 variables_.push_back(var);
1322 }

References variables_.

◆ set_header()

void HDLGenerator::Module::set_header ( )
inline

Definition at line 1188 of file HDLGenerator.hh.

1188 {
1189 auto now = std::chrono::system_clock::now();
1190 auto now_c = std::chrono::system_clock::to_time_t(now);
1191 char buffer[31];
1192 std::stringstream ss;
1194 "2023", "");
1195 std::vector<TCEString> licenseStrs = licenseStr.split("\n");
1196 for (unsigned int i = 0; i < licenseStrs.size(); i++) {
1197 headerComment_.emplace_back(licenseStrs.at(i));
1198 }
1199 std::strftime(buffer, 30, "%c", std::localtime(&now_c));
1200 ss << buffer; // std::put_time(std::localtime(&now_c), "%c");
1201 headerComment_.emplace_back("");
1202 headerComment_.emplace_back(
1203 std::string("Generated on ") + ss.str());
1204 headerComment_.emplace_back("");
1205 }
static std::string generateMITLicense(const std::string &year, const std::string &comment)
std::vector< TCEString > split(const std::string &delim) const
Definition TCEString.cc:114

References LicenseGenerator::generateMITLicense(), headerComment_, and TCEString::split().

Referenced by Module(), and Module().

Here is the call graph for this function:

◆ set_prefix()

void HDLGenerator::Module::set_prefix ( std::string  prefix)
inline

Definition at line 1207 of file HDLGenerator.hh.

1207 {
1208 prefix_ = prefix;
1209 }

References prefix_.

Referenced by FUGen::createOperationResources().

◆ width()

Width HDLGenerator::Module::width ( const std::string &  name)
inlinefinalvirtual

Reimplemented from HDLGenerator::Generatable.

Definition at line 1324 of file HDLGenerator.hh.

1324 {
1325 for (auto&& v : parameters_) {
1326 if (v.name() == name) {
1327 return v.width();
1328 }
1329 }
1330 for (auto&& v : constants_) {
1331 if (v.name() == name) {
1332 return v.width();
1333 }
1334 }
1335 for (auto&& v : registers_) {
1336 if (v.name() == name) {
1337 return v.width();
1338 }
1339 }
1340 for (auto&& v : wires_) {
1341 if (v->name() == name) {
1342 return v->width();
1343 }
1344 }
1345 for (auto&& v : variables_) {
1346 if (v->name() == name) {
1347 return v->width();
1348 }
1349 }
1350 for (auto&& v : ports_) {
1351 if (v.name() == name) {
1352 return v.width();
1353 }
1354 }
1355 // not finding a thing is an error.
1356 throw std::runtime_error("Couldn't find width for " + name);
1357 }

References constants_, HDLGenerator::Generatable::name(), parameters_, ports_, registers_, variables_, and wires_.

Here is the call graph for this function:

◆ wireType()

WireType HDLGenerator::Module::wireType ( const std::string &  name)
inlinefinalvirtual

Reimplemented from HDLGenerator::Generatable.

Definition at line 1359 of file HDLGenerator.hh.

1359 {
1360 for (auto&& v : ports_) {
1361 if (v.name() == name) {
1362 return v.wireType();
1363 }
1364 }
1365 for (auto&& v : wires_) {
1366 if (v->name() == name) {
1367 return v->wireType();
1368 }
1369 }
1370 for (auto&& v : variables_) {
1371 if (v->name() == name) {
1372 return v->wireType();
1373 }
1374 }
1375 // not finding a thing is an error.
1376 throw std::runtime_error("Couldn't find wire type for " + name);
1377 }

References HDLGenerator::Generatable::name(), ports_, variables_, and wires_.

Here is the call graph for this function:

◆ writes()

void HDLGenerator::Module::writes ( const std::string &  var)
inlinefinalvirtual

Reimplemented from HDLGenerator::Generatable.

Definition at line 1381 of file HDLGenerator.hh.

1381{ (void)var; }

Member Data Documentation

◆ behaviours_

std::vector<std::shared_ptr<Behaviour> > HDLGenerator::Module::behaviours_
private

Definition at line 1695 of file HDLGenerator.hh.

Referenced by build(), implement(), operator<<(), and operator<<().

◆ binaryConstants_

std::vector<BinaryConstant> HDLGenerator::Module::binaryConstants_
private

Definition at line 1691 of file HDLGenerator.hh.

Referenced by implement(), isConstant(), and operator<<().

◆ constants_

std::vector<IntegerConstant> HDLGenerator::Module::constants_
private

Definition at line 1690 of file HDLGenerator.hh.

Referenced by implement(), isConstant(), operator<<(), and width().

◆ headerComment_

std::vector<std::string> HDLGenerator::Module::headerComment_
private

Definition at line 1687 of file HDLGenerator.hh.

Referenced by appendToHeader(), implement(), and set_header().

◆ id_

int HDLGenerator::Module::id_ = 0
private

Definition at line 1684 of file HDLGenerator.hh.

Referenced by instantiate(), and Module().

◆ modules_

std::vector<Module> HDLGenerator::Module::modules_
private

Definition at line 1696 of file HDLGenerator.hh.

Referenced by implement(), operator<<(), and operator<<().

◆ options_

std::unordered_set<std::string> HDLGenerator::Module::options_
private

Definition at line 1686 of file HDLGenerator.hh.

Referenced by hasOption(), and operator<<().

◆ parameters_

std::vector<Parameter> HDLGenerator::Module::parameters_
private

Definition at line 1688 of file HDLGenerator.hh.

Referenced by declare(), implement(), instantiate(), Module(), operator<<(), and width().

◆ ports_

std::vector<Port> HDLGenerator::Module::ports_
private

Definition at line 1689 of file HDLGenerator.hh.

Referenced by declare(), implement(), instantiate(), operator<<(), width(), and wireType().

◆ prefix_

std::string HDLGenerator::Module::prefix_
private

Definition at line 1685 of file HDLGenerator.hh.

Referenced by instantiate(), and set_prefix().

◆ registers_

std::vector<Register> HDLGenerator::Module::registers_
private

Definition at line 1693 of file HDLGenerator.hh.

Referenced by clear(), getRegister(), implement(), isRegister(), operator<<(), operator<<(), and width().

◆ variables_

std::vector<std::shared_ptr<Variable> > HDLGenerator::Module::variables_
private

Definition at line 1694 of file HDLGenerator.hh.

Referenced by clear(), implement(), isVariable(), registerVariable(), width(), and wireType().

◆ wires_

std::vector<std::shared_ptr<Wire> > HDLGenerator::Module::wires_
private

Definition at line 1692 of file HDLGenerator.hh.

Referenced by implement(), operator<<(), width(), and wireType().


The documentation for this class was generated from the following file: