Author: Ken Schumack (c) 2001-2004. All rights reserved. This module is free software. It may be used, redistributed and/or modified under the terms of the Perl Artistic License. (see http://www.perl.com/pub/a/language/misc/Artistic.html) I do ask that you please let me know if you find bugs or have idea for improvements. You can reach me at Schumack@cpan.org Have fun, Ken
CircuitLayout - circuit layout module
This is CircuitLayout, a module for working with circuit layout items like boundaries, texts, rectangles, and srefs.
Send feedback/suggestions to Schumack@cpan.org
returns string of pitches given a ref to an array of CircuitLayout::Boundary items
## Coord object for CircuitLayout::Text origin coordinate... my $text = new CircuitLayout::Text(-origin=>$coord, -string=>$string); -or-
my @point = (0,0); ## anonymous array or array ref my $edge = new CircuitLayout::Edge(-origin=>\@point, -string=>"VDD");
draws on a worldCanvas
returns precision (integer)
returns origin as Coord object use -value to change and pass in Coord or x,y array
returns string in "x1,y1" where x and y print precision is controlled by objects printPrecision
Note: returns just one coordinate but method name is plural none the less to be consistant with other methods.
## CircuitLayout::Coord object for Lower Left Coordinate... my $edge = new CircuitLayout::Edge(-startCoord=>$coord1, -endCoord=>$coord2); -or-
my @startPoint = (0,0); ## anonymous array or array ref my $edge = new CircuitLayout::Edge(-startCoord=>\@startPoint, -endCoord=>[2.3,4.5]);
my $isLeft = $edge -> isLeft(-coord=>$coord);
my $edgeDirection = $edge -> direction;
Returns one of 8 compass directions: 'N','NE','E','SE','S','SW','W','NW'
my $edge = new CircuitLayout::Edge(-startCoord=>[0,0],-endCoord=>[5,5]);
print $edge -> direction; ## prints 'NE';
my $test = $edge -> is45multiple;
Returns true or false ( 1 or 0 ) depending on whether edge is a 45 degree multiple
print $edge -> is45multiple; ## prints 1;
Returns x value where CircuitLayout::Edge actually crosses x axis or would cross if it was extended.
Returns 0 or 1 depending on whether CircuitLayout::Edge straddles or touches horizontal X ray. Default X ray is X axis (y value==0)
$edge -> straddleTouchXray; -or- $edge -> straddleTouchXray(-yValue=>4.3);
Returns CircuitLayout::Edge as 'x1,y1;x2,y2' string.
print $edge -> printableCoords;
Returns 1st edge coordinate as a Coord.
Returns last edge coordinate as a Coord.
my $edgeExtent = $edge -> directionExtent;
Returns position (real number) of edge in one of 4 magor compass directions: 'N','E','S','W'
my $edge = new CircuitLayout::Edge(-startCoord=>[0,0],-endCoord=>[0,5]);
print $edge -> directionExtent(-direction=>'N'); ## prints 5;
my $edgeLength = $edge -> length;
Returns length of edge
my $edge = new CircuitLayout::Edge(-startCoord=>[0,1],-endCoord=>[0,5]);
print $edge -> length(); ## prints 4;
my $edgeExtentLength = $edge -> lengthAtExtent;
Returns position (real number) of edge length at maximum point in one of 4 magor compass directions: 'N','E','S','W'
print $edge -> lengthAtExtent(-direction=>'N'); ## prints 4;
print 'inside == true' if ($edge -> inside(-coord => $coord);
Returns 0 | 1 depending on whether coord is inside of edge
## CircuitLayout::Coord object for Lower Left Coordinate... my $path = new CircuitLayout::Path(
## CircuitLayout::Coord object for Lower Left Coordinate... my $rect = new CircuitLayout::Rectangle(-llCoord=>$coord1, -urCoord=>$coord2); -or-
my @llPoint = (0,0); ## anonymous array or array ref my $rect = new CircuitLayout::Rectangle(-llCoord=>\@llPoint, -urCoord=>[2.3,4.5]);
returns string in "x1,y1;x2,y2" where x and y print precision is controlled by objects printPrecision
Note: x1,y1 is lower left
usage: my $rect = new CircuitLayout::Rectangle(...);
print "is (4,6) inside ? ... ",$rect -> inside(-coord=>[4,6]);
print "is (4,6) interiorTo ? ... ",$rect -> interiorTo(-coord=>[4,6]);
usage: my $boundary = new CircuitLayout::Boundary(-xy=>\@xyArray) -or- my $boundary = new CircuitLayout::Boundary(-coords=>\$coords)
returns string in "x1,y1;x2,y2;x...." where x and y print precision is controlled by objects printPrecision
returns self (already a Boundary)
usage: my @xys=(0,0, 10,0, 10,10, 0,10);
my $boundary = new CircuitLayout::Boundary(-xy=>\@xys);
print "is (4,6) inside ? ... ",$boundary -> inside(-coord=>[4,6]);
print "is (4,6) interiorTo ? ... ",$boundary -> interiorTo(-coord=>[4,6]);
returns Boundary representation of 2 point rectangle
usage: my $sref = new CircuitLayout::Sref(-xy=>\@xyArray) -or- my $sref = new CircuitLayout::Sref(-coords=>\$coords)
returns name as "string" use -value to change and pass in string
Note: returns origin (which is just one coordinate) but method name is plural none the less to be consistant with other methods.
#!/usr/local/bin/perl -w use strict; $|++; use lib '.'; use CircuitLayout; use GDS2; $\="\n"; my $streamFileName = $ARGV[0]; my $gds2File = new GDS2(-fileName => $streamFileName); my $inBoundary=0; my $layerNum; my @layerIndexCnt; my %boundaries; while (my $record = $gds2File -> readGds2Record) { $inBoundary=1 if($gds2File -> isBoundary); $inBoundary=0 if($gds2File -> isEndel); if ($inBoundary) { $layerNum = $gds2File -> returnLayer if($gds2File -> isLayer); if($gds2File -> isXy) { if (! defined $layerIndexCnt[$layerNum]) { $layerIndexCnt[$layerNum] = 0; } my $layerIndex = $layerIndexCnt[$layerNum]; ## Use "my @xys" here to get unique memory location my @xys = $gds2File -> returnXyAsArray(-withClosure=>0,-asInteger=>0); my $boundary = new CircuitLayout::Boundary(-xy=>\@xys,-layer=>$layerNum); $boundaries{$layerNum}{$layerIndex} = \$boundary; $layerIndexCnt[$layerNum]++; } } } my $boundary; foreach my $layer (sort {$a <=> $b} keys %boundaries) { foreach my $x (keys %{$boundaries{$layer}}) { $boundary = ${$boundaries{$layer}{$x}}; print $boundary -> layer,':',$boundary -> printableCoords; } } ################################################################################
1 POD Error
The following errors were encountered while parsing the POD:
=pod directives shouldn't be over one line long! Ignoring all 2 lines of content
To install CircuitLayout, copy and paste the appropriate command in to your terminal.
cpanm
cpanm CircuitLayout
CPAN shell
perl -MCPAN -e shell install CircuitLayout
For more information on module installation, please visit the detailed CPAN module installation guide.