|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r62127 - in sandbox/gtl/doc: images tutorial
From: lucanus.j.simonson_at_[hidden]
Date: 2010-05-21 14:06:35
Author: ljsimons
Date: 2010-05-21 14:06:31 EDT (Fri, 21 May 2010)
New Revision: 62127
URL: http://svn.boost.org/trac/boost/changeset/62127
Log:
added tutorial and copyright notice to all html files
Added:
sandbox/gtl/doc/images/NAND.PNG (contents, props changed)
sandbox/gtl/doc/tutorial/
sandbox/gtl/doc/tutorial/compare_schematics.hpp (contents, props changed)
sandbox/gtl/doc/tutorial/connectivity_database.hpp (contents, props changed)
sandbox/gtl/doc/tutorial/device.hpp (contents, props changed)
sandbox/gtl/doc/tutorial/extract.cpp (contents, props changed)
sandbox/gtl/doc/tutorial/extract_devices.hpp (contents, props changed)
sandbox/gtl/doc/tutorial/layout_database.hpp (contents, props changed)
sandbox/gtl/doc/tutorial/layout_pin.hpp (contents, props changed)
sandbox/gtl/doc/tutorial/layout_rectangle.hpp (contents, props changed)
sandbox/gtl/doc/tutorial/nand.layout (contents, props changed)
sandbox/gtl/doc/tutorial/nand.schematic (contents, props changed)
sandbox/gtl/doc/tutorial/nand_short.layout (contents, props changed)
sandbox/gtl/doc/tutorial/nor.layout (contents, props changed)
sandbox/gtl/doc/tutorial/nor.schematic (contents, props changed)
sandbox/gtl/doc/tutorial/parse_layout.hpp (contents, props changed)
sandbox/gtl/doc/tutorial/schematic_database.hpp (contents, props changed)
Added: sandbox/gtl/doc/images/NAND.PNG
==============================================================================
Binary file. No diff available.
Added: sandbox/gtl/doc/tutorial/compare_schematics.hpp
==============================================================================
--- (empty file)
+++ sandbox/gtl/doc/tutorial/compare_schematics.hpp 2010-05-21 14:06:31 EDT (Fri, 21 May 2010)
@@ -0,0 +1,96 @@
+/*
+Copyright 2010 Intel Corporation
+
+Use, modification and distribution are subject to the Boost Software License,
+Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+http://www.boost.org/LICENSE_1_0.txt).
+*/
+//compare_schematics.hpp
+#ifndef BOOST_POLYGON_TUTORIAL_COMPARE_SCHEMATICS_HPP
+#define BOOST_POLYGON_TUTORIAL_COMPARE_SCHEMATICS_HPP
+#include <string>
+#include "schematic_database.hpp"
+
+bool compare_connectivity(std::string& ref_net, std::string& net,
+ schematic_database& reference_schematic,
+ schematic_database& schematic,
+ std::vector<std::size_t>& reference_to_internal_device_map,
+ std::size_t node_id) {
+ std::set<std::size_t>& ref_nodes = reference_schematic.nets[ref_net];
+ std::set<std::size_t>& nodes = schematic.nets[net];
+ for(std::set<std::size_t>::iterator itr = ref_nodes.begin();
+ itr != ref_nodes.end() && *itr < node_id; ++itr) {
+ if(nodes.find(reference_to_internal_device_map[*itr]) == nodes.end())
+ return false;
+ }
+ return true;
+}
+
+bool compare_schematics_recursive
+(schematic_database& reference_schematic,
+ schematic_database& schematic,
+ std::vector<std::size_t>& reference_to_internal_device_map,
+ std::set<std::size_t>& assigned_devices, std::size_t node_id){
+ //do check of equivalence up to this node
+ for(std::size_t i = 0; i < node_id; ++i) {
+ for(std::size_t j = 0; j < reference_schematic.devices[i].terminals.size(); ++j) {
+ device& rd = reference_schematic.devices[i];
+ device& xd = schematic.devices[reference_to_internal_device_map[i]];
+ if(rd.type == "PIN") {
+ if(rd.terminals[j] != xd.terminals[j])
+ return false;
+ } else {
+ //connectivity must be the same
+ if(j == 1) {
+ //gate has to be the same net
+ if(!compare_connectivity(rd.terminals[1], xd.terminals[1], reference_schematic, schematic,
+ reference_to_internal_device_map, node_id))
+ return false;
+ } else {
+ //order of nets in source and drain is not important so check both ways and accept either
+ if(!compare_connectivity(rd.terminals[j], xd.terminals[0], reference_schematic, schematic,
+ reference_to_internal_device_map, node_id) &&
+ !compare_connectivity(rd.terminals[j], xd.terminals[2], reference_schematic, schematic,
+ reference_to_internal_device_map, node_id))
+ return false;
+ }
+ }
+ }
+ }
+ if(node_id >= reference_schematic.devices.size())
+ return true; //final success
+
+ //recurse into subsequent nodes
+ for(std::size_t i = 0; i < schematic.devices.size(); ++i) {
+ if(reference_schematic.devices[node_id].type !=
+ schematic.devices[i].type)
+ continue; //skip dissimilar devices
+ //avoid multi-assignment of devices
+ if(assigned_devices.find(i) == assigned_devices.end()) {
+ reference_to_internal_device_map[node_id] = i;
+ std::set<std::size_t>::iterator itr = assigned_devices.insert(assigned_devices.end(), i);
+ if(compare_schematics_recursive(reference_schematic, schematic,
+ reference_to_internal_device_map,
+ assigned_devices, node_id + 1))
+ return true;
+ assigned_devices.erase(itr);
+ }
+ }
+ //could not find match between schematics
+ return false;
+}
+
+//this is a trivial brute force comparison algorithm because comparing
+//schematics does not require the use of Boost.Polygon and doing it more
+//optimally does not add to the tutorial
+inline bool compare_schematics(schematic_database& reference_schematic,
+ schematic_database& schematic) {
+ std::vector<std::size_t>
+ reference_to_internal_device_map(reference_schematic.devices.size(), 0);
+ std::set<std::size_t> assigned_devices;
+ return compare_schematics_recursive(reference_schematic, schematic,
+ reference_to_internal_device_map,
+ assigned_devices, 0);
+}
+
+#endif
Added: sandbox/gtl/doc/tutorial/connectivity_database.hpp
==============================================================================
--- (empty file)
+++ sandbox/gtl/doc/tutorial/connectivity_database.hpp 2010-05-21 14:06:31 EDT (Fri, 21 May 2010)
@@ -0,0 +1,149 @@
+/*
+ Copyright 2010 Intel Corporation
+
+ Use, modification and distribution are subject to the Boost Software License,
+ Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt).
+*/
+//connectivity_database.hpp
+#ifndef BOOST_POLYGON_TUTORIAL_CONNECTIVITY_DATABASE_HPP
+#define BOOST_POLYGON_TUTORIAL_CONNECTIVITY_DATABASE_HPP
+#include <boost/polygon/polygon.hpp>
+#include <map>
+#include <sstream>
+#include "layout_database.hpp"
+#include "layout_pin.hpp"
+
+typedef std::map<std::string, layout_database > connectivity_database;
+
+//map layout pin data type to boost::polygon::rectangle_concept
+namespace boost { namespace polygon{
+ template <>
+ struct rectangle_traits<layout_pin> {
+ typedef int coordinate_type;
+ typedef interval_data<int> interval_type;
+ static inline interval_type get(const layout_pin& pin, orientation_2d orient) {
+ if(orient == HORIZONTAL)
+ return interval_type(pin.xl, pin.xh);
+ return interval_type(pin.yl, pin.yh);
+ }
+ };
+
+ template <>
+ struct geometry_concept<layout_pin> { typedef rectangle_concept type; };
+}}
+
+typedef boost::polygon::polygon_90_data<int> polygon;
+typedef boost::polygon::polygon_90_set_data<int> polygon_set;
+
+inline void populate_connected_component
+(connectivity_database& connectivity, std::vector<polygon>& polygons,
+ std::vector<int> polygon_color, std::vector<std::set<int> >& graph,
+ std::size_t node_id, std::size_t polygon_id_offset, std::string& net,
+ std::vector<std::string>& net_ids, std::string net_prefix,
+ std::string& layout_layer) {
+ if(polygon_color[node_id] == 1)
+ return;
+ polygon_color[node_id] = 1;
+ if(node_id < polygon_id_offset && net_ids[node_id] != net) {
+ //merge nets in connectivity database
+ //if one of the nets is internal net merge it into the other
+ std::string net1 = net_ids[node_id];
+ std::string net2 = net;
+ if(net.compare(0, net_prefix.length(), net_prefix) == 0) {
+ net = net1;
+ std::swap(net1, net2);
+ } else {
+ net_ids[node_id] = net;
+ }
+ connectivity_database::iterator itr = connectivity.find(net1);
+ if(itr != connectivity.end()) {
+ for(layout_database::iterator itr2 = (*itr).second.begin();
+ itr2 != (*itr).second.end(); ++itr2) {
+ connectivity[net2][(*itr2).first].insert((*itr2).second);
+ }
+ connectivity.erase(itr);
+ }
+ }
+ if(node_id >= polygon_id_offset)
+ connectivity[net][layout_layer].insert(polygons[node_id - polygon_id_offset]);
+ for(std::set<int>::iterator itr = graph[node_id].begin();
+ itr != graph[node_id].end(); ++itr) {
+ populate_connected_component(connectivity, polygons, polygon_color, graph,
+ *itr, polygon_id_offset, net, net_ids, net_prefix, layout_layer);
+ }
+}
+
+inline void connect_layout_to_layer(connectivity_database& connectivity, polygon_set& layout, std::string layout_layer, std::string layer, std::string net_prefix, int& net_suffix) {
+ if(layout_layer.empty())
+ return;
+ boost::polygon::connectivity_extraction_90<int> ce;
+ std::vector<std::string> net_ids;
+ for(connectivity_database::iterator itr = connectivity.begin(); itr != connectivity.end(); ++itr) {
+ net_ids.push_back((*itr).first);
+ ce.insert((*itr).second[layer]);
+ }
+ std::vector<polygon> polygons;
+ layout.get_polygons(polygons);
+ std::size_t polygon_id_offset = net_ids.size();
+ for(std::size_t i = 0; i < polygons.size(); ++i) {
+ ce.insert(polygons[i]);
+ }
+ std::vector<std::set<int> > graph(polygons.size() + net_ids.size(), std::set<int>());
+ ce.extract(graph);
+ std::vector<int> polygon_color(polygons.size() + net_ids.size(), 0);
+ //for each net in net_ids populate connected component with net
+ for(std::size_t node_id = 0; node_id < net_ids.size(); ++node_id) {
+ populate_connected_component(connectivity, polygons, polygon_color, graph, node_id,
+ polygon_id_offset, net_ids[node_id], net_ids,
+ net_prefix, layout_layer);
+ }
+ //for each polygon_color that is zero populate connected compontent with net_prefix + net_suffix++
+ for(std::size_t i = 0; i < polygons.size(); ++i) {
+ if(polygon_color[i + polygon_id_offset] == 0) {
+ std::stringstream ss(std::stringstream::in | std::stringstream::out);
+ ss << net_prefix << net_suffix++;
+ std::string internal_net;
+ ss >> internal_net;
+ populate_connected_component(connectivity, polygons, polygon_color, graph,
+ i + polygon_id_offset,
+ polygon_id_offset, internal_net, net_ids,
+ net_prefix, layout_layer);
+ }
+ }
+}
+
+//given a layout_database we populate a connectivity database
+inline void populate_connectivity_database(connectivity_database& connectivity, std::vector<layout_pin>& pins, layout_database& layout) {
+ using namespace boost::polygon;
+ using namespace boost::polygon::operators;
+ for(std::size_t i = 0; i < pins.size(); ++i) {
+ connectivity[pins[i].net][pins[i].layer].insert(pins[i]);
+ }
+ int internal_net_suffix = 0;
+ //connect metal1 layout to pins which were on metal1
+ connect_layout_to_layer(connectivity, layout["METAL1"], "METAL1",
+ "METAL1", "__internal_net_", internal_net_suffix);
+ //connect via0 layout to metal1
+ connect_layout_to_layer(connectivity, layout["VIA0"], "VIA0",
+ "METAL1", "__internal_net_", internal_net_suffix);
+ //poly needs to have gates subtracted from it to prevent shorting through transistors
+ polygon_set poly_not_gate = layout["POLY"] - layout["GATE"];
+ //connect poly minus gate to via0
+ connect_layout_to_layer(connectivity, poly_not_gate, "POLY",
+ "VIA0", "__internal_net_", internal_net_suffix);
+ //we don't want to short signals through transistors so we subtract the gate regions
+ //from the diffusions
+ polygon_set diff_not_gate = (layout["PDIFF"] + layout["NDIFF"]) - layout["GATE"];
+ //connect diffusion minus gate to poly
+ //Note that I made up the DIFF layer name for combined P and NDIFF
+ connect_layout_to_layer(connectivity, diff_not_gate, "DIFF",
+ "POLY", "__internal_net_", internal_net_suffix);
+ //connect gate to poly to make connections through gates on poly
+ connect_layout_to_layer(connectivity, layout["GATE"], "GATE",
+ "POLY", "__internal_net_", internal_net_suffix);
+ //now we have traced connectivity of the layout down to the transistor level
+ //any polygons not connected to pins have been assigned internal net names
+}
+
+#endif
Added: sandbox/gtl/doc/tutorial/device.hpp
==============================================================================
--- (empty file)
+++ sandbox/gtl/doc/tutorial/device.hpp 2010-05-21 14:06:31 EDT (Fri, 21 May 2010)
@@ -0,0 +1,38 @@
+/*
+ Copyright 2010 Intel Corporation
+
+ Use, modification and distribution are subject to the Boost Software License,
+ Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt).
+*/
+
+//device.hpp
+#ifndef BOOST_POLYGON_TUTORIAL_DEVICE_HPP
+#define BOOST_POLYGON_TUTORIAL_DEVICE_HPP
+#include <string>
+#include <vector>
+#include <iostream>
+
+struct device {
+ std::string type;
+ std::vector<std::string> terminals;
+};
+
+inline std::ostream& operator << (std::ostream& o, const device& r)
+{
+ o << r.type << " ";
+ for(std::size_t i = 0; i < r.terminals.size(); ++i) {
+ o << r.terminals[i] << " ";
+ }
+ return o;
+}
+
+inline std::istream& operator >> (std::istream& i, device& r)
+{
+ i >> r.type;
+ r.terminals = std::vector<std::string>(3, std::string());
+ i >> r.terminals[0] >> r.terminals[1] >> r.terminals[2];
+ return i;
+}
+
+#endif
Added: sandbox/gtl/doc/tutorial/extract.cpp
==============================================================================
--- (empty file)
+++ sandbox/gtl/doc/tutorial/extract.cpp 2010-05-21 14:06:31 EDT (Fri, 21 May 2010)
@@ -0,0 +1,63 @@
+/*
+Copyright 2010 Intel Corporation
+
+Use, modification and distribution are subject to the Boost Software License,
+Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+http://www.boost.org/LICENSE_1_0.txt).
+*/
+#include "schematic_database.hpp"
+#include "layout_pin.hpp"
+#include "layout_rectangle.hpp"
+#include "connectivity_database.hpp"
+#include "compare_schematics.hpp"
+#include "extract_devices.hpp"
+#include "parse_layout.hpp"
+#include "layout_database.hpp"
+#include "device.hpp"
+#include <string>
+#include <fstream>
+#include <iostream>
+
+bool compare_files(std::string layout_file, std::string schematic_file) {
+ std::ifstream sin(schematic_file.c_str());
+ std::ifstream lin(layout_file.c_str());
+
+ std::vector<layout_rectangle> rects;
+ std::vector<layout_pin> pins;
+ parse_layout(rects, pins, lin);
+
+ schematic_database reference_schematic;
+ parse_schematic_database(reference_schematic, sin);
+
+ layout_database layout;
+ populate_layout_database(layout, rects);
+
+ connectivity_database connectivity;
+ populate_connectivity_database(connectivity, pins, layout);
+
+ schematic_database schematic;
+ std::vector<device>& devices = schematic.devices;
+ for(std::size_t i = 0; i < pins.size(); ++i) {
+ devices.push_back(device());
+ devices.back().type = "PIN";
+ devices.back().terminals.push_back(pins[i].net);
+ }
+ extract_devices(devices, connectivity, layout);
+ extract_netlist(schematic.nets, devices);
+
+ return compare_schematics(reference_schematic, schematic);
+}
+
+int main(int argc, char **argv) {
+ if(argc < 3) {
+ std::cout << "usage: " << argv[0] << " <layout_file> <schematic_file>" << std::endl;
+ return -1;
+ }
+ bool result = compare_files(argv[1], argv[2]);
+ if(result == false) {
+ std::cout << "Layout does not match schematic." << std::endl;
+ return 1;
+ }
+ std::cout << "Layout does match schematic." << std::endl;
+ return 0;
+}
Added: sandbox/gtl/doc/tutorial/extract_devices.hpp
==============================================================================
--- (empty file)
+++ sandbox/gtl/doc/tutorial/extract_devices.hpp 2010-05-21 14:06:31 EDT (Fri, 21 May 2010)
@@ -0,0 +1,99 @@
+/*
+Copyright 2010 Intel Corporation
+
+Use, modification and distribution are subject to the Boost Software License,
+Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+http://www.boost.org/LICENSE_1_0.txt).
+*/
+//extract_devices.hpp
+#ifndef BOOST_POLYGON_TUTORIAL_EXTRACT_DEVICES_HPP
+#define BOOST_POLYGON_TUTORIAL_EXTRACT_DEVICES_HPP
+#include <string>
+#include <iostream>
+#include <fstream>
+#include <vector>
+#include "connectivity_database.hpp"
+#include "device.hpp"
+
+typedef boost::polygon::connectivity_extraction_90<int> connectivity_extraction;
+inline std::vector<std::set<int> >
+extract_layer(connectivity_extraction& ce, std::vector<std::string>& net_ids,
+ connectivity_database& connectivity, polygon_set& layout,
+ std::string layer) {
+ for(connectivity_database::iterator itr = connectivity.begin(); itr != connectivity.end(); ++itr) {
+ net_ids.push_back((*itr).first);
+ ce.insert((*itr).second[layer]);
+ }
+ std::vector<polygon> polygons;
+ layout.get_polygons(polygons);
+ for(std::size_t i = 0; i < polygons.size(); ++i) {
+ ce.insert(polygons[i]);
+ }
+ std::vector<std::set<int> > graph(polygons.size() + net_ids.size(), std::set<int>());
+ ce.extract(graph);
+ return graph;
+}
+
+inline void extract_device_type(std::vector<device>& devices, connectivity_database& connectivity,
+ polygon_set& layout, std::string type) {
+ //recall that P and NDIFF were merged into one DIFF layer in the connectivity database
+ //find the two nets on the DIFF layer that interact with each transistor
+ //and then find the net on the poly layer that interacts with each transistor
+ boost::polygon::connectivity_extraction_90<int> cediff;
+ std::vector<std::string> net_ids_diff;
+ std::vector<std::set<int> > graph_diff =
+ extract_layer(cediff, net_ids_diff, connectivity, layout, "DIFF");
+ boost::polygon::connectivity_extraction_90<int> cepoly;
+ std::vector<std::string> net_ids_poly;
+ std::vector<std::set<int> > graph_poly =
+ extract_layer(cepoly, net_ids_poly, connectivity, layout, "POLY");
+ std::vector<device> tmp_devices(graph_diff.size() - net_ids_poly.size());
+ for(std::size_t i = net_ids_poly.size(); i < graph_diff.size(); ++i) {
+ tmp_devices[i - net_ids_diff.size()].type = type;
+ tmp_devices[i - net_ids_diff.size()].terminals = std::vector<std::string>(3, std::string());
+ std::size_t j = 0;
+ for(std::set<int>::iterator itr = graph_diff[i].begin();
+ itr != graph_diff[i].end(); ++itr, ++j) {
+ if(j == 0) {
+ tmp_devices[i - net_ids_diff.size()].terminals[0] = net_ids_diff[*itr];
+ } else if(j == 1) {
+ tmp_devices[i - net_ids_diff.size()].terminals[2] = net_ids_diff[*itr];
+ } else {
+ //error, too many diff connections
+ tmp_devices[i - net_ids_diff.size()].terminals = std::vector<std::string>(3, std::string());
+ }
+ }
+ j = 0;
+ for(std::set<int>::iterator itr = graph_poly[i].begin();
+ itr != graph_poly[i].end(); ++itr, ++j) {
+ if(j == 0) {
+ tmp_devices[i - net_ids_diff.size()].terminals[1] = net_ids_poly[*itr];
+ } else {
+ //error, too many poly connections
+ tmp_devices[i - net_ids_poly.size()].terminals = std::vector<std::string>(3, std::string());
+ }
+ }
+ }
+
+ devices.insert(devices.end(), tmp_devices.begin(), tmp_devices.end());
+}
+
+//populates vector of devices based on connectivity and layout data
+inline void extract_devices(std::vector<device>& devices, connectivity_database& connectivity,
+ layout_database& layout) {
+ using namespace boost::polygon::operators;
+ //p-type transistors are gate that interact with p diffusion and nwell
+ polygon_set ptransistors = layout["GATE"];
+ ptransistors.interact(layout["PDIFF"]);
+ ptransistors.interact(layout["NWELL"]);
+ //n-type transistors are gate that interact with n diffusion and not nwell
+ polygon_set ntransistors = layout["GATE"];
+ ntransistors.interact(layout["NDIFF"]);
+ polygon_set not_ntransistors = ntransistors;
+ not_ntransistors.interact(layout["NWELL"]);
+ ntransistors -= not_ntransistors;
+ extract_device_type(devices, connectivity, ptransistors, "PTRANS");
+ extract_device_type(devices, connectivity, ntransistors, "NTRANS");
+}
+
+#endif
Added: sandbox/gtl/doc/tutorial/layout_database.hpp
==============================================================================
--- (empty file)
+++ sandbox/gtl/doc/tutorial/layout_database.hpp 2010-05-21 14:06:31 EDT (Fri, 21 May 2010)
@@ -0,0 +1,41 @@
+/*
+Copyright 2010 Intel Corporation
+
+Use, modification and distribution are subject to the Boost Software License,
+Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+http://www.boost.org/LICENSE_1_0.txt).
+*/
+
+//layout_database.hpp
+#ifndef BOOST_POLYGON_TUTORIAL_LAYOUT_DATABASE_HPP
+#define BOOST_POLYGON_TUTORIAL_LAYOUT_DATABASE_HPP
+#include <boost/polygon/polygon.hpp>
+#include <map>
+#include "layout_rectangle.hpp"
+
+typedef std::map<std::string, boost::polygon::polygon_90_set_data<int> > layout_database;
+
+//map the layout rectangle data type to the boost::polygon::rectangle_concept
+namespace boost { namespace polygon{
+ template <>
+ struct rectangle_traits<layout_rectangle> {
+ typedef int coordinate_type;
+ typedef interval_data<int> interval_type;
+ static inline interval_type get(const layout_rectangle& rectangle, orientation_2d orient) {
+ if(orient == HORIZONTAL)
+ return interval_type(rectangle.xl, rectangle.xh);
+ return interval_type(rectangle.yl, rectangle.yh);
+ }
+ };
+
+ template <>
+ struct geometry_concept<layout_rectangle> { typedef rectangle_concept type; };
+}}
+
+//insert layout rectangles into a layout database
+inline void populate_layout_database(layout_database& layout, std::vector<layout_rectangle>& rects) {
+ for(std::size_t i = 0; i < rects.size(); ++i) {
+ layout[rects[i].layer].insert(rects[i]);
+ }
+}
+#endif
Added: sandbox/gtl/doc/tutorial/layout_pin.hpp
==============================================================================
--- (empty file)
+++ sandbox/gtl/doc/tutorial/layout_pin.hpp 2010-05-21 14:06:31 EDT (Fri, 21 May 2010)
@@ -0,0 +1,33 @@
+/*
+Copyright 2010 Intel Corporation
+
+Use, modification and distribution are subject to the Boost Software License,
+Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+http://www.boost.org/LICENSE_1_0.txt).
+*/
+
+//layout_pin.hpp
+#ifndef BOOST_POLYGON_TUTORIAL_LAYOUT_PIN_HPP
+#define BOOST_POLYGON_TUTORIAL_LAYOUT_PIN_HPP
+#include <string>
+#include <iostream>
+
+struct layout_pin {
+ int xl, yl, xh, yh;
+ std::string layer;
+ std::string net;
+};
+
+inline std::ostream& operator << (std::ostream& o, const layout_pin& r)
+{
+ o << r.xl << " " << r.xh << " " << r.yl << " " << r.yh << " " << r.layer << " " << r.net;
+ return o;
+}
+
+inline std::istream& operator >> (std::istream& i, layout_pin& r)
+{
+ i >> r.xl >> r.xh >> r.yl >> r.yh >> r.layer >> r.net;
+ return i;
+}
+
+#endif
Added: sandbox/gtl/doc/tutorial/layout_rectangle.hpp
==============================================================================
--- (empty file)
+++ sandbox/gtl/doc/tutorial/layout_rectangle.hpp 2010-05-21 14:06:31 EDT (Fri, 21 May 2010)
@@ -0,0 +1,32 @@
+/*
+Copyright 2010 Intel Corporation
+
+Use, modification and distribution are subject to the Boost Software License,
+Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+http://www.boost.org/LICENSE_1_0.txt).
+*/
+
+//layout_rectangle.hpp
+#ifndef BOOST_POLYGON_TUTORIAL_LAYOUT_RECTANGLE_HPP
+#define BOOST_POLYGON_TUTORIAL_LAYOUT_RECTANGLE_HPP
+#include <string>
+#include <iostream>
+
+struct layout_rectangle {
+ int xl, yl, xh, yh;
+ std::string layer;
+};
+
+inline std::ostream& operator << (std::ostream& o, const layout_rectangle& r)
+{
+ o << r.xl << " " << r.xh << " " << r.yl << " " << r.yh << " " << r.layer;
+ return o;
+}
+
+inline std::istream& operator >> (std::istream& i, layout_rectangle& r)
+{
+ i >> r.xl >> r.xh >> r.yl >> r.yh >> r.layer;
+ return i;
+}
+
+#endif
Added: sandbox/gtl/doc/tutorial/nand.layout
==============================================================================
--- (empty file)
+++ sandbox/gtl/doc/tutorial/nand.layout 2010-05-21 14:06:31 EDT (Fri, 21 May 2010)
@@ -0,0 +1,29 @@
+Rectangle 0 60 24 48 NWELL
+Rectangle 3 57 32 43 PDIFF
+Rectangle 3 57 5 16 NDIFF
+Rectangle 5 7 0 17 POLY
+Rectangle 5 7 22 45 POLY
+Rectangle 17 19 3 45 POLY
+Rectangle 29 31 31 48 POLY
+Rectangle 41 43 3 45 POLY
+Rectangle 53 55 3 45 POLY
+Rectangle 17 19 4 17 GATE
+Rectangle 17 19 31 44 GATE
+Rectangle 41 43 4 17 GATE
+Rectangle 41 43 31 44 GATE
+Rectangle 5 7 0 2 VIA0
+Rectangle 5 7 23 25 VIA0
+Rectangle 17 19 28 30 VIA0
+Rectangle 29 31 46 48 VIA0
+Rectangle 41 43 18 20 VIA0
+Rectangle 53 55 23 25 VIA0
+Rectangle 0 60 0 2 METAL1
+Rectangle 3 57 28 30 METAL1
+Rectangle 0 60 46 48 METAL1
+Rectangle 3 57 18 20 METAL1
+Rectangle 3 57 23 25 METAL1
+Pin 29 31 0 2 METAL1 GND
+Pin 29 31 23 25 METAL1 OUTPUT
+Pin 29 31 28 30 METAL1 INPUT1
+Pin 29 31 46 48 METAL1 VDD
+Pin 29 31 18 20 METAL1 INPUT2
Added: sandbox/gtl/doc/tutorial/nand.schematic
==============================================================================
--- (empty file)
+++ sandbox/gtl/doc/tutorial/nand.schematic 2010-05-21 14:06:31 EDT (Fri, 21 May 2010)
@@ -0,0 +1,9 @@
+Pin OUTPUT
+Pin INPUT1
+Pin INPUT2
+Pin VDD
+Pin GND
+Device PTRANS VDD INPUT1 OUTPUT
+Device PTRANS VDD INPUT2 OUTPUT
+Device NTRANS GND INPUT1 NET1
+Device NTRANS NET1 INPUT2 OUTPUT
Added: sandbox/gtl/doc/tutorial/nand_short.layout
==============================================================================
--- (empty file)
+++ sandbox/gtl/doc/tutorial/nand_short.layout 2010-05-21 14:06:31 EDT (Fri, 21 May 2010)
@@ -0,0 +1,29 @@
+Rectangle 0 60 24 48 NWELL
+Rectangle 3 57 32 43 PDIFF
+Rectangle 3 57 5 16 NDIFF
+Rectangle 5 7 0 17 POLY
+Rectangle 5 7 22 45 POLY
+Rectangle 17 19 3 45 POLY
+Rectangle 29 31 31 48 POLY
+Rectangle 41 43 3 45 POLY
+Rectangle 53 55 3 45 POLY
+Rectangle 17 19 4 17 GATE
+Rectangle 17 19 31 44 GATE
+Rectangle 53 55 4 17 GATE
+Rectangle 53 55 31 44 GATE
+Rectangle 5 7 0 2 VIA0
+Rectangle 5 7 23 25 VIA0
+Rectangle 17 19 28 30 VIA0
+Rectangle 29 31 46 48 VIA0
+Rectangle 41 43 18 20 VIA0
+Rectangle 53 55 23 25 VIA0
+Rectangle 0 60 0 2 METAL1
+Rectangle 3 57 28 30 METAL1
+Rectangle 0 60 46 48 METAL1
+Rectangle 3 57 18 20 METAL1
+Rectangle 3 57 23 25 METAL1
+Pin 29 31 0 2 METAL1 GND
+Pin 29 31 23 25 METAL1 OUTPUT
+Pin 29 31 28 30 METAL1 INPUT1
+Pin 29 31 46 48 METAL1 VDD
+Pin 29 31 18 20 METAL1 INPUT2
Added: sandbox/gtl/doc/tutorial/nor.layout
==============================================================================
--- (empty file)
+++ sandbox/gtl/doc/tutorial/nor.layout 2010-05-21 14:06:31 EDT (Fri, 21 May 2010)
@@ -0,0 +1,29 @@
+Rectangle 0 60 0 24 NWELL
+Rectangle 3 57 32 43 NDIFF
+Rectangle 3 57 5 16 PDIFF
+Rectangle 5 7 0 17 POLY
+Rectangle 5 7 22 45 POLY
+Rectangle 17 19 3 45 POLY
+Rectangle 29 31 31 48 POLY
+Rectangle 41 43 3 45 POLY
+Rectangle 53 55 3 45 POLY
+Rectangle 17 19 4 17 GATE
+Rectangle 17 19 31 44 GATE
+Rectangle 41 43 4 17 GATE
+Rectangle 41 43 31 44 GATE
+Rectangle 5 7 0 2 VIA0
+Rectangle 5 7 23 25 VIA0
+Rectangle 17 19 28 30 VIA0
+Rectangle 29 31 46 48 VIA0
+Rectangle 41 43 18 20 VIA0
+Rectangle 53 55 23 25 VIA0
+Rectangle 0 60 0 2 METAL1
+Rectangle 3 57 28 30 METAL1
+Rectangle 0 60 46 48 METAL1
+Rectangle 3 57 18 20 METAL1
+Rectangle 3 57 23 25 METAL1
+Pin 29 31 0 2 METAL1 GND
+Pin 29 31 23 25 METAL1 OUTPUT
+Pin 29 31 28 30 METAL1 INPUT1
+Pin 29 31 46 48 METAL1 VDD
+Pin 29 31 18 20 METAL1 INPUT2
Added: sandbox/gtl/doc/tutorial/nor.schematic
==============================================================================
--- (empty file)
+++ sandbox/gtl/doc/tutorial/nor.schematic 2010-05-21 14:06:31 EDT (Fri, 21 May 2010)
@@ -0,0 +1,9 @@
+Pin OUTPUT
+Pin INPUT1
+Pin INPUT2
+Pin VDD
+Pin GND
+Device NTRANS VDD INPUT1 OUTPUT
+Device NTRANS VDD INPUT2 OUTPUT
+Device PTRANS GND INPUT1 NET1
+Device PTRANS NET1 INPUT2 OUTPUT
Added: sandbox/gtl/doc/tutorial/parse_layout.hpp
==============================================================================
--- (empty file)
+++ sandbox/gtl/doc/tutorial/parse_layout.hpp 2010-05-21 14:06:31 EDT (Fri, 21 May 2010)
@@ -0,0 +1,39 @@
+/*
+Copyright 2010 Intel Corporation
+
+Use, modification and distribution are subject to the Boost Software License,
+Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+http://www.boost.org/LICENSE_1_0.txt).
+*/
+
+//parse_layout.hpp
+#ifndef BOOST_POLYGON_TUTORIAL_PARSE_LAYOUT_HPP
+#define BOOST_POLYGON_TUTORIAL_PARSE_LAYOUT_HPP
+#include <string>
+#include <iostream>
+#include <fstream>
+#include <vector>
+#include "layout_rectangle.hpp"
+#include "layout_pin.hpp"
+
+//populates vectors of layout rectangles and pins
+inline void parse_layout(std::vector<layout_rectangle>& rects, std::vector<layout_pin>& pins,
+ std::ifstream& sin) {
+ while(!sin.eof()) {
+ std::string type_id;
+ sin >> type_id;
+ if(type_id == "Rectangle") {
+ layout_rectangle rect;
+ sin >> rect;
+ rects.push_back(rect);
+ } else if (type_id == "Pin") {
+ layout_pin pin;
+ sin >> pin;
+ pins.push_back(pin);
+ } else if (type_id == "") {
+ break;
+ }
+ }
+}
+
+#endif
Added: sandbox/gtl/doc/tutorial/schematic_database.hpp
==============================================================================
--- (empty file)
+++ sandbox/gtl/doc/tutorial/schematic_database.hpp 2010-05-21 14:06:31 EDT (Fri, 21 May 2010)
@@ -0,0 +1,58 @@
+/*
+Copyright 2010 Intel Corporation
+
+Use, modification and distribution are subject to the Boost Software License,
+Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+http://www.boost.org/LICENSE_1_0.txt).
+*/
+
+//schematic_database.hpp
+#ifndef BOOST_POLYGON_TUTORIAL_SCHEMATIC_DATABASE_HPP
+#define BOOST_POLYGON_TUTORIAL_SCHEMATIC_DATABASE_HPP
+#include <string>
+#include <fstream>
+#include <map>
+#include <set>
+#include "device.hpp"
+
+struct schematic_database{
+ std::vector<device> devices;
+ std::map<std::string, std::set<std::size_t> > nets;
+};
+
+//given a vector of devices populate the map of net name to set of device index
+inline void extract_netlist(std::map<std::string, std::set<std::size_t> >& nets,
+ std::vector<device>& devices) {
+ for(std::size_t i = 0; i < devices.size(); ++i) {
+ for(std::size_t j = 0; j < devices[i].terminals.size(); ++j) {
+ //create association between net name and device id
+ nets[devices[i].terminals[j]].insert(nets[devices[i].terminals[j]].end(), i);
+ }
+ }
+}
+
+inline void parse_schematic_database(schematic_database& schematic,
+ std::ifstream& sin) {
+ std::vector<device>& devices = schematic.devices;
+ while(!sin.eof()) {
+ std::string type_id;
+ sin >> type_id;
+ if(type_id == "Device") {
+ device d;
+ sin >> d;
+ devices.push_back(d);
+ } else if (type_id == "Pin") {
+ std::string net;
+ sin >> net;
+ device d;
+ d.type = "PIN";
+ d.terminals.push_back(net);
+ devices.push_back(d);
+ } else if (type_id == "") {
+ break;
+ }
+ }
+ extract_netlist(schematic.nets, devices);
+}
+
+#endif
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk