|
degate 0.1.1
|
A gate template is a container for common properties, that physically placed gates of that type share. More...
#include <GateTemplate.h>

Public Types | |
| enum | IMPLEMENTATION_TYPE { UNDEFINED = 0, TEXT = 1, VHDL = 2, VHDL_TESTBENCH = 3, VERILOG = 4, VERILOG_TESTBENCH = 5 } |
| Implementation types for a template. More... | |
| typedef std::map < IMPLEMENTATION_TYPE, std::string > | implementation_collection |
| typedef implementation_collection::iterator | implementation_iter |
| typedef std::map < Layer::LAYER_TYPE, GateTemplateImage_shptr > | image_collection |
| typedef image_collection::iterator | image_iterator |
| typedef std::set < GateTemplatePort_shptr > ::iterator | port_iterator |
Public Member Functions | |
| GateTemplate (unsigned int width, unsigned int height) | |
| The constructor to set up a new gate template. | |
| GateTemplate (int _min_x, int _max_x, int _min_y, int _max_y) | |
| The constructor to set up a new gate template. | |
| GateTemplate () | |
| Default constructor. | |
| virtual | ~GateTemplate () |
| The destructor. | |
| virtual unsigned int | get_width () const |
| Get the width of a gate template. | |
| virtual unsigned int | get_height () const |
| Get the height of a gate template. | |
| virtual void | set_width (unsigned int width) |
| Set the width of a gate template. | |
| virtual void | set_height (unsigned int) |
| Set the height of a gate template. | |
| virtual BoundingBox const & | get_bounding_box () const |
| Get the bounding box of the template. | |
| virtual void | set_image (Layer::LAYER_TYPE layer_type, GateTemplateImage_shptr img) |
| Set a reference image for the template. | |
| virtual GateTemplateImage_shptr | get_image (Layer::LAYER_TYPE layer_type) |
| Get a reference image for the template. | |
| virtual bool | has_image (Layer::LAYER_TYPE layer_type) const |
| Check if there is a reference image for a layer type. | |
| virtual void | add_template_port (GateTemplatePort_shptr template_port) |
| Add a template port to a gate template. | |
| virtual bool | remove_template_port (GateTemplatePort_shptr template_port) |
| Remove a port from a gate template. | |
| virtual bool | remove_template_port (object_id_t object_id) |
| Remove a port from a gate template. | |
| virtual GateTemplatePort_shptr | get_template_port (object_id_t object_id) |
| Get a template port. | |
| virtual bool | has_template_port (object_id_t object_id) const |
| Check if a template has a specific template port. | |
| virtual port_iterator | ports_begin () |
| Get an iterator. | |
| virtual port_iterator | ports_end () |
| Get end marker for the iteration over ports. | |
| virtual image_iterator | images_begin () |
| Get an iterator to iterate over images. | |
| virtual image_iterator | images_end () |
| Get end marker for the iteration over images. | |
| virtual unsigned int | get_reference_counter () const |
| Get the reference counter. | |
| virtual implementation_iter | implementations_begin () |
| Get an iterator to iterate over implementations. | |
| virtual implementation_iter | implementations_end () |
| Get an end marker for the iteration. | |
| virtual void | set_implementation (IMPLEMENTATION_TYPE impl_type, std::string const &code) |
| Set VHDL/Verilog implementation for the gate template. | |
| std::string | get_implementation (IMPLEMENTATION_TYPE impl_type) const |
| Get code for an implementation type. | |
| virtual void | print (std::ostream &os) |
| Print gate template's meta information to an output stream. | |
| virtual unsigned int | get_number_of_ports () const |
| Get number of defined ports. | |
| virtual void | set_logic_class (std::string const &logic_class) |
| Set logic class for a standard cell. | |
| virtual std::string | get_logic_class () const |
| Get logic class for a standard cell. | |
Static Public Member Functions | |
| static std::string | get_impl_type_as_string (IMPLEMENTATION_TYPE impl_type) |
| Convert an implementation-type constant to a printable string. | |
| static IMPLEMENTATION_TYPE | get_impl_type_from_string (std::string const &impl_type_str) |
| Convert an implementation type string to a correspondig constant. | |
Protected Member Functions | |
| virtual void | increment_reference_counter () |
| Increment the reference counter. | |
| virtual void | decrement_reference_counter () |
| Decrement the reference counter. | |
Private Attributes | |
| BoundingBox | bounding_box |
| unsigned int | reference_counter |
| std::set< GateTemplatePort_shptr > | ports |
| implementation_collection | implementations |
| image_collection | images |
| std::string | logic_class |
Friends | |
| class | Gate |
A gate template is a container for common properties, that physically placed gates of that type share.
Definition at line 41 of file GateTemplate.h.
| typedef std::map<Layer::LAYER_TYPE, GateTemplateImage_shptr> degate::GateTemplate::image_collection |
Definition at line 62 of file GateTemplate.h.
| typedef image_collection::iterator degate::GateTemplate::image_iterator |
Definition at line 63 of file GateTemplate.h.
| typedef std::map<IMPLEMENTATION_TYPE, std::string > degate::GateTemplate::implementation_collection |
Definition at line 59 of file GateTemplate.h.
| typedef implementation_collection::iterator degate::GateTemplate::implementation_iter |
Definition at line 60 of file GateTemplate.h.
| typedef std::set< GateTemplatePort_shptr >::iterator degate::GateTemplate::port_iterator |
Definition at line 94 of file GateTemplate.h.
Implementation types for a template.
Definition at line 50 of file GateTemplate.h.
{
UNDEFINED = 0,
TEXT = 1,
VHDL = 2,
VHDL_TESTBENCH = 3,
VERILOG = 4,
VERILOG_TESTBENCH = 5
};
| GateTemplate::GateTemplate | ( | unsigned int | width, |
| unsigned int | height | ||
| ) |
The constructor to set up a new gate template.
Definition at line 40 of file GateTemplate.cc.
: bounding_box(0, width, 0, height), reference_counter(0) { }
| GateTemplate::GateTemplate | ( | int | _min_x, |
| int | _max_x, | ||
| int | _min_y, | ||
| int | _max_y | ||
| ) |
The constructor to set up a new gate template.
Definition at line 36 of file GateTemplate.cc.
: bounding_box(_min_x, _max_x, _min_y, _max_y), reference_counter(0) { }
| GateTemplate::GateTemplate | ( | ) |
Default constructor.
Definition at line 44 of file GateTemplate.cc.
: bounding_box(0, 0, 0, 0), reference_counter(0) { }
| GateTemplate::~GateTemplate | ( | ) | [virtual] |
| void GateTemplate::add_template_port | ( | GateTemplatePort_shptr | template_port | ) | [virtual] |
Add a template port to a gate template.
This is an isolated function. The port is just added to the gate template. Nothing else. Adding a port to a template requires some updates in the logic model. Therefore you should prefer the corresponding method from the LogicModel class.
| InvalidObjectIDException | This exception is thrown if the template port has no valid object ID. |
Definition at line 91 of file GateTemplate.cc.
References ports.
{
if(!template_port->has_valid_object_id())
throw InvalidObjectIDException("Error in GateTemplate::add_template_port(). "
"The object ID is invalid.");
ports.insert(template_port);
}
| void GateTemplate::decrement_reference_counter | ( | ) | [protected, virtual] |
Decrement the reference counter.
Definition at line 31 of file GateTemplate.cc.
References reference_counter.
{
reference_counter--;
}
| BoundingBox const & GateTemplate::get_bounding_box | ( | ) | const [virtual] |
Get the bounding box of the template.
Definition at line 68 of file GateTemplate.cc.
References bounding_box.
{
return bounding_box;
}
| unsigned int GateTemplate::get_height | ( | ) | const [virtual] |
Get the height of a gate template.
Definition at line 56 of file GateTemplate.cc.
References bounding_box, and degate::BoundingBox::get_height().
{
return bounding_box.get_height();
}

| GateTemplateImage_shptr GateTemplate::get_image | ( | Layer::LAYER_TYPE | layer_type | ) | [virtual] |
Get a reference image for the template.
| CollectionLookupException | Throws this exception, if there is no image. |
Definition at line 80 of file GateTemplate.cc.
References images.
{
image_collection::iterator found = images.find(layer_type);
if(found == images.end())
throw CollectionLookupException("Can't find reference image.");
else return (*found).second;
}
| std::string GateTemplate::get_impl_type_as_string | ( | IMPLEMENTATION_TYPE | impl_type | ) | [static] |
Convert an implementation-type constant to a printable string.
Definition at line 220 of file GateTemplate.cc.
References TEXT, VERILOG, VERILOG_TESTBENCH, VHDL, and VHDL_TESTBENCH.
{
switch(impl_type) {
case TEXT:
return std::string("text");
case VHDL:
return std::string("vhdl");
case VHDL_TESTBENCH:
return std::string("vhdl-testbench");
case VERILOG:
return std::string("verilog");
case VERILOG_TESTBENCH:
return std::string("verilog-testbench");
default:
return std::string("undefined");
}
}
| GateTemplate::IMPLEMENTATION_TYPE GateTemplate::get_impl_type_from_string | ( | std::string const & | impl_type_str | ) | [static] |
Convert an implementation type string to a correspondig constant.
| DegateRuntimeException | Throws this exception, if the string cannot be parsed. |
Definition at line 237 of file GateTemplate.cc.
References TEXT, UNDEFINED, VERILOG, VERILOG_TESTBENCH, VHDL, and VHDL_TESTBENCH.
{
if(impl_type_str == "text") return TEXT;
else if(impl_type_str == "vhdl") return VHDL;
else if(impl_type_str == "vhdl-testbench") return VHDL_TESTBENCH;
else if(impl_type_str == "verilog") return VERILOG;
else if(impl_type_str == "verilog-testbench") return VERILOG_TESTBENCH;
else if(impl_type_str == "undefined" ||
impl_type_str == "") return UNDEFINED;
else {
boost::format f("Can't parse implementation type '%1%'.");
f % impl_type_str;
throw DegateRuntimeException(f.str());
}
}
| std::string GateTemplate::get_implementation | ( | IMPLEMENTATION_TYPE | impl_type | ) | const |
Get code for an implementation type.
| CollectionLookupException | Throws an exception, if there is no code for the requested type. |
Definition at line 176 of file GateTemplate.cc.
References implementations.
{
implementation_collection::const_iterator found = implementations.find(impl_type);
if(found == implementations.end()) {
throw CollectionLookupException("There is no implementation for the requested type");
}
else
return found->second;
}
| std::string GateTemplate::get_logic_class | ( | ) | const [virtual] |
Get logic class for a standard cell.
Definition at line 258 of file GateTemplate.cc.
References logic_class.
{
return logic_class;
}
| unsigned int GateTemplate::get_number_of_ports | ( | ) | const [virtual] |
Get number of defined ports.
Definition at line 214 of file GateTemplate.cc.
References ports.
{
return ports.size();
}
| unsigned int GateTemplate::get_reference_counter | ( | ) | const [virtual] |
Get the reference counter.
Definition at line 167 of file GateTemplate.cc.
References reference_counter.
{
return reference_counter;
}
| GateTemplatePort_shptr GateTemplate::get_template_port | ( | object_id_t | object_id | ) | [virtual] |
Get a template port.
| InvalidObjectIDException | This exception is thrown if the object ID is invalid. |
| CollectionLookupException | This exception is thrown if a template port with object ID object_id was not found. |
Definition at line 122 of file GateTemplate.cc.
References degate::LogicModelObjectBase::object_id, and ports.
{
if(object_id == 0)
throw InvalidObjectIDException("Error in GateTemplate::get_template_port(). "
"The object ID is invalid.");
for(port_iterator iter = ports.begin(); iter != ports.end(); ++iter) {
if((*iter)->get_object_id() == object_id) {
return *iter;
}
}
throw CollectionLookupException("The gate template has no template port with that ID.");
}
| unsigned int GateTemplate::get_width | ( | ) | const [virtual] |
Get the width of a gate template.
Definition at line 52 of file GateTemplate.cc.
References bounding_box, and degate::BoundingBox::get_width().
{
return bounding_box.get_width();
}

| bool GateTemplate::has_image | ( | Layer::LAYER_TYPE | layer_type | ) | const [virtual] |
Check if there is a reference image for a layer type.
Definition at line 87 of file GateTemplate.cc.
References images.
| bool GateTemplate::has_template_port | ( | object_id_t | object_id | ) | const [virtual] |
Check if a template has a specific template port.
| InvalidObjectIDException | This exception is thrown if the object ID is invalid. |
Definition at line 136 of file GateTemplate.cc.
References degate::LogicModelObjectBase::object_id, and ports.
{
if(object_id == 0)
throw InvalidObjectIDException("Error in GateTemplate::get_template_port(). "
"The object ID is invalid.");
for(port_iterator iter = ports.begin(); iter != ports.end(); ++iter) {
if((*iter)->get_object_id() == object_id) {
return true;
}
}
return false;
}
| GateTemplate::image_iterator GateTemplate::images_begin | ( | ) | [virtual] |
Get an iterator to iterate over images.
Definition at line 157 of file GateTemplate.cc.
References images.
Referenced by print().
{
return images.begin();
}

| GateTemplate::image_iterator GateTemplate::images_end | ( | ) | [virtual] |
Get end marker for the iteration over images.
Definition at line 161 of file GateTemplate.cc.
References images.
Referenced by print().
{
return images.end();
}

| GateTemplate::implementation_iter GateTemplate::implementations_begin | ( | ) | [virtual] |
Get an iterator to iterate over implementations.
Definition at line 186 of file GateTemplate.cc.
References implementations.
{
return implementations.begin();
}
| GateTemplate::implementation_iter GateTemplate::implementations_end | ( | ) | [virtual] |
Get an end marker for the iteration.
Definition at line 190 of file GateTemplate.cc.
References implementations.
{
return implementations.end();
}
| void GateTemplate::increment_reference_counter | ( | ) | [protected, virtual] |
Increment the reference counter.
Definition at line 27 of file GateTemplate.cc.
References reference_counter.
{
reference_counter++;
}
| GateTemplate::port_iterator GateTemplate::ports_begin | ( | ) | [virtual] |
Get an iterator.
Definition at line 149 of file GateTemplate.cc.
References ports.
{
return ports.begin();
}
| GateTemplate::port_iterator GateTemplate::ports_end | ( | ) | [virtual] |
Get end marker for the iteration over ports.
Definition at line 153 of file GateTemplate.cc.
References ports.
{
return ports.end();
}
| void GateTemplate::print | ( | std::ostream & | os | ) | [virtual] |
Print gate template's meta information to an output stream.
Definition at line 194 of file GateTemplate.cc.
References degate::LogicModelObjectBase::get_description(), degate::Layer::get_layer_type_as_string(), degate::LogicModelObjectBase::get_name(), degate::LogicModelObjectBase::get_object_id(), images_begin(), and images_end().
{
os
<< "Gate template name : " << get_name() << std::endl
<< "Gate template descr. : " << get_description() << std::endl
<< "Gate object ID : " << get_object_id() << std::endl
<< std::endl
;
for(image_iterator img_i = images_begin(); img_i != images_end(); ++img_i) {
Layer::LAYER_TYPE layer_type = (*img_i).first;
os
<< "Image for layer of type : " << Layer::get_layer_type_as_string(layer_type) << std::endl
<< std::endl
;
}
}

| bool GateTemplate::remove_template_port | ( | GateTemplatePort_shptr | template_port | ) | [virtual] |
Remove a port from a gate template.
This is an isolated function. The port is just removed from the gate template. Nothing else. Removing a port from a template requires some updates in the logic model. Therefore you should prefer the corresponding method from the LogicModel class.
Definition at line 99 of file GateTemplate.cc.
References ports.
{
assert(template_port->has_valid_object_id());
return ports.erase(template_port) > 0;
}
| bool GateTemplate::remove_template_port | ( | object_id_t | object_id | ) | [virtual] |
Remove a port from a gate template.
| InvalidObjectIDException | This exception is thrown if the template port has no valid object ID. |
Definition at line 105 of file GateTemplate.cc.
References degate::LogicModelObjectBase::object_id, and ports.
{
if(object_id == 0)
throw InvalidObjectIDException("Error in GateTemplate::remove_template_port(). "
"The object ID is invalid.");
for(port_iterator iter = ports.begin(); iter != ports.end(); ++iter) {
if((*iter)->get_object_id() == object_id) {
ports.erase(iter);
return true;
}
}
assert(1 == 0); // should not reach this line
return false;
}
| void GateTemplate::set_height | ( | unsigned int | height | ) | [virtual] |
Set the height of a gate template.
It does not adjust dimensions of gates that reference this template.
Definition at line 64 of file GateTemplate.cc.
References bounding_box, degate::BoundingBox::get_min_y(), and degate::BoundingBox::set_max_y().
{
bounding_box.set_max_y(bounding_box.get_min_y() + height);
}

| void GateTemplate::set_image | ( | Layer::LAYER_TYPE | layer_type, |
| GateTemplateImage_shptr | img | ||
| ) | [virtual] |
Set a reference image for the template.
You can store reference images for different layers, that is for the transistor layer, for the logic layer and for a metal layer. The images must have equal image dimensions. It is not checked here.
| InvalidPointerException | Throws this excpetion, if img is NULL. |
Definition at line 73 of file GateTemplate.cc.
References debug(), images, and TM.
{
if(img == NULL) throw InvalidPointerException("Invalid pointer for image.");
debug(TM, "set image for template.");
images[layer_type] = img;
}

| void GateTemplate::set_implementation | ( | IMPLEMENTATION_TYPE | impl_type, |
| std::string const & | code | ||
| ) | [virtual] |
Set VHDL/Verilog implementation for the gate template.
| impl_type | Set VHDL or Verilog. |
| code | The implementation. |
Definition at line 172 of file GateTemplate.cc.
References implementations.
{
implementations[impl_type] = code;
}
| void GateTemplate::set_logic_class | ( | std::string const & | logic_class | ) | [virtual] |
Set logic class for a standard cell.
There are two reasons for having this kind of tagging. First we want to render dedicated electronic symbols for standard gates, e.g. nands, xors and flipflops, independed of the standard cells name. Second we want to search for common building blocks, e.g. linear feedback shift registers, that we basically describe as a set of connected flipflops with some xor gates between them, independend of the gate's naming.
Definition at line 253 of file GateTemplate.cc.
References logic_class.
{
this->logic_class = logic_class;
}
| void GateTemplate::set_width | ( | unsigned int | width | ) | [virtual] |
Set the width of a gate template.
It does not adjust dimensions of gates that reference this template.
Definition at line 60 of file GateTemplate.cc.
References bounding_box, degate::BoundingBox::get_min_x(), and degate::BoundingBox::set_max_x().
{
bounding_box.set_max_x(bounding_box.get_min_x() + width);
}

friend class Gate [friend] |
Definition at line 43 of file GateTemplate.h.
Definition at line 67 of file GateTemplate.h.
Referenced by get_bounding_box(), get_height(), get_width(), set_height(), and set_width().
image_collection degate::GateTemplate::images [private] |
Definition at line 73 of file GateTemplate.h.
Referenced by get_image(), has_image(), images_begin(), images_end(), and set_image().
Definition at line 72 of file GateTemplate.h.
Referenced by get_implementation(), implementations_begin(), implementations_end(), and set_implementation().
std::string degate::GateTemplate::logic_class [private] |
Definition at line 75 of file GateTemplate.h.
Referenced by get_logic_class(), and set_logic_class().
std::set<GateTemplatePort_shptr> degate::GateTemplate::ports [private] |
Definition at line 70 of file GateTemplate.h.
Referenced by add_template_port(), get_number_of_ports(), get_template_port(), has_template_port(), ports_begin(), ports_end(), and remove_template_port().
unsigned int degate::GateTemplate::reference_counter [private] |
Definition at line 68 of file GateTemplate.h.
Referenced by decrement_reference_counter(), get_reference_counter(), and increment_reference_counter().
1.7.4