WIP: renamed port -> terminal for devices. This is correct technical term. A port is a two-terminal entity.

This commit is contained in:
Matthias Koefferlein 2018-12-25 20:19:37 +01:00
parent 9c9d99da7c
commit 4f8416766c
14 changed files with 494 additions and 494 deletions

View File

@ -52,9 +52,9 @@ Device::Device ()
Device::~Device ()
{
for (std::vector<Net::port_iterator>::const_iterator p = m_port_refs.begin (); p != m_port_refs.end (); ++p) {
if (*p != Net::port_iterator () && (*p)->net ()) {
(*p)->net ()->erase_port (*p);
for (std::vector<Net::terminal_iterator>::const_iterator t = m_terminal_refs.begin (); t != m_terminal_refs.end (); ++t) {
if (*t != Net::terminal_iterator () && (*t)->net ()) {
(*t)->net ()->erase_terminal (*t);
}
}
}
@ -84,41 +84,41 @@ void Device::set_name (const std::string &n)
m_name = n;
}
void Device::set_port_ref_for_port (size_t port_id, Net::port_iterator iter)
void Device::set_terminal_ref_for_terminal (size_t terminal_id, Net::terminal_iterator iter)
{
if (m_port_refs.size () < port_id + 1) {
m_port_refs.resize (port_id + 1, Net::port_iterator ());
if (m_terminal_refs.size () < terminal_id + 1) {
m_terminal_refs.resize (terminal_id + 1, Net::terminal_iterator ());
}
m_port_refs [port_id] = iter;
m_terminal_refs [terminal_id] = iter;
}
const Net *Device::net_for_port (size_t port_id) const
const Net *Device::net_for_terminal (size_t terminal_id) const
{
if (port_id < m_port_refs.size ()) {
Net::port_iterator p = m_port_refs [port_id];
if (p != Net::port_iterator ()) {
if (terminal_id < m_terminal_refs.size ()) {
Net::terminal_iterator p = m_terminal_refs [terminal_id];
if (p != Net::terminal_iterator ()) {
return p->net ();
}
}
return 0;
}
void Device::connect_port (size_t port_id, Net *net)
void Device::connect_terminal (size_t terminal_id, Net *net)
{
if (net_for_port (port_id) == net) {
if (net_for_terminal (terminal_id) == net) {
return;
}
if (port_id < m_port_refs.size ()) {
Net::port_iterator p = m_port_refs [port_id];
if (p != Net::port_iterator () && p->net ()) {
p->net ()->erase_port (p);
if (terminal_id < m_terminal_refs.size ()) {
Net::terminal_iterator p = m_terminal_refs [terminal_id];
if (p != Net::terminal_iterator () && p->net ()) {
p->net ()->erase_terminal (p);
}
m_port_refs [port_id] = Net::port_iterator ();
m_terminal_refs [terminal_id] = Net::terminal_iterator ();
}
if (net) {
net->add_port (NetPortRef (this, port_id));
net->add_terminal (NetTerminalRef (this, terminal_id));
}
}
@ -244,48 +244,48 @@ void SubCircuit::connect_pin (size_t pin_id, Net *net)
}
// --------------------------------------------------------------------------------
// NetPortRef class implementation
// NetTerminalRef class implementation
NetPortRef::NetPortRef ()
: m_port_id (0), mp_device (0), mp_net (0)
NetTerminalRef::NetTerminalRef ()
: m_terminal_id (0), mp_device (0), mp_net (0)
{
// .. nothing yet ..
}
NetPortRef::NetPortRef (Device *device, size_t port_id)
: m_port_id (port_id), mp_device (device), mp_net (0)
NetTerminalRef::NetTerminalRef (Device *device, size_t terminal_id)
: m_terminal_id (terminal_id), mp_device (device), mp_net (0)
{
// .. nothing yet ..
}
NetPortRef::NetPortRef (const NetPortRef &other)
: m_port_id (other.m_port_id), mp_device (other.mp_device), mp_net (0)
NetTerminalRef::NetTerminalRef (const NetTerminalRef &other)
: m_terminal_id (other.m_terminal_id), mp_device (other.mp_device), mp_net (0)
{
// .. nothing yet ..
}
NetPortRef &NetPortRef::operator= (const NetPortRef &other)
NetTerminalRef &NetTerminalRef::operator= (const NetTerminalRef &other)
{
if (this != &other) {
m_port_id = other.m_port_id;
m_terminal_id = other.m_terminal_id;
mp_device = other.mp_device;
}
return *this;
}
const DevicePortDefinition *
NetPortRef::port_def () const
const DeviceTerminalDefinition *
NetTerminalRef::terminal_def () const
{
const DeviceClass *dc = device_class ();
if (dc) {
return dc->port_definition (m_port_id);
return dc->terminal_definition (m_terminal_id);
} else {
return 0;
}
}
const DeviceClass *
NetPortRef::device_class () const
NetTerminalRef::device_class () const
{
return mp_device ? mp_device->device_class () : 0;
}
@ -366,8 +366,8 @@ Net &Net::operator= (const Net &other)
add_pin (*i);
}
for (const_port_iterator i = other.begin_ports (); i != other.end_ports (); ++i) {
add_port (*i);
for (const_terminal_iterator i = other.begin_terminals (); i != other.end_terminals (); ++i) {
add_terminal (*i);
}
}
@ -384,8 +384,8 @@ void Net::clear ()
m_name.clear ();
m_cluster_id = 0;
while (! m_ports.empty ()) {
erase_port (begin_ports ());
while (! m_terminals.empty ()) {
erase_terminal (begin_terminals ());
}
while (! m_pins.empty ()) {
@ -428,24 +428,24 @@ void Net::erase_pin (pin_iterator iter)
m_pins.erase (iter);
}
void Net::add_port (const NetPortRef &port)
void Net::add_terminal (const NetTerminalRef &terminal)
{
if (! port.device ()) {
if (! terminal.device ()) {
return;
}
m_ports.push_back (port);
NetPortRef &new_port = m_ports.back ();
new_port.set_net (this);
new_port.device ()->set_port_ref_for_port (new_port.port_id (), --m_ports.end ());
m_terminals.push_back (terminal);
NetTerminalRef &new_terminal = m_terminals.back ();
new_terminal.set_net (this);
new_terminal.device ()->set_terminal_ref_for_terminal (new_terminal.terminal_id (), --m_terminals.end ());
}
void Net::erase_port (port_iterator iter)
void Net::erase_terminal (terminal_iterator iter)
{
if (iter->device ()) {
iter->device ()->set_port_ref_for_port (iter->port_id (), port_iterator ());
iter->device ()->set_terminal_ref_for_terminal (iter->terminal_id (), terminal_iterator ());
}
m_ports.erase (iter);
m_terminals.erase (iter);
}
void Net::set_circuit (Circuit *circuit)
@ -500,10 +500,10 @@ Circuit &Circuit::operator= (const Circuit &other)
n->set_name (i->name ());
add_net (n);
for (Net::const_port_iterator p = i->begin_ports (); p != i->end_ports (); ++p) {
for (Net::const_terminal_iterator p = i->begin_terminals (); p != i->end_terminals (); ++p) {
std::map<const Device *, Device *>::const_iterator m = device_table.find (p->device ());
tl_assert (m != device_table.end ());
n->add_port (NetPortRef (m->second, p->port_id ()));
n->add_terminal (NetTerminalRef (m->second, p->terminal_id ()));
}
for (Net::const_pin_iterator p = i->begin_pins (); p != i->end_pins (); ++p) {
@ -671,10 +671,10 @@ static void check_device_before_remove (db::Circuit *c, const db::Device *d)
if (d->device_class () != 0) {
throw tl::Exception (tl::to_string (tr ("Internal error: No device class after removing device in device combination")) + ": name=" + d->name () + ", circuit=" + c->name ());
}
const std::vector<db::DevicePortDefinition> &pd = d->device_class ()->port_definitions ();
for (std::vector<db::DevicePortDefinition>::const_iterator p = pd.begin (); p != pd.end (); ++p) {
if (d->net_for_port (p->id ()) != 0) {
throw tl::Exception (tl::to_string (tr ("Internal error: Port still connected after removing device in device combination")) + ": name=" + d->name () + ", circuit=" + c->name () + ", port=" + p->name ());
const std::vector<db::DeviceTerminalDefinition> &pd = d->device_class ()->terminal_definitions ();
for (std::vector<db::DeviceTerminalDefinition>::const_iterator p = pd.begin (); p != pd.end (); ++p) {
if (d->net_for_terminal (p->id ()) != 0) {
throw tl::Exception (tl::to_string (tr ("Internal error: Terminal still connected after removing device in device combination")) + ": name=" + d->name () + ", circuit=" + c->name () + ", terminal=" + p->name ());
}
}
}
@ -693,9 +693,9 @@ void Circuit::combine_parallel_devices (const db::DeviceClass &cls)
}
key_type k;
const std::vector<db::DevicePortDefinition> &ports = cls.port_definitions ();
for (std::vector<db::DevicePortDefinition>::const_iterator p = ports.begin (); p != ports.end (); ++p) {
const db::Net *n = d->net_for_port (p->id ());
const std::vector<db::DeviceTerminalDefinition> &terminals = cls.terminal_definitions ();
for (std::vector<db::DeviceTerminalDefinition>::const_iterator p = terminals.begin (); p != terminals.end (); ++p) {
const db::Net *n = d->net_for_terminal (p->id ());
if (n) {
k.push_back (n);
}
@ -734,22 +734,22 @@ static std::pair<db::Device *, db::Device *> attached_two_devices (db::Net &net,
db::Device *d1 = 0, *d2 = 0;
Net::port_iterator p = net.begin_ports ();
if (p == net.end_ports () || tl::id_of (p->device_class ()) != tl::id_of (&cls)) {
Net::terminal_iterator p = net.begin_terminals ();
if (p == net.end_terminals () || tl::id_of (p->device_class ()) != tl::id_of (&cls)) {
return std::make_pair ((db::Device *) 0, (db::Device *) 0);
} else {
d1 = p->device ();
}
++p;
if (p == net.end_ports () || tl::id_of (p->device_class ()) != tl::id_of (&cls)) {
if (p == net.end_terminals () || tl::id_of (p->device_class ()) != tl::id_of (&cls)) {
return std::make_pair ((db::Device *) 0, (db::Device *) 0);
} else {
d2 = p->device ();
}
++p;
if (p != net.end_ports () || d1 == d2 || !d1 || !d2) {
if (p != net.end_terminals () || d1 == d2 || !d1 || !d2) {
return std::make_pair ((db::Device *) 0, (db::Device *) 0);
} else {
return std::make_pair (d1, d2);
@ -778,14 +778,14 @@ void Circuit::combine_serial_devices (const db::DeviceClass &cls)
std::vector<const db::Net *> other_nets;
const std::vector<db::DevicePortDefinition> &ports = cls.port_definitions ();
for (std::vector<db::DevicePortDefinition>::const_iterator p = ports.begin (); p != ports.end (); ++p) {
const std::vector<db::DeviceTerminalDefinition> &terminals = cls.terminal_definitions ();
for (std::vector<db::DeviceTerminalDefinition>::const_iterator p = terminals.begin (); p != terminals.end (); ++p) {
db::Net *on;
on = dd.first->net_for_port (p->id ());
on = dd.first->net_for_terminal (p->id ());
if (on && ! same_or_swapped (dd, attached_two_devices (*on, cls))) {
other_nets.push_back (on);
}
on = dd.second->net_for_port (p->id ());
on = dd.second->net_for_terminal (p->id ());
if (on && ! same_or_swapped (dd, attached_two_devices (*on, cls))) {
other_nets.push_back (on);
}
@ -794,7 +794,7 @@ void Circuit::combine_serial_devices (const db::DeviceClass &cls)
std::sort (other_nets.begin (), other_nets.end ());
other_nets.erase (std::unique (other_nets.begin (), other_nets.end ()), other_nets.end ());
if (other_nets.size () <= cls.port_definitions().size ()) {
if (other_nets.size () <= cls.terminal_definitions().size ()) {
// found a combination candidate
if (cls.combine_devices (dd.first, dd.second)) {
@ -839,29 +839,29 @@ DeviceClass::DeviceClass (const DeviceClass &other)
DeviceClass &DeviceClass::operator= (const DeviceClass &other)
{
if (this != &other) {
m_port_definitions = other.m_port_definitions;
m_terminal_definitions = other.m_terminal_definitions;
m_name = other.m_name;
m_description = other.m_description;
}
return *this;
}
const DevicePortDefinition &DeviceClass::add_port_definition (const DevicePortDefinition &pd)
const DeviceTerminalDefinition &DeviceClass::add_terminal_definition (const DeviceTerminalDefinition &pd)
{
m_port_definitions.push_back (pd);
m_port_definitions.back ().set_id (m_port_definitions.size () - 1);
return m_port_definitions.back ();
m_terminal_definitions.push_back (pd);
m_terminal_definitions.back ().set_id (m_terminal_definitions.size () - 1);
return m_terminal_definitions.back ();
}
void DeviceClass::clear_port_definitions ()
void DeviceClass::clear_terminal_definitions ()
{
m_port_definitions.clear ();
m_terminal_definitions.clear ();
}
const DevicePortDefinition *DeviceClass::port_definition (size_t id) const
const DeviceTerminalDefinition *DeviceClass::terminal_definition (size_t id) const
{
if (id < m_port_definitions.size ()) {
return & m_port_definitions [id];
if (id < m_terminal_definitions.size ()) {
return & m_terminal_definitions [id];
} else {
return 0;
}

View File

@ -44,55 +44,55 @@ class SubCircuit;
class Pin;
class Device;
class DeviceClass;
class DevicePortDefinition;
class DeviceTerminalDefinition;
class Netlist;
class Net;
/**
* @brief A reference to a port of a device
* @brief A reference to a terminal of a device
*
* A port must always refer to a device inside the current circuit.
* A terminal must always refer to a device inside the current circuit.
*/
class DB_PUBLIC NetPortRef
class DB_PUBLIC NetTerminalRef
{
public:
/**
* @brief Default constructor
*/
NetPortRef ();
NetTerminalRef ();
/**
* @brief Creates a pin reference to the given pin of the current circuit
*/
NetPortRef (Device *device, size_t port_id);
NetTerminalRef (Device *device, size_t terminal_id);
/**
* @brief Copy constructor
*/
NetPortRef (const NetPortRef &other);
NetTerminalRef (const NetTerminalRef &other);
/**
* @brief Assignment
*/
NetPortRef &operator= (const NetPortRef &other);
NetTerminalRef &operator= (const NetTerminalRef &other);
/**
* @brief Comparison
*/
bool operator< (const NetPortRef &other) const
bool operator< (const NetTerminalRef &other) const
{
if (mp_device != other.mp_device) {
return mp_device < other.mp_device;
}
return m_port_id < other.m_port_id;
return m_terminal_id < other.m_terminal_id;
}
/**
* @brief Equality
*/
bool operator== (const NetPortRef &other) const
bool operator== (const NetTerminalRef &other) const
{
return (mp_device == other.mp_device && m_port_id == other.m_port_id);
return (mp_device == other.mp_device && m_terminal_id == other.m_terminal_id);
}
/**
@ -112,19 +112,19 @@ public:
}
/**
* @brief Gets the port index
* @brief Gets the terminal index
*/
size_t port_id () const
size_t terminal_id () const
{
return m_port_id;
return m_terminal_id;
}
/**
* @brief Gets the port definition
* @brief Gets the terminal definition
*
* Returns 0 if the port is not a valid port reference.
* Returns 0 if the terminal is not a valid terminal reference.
*/
const DevicePortDefinition *port_def () const;
const DeviceTerminalDefinition *terminal_def () const;
/**
* @brief Returns the device class
@ -132,7 +132,7 @@ public:
const DeviceClass *device_class () const;
/**
* @brief Gets the net the port lives in
* @brief Gets the net the terminal lives in
*/
Net *net ()
{
@ -140,7 +140,7 @@ public:
}
/**
* @brief Gets the net the port lives in (const version)
* @brief Gets the net the terminal lives in (const version)
*/
const Net *net () const
{
@ -150,12 +150,12 @@ public:
private:
friend class Net;
size_t m_port_id;
size_t m_terminal_id;
Device *mp_device;
Net *mp_net;
/**
* @brief Sets the net the port lives in
* @brief Sets the net the terminal lives in
*/
void set_net (Net *net)
{
@ -271,7 +271,7 @@ private:
Net *mp_net;
/**
* @brief Sets the net the port lives in
* @brief Sets the net the terminal lives in
*/
void set_net (Net *net)
{
@ -282,15 +282,15 @@ private:
/**
* @brief A net
*
* A net connects ports of devices and pins or circuits
* A net connects terminals of devices and pins or circuits
*/
class DB_PUBLIC Net
: public tl::Object
{
public:
typedef std::list<NetPortRef> port_list;
typedef port_list::const_iterator const_port_iterator;
typedef port_list::iterator port_iterator;
typedef std::list<NetTerminalRef> terminal_list;
typedef terminal_list::const_iterator const_terminal_iterator;
typedef terminal_list::iterator terminal_iterator;
typedef std::list<NetPinRef> pin_list;
typedef pin_list::const_iterator const_pin_iterator;
typedef pin_list::iterator pin_iterator;
@ -411,45 +411,45 @@ public:
}
/**
* @brief Adds a port to this net
* @brief Adds a terminal to this net
*/
void add_port (const NetPortRef &port);
void add_terminal (const NetTerminalRef &terminal);
/**
* @brief Erases the given port from this net
* @brief Erases the given terminal from this net
*/
void erase_port (port_iterator iter);
void erase_terminal (terminal_iterator iter);
/**
* @brief Begin iterator for the ports of the net (const version)
* @brief Begin iterator for the terminals of the net (const version)
*/
const_port_iterator begin_ports () const
const_terminal_iterator begin_terminals () const
{
return m_ports.begin ();
return m_terminals.begin ();
}
/**
* @brief End iterator for the ports of the net (const version)
* @brief End iterator for the terminals of the net (const version)
*/
const_port_iterator end_ports () const
const_terminal_iterator end_terminals () const
{
return m_ports.end ();
return m_terminals.end ();
}
/**
* @brief Begin iterator for the ports of the net (non-const version)
* @brief Begin iterator for the terminals of the net (non-const version)
*/
port_iterator begin_ports ()
terminal_iterator begin_terminals ()
{
return m_ports.begin ();
return m_terminals.begin ();
}
/**
* @brief End iterator for the ports of the net (non-const version)
* @brief End iterator for the terminals of the net (non-const version)
*/
port_iterator end_ports ()
terminal_iterator end_terminals ()
{
return m_ports.end ();
return m_terminals.end ();
}
/**
@ -457,13 +457,13 @@ public:
*/
bool floating () const
{
return (m_pins.size () + m_ports.size ()) < 2;
return (m_pins.size () + m_terminals.size ()) < 2;
}
private:
friend class Circuit;
port_list m_ports;
terminal_list m_terminals;
pin_list m_pins;
std::string m_name;
size_t m_cluster_id;
@ -579,27 +579,27 @@ public:
}
/**
* @brief Gets the net attached to a specific port
* @brief Gets the net attached to a specific terminal
* Returns 0 if no net is attached.
*/
const Net *net_for_port (size_t port_id) const;
const Net *net_for_terminal (size_t terminal_id) const;
/**
* @brief Gets the net attached to a specific port (non-const version)
* @brief Gets the net attached to a specific terminal (non-const version)
* Returns 0 if no net is attached.
*/
Net *net_for_port (size_t port_id)
Net *net_for_terminal (size_t terminal_id)
{
return const_cast<Net *> (((const Device *) this)->net_for_port (port_id));
return const_cast<Net *> (((const Device *) this)->net_for_terminal (terminal_id));
}
/**
* @brief Connects the given port to the given net
* If the net is 0 the port is disconnected.
* If non-null, a NetPortRef object will be inserted into the
* net and connected with the given port.
* @brief Connects the given terminal to the given net
* If the net is 0 the terminal is disconnected.
* If non-null, a NetTerminalRef object will be inserted into the
* net and connected with the given terminal.
*/
void connect_port (size_t port_id, Net *net);
void connect_terminal (size_t terminal_id, Net *net);
/**
* @brief Gets the value for the parameter with the given ID
@ -617,13 +617,13 @@ private:
DeviceClass *mp_device_class;
std::string m_name;
std::vector<Net::port_iterator> m_port_refs;
std::vector<Net::terminal_iterator> m_terminal_refs;
std::vector<double> m_parameters;
/**
* @brief Sets the port reference for a specific port
* @brief Sets the terminal reference for a specific terminal
*/
void set_port_ref_for_port (size_t port_id, Net::port_iterator iter);
void set_terminal_ref_for_terminal (size_t terminal_id, Net::terminal_iterator iter);
/**
* @brief Sets the device class
@ -1105,31 +1105,31 @@ private:
};
/**
* @brief A device port definition
* @brief A device terminal definition
*/
class DB_PUBLIC DevicePortDefinition
class DB_PUBLIC DeviceTerminalDefinition
{
public:
/**
* @brief Creates an empty device port definition
* @brief Creates an empty device terminal definition
*/
DevicePortDefinition ()
DeviceTerminalDefinition ()
: m_name (), m_description (), m_id (0)
{
// .. nothing yet ..
}
/**
* @brief Creates a device port definition with the given name and description
* @brief Creates a device terminal definition with the given name and description
*/
DevicePortDefinition (const std::string &name, const std::string &description)
DeviceTerminalDefinition (const std::string &name, const std::string &description)
: m_name (name), m_description (description), m_id (0)
{
// .. nothing yet ..
}
/**
* @brief Gets the port name
* @brief Gets the terminal name
*/
const std::string &name () const
{
@ -1137,7 +1137,7 @@ public:
}
/**
* @brief Sets the port name
* @brief Sets the terminal name
*/
void set_name (const std::string &n)
{
@ -1145,7 +1145,7 @@ public:
}
/**
* @brief Gets the port description
* @brief Gets the terminal description
*/
const std::string &description () const
{
@ -1153,7 +1153,7 @@ public:
}
/**
* @brief Sets the port description
* @brief Sets the terminal description
*/
void set_description (const std::string &d)
{
@ -1161,7 +1161,7 @@ public:
}
/**
* @brief Gets the port ID
* @brief Gets the terminal ID
*/
size_t id () const
{
@ -1282,7 +1282,7 @@ class DB_PUBLIC DeviceClass
: public gsi::ObjectBase, public tl::Object, public tl::UniqueId
{
public:
typedef size_t port_id_type;
typedef size_t terminal_id_type;
/**
* @brief Constructor
@ -1359,31 +1359,31 @@ public:
}
/**
* @brief Gets the port definitions
* @brief Gets the terminal definitions
*
* The port definitions indicate what ports the device offers.
* The number of ports is constant per class. The index of the port
* is used as an ID of the port, hence the order must be static.
* The terminal definitions indicate what terminals the device offers.
* The number of terminals is constant per class. The index of the terminal
* is used as an ID of the terminal, hence the order must be static.
*/
const std::vector<DevicePortDefinition> &port_definitions () const
const std::vector<DeviceTerminalDefinition> &terminal_definitions () const
{
return m_port_definitions;
return m_terminal_definitions;
}
/**
* @brief Adds a port definition
* @brief Adds a terminal definition
*/
const DevicePortDefinition &add_port_definition (const DevicePortDefinition &pd);
const DeviceTerminalDefinition &add_terminal_definition (const DeviceTerminalDefinition &pd);
/**
* @brief Clears the port definition
* @brief Clears the terminal definition
*/
void clear_port_definitions ();
void clear_terminal_definitions ();
/**
* @brief Gets the port definition from the ID
* @brief Gets the terminal definition from the ID
*/
const DevicePortDefinition *port_definition (size_t id) const;
const DeviceTerminalDefinition *terminal_definition (size_t id) const;
/**
* @brief Gets the parameter definitions
@ -1451,7 +1451,7 @@ private:
friend class Netlist;
std::string m_name, m_description;
std::vector<DevicePortDefinition> m_port_definitions;
std::vector<DeviceTerminalDefinition> m_terminal_definitions;
std::vector<DeviceParameterDefinition> m_parameter_definitions;
db::Netlist *mp_netlist;

View File

@ -26,14 +26,14 @@ namespace db
{
// ------------------------------------------------------------------------------------
// DeviceClassTwoPortDevice implementation
// DeviceClassTwoTerminalDevice implementation
bool DeviceClassTwoPortDevice::combine_devices (Device *a, Device *b) const
bool DeviceClassTwoTerminalDevice::combine_devices (Device *a, Device *b) const
{
db::Net *na1 = a->net_for_port (0);
db::Net *na2 = a->net_for_port (1);
db::Net *nb1 = b->net_for_port (0);
db::Net *nb2 = b->net_for_port (1);
db::Net *na1 = a->net_for_terminal (0);
db::Net *na2 = a->net_for_terminal (1);
db::Net *nb1 = b->net_for_terminal (0);
db::Net *nb2 = b->net_for_terminal (1);
bool res = true;
@ -45,19 +45,19 @@ bool DeviceClassTwoPortDevice::combine_devices (Device *a, Device *b) const
// serial a(B) to b(A or B)
serial (a, b);
a->connect_port (1, (na2 == nb1 ? nb2 : nb1));
a->connect_terminal (1, (na2 == nb1 ? nb2 : nb1));
} else if (na1 == nb1 || na1 == nb2) {
// serial a(A) to b(A or B)
serial (a, b);
a->connect_port (0, (na1 == nb1 ? nb2 : nb1));
a->connect_terminal (0, (na1 == nb1 ? nb2 : nb1));
}
if (res) {
b->connect_port (0, 0);
b->connect_port (1, 0);
b->connect_terminal (0, 0);
b->connect_terminal (1, 0);
return true;
} else {
return false;
@ -70,8 +70,8 @@ bool DeviceClassTwoPortDevice::combine_devices (Device *a, Device *b) const
DeviceClassResistor::DeviceClassResistor ()
{
add_port_definition (db::DevicePortDefinition ("A", "Port A"));
add_port_definition (db::DevicePortDefinition ("B", "Port B"));
add_terminal_definition (db::DeviceTerminalDefinition ("A", "Terminal A"));
add_terminal_definition (db::DeviceTerminalDefinition ("B", "Terminal B"));
add_parameter_definition (db::DeviceParameterDefinition ("R", "Resistance (Ohm)", 0.0));
}
@ -95,8 +95,8 @@ void DeviceClassResistor::serial (Device *a, Device *b) const
DeviceClassCapacitor::DeviceClassCapacitor ()
{
add_port_definition (db::DevicePortDefinition ("A", "Port A"));
add_port_definition (db::DevicePortDefinition ("B", "Port B"));
add_terminal_definition (db::DeviceTerminalDefinition ("A", "Terminal A"));
add_terminal_definition (db::DeviceTerminalDefinition ("B", "Terminal B"));
add_parameter_definition (db::DeviceParameterDefinition ("C", "Capacitance (Farad)", 0.0));
}
@ -120,8 +120,8 @@ void DeviceClassCapacitor::parallel (Device *a, Device *b) const
DeviceClassInductor::DeviceClassInductor ()
{
add_port_definition (db::DevicePortDefinition ("A", "Port A"));
add_port_definition (db::DevicePortDefinition ("B", "Port B"));
add_terminal_definition (db::DeviceTerminalDefinition ("A", "Terminal A"));
add_terminal_definition (db::DeviceTerminalDefinition ("B", "Terminal B"));
add_parameter_definition (db::DeviceParameterDefinition ("L", "Inductance (Henry)", 0.0));
}
@ -145,25 +145,25 @@ void DeviceClassInductor::serial (Device *a, Device *b) const
DeviceClassDiode::DeviceClassDiode ()
{
add_port_definition (db::DevicePortDefinition ("A", "Anode"));
add_port_definition (db::DevicePortDefinition ("C", "Cathode"));
add_terminal_definition (db::DeviceTerminalDefinition ("A", "Anode"));
add_terminal_definition (db::DeviceTerminalDefinition ("C", "Cathode"));
add_parameter_definition (db::DeviceParameterDefinition ("A", "Area (square micrometer)", 0.0));
}
bool DeviceClassDiode::combine_devices (Device *a, Device *b) const
{
const db::Net *na1 = a->net_for_port (0);
const db::Net *na2 = a->net_for_port (1);
const db::Net *nb1 = b->net_for_port (0);
const db::Net *nb2 = b->net_for_port (1);
const db::Net *na1 = a->net_for_terminal (0);
const db::Net *na2 = a->net_for_terminal (1);
const db::Net *nb1 = b->net_for_terminal (0);
const db::Net *nb2 = b->net_for_terminal (1);
// only parallel diodes can be combined and their areas will add
if ((na1 == nb1 && na2 == nb2) || (na1 == nb2 && na2 == nb1)) {
a->set_parameter_value (0, a->parameter_value (0) + b->parameter_value (0));
b->connect_port (0, 0);
b->connect_port (1, 0);
b->connect_terminal (0, 0);
b->connect_terminal (1, 0);
return true;
@ -177,9 +177,9 @@ bool DeviceClassDiode::combine_devices (Device *a, Device *b) const
DeviceClassMOS3Transistor::DeviceClassMOS3Transistor ()
{
add_port_definition (db::DevicePortDefinition ("S", "Source"));
add_port_definition (db::DevicePortDefinition ("G", "Gate"));
add_port_definition (db::DevicePortDefinition ("D", "Drain"));
add_terminal_definition (db::DeviceTerminalDefinition ("S", "Source"));
add_terminal_definition (db::DeviceTerminalDefinition ("G", "Gate"));
add_terminal_definition (db::DeviceTerminalDefinition ("D", "Drain"));
add_parameter_definition (db::DeviceParameterDefinition ("L", "Gate length (micrometer)", 0.0));
add_parameter_definition (db::DeviceParameterDefinition ("W", "Gate width (micrometer)", 0.0));
@ -189,12 +189,12 @@ DeviceClassMOS3Transistor::DeviceClassMOS3Transistor ()
bool DeviceClassMOS3Transistor::combine_devices (Device *a, Device *b) const
{
const db::Net *nas = a->net_for_port (0);
const db::Net *nag = a->net_for_port (1);
const db::Net *nad = a->net_for_port (2);
const db::Net *nbs = b->net_for_port (0);
const db::Net *nbg = b->net_for_port (1);
const db::Net *nbd = b->net_for_port (2);
const db::Net *nas = a->net_for_terminal (0);
const db::Net *nag = a->net_for_terminal (1);
const db::Net *nad = a->net_for_terminal (2);
const db::Net *nbs = b->net_for_terminal (0);
const db::Net *nbg = b->net_for_terminal (1);
const db::Net *nbd = b->net_for_terminal (2);
// parallel transistors can be combined into one
if (((nas == nbs && nad == nbd) || (nas == nbd && nad == nbs)) && nag == nbg) {
@ -205,9 +205,9 @@ bool DeviceClassMOS3Transistor::combine_devices (Device *a, Device *b) const
a->set_parameter_value (1, a->parameter_value (1) + b->parameter_value (1));
a->set_parameter_value (2, a->parameter_value (2) + b->parameter_value (2));
a->set_parameter_value (3, a->parameter_value (3) + b->parameter_value (3));
b->connect_port (0, 0);
b->connect_port (1, 0);
b->connect_port (2, 0);
b->connect_terminal (0, 0);
b->connect_terminal (1, 0);
b->connect_terminal (2, 0);
return true;
@ -223,10 +223,10 @@ bool DeviceClassMOS3Transistor::combine_devices (Device *a, Device *b) const
DeviceClassMOS4Transistor::DeviceClassMOS4Transistor ()
{
add_port_definition (db::DevicePortDefinition ("S", "Source"));
add_port_definition (db::DevicePortDefinition ("G", "Gate"));
add_port_definition (db::DevicePortDefinition ("D", "Drain"));
add_port_definition (db::DevicePortDefinition ("B", "Bulk"));
add_terminal_definition (db::DeviceTerminalDefinition ("S", "Source"));
add_terminal_definition (db::DeviceTerminalDefinition ("G", "Gate"));
add_terminal_definition (db::DeviceTerminalDefinition ("D", "Drain"));
add_terminal_definition (db::DeviceTerminalDefinition ("B", "Bulk"));
add_parameter_definition (db::DeviceParameterDefinition ("L", "Gate length (micrometer)", 0.0));
add_parameter_definition (db::DeviceParameterDefinition ("W", "Gate width (micrometer)", 0.0));
@ -236,14 +236,14 @@ DeviceClassMOS4Transistor::DeviceClassMOS4Transistor ()
bool DeviceClassMOS4Transistor::combine_devices (Device *a, Device *b) const
{
const db::Net *nas = a->net_for_port (0);
const db::Net *nag = a->net_for_port (1);
const db::Net *nad = a->net_for_port (2);
const db::Net *nab = a->net_for_port (3);
const db::Net *nbs = b->net_for_port (0);
const db::Net *nbg = b->net_for_port (1);
const db::Net *nbd = b->net_for_port (2);
const db::Net *nbb = b->net_for_port (3);
const db::Net *nas = a->net_for_terminal (0);
const db::Net *nag = a->net_for_terminal (1);
const db::Net *nad = a->net_for_terminal (2);
const db::Net *nab = a->net_for_terminal (3);
const db::Net *nbs = b->net_for_terminal (0);
const db::Net *nbg = b->net_for_terminal (1);
const db::Net *nbd = b->net_for_terminal (2);
const db::Net *nbb = b->net_for_terminal (3);
// parallel transistors can be combined into one
if (((nas == nbs && nad == nbd) || (nas == nbd && nad == nbs)) && nag == nbg && nab == nbb) {
@ -254,10 +254,10 @@ bool DeviceClassMOS4Transistor::combine_devices (Device *a, Device *b) const
a->set_parameter_value (1, a->parameter_value (1) + b->parameter_value (1));
a->set_parameter_value (2, a->parameter_value (2) + b->parameter_value (2));
a->set_parameter_value (3, a->parameter_value (3) + b->parameter_value (3));
b->connect_port (0, 0);
b->connect_port (1, 0);
b->connect_port (2, 0);
b->connect_port (3, 0);
b->connect_terminal (0, 0);
b->connect_terminal (1, 0);
b->connect_terminal (2, 0);
b->connect_terminal (3, 0);
return true;

View File

@ -30,9 +30,9 @@ namespace db
{
/**
* @brief A basic two-port device class
* @brief A basic two-terminal device class
*/
class DB_PUBLIC DeviceClassTwoPortDevice
class DB_PUBLIC DeviceClassTwoTerminalDevice
: public db::DeviceClass
{
public:
@ -47,10 +47,10 @@ public:
/**
* @brief A basic resistor device class
* A resistor defines a single parameter, "R", which is the resistance in Ohm.
* It defines two ports, "A" and "B" for the two terminals.
* It defines two terminals, "A" and "B" for the two terminals.
*/
class DB_PUBLIC DeviceClassResistor
: public db::DeviceClassTwoPortDevice
: public db::DeviceClassTwoTerminalDevice
{
public:
DeviceClassResistor ();
@ -67,10 +67,10 @@ public:
/**
* @brief A basic capacitor device class
* A capacitor defines a single parameter, "C", which is the capacitance in Farad.
* It defines two ports, "A" and "B" for the two terminals.
* It defines two terminals, "A" and "B" for the two terminals.
*/
class DB_PUBLIC DeviceClassCapacitor
: public db::DeviceClassTwoPortDevice
: public db::DeviceClassTwoTerminalDevice
{
public:
DeviceClassCapacitor ();
@ -87,10 +87,10 @@ public:
/**
* @brief A basic inductor device class
* An inductor defines a single parameter, "L", which is the inductance in Henry.
* It defines two ports, "A" and "B" for the two terminals.
* It defines two terminals, "A" and "B" for the two terminals.
*/
class DB_PUBLIC DeviceClassInductor
: public db::DeviceClassTwoPortDevice
: public db::DeviceClassTwoTerminalDevice
{
public:
DeviceClassInductor ();
@ -108,7 +108,7 @@ public:
* @brief A basic diode device class
* A diode defines a single parameter, "A", which is the area in square micrometers (YES: micrometers, as this is the basic unit of measure
* in KLayout).
* It defines two ports, "A" and "C" for anode and cathode.
* It defines two terminals, "A" and "C" for anode and cathode.
*/
class DB_PUBLIC DeviceClassDiode
: public db::DeviceClass
@ -129,7 +129,7 @@ public:
* @brief A basic MOSFET device class with three terminals
* A MOSFET defines four parameters: "W" for the gate width in micrometers, "L" for the gate length in micrometers,
* "AS" for the source area and "AD" for the drain area.
* The MOSFET device defines three ports, "S", "D" and "G" for source, drain and gate.
* The MOSFET device defines three terminals, "S", "D" and "G" for source, drain and gate.
*/
class DB_PUBLIC DeviceClassMOS3Transistor
: public db::DeviceClass
@ -149,7 +149,7 @@ public:
/**
* @brief A basic MOSFET device class with four terminals
* The four-terminal MOSFET behaves identical to the three-terminal one but adds one more
* port for the bulk.
* terminal for the bulk.
*/
class DB_PUBLIC DeviceClassMOS4Transistor
: public db::DeviceClass

View File

@ -62,7 +62,7 @@ void NetlistDeviceExtractor::extract (db::Layout &layout, db::Cell &cell, const
mp_layout = &layout;
// port properties are kept in property index 0
// terminal properties are kept in property index 0
m_propname_id = mp_layout->properties_repository ().prop_name_id (tl::Variant (int (0)));
tl_assert (m_netlist.get () != 0);
@ -165,30 +165,30 @@ Device *NetlistDeviceExtractor::create_device (unsigned int device_class_index)
return device;
}
void NetlistDeviceExtractor::define_port (Device *device, size_t port_id, size_t layer_index, const db::Polygon &polygon)
void NetlistDeviceExtractor::define_terminal (Device *device, size_t terminal_id, size_t layer_index, const db::Polygon &polygon)
{
tl_assert (mp_layout != 0);
// Build a property set for the DevicePortProperty
// Build a property set for the DeviceTerminalProperty
db::PropertiesRepository::properties_set ps;
tl::Variant &v = ps.insert (std::make_pair (m_propname_id, tl::Variant ()))->second;
v = tl::Variant (new db::DevicePortProperty (db::NetPortRef (device, port_id)), db::NetlistProperty::variant_class (), true);
v = tl::Variant (new db::DeviceTerminalProperty (db::NetTerminalRef (device, terminal_id)), db::NetlistProperty::variant_class (), true);
db::properties_id_type pi = mp_layout->properties_repository ().properties_id (ps);
db::PolygonRef pr (polygon, mp_layout->shape_repository ());
mp_layout->cell (m_cell_index).shapes (layer_index).insert (db::PolygonRefWithProperties (pr, pi));
}
void NetlistDeviceExtractor::define_port (Device *device, size_t port_id, size_t layer_index, const db::Box &box)
void NetlistDeviceExtractor::define_terminal (Device *device, size_t terminal_id, size_t layer_index, const db::Box &box)
{
define_port (device, port_id, layer_index, db::Polygon (box));
define_terminal (device, terminal_id, layer_index, db::Polygon (box));
}
void NetlistDeviceExtractor::define_port (Device *device, size_t port_id, size_t layer_index, const db::Point &point)
void NetlistDeviceExtractor::define_terminal (Device *device, size_t terminal_id, size_t layer_index, const db::Point &point)
{
// NOTE: we add one DBU to the "point" to prevent it from vanishing
db::Vector dv (1, 1);
define_port (device, port_id, layer_index, db::Polygon (db::Box (point - dv, point + dv)));
define_terminal (device, terminal_id, layer_index, db::Polygon (db::Box (point - dv, point + dv)));
}
}

View File

@ -71,9 +71,9 @@ public:
* cells from the layout.
*
* Devices will be generated inside the netlist's circuits as they are extracted
* from the layout. Inside the layout, device port annotation shapes are created with the
* corresponding DevicePortProperty objects attached. The will be used when extracting
* the nets later to associate nets with device ports.
* from the layout. Inside the layout, device terminal annotation shapes are created with the
* corresponding DeviceTerminalProperty objects attached. The will be used when extracting
* the nets later to associate nets with device terminals.
*
* The definition of the input layers is device class specific.
*
@ -104,8 +104,8 @@ public:
* so the implementation needs to consider this case. The geometries are already merged.
*
* The implementation of this method shall use "create_device" to create new
* devices based on the geometry found. It shall use "define_port" to define
* ports by which the nets extracted in the network extraction step connect
* devices based on the geometry found. It shall use "define_terminal" to define
* terminals by which the nets extracted in the network extraction step connect
* to the new devices.
*/
virtual void extract_devices (const std::vector<db::Region> &layer_geometry);
@ -126,19 +126,19 @@ protected:
Device *create_device (unsigned int device_class_index = 0);
/**
* @brief Defines a device port in the layout (a polygon)
* @brief Defines a device terminal in the layout (a polygon)
*/
void define_port (Device *device, size_t port_id, size_t layer_index, const db::Polygon &polygon);
void define_terminal (Device *device, size_t terminal_id, size_t layer_index, const db::Polygon &polygon);
/**
* @brief Defines a device port in the layout (a box)
* @brief Defines a device terminal in the layout (a box)
*/
void define_port (Device *device, size_t port_id, size_t layer_index, const db::Box &box);
void define_terminal (Device *device, size_t terminal_id, size_t layer_index, const db::Box &box);
/**
* @brief Defines a point-like device port in the layout
* @brief Defines a point-like device terminal in the layout
*/
void define_port (Device *device, size_t port_id, size_t layer_index, const db::Point &point);
void define_terminal (Device *device, size_t terminal_id, size_t layer_index, const db::Point &point);
/**
* @brief Gets the database unit

View File

@ -190,70 +190,70 @@ std::string NetNameProperty::to_string () const
}
// --------------------------------------------------------------------------------------------
// DevicePortProperty Implementation
// DeviceTerminalProperty Implementation
DevicePortProperty::DevicePortProperty ()
DeviceTerminalProperty::DeviceTerminalProperty ()
: NetlistProperty ()
{
// .. nothing yet ..
}
DevicePortProperty::DevicePortProperty (const DevicePortProperty &other)
: NetlistProperty (other), m_port_ref (other.m_port_ref)
DeviceTerminalProperty::DeviceTerminalProperty (const DeviceTerminalProperty &other)
: NetlistProperty (other), m_terminal_ref (other.m_terminal_ref)
{
// .. nothing yet ..
}
DevicePortProperty::DevicePortProperty (const db::NetPortRef &p)
: NetlistProperty (), m_port_ref (p)
DeviceTerminalProperty::DeviceTerminalProperty (const db::NetTerminalRef &p)
: NetlistProperty (), m_terminal_ref (p)
{
// .. nothing yet ..
}
DevicePortProperty &DevicePortProperty::operator= (const DevicePortProperty &other)
DeviceTerminalProperty &DeviceTerminalProperty::operator= (const DeviceTerminalProperty &other)
{
NetlistProperty::operator= (other);
if (this != &other) {
m_port_ref = other.m_port_ref;
m_terminal_ref = other.m_terminal_ref;
}
return *this;
}
void DevicePortProperty::set_port_ref (const db::NetPortRef &p)
void DeviceTerminalProperty::set_terminal_ref (const db::NetTerminalRef &p)
{
m_port_ref = p;
m_terminal_ref = p;
}
bool DevicePortProperty::equals (const NetlistProperty *p) const
bool DeviceTerminalProperty::equals (const NetlistProperty *p) const
{
const DevicePortProperty *pp = static_cast<const DevicePortProperty *> (p);
return NetlistProperty::equals (p) && m_port_ref == pp->m_port_ref;
const DeviceTerminalProperty *pp = static_cast<const DeviceTerminalProperty *> (p);
return NetlistProperty::equals (p) && m_terminal_ref == pp->m_terminal_ref;
}
bool DevicePortProperty::less (const NetlistProperty *p) const
bool DeviceTerminalProperty::less (const NetlistProperty *p) const
{
if (! NetlistProperty::equals (p)) {
return NetlistProperty::less (p);
} else {
const DevicePortProperty *pp = static_cast<const DevicePortProperty *> (p);
return m_port_ref < pp->m_port_ref;
const DeviceTerminalProperty *pp = static_cast<const DeviceTerminalProperty *> (p);
return m_terminal_ref < pp->m_terminal_ref;
}
}
void DevicePortProperty::assign (const NetlistProperty *p)
void DeviceTerminalProperty::assign (const NetlistProperty *p)
{
NetlistProperty::assign (p);
const DevicePortProperty *pp = static_cast<const DevicePortProperty *> (p);
m_port_ref = pp->m_port_ref;
const DeviceTerminalProperty *pp = static_cast<const DeviceTerminalProperty *> (p);
m_terminal_ref = pp->m_terminal_ref;
}
std::string DevicePortProperty::to_string () const
std::string DeviceTerminalProperty::to_string () const
{
if (m_port_ref.device () && m_port_ref.port_def ()) {
return "port:" + tl::to_word_or_quoted_string (m_port_ref.device ()->name ()) + ":" + tl::to_word_or_quoted_string (m_port_ref.port_def ()->name ());
if (m_terminal_ref.device () && m_terminal_ref.terminal_def ()) {
return "terminal:" + tl::to_word_or_quoted_string (m_terminal_ref.device ()->name ()) + ":" + tl::to_word_or_quoted_string (m_terminal_ref.terminal_def ()->name ());
} else {
return "port";
return "terminal";
}
}

View File

@ -224,56 +224,56 @@ private:
};
/**
* @brief A reference to a device port
* @brief A reference to a device terminal
*
* This property is used to mark a shape as a device port reference.
* Such a port reference points to a port of a specific device.
* This property is used to mark a shape as a device terminal reference.
* Such a terminal reference points to a terminal of a specific device.
* Attaching such a property to a shape allows connecting the
* net to the device later.
*/
class DB_PUBLIC DevicePortProperty
class DB_PUBLIC DeviceTerminalProperty
: public db::NetlistProperty
{
public:
/**
* @brief Creates a netlist name property without a specific name
*/
DevicePortProperty ();
DeviceTerminalProperty ();
/**
* @brief copy constructor
*/
DevicePortProperty (const db::DevicePortProperty &other);
DeviceTerminalProperty (const db::DeviceTerminalProperty &other);
/**
* @brief Creates a netlist name property with the given name
*/
DevicePortProperty (const db::NetPortRef &port_ref);
DeviceTerminalProperty (const db::NetTerminalRef &terminal_ref);
/**
* @brief Assignment
*/
DevicePortProperty &operator= (const DevicePortProperty &other);
DeviceTerminalProperty &operator= (const DeviceTerminalProperty &other);
/**
* @brief Sets the port reference
* @brief Sets the terminal reference
*/
void set_port_ref (const db::NetPortRef &port_ref);
void set_terminal_ref (const db::NetTerminalRef &terminal_ref);
/**
* @brief Gets the port reference
* @brief Gets the terminal reference
*/
const db::NetPortRef &port_ref () const
const db::NetTerminalRef &terminal_ref () const
{
return m_port_ref;
return m_terminal_ref;
}
/**
* @brief Clones the object
*/
virtual DevicePortProperty *clone () const
virtual DeviceTerminalProperty *clone () const
{
return new DevicePortProperty (*this);
return new DeviceTerminalProperty (*this);
}
/**
@ -297,7 +297,7 @@ public:
virtual std::string to_string () const;
private:
db::NetPortRef m_port_ref;
db::NetTerminalRef m_terminal_ref;
};
}

View File

@ -42,9 +42,9 @@ Class<db::Pin> decl_dbPin ("db", "Pin",
"This class has been added in version 0.26."
);
static void device_disconnect_port (db::Device *device, size_t port_id)
static void device_disconnect_terminal (db::Device *device, size_t terminal_id)
{
device->connect_port (port_id, 0);
device->connect_terminal (terminal_id, 0);
}
static bool device_has_param_with_name (const db::DeviceClass *device_class, const std::string &name)
@ -93,15 +93,15 @@ Class<db::Device> decl_dbDevice ("db", "Device",
gsi::method ("name", &db::Device::name,
"@brief Gets the name of the device.\n"
) +
gsi::method ("net_for_port", (db::Net *(db::Device::*) (size_t)) &db::Device::net_for_port, gsi::arg ("port_id"),
"@brief Gets the net connected to the specified port.\n"
"If the port is not connected, nil is returned for the net."
gsi::method ("net_for_terminal", (db::Net *(db::Device::*) (size_t)) &db::Device::net_for_terminal, gsi::arg ("terminal_id"),
"@brief Gets the net connected to the specified terminal.\n"
"If the terminal is not connected, nil is returned for the net."
) +
gsi::method ("connect_port", &db::Device::connect_port, gsi::arg ("port_id"), gsi::arg ("net"),
"@brief Connects the given port to the specified net.\n"
gsi::method ("connect_terminal", &db::Device::connect_terminal, gsi::arg ("terminal_id"), gsi::arg ("net"),
"@brief Connects the given terminal to the specified net.\n"
) +
gsi::method_ext ("disconnect_port", &device_disconnect_port, gsi::arg ("port_id"),
"@brief Disconnects the given port from any net.\n"
gsi::method_ext ("disconnect_terminal", &device_disconnect_terminal, gsi::arg ("terminal_id"),
"@brief Disconnects the given terminal from any net.\n"
) +
gsi::method ("parameter", &db::Device::parameter_value, gsi::arg ("param_id"),
"@brief Gets the parameter value for the given parameter ID."
@ -123,12 +123,12 @@ Class<db::Device> decl_dbDevice ("db", "Device",
"The type of device is represented by a \\DeviceClass object. Device objects "
"live in \\Circuit objects, the device class objects live in the \\Netlist object.\n"
"\n"
"Devices connect to nets through ports. Ports are described by a port ID which is "
"essentially the zero-based index of the port. Port definitions can be "
"obtained from the device class using the \\DeviceClass#port_definitions method.\n"
"Devices connect to nets through terminals. Terminals are described by a terminal ID which is "
"essentially the zero-based index of the terminal. Terminal definitions can be "
"obtained from the device class using the \\DeviceClass#terminal_definitions method.\n"
"\n"
"Devices connect to nets through the \\Device#connect_port method. "
"Device ports can be disconnected using \\Device#disconnect_port.\n"
"Devices connect to nets through the \\Device#connect_terminal method. "
"Device terminals can be disconnected using \\Device#disconnect_terminal.\n"
"\n"
"This class has been added in version 0.26."
);
@ -195,24 +195,24 @@ Class<db::SubCircuit> decl_dbSubCircuit ("db", "SubCircuit",
"This class has been added in version 0.26."
);
Class<db::NetPortRef> decl_dbNetPortRef ("db", "NetPortRef",
gsi::method ("port_id", &db::NetPortRef::port_id,
"@brief Gets the ID of the port of the device the connection is made to."
Class<db::NetTerminalRef> decl_dbNetTerminalRef ("db", "NetTerminalRef",
gsi::method ("terminal_id", &db::NetTerminalRef::terminal_id,
"@brief Gets the ID of the terminal of the device the connection is made to."
) +
gsi::method ("device", (db::Device *(db::NetPortRef::*) ()) &db::NetPortRef::device,
gsi::method ("device", (db::Device *(db::NetTerminalRef::*) ()) &db::NetTerminalRef::device,
"@brief Gets the device reference.\n"
"Gets the device object that this connection is made to."
) +
gsi::method ("net", (db::Net *(db::NetPortRef::*) ()) &db::NetPortRef::net,
"@brief Gets the net this port reference is attached to"
gsi::method ("net", (db::Net *(db::NetTerminalRef::*) ()) &db::NetTerminalRef::net,
"@brief Gets the net this terminal reference is attached to"
) +
gsi::method ("device_class", (db::DeviceClass *(db::NetPortRef::*) ()) &db::NetPortRef::device_class,
gsi::method ("device_class", (db::DeviceClass *(db::NetTerminalRef::*) ()) &db::NetTerminalRef::device_class,
"@brief Gets the class of the device which is addressed."
) +
gsi::method ("port_def", (db::DevicePortDefinition *(db::NetPortRef::*) ()) &db::NetPortRef::port_def,
"@brief Gets the port definition of the port that is connected"
gsi::method ("terminal_def", (db::DeviceTerminalDefinition *(db::NetTerminalRef::*) ()) &db::NetTerminalRef::terminal_def,
"@brief Gets the terminal definition of the terminal that is connected"
),
"@brief A connection to a port of a device.\n"
"@brief A connection to a terminal of a device.\n"
"This object is used inside a net (see \\Net) to describe the connections a net makes.\n"
"\n"
"This class has been added in version 0.26."
@ -273,54 +273,54 @@ Class<db::Net> decl_dbNet ("db", "Net",
"are either connections to subcircuit pins or to outgoing pins of the "
"circuit the net lives in."
) +
gsi::iterator ("each_port", (db::Net::port_iterator (db::Net::*) ()) &db::Net::begin_ports, (db::Net::port_iterator (db::Net::*) ()) &db::Net::end_ports,
"@brief Iterates over all ports the net connects.\n"
"Ports connect devices. Port connections are described by \\NetPortRef "
gsi::iterator ("each_terminal", (db::Net::terminal_iterator (db::Net::*) ()) &db::Net::begin_terminals, (db::Net::terminal_iterator (db::Net::*) ()) &db::Net::end_terminals,
"@brief Iterates over all terminals the net connects.\n"
"Terminals connect devices. Terminal connections are described by \\NetTerminalRef "
"objects."
),
"@brief A single net.\n"
"A net connects multiple pins or ports together. Pins are either "
"A net connects multiple pins or terminals together. Pins are either "
"pin or subcircuits of outgoing pins of the circuit the net lives in. "
"Ports are connections made to specific ports of devices.\n"
"Terminals are connections made to specific terminals of devices.\n"
"\n"
"To connect a net to an outgoing pin of a circuit, use \\Circuit#connect_pin, to "
"disconnect a net from an outgoing pin use \\Circuit#disconnect_pin. "
"To connect a net to a pin of a subcircuit, use \\SubCircuit#connect_pin, to "
"disconnect a net from a pin of a subcircuit, use \\SubCircuit#disconnect_pin. "
"To connect a net to a port of a device, use \\Device#connect_port, to "
"disconnect a net from a port of a device, use \\Device#disconnect_port.\n"
"To connect a net to a terminal of a device, use \\Device#connect_terminal, to "
"disconnect a net from a terminal of a device, use \\Device#disconnect_terminal.\n"
"\n"
"This class has been added in version 0.26."
);
static db::DevicePortDefinition *new_port_definition (const std::string &name, const std::string &description)
static db::DeviceTerminalDefinition *new_terminal_definition (const std::string &name, const std::string &description)
{
return new db::DevicePortDefinition (name, description);
return new db::DeviceTerminalDefinition (name, description);
}
Class<db::DevicePortDefinition> decl_dbDevicePortDefinition ("db", "DevicePortDefinition",
gsi::constructor ("new", &gsi::new_port_definition, gsi::arg ("name"), gsi::arg ("description", std::string ()),
"@brief Creates a new port definition."
Class<db::DeviceTerminalDefinition> decl_dbDeviceTerminalDefinition ("db", "DeviceTerminalDefinition",
gsi::constructor ("new", &gsi::new_terminal_definition, gsi::arg ("name"), gsi::arg ("description", std::string ()),
"@brief Creates a new terminal definition."
) +
gsi::method ("name", &db::DevicePortDefinition::name,
"@brief Gets the name of the port."
gsi::method ("name", &db::DeviceTerminalDefinition::name,
"@brief Gets the name of the terminal."
) +
gsi::method ("name=", &db::DevicePortDefinition::set_name, gsi::arg ("name"),
"@brief Sets the name of the port."
gsi::method ("name=", &db::DeviceTerminalDefinition::set_name, gsi::arg ("name"),
"@brief Sets the name of the terminal."
) +
gsi::method ("description", &db::DevicePortDefinition::description,
"@brief Gets the description of the port."
gsi::method ("description", &db::DeviceTerminalDefinition::description,
"@brief Gets the description of the terminal."
) +
gsi::method ("description=", &db::DevicePortDefinition::set_description, gsi::arg ("description"),
"@brief Sets the description of the port."
gsi::method ("description=", &db::DeviceTerminalDefinition::set_description, gsi::arg ("description"),
"@brief Sets the description of the terminal."
) +
gsi::method ("id", &db::DevicePortDefinition::id,
"@brief Gets the ID of the port.\n"
"The ID of the port is used in some places to refer to a specific port (e.g. in "
"the \\NetPortRef object)."
gsi::method ("id", &db::DeviceTerminalDefinition::id,
"@brief Gets the ID of the terminal.\n"
"The ID of the terminal is used in some places to refer to a specific terminal (e.g. in "
"the \\NetTerminalRef object)."
),
"@brief A port descriptor\n"
"This class is used inside the \\DeviceClass class to describe a port of the device.\n"
"@brief A terminal descriptor\n"
"This class is used inside the \\DeviceClass class to describe a terminal of the device.\n"
"\n"
"This class has been added in version 0.26."
);
@ -385,13 +385,13 @@ Class<db::DeviceClass> decl_dbDeviceClass ("db", "DeviceClass",
"to check for object identity - i.e. to determine whether two devices share the "
"same device class."
) +
gsi::method ("port_definitions", &db::DeviceClass::port_definitions,
"@brief Gets the list of port definitions of the device.\n"
"See the \\DevicePortDefinition class description for details."
gsi::method ("terminal_definitions", &db::DeviceClass::terminal_definitions,
"@brief Gets the list of terminal definitions of the device.\n"
"See the \\DeviceTerminalDefinition class description for details."
) +
gsi::method ("port_definition", &db::DeviceClass::port_definition, gsi::arg ("port_id"),
"@brief Gets the port definition object for a given ID.\n"
"Port definition IDs are used in some places to reference a specific port of a device. "
gsi::method ("terminal_definition", &db::DeviceClass::terminal_definition, gsi::arg ("terminal_id"),
"@brief Gets the terminal definition object for a given ID.\n"
"Terminal definition IDs are used in some places to reference a specific terminal of a device. "
"This method obtains the corresponding definition object."
) +
gsi::method ("parameter_definitions", &db::DeviceClass::parameter_definitions,
@ -455,10 +455,10 @@ private:
}
static void gdc_add_port_definition (GenericDeviceClass *cls, db::DevicePortDefinition *port_def)
static void gdc_add_terminal_definition (GenericDeviceClass *cls, db::DeviceTerminalDefinition *terminal_def)
{
if (port_def) {
*port_def = cls->add_port_definition (*port_def);
if (terminal_def) {
*terminal_def = cls->add_terminal_definition (*terminal_def);
}
}
@ -470,17 +470,17 @@ static void gdc_add_parameter_definition (GenericDeviceClass *cls, db::DevicePar
}
Class<GenericDeviceClass> decl_GenericDeviceClass (decl_dbDeviceClass, "db", "GenericDeviceClass",
gsi::method_ext ("add_port", &gsi::gdc_add_port_definition, gsi::arg ("port_def"),
"@brief Adds the given port definition to the device class\n"
"This method will define a new port. The new port is added at the end of existing ports. "
"The port definition object passed as the argument is modified to contain the "
"new ID of the port.\n"
gsi::method_ext ("add_terminal", &gsi::gdc_add_terminal_definition, gsi::arg ("terminal_def"),
"@brief Adds the given terminal definition to the device class\n"
"This method will define a new terminal. The new terminal is added at the end of existing terminals. "
"The terminal definition object passed as the argument is modified to contain the "
"new ID of the terminal.\n"
"\n"
"The port is copied into the device class. Modifying the port object later "
"does not have the effect of changing the port definition."
"The terminal is copied into the device class. Modifying the terminal object later "
"does not have the effect of changing the terminal definition."
) +
gsi::method ("clear_ports", &GenericDeviceClass::clear_port_definitions,
"@brief Clears the list of ports\n"
gsi::method ("clear_terminals", &GenericDeviceClass::clear_terminal_definitions,
"@brief Clears the list of terminals\n"
) +
gsi::method_ext ("add_parameter", &gsi::gdc_add_parameter_definition, gsi::arg ("parameter_def"),
"@brief Adds the given parameter definition to the device class\n"
@ -501,10 +501,10 @@ Class<GenericDeviceClass> decl_GenericDeviceClass (decl_dbDeviceClass, "db", "Ge
"@brief Sets the description of the device\n"
),
"@brief A generic device class\n"
"This class allows building generic device classes. Specificially, ports can be defined "
"by adding port definitions. Port definitions should not be added dynamically. To create "
"This class allows building generic device classes. Specificially, terminals can be defined "
"by adding terminal definitions. Terminal definitions should not be added dynamically. To create "
"your own device, instantiate the \\GenericDeviceClass object, set name and description and "
"specify the ports. Then add this new device class to the \\Netlist object where it will live "
"specify the terminals. Then add this new device class to the \\Netlist object where it will live "
"and be used to define device instances (\\Device objects).\n"
"\n"
"In addition, parameters can be defined which correspond to values stored inside the "
@ -695,11 +695,11 @@ Class<db::Circuit> decl_dbCircuit ("db", "Circuit",
"Devices are created using the \\create_device method. Subcircuits are "
"created using the \\create_subcircuit method.\n"
"\n"
"Devices are connected through 'ports', subcircuits are connected through "
"their pins. Ports and pins are described by integer ID's in the context of "
"Devices are connected through 'terminals', subcircuits are connected through "
"their pins. Terminals and pins are described by integer ID's in the context of "
"most methods.\n"
"\n"
"Finally, the circuit consists of the nets. Nets connect ports of devices "
"Finally, the circuit consists of the nets. Nets connect terminals of devices "
"and pins of subcircuits or the circuit itself. Nets are created using "
"\\create_net and are represented by objects of the \\Net class.\n"
"See there for more about nets.\n"

View File

@ -46,7 +46,7 @@ gsi::Class<db::NetlistProperty> decl_NetlistProperty ("db", "NetlistProperty",
"@brief A generic base class for netlist properties.\n"
"\n"
"Netlist properties are used to annotate shapes or other objects with net properties. "
"Netlist properties are net names or device ports. "
"Netlist properties are net names or device terminals. "
"Netlist properties can be stored inside property sets. "
"This class provides the base class for such netlist properties."
"\n\n"
@ -87,34 +87,34 @@ gsi::Class<db::NetNameProperty> decl_NetNameProperty (decl_NetlistProperty, "db"
);
// ---------------------------------------------------------------
// db::DevicePortProperty binding
// db::DeviceTerminalProperty binding
static db::DevicePortProperty *new_devport ()
static db::DeviceTerminalProperty *new_devterminal ()
{
return new db::DevicePortProperty ();
return new db::DeviceTerminalProperty ();
}
static db::DevicePortProperty *new_devport2 (const db::NetPortRef &n)
static db::DeviceTerminalProperty *new_devterminal2 (const db::NetTerminalRef &n)
{
return new db::DevicePortProperty (n);
return new db::DeviceTerminalProperty (n);
}
gsi::Class<db::DevicePortProperty> decl_DevicePortProperty (decl_NetlistProperty, "db", "DevicePortProperty",
gsi::constructor ("new", &new_devport,
"@brief Creates a new device port property"
gsi::Class<db::DeviceTerminalProperty> decl_DeviceTerminalProperty (decl_NetlistProperty, "db", "DeviceTerminalProperty",
gsi::constructor ("new", &new_devterminal,
"@brief Creates a new device terminal property"
) +
gsi::constructor ("new", &new_devport2, gsi::arg ("port_ref"),
"@brief Creates a new device port property with the given port reference"
gsi::constructor ("new", &new_devterminal2, gsi::arg ("terminal_ref"),
"@brief Creates a new device terminal property with the given terminal reference"
) +
gsi::method ("port_ref=", &db::DevicePortProperty::set_port_ref, gsi::arg ("p"),
"@brief Sets the port reference\n"
gsi::method ("terminal_ref=", &db::DeviceTerminalProperty::set_terminal_ref, gsi::arg ("p"),
"@brief Sets the terminal reference\n"
) +
gsi::method ("port_ref", &db::DevicePortProperty::port_ref,
"@brief Gets the port reference\n"
gsi::method ("terminal_ref", &db::DeviceTerminalProperty::terminal_ref,
"@brief Gets the terminal reference\n"
),
"@brief A device port reference property.\n"
"@brief A device terminal reference property.\n"
"\n"
"The netlist property annotates a shape or other object with a reference to a device port."
"The netlist property annotates a shape or other object with a reference to a device terminal."
"\n\n"
"This class was introduced in version 0.26.\n"
);

View File

@ -47,23 +47,23 @@ TEST(1_NameBasic)
EXPECT_EQ (n2.to_string (), "name:'\"quoted\"'");
}
TEST(2_PortRefBasic)
TEST(2_TerminalRefBasic)
{
db::DeviceClass dc;
dc.add_port_definition (db::DevicePortDefinition ("A", "Port A"));
dc.add_port_definition (db::DevicePortDefinition ("B", "Port B"));
dc.add_terminal_definition (db::DeviceTerminalDefinition ("A", "Terminal A"));
dc.add_terminal_definition (db::DeviceTerminalDefinition ("B", "Terminal B"));
db::Device d (&dc, "D");
db::DevicePortProperty dp (db::NetPortRef (&d, 1));
EXPECT_EQ (dp.to_string (), "port:D:B");
db::DeviceTerminalProperty dp (db::NetTerminalRef (&d, 1));
EXPECT_EQ (dp.to_string (), "terminal:D:B");
dp.set_port_ref (db::NetPortRef (&d, 0));
EXPECT_EQ (dp.to_string (), "port:D:A");
EXPECT_EQ (dp.port_ref () == db::NetPortRef (&d, 0), true);
dp.set_terminal_ref (db::NetTerminalRef (&d, 0));
EXPECT_EQ (dp.to_string (), "terminal:D:A");
EXPECT_EQ (dp.terminal_ref () == db::NetTerminalRef (&d, 0), true);
db::DevicePortProperty dp2 = dp;
EXPECT_EQ (dp2.to_string (), "port:D:A");
db::DeviceTerminalProperty dp2 = dp;
EXPECT_EQ (dp2.to_string (), "terminal:D:A");
}
TEST(3_Variants)

View File

@ -28,7 +28,7 @@
#include <memory>
static std::string pd2string (const db::DevicePortDefinition &pd)
static std::string pd2string (const db::DeviceTerminalDefinition &pd)
{
return pd.name () + "(" + pd.description () + ") #" + tl::to_string (pd.id ());
}
@ -38,16 +38,16 @@ static std::string pd2string (const db::DeviceParameterDefinition &pd)
return pd.name () + "(" + pd.description () + ")=" + tl::to_string (pd.default_value ()) + " #" + tl::to_string (pd.id ());
}
TEST(1_DevicePortDefinition)
TEST(1_DeviceTerminalDefinition)
{
db::DevicePortDefinition pd;
db::DeviceTerminalDefinition pd;
EXPECT_EQ (pd2string (pd), "() #0");
pd.set_name ("name");
pd.set_description ("nothing yet");
EXPECT_EQ (pd2string (pd), "name(nothing yet) #0");
db::DevicePortDefinition pd2;
db::DeviceTerminalDefinition pd2;
pd2 = pd;
EXPECT_EQ (pd2string (pd2), "name(nothing yet) #0");
pd2.set_name ("name2");
@ -55,13 +55,13 @@ TEST(1_DevicePortDefinition)
EXPECT_EQ (pd2string (pd2), "name2(now it has something) #0");
db::DeviceClass dc;
dc.add_port_definition (pd);
dc.add_port_definition (pd2);
EXPECT_EQ (pd2string (dc.port_definitions ()[0]), "name(nothing yet) #0");
EXPECT_EQ (pd2string (dc.port_definitions ()[1]), "name2(now it has something) #1");
dc.add_terminal_definition (pd);
dc.add_terminal_definition (pd2);
EXPECT_EQ (pd2string (dc.terminal_definitions ()[0]), "name(nothing yet) #0");
EXPECT_EQ (pd2string (dc.terminal_definitions ()[1]), "name2(now it has something) #1");
dc.clear_port_definitions ();
EXPECT_EQ (dc.port_definitions ().empty (), true);
dc.clear_terminal_definitions ();
EXPECT_EQ (dc.terminal_definitions ().empty (), true);
db::DeviceParameterDefinition ppd ("P1", "Parameter 1", 1.0);
dc.add_parameter_definition (ppd);
@ -79,11 +79,11 @@ TEST(1_DevicePortDefinition)
TEST(2_DeviceClass)
{
db::DevicePortDefinition pd;
db::DeviceTerminalDefinition pd;
pd.set_name ("name");
pd.set_description ("nothing yet");
db::DevicePortDefinition pd2;
db::DeviceTerminalDefinition pd2;
pd2.set_name ("name2");
pd2.set_description ("now it has something");
@ -92,23 +92,23 @@ TEST(2_DeviceClass)
dc.set_description ("devdesc");
EXPECT_EQ (dc.name (), "devname");
EXPECT_EQ (dc.description (), "devdesc");
dc.add_port_definition (pd);
dc.add_port_definition (pd2);
EXPECT_EQ (dc.port_definitions ().size (), size_t (2));
EXPECT_EQ (pd2string (dc.port_definitions ()[0]), "name(nothing yet) #0");
EXPECT_EQ (pd2string (dc.port_definitions ()[1]), "name2(now it has something) #1");
dc.add_terminal_definition (pd);
dc.add_terminal_definition (pd2);
EXPECT_EQ (dc.terminal_definitions ().size (), size_t (2));
EXPECT_EQ (pd2string (dc.terminal_definitions ()[0]), "name(nothing yet) #0");
EXPECT_EQ (pd2string (dc.terminal_definitions ()[1]), "name2(now it has something) #1");
EXPECT_EQ (pd2string (*dc.port_definition (dc.port_definitions ()[0].id ())), "name(nothing yet) #0");
EXPECT_EQ (pd2string (*dc.port_definition (dc.port_definitions ()[1].id ())), "name2(now it has something) #1");
EXPECT_EQ (dc.port_definition (3), 0);
EXPECT_EQ (pd2string (*dc.terminal_definition (dc.terminal_definitions ()[0].id ())), "name(nothing yet) #0");
EXPECT_EQ (pd2string (*dc.terminal_definition (dc.terminal_definitions ()[1].id ())), "name2(now it has something) #1");
EXPECT_EQ (dc.terminal_definition (3), 0);
db::DeviceClass dc2 = dc;
EXPECT_EQ (dc2.name (), "devname");
EXPECT_EQ (dc2.description (), "devdesc");
EXPECT_EQ (dc2.port_definitions ().size (), size_t (2));
EXPECT_EQ (pd2string (*dc2.port_definition (dc2.port_definitions ()[0].id ())), "name(nothing yet) #0");
EXPECT_EQ (pd2string (*dc2.port_definition (dc2.port_definitions ()[1].id ())), "name2(now it has something) #1");
EXPECT_EQ (dc2.port_definition (3), 0);
EXPECT_EQ (dc2.terminal_definitions ().size (), size_t (2));
EXPECT_EQ (pd2string (*dc2.terminal_definition (dc2.terminal_definitions ()[0].id ())), "name(nothing yet) #0");
EXPECT_EQ (pd2string (*dc2.terminal_definition (dc2.terminal_definitions ()[1].id ())), "name2(now it has something) #1");
EXPECT_EQ (dc2.terminal_definition (3), 0);
}
static std::string pins2string (const db::Circuit &c)
@ -152,13 +152,13 @@ TEST(3_CircuitBasic)
static std::string net2string (const db::Net &n)
{
std::string res;
for (db::Net::const_port_iterator i = n.begin_ports (); i != n.end_ports (); ++i) {
for (db::Net::const_terminal_iterator i = n.begin_terminals (); i != n.end_terminals (); ++i) {
if (! res.empty ()) {
res += ",";
}
res += i->device () ? i->device ()->name () : "(null)";
res += ":";
res += i->port_def () ? i->port_def ()->name () : "(null)";
res += i->terminal_def () ? i->terminal_def ()->name () : "(null)";
}
for (db::Net::const_pin_iterator i = n.begin_pins (); i != n.end_pins (); ++i) {
if (! res.empty ()) {
@ -208,12 +208,12 @@ static std::string netlist2 (const db::Circuit &c)
continue;
}
pins.clear ();
for (size_t i = 0; i < d->device_class ()->port_definitions ().size (); ++i) {
for (size_t i = 0; i < d->device_class ()->terminal_definitions ().size (); ++i) {
if (! pins.empty ()) {
pins += ",";
}
const db::Net *net = d->net_for_port (i);
pins += d->device_class ()->port_definitions () [i].name ();
const db::Net *net = d->net_for_terminal (i);
pins += d->device_class ()->terminal_definitions () [i].name ();
pins += "=";
pins += net ? net->name () : std::string ("(null)");
}
@ -244,16 +244,16 @@ TEST(4_CircuitDevices)
{
db::DeviceClass dc1;
dc1.set_name ("dc1");
dc1.add_port_definition (db::DevicePortDefinition ("S", "Source"));
dc1.add_port_definition (db::DevicePortDefinition ("G", "Gate"));
dc1.add_port_definition (db::DevicePortDefinition ("D", "Drain"));
dc1.add_terminal_definition (db::DeviceTerminalDefinition ("S", "Source"));
dc1.add_terminal_definition (db::DeviceTerminalDefinition ("G", "Gate"));
dc1.add_terminal_definition (db::DeviceTerminalDefinition ("D", "Drain"));
dc1.add_parameter_definition (db::DeviceParameterDefinition ("U", "", 1.0));
dc1.add_parameter_definition (db::DeviceParameterDefinition ("V", "", 2.0));
db::DeviceClass dc2;
dc2.set_name ("dc2");
dc2.add_port_definition (db::DevicePortDefinition ("A", ""));
dc2.add_port_definition (db::DevicePortDefinition ("B", ""));
dc2.add_terminal_definition (db::DeviceTerminalDefinition ("A", ""));
dc2.add_terminal_definition (db::DeviceTerminalDefinition ("B", ""));
dc2.add_parameter_definition (db::DeviceParameterDefinition ("U", "", 2.0));
dc2.add_parameter_definition (db::DeviceParameterDefinition ("V", "", 1.0));
@ -297,16 +297,16 @@ TEST(4_CircuitDevices)
n1->set_name ("n1");
EXPECT_EQ (n1->circuit (), 0);
c->add_net (n1);
n1->add_port (db::NetPortRef (d1, 0));
n1->add_port (db::NetPortRef (d2a, 0));
n1->add_terminal (db::NetTerminalRef (d1, 0));
n1->add_terminal (db::NetTerminalRef (d2a, 0));
EXPECT_EQ (n1->circuit (), c.get ());
db::Net *n2 = new db::Net ();
n2->set_name ("n2");
c->add_net (n2);
n2->add_port (db::NetPortRef (d1, 1));
n2->add_port (db::NetPortRef (d2a, 1));
n2->add_port (db::NetPortRef (d2b, 0));
n2->add_terminal (db::NetTerminalRef (d1, 1));
n2->add_terminal (db::NetTerminalRef (d2a, 1));
n2->add_terminal (db::NetTerminalRef (d2b, 0));
EXPECT_EQ (netlist2 (*c),
"c:\n"
@ -318,8 +318,8 @@ TEST(4_CircuitDevices)
db::Net *n3 = new db::Net ();
n3->set_name ("n3");
c->add_net (n3);
n3->add_port (db::NetPortRef (d1, 2));
n3->add_port (db::NetPortRef (d2b, 1));
n3->add_terminal (db::NetTerminalRef (d1, 2));
n3->add_terminal (db::NetTerminalRef (d2b, 1));
EXPECT_EQ (nets2string (*c),
"d1:S,d2a:A\n"
@ -378,8 +378,8 @@ TEST(4_NetlistSubcircuits)
db::DeviceClass *dc = new db::DeviceClass ();
dc->set_name ("dc2");
dc->add_port_definition (db::DevicePortDefinition ("A", ""));
dc->add_port_definition (db::DevicePortDefinition ("B", ""));
dc->add_terminal_definition (db::DeviceTerminalDefinition ("A", ""));
dc->add_terminal_definition (db::DeviceTerminalDefinition ("B", ""));
nl->add_device_class (dc);
db::Circuit *c1 = new db::Circuit ();
@ -411,12 +411,12 @@ TEST(4_NetlistSubcircuits)
c2->add_net (n2a);
n2a->set_name ("n2a");
n2a->add_pin (db::NetPinRef (0));
n2a->add_port (db::NetPortRef (d, 0));
n2a->add_terminal (db::NetTerminalRef (d, 0));
db::Net *n2b = new db::Net ();
c2->add_net (n2b);
n2b->set_name ("n2b");
n2b->add_port (db::NetPortRef (d, 1));
n2b->add_terminal (db::NetTerminalRef (d, 1));
n2b->add_pin (db::NetPinRef (1));
db::Net *n1a = new db::Net ();
@ -458,7 +458,7 @@ TEST(4_NetlistSubcircuits)
// check netlist
for (db::Netlist::circuit_iterator c = nl->begin_circuits (); c != nl->end_circuits (); ++c) {
for (db::Circuit::net_iterator n = c->begin_nets (); n != c->end_nets (); ++n) {
for (db::Net::port_iterator i = n->begin_ports (); i != n->end_ports (); ++i) {
for (db::Net::terminal_iterator i = n->begin_terminals (); i != n->end_terminals (); ++i) {
EXPECT_EQ (i->net (), n.operator-> ());
}
for (db::Net::pin_iterator i = n->begin_pins (); i != n->end_pins (); ++i) {
@ -493,7 +493,7 @@ TEST(4_NetlistSubcircuits)
// check netlist
for (db::Netlist::circuit_iterator c = nl2.begin_circuits (); c != nl2.end_circuits (); ++c) {
for (db::Circuit::net_iterator n = c->begin_nets (); n != c->end_nets (); ++n) {
for (db::Net::port_iterator i = n->begin_ports (); i != n->end_ports (); ++i) {
for (db::Net::terminal_iterator i = n->begin_terminals (); i != n->end_terminals (); ++i) {
EXPECT_EQ (i->net (), n.operator-> ());
}
for (db::Net::pin_iterator i = n->begin_pins (); i != n->end_pins (); ++i) {
@ -535,12 +535,12 @@ TEST(6_Net)
EXPECT_EQ (int (n.cluster_id ()), 0);
}
TEST(7_NetPortsEditing)
TEST(7_NetTerminalsEditing)
{
db::Circuit c;
db::DeviceClass dc;
dc.add_port_definition (db::DevicePortDefinition ("A", ""));
dc.add_port_definition (db::DevicePortDefinition ("B", ""));
dc.add_terminal_definition (db::DeviceTerminalDefinition ("A", ""));
dc.add_terminal_definition (db::DeviceTerminalDefinition ("B", ""));
db::Device *d1 = new db::Device (&dc, "D1");
c.add_device (d1);
@ -555,31 +555,31 @@ TEST(7_NetPortsEditing)
n2->set_name ("n2");
c.add_net (n2);
d1->connect_port (0, n1);
d1->connect_port (1, n2);
d1->connect_terminal (0, n1);
d1->connect_terminal (1, n2);
d2->connect_port (1, n1);
d2->connect_port (0, n2);
d2->connect_terminal (1, n1);
d2->connect_terminal (0, n2);
EXPECT_EQ (d1->net_for_port (0), n1);
EXPECT_EQ (d1->net_for_port (1), n2);
EXPECT_EQ (d2->net_for_port (0), n2);
EXPECT_EQ (d2->net_for_port (1), n1);
EXPECT_EQ (d1->net_for_terminal (0), n1);
EXPECT_EQ (d1->net_for_terminal (1), n2);
EXPECT_EQ (d2->net_for_terminal (0), n2);
EXPECT_EQ (d2->net_for_terminal (1), n1);
EXPECT_EQ (net2string (*n1), "D1:A,D2:B");
EXPECT_EQ (net2string (*n2), "D1:B,D2:A");
d1->connect_port (0, n2);
d1->connect_port (1, n1);
d1->connect_terminal (0, n2);
d1->connect_terminal (1, n1);
EXPECT_EQ (d1->net_for_port (0), n2);
EXPECT_EQ (d1->net_for_port (1), n1);
EXPECT_EQ (d1->net_for_terminal (0), n2);
EXPECT_EQ (d1->net_for_terminal (1), n1);
EXPECT_EQ (net2string (*n1), "D2:B,D1:B");
EXPECT_EQ (net2string (*n2), "D2:A,D1:A");
d1->connect_port (0, 0);
EXPECT_EQ (d1->net_for_port (0), 0);
d1->connect_terminal (0, 0);
EXPECT_EQ (d1->net_for_terminal (0), 0);
EXPECT_EQ (net2string (*n1), "D2:B,D1:B");
EXPECT_EQ (net2string (*n2), "D2:A");
@ -601,8 +601,8 @@ TEST(7_NetPortsEditing)
EXPECT_EQ (net2string (*n2), "D2:A");
EXPECT_EQ (d2->net_for_port (0), n2);
EXPECT_EQ (d2->net_for_port (1), 0);
EXPECT_EQ (d2->net_for_terminal (0), n2);
EXPECT_EQ (d2->net_for_terminal (1), 0);
}
TEST(8_NetSubCircuitsEditing)
@ -702,18 +702,18 @@ TEST(8_NetSubCircuitsEditing)
EXPECT_EQ (sc2->net_for_pin (1), 0);
}
TEST(9_NetPortRefBasics)
TEST(9_NetTerminalRefBasics)
{
db::Device d1, d2;
EXPECT_EQ (db::NetPortRef (&d1, 0) == db::NetPortRef (&d1, 0), true);
EXPECT_EQ (db::NetPortRef (&d1, 0) == db::NetPortRef (&d1, 1), false);
EXPECT_EQ (db::NetPortRef (&d1, 0) == db::NetPortRef (&d2, 0), false);
EXPECT_EQ (db::NetTerminalRef (&d1, 0) == db::NetTerminalRef (&d1, 0), true);
EXPECT_EQ (db::NetTerminalRef (&d1, 0) == db::NetTerminalRef (&d1, 1), false);
EXPECT_EQ (db::NetTerminalRef (&d1, 0) == db::NetTerminalRef (&d2, 0), false);
EXPECT_EQ (db::NetPortRef (&d1, 0) < db::NetPortRef (&d1, 0), false);
EXPECT_EQ (db::NetPortRef (&d1, 0) < db::NetPortRef (&d1, 1), true);
EXPECT_EQ (db::NetPortRef (&d1, 1) < db::NetPortRef (&d1, 0), false);
EXPECT_NE ((db::NetPortRef (&d1, 0) < db::NetPortRef (&d2, 0)), (db::NetPortRef (&d2, 0) < db::NetPortRef (&d1, 0)));
EXPECT_EQ (db::NetTerminalRef (&d1, 0) < db::NetTerminalRef (&d1, 0), false);
EXPECT_EQ (db::NetTerminalRef (&d1, 0) < db::NetTerminalRef (&d1, 1), true);
EXPECT_EQ (db::NetTerminalRef (&d1, 1) < db::NetTerminalRef (&d1, 0), false);
EXPECT_NE ((db::NetTerminalRef (&d1, 0) < db::NetTerminalRef (&d2, 0)), (db::NetTerminalRef (&d2, 0) < db::NetTerminalRef (&d1, 0)));
}
TEST(10_NetPinRefBasics)

View File

@ -141,15 +141,15 @@ class DBNetlist_TestClass < TestBase
dc.name = "DC"
dc.description = "A device class"
pd = RBA::DevicePortDefinition::new
pd = RBA::DeviceTerminalDefinition::new
pd.name = "A"
pd.description = "Port A"
dc.add_port(pd)
pd.description = "Terminal A"
dc.add_terminal(pd)
pd = RBA::DevicePortDefinition::new
pd = RBA::DeviceTerminalDefinition::new
pd.name = "B"
pd.description = "Port B"
dc.add_port(pd)
pd.description = "Terminal B"
dc.add_terminal(pd)
c = RBA::Circuit::new
nl.add(c)
@ -185,31 +185,31 @@ class DBNetlist_TestClass < TestBase
net = c.create_net("NET")
d1.connect_port(1, net)
assert_equal(d1.net_for_port(1).name, "NET")
assert_equal(d1.net_for_port(0).inspect, "nil")
d1.connect_terminal(1, net)
assert_equal(d1.net_for_terminal(1).name, "NET")
assert_equal(d1.net_for_terminal(0).inspect, "nil")
d2.connect_port(0, net)
d2.connect_terminal(0, net)
dnames = []
net.each_port { |p| dnames << p.device.name + ":" + p.port_def.name }
net.each_terminal { |p| dnames << p.device.name + ":" + p.terminal_def.name }
assert_equal(dnames, [ "D1:B", "D2:A" ])
dnames = []
net.each_port { |p| dnames << p.device_class.name + ":" + p.port_id.to_s }
net.each_terminal { |p| dnames << p.device_class.name + ":" + p.terminal_id.to_s }
assert_equal(dnames, [ "DC:1", "DC:0" ])
net.each_port { |p| assert_equal(p.net.name, "NET") }
net.each_terminal { |p| assert_equal(p.net.name, "NET") }
d1.disconnect_port(1)
assert_equal(d1.net_for_port(1).inspect, "nil")
d1.disconnect_terminal(1)
assert_equal(d1.net_for_terminal(1).inspect, "nil")
dnames = []
net.each_port { |p| dnames << p.device.name + ":" + p.port_def.name }
net.each_terminal { |p| dnames << p.device.name + ":" + p.terminal_def.name }
assert_equal(dnames, [ "D2:A" ])
net.each_port { |p| assert_equal(p.net.name, "NET") }
net.each_terminal { |p| assert_equal(p.net.name, "NET") }
net.clear
assert_equal(d1.net_for_port(1).inspect, "nil")
assert_equal(d1.net_for_port(0).inspect, "nil")
assert_equal(d1.net_for_terminal(1).inspect, "nil")
assert_equal(d1.net_for_terminal(0).inspect, "nil")
end
@ -320,30 +320,30 @@ class DBNetlist_TestClass < TestBase
dc.description = "A device class"
assert_equal(dc.description, "A device class")
pd = RBA::DevicePortDefinition::new("A", "Port A")
dc.add_port(pd)
pd = RBA::DeviceTerminalDefinition::new("A", "Terminal A")
dc.add_terminal(pd)
assert_equal(pd.id, 0)
assert_equal(pd.name, "A")
assert_equal(pd.description, "Port A")
assert_equal(pd.description, "Terminal A")
pd = RBA::DevicePortDefinition::new
pd = RBA::DeviceTerminalDefinition::new
pd.name = "B"
pd.description = "Port B"
dc.add_port(pd)
pd.description = "Terminal B"
dc.add_terminal(pd)
assert_equal(pd.id, 1)
assert_equal(pd.name, "B")
assert_equal(pd.description, "Port B")
assert_equal(pd.description, "Terminal B")
names = []
dc.port_definitions.each { |pd| names << pd.name }
dc.terminal_definitions.each { |pd| names << pd.name }
assert_equal(names, [ "A", "B" ])
dc.clear_ports
dc.clear_terminals
names = []
dc.port_definitions.each { |pd| names << pd.name }
dc.terminal_definitions.each { |pd| names << pd.name }
assert_equal(names, [])
pd = RBA::DeviceParameterDefinition::new("P1", "Parameter 1", 2.0)

View File

@ -46,31 +46,31 @@ class DBNetlistProperty_TestClass < TestBase
end
def test_3_DevicePort
def test_3_DeviceTerminal
np = RBA::DevicePortProperty::new
assert_equal(np.is_a?(RBA::DevicePortProperty), true)
assert_equal(np.is_a?(RBA::DevicePortProperty), true)
assert_equal(np.to_s, "port")
np = RBA::DeviceTerminalProperty::new
assert_equal(np.is_a?(RBA::DeviceTerminalProperty), true)
assert_equal(np.is_a?(RBA::DeviceTerminalProperty), true)
assert_equal(np.to_s, "terminal")
dc = RBA::GenericDeviceClass::new
dp = RBA::DevicePortDefinition::new
dp = RBA::DeviceTerminalDefinition::new
dp.name = "A"
dc.add_port(dp)
dc.add_terminal(dp)
dp.name = "B"
dc.add_port(dp)
dc.add_terminal(dp)
c = RBA::Circuit::new
d = c.create_device(dc, "D")
n = c.create_net("NET")
d.connect_port(0, n)
d.connect_terminal(0, n)
# there is no other way to produce a NetPortRef object yet
n.each_port { |p| np.port_ref = p }
# there is no other way to produce a NetTerminalRef object yet
n.each_terminal { |p| np.terminal_ref = p }
assert_equal(np.to_s, "port:D:A")
assert_equal(np.port_ref.device.name, "D")
assert_equal(np.to_s, "terminal:D:A")
assert_equal(np.terminal_ref.device.name, "D")
end