Files
OpenSTA/include/sta/Network.hh
James Cherry 3f7df84fb8 Network::id for maps/sets
commit be70d30ae05665021254b0d7e69fb8d2f0a82890
Author: James Cherry <cherry@parallaxsw.com>
Date:   Tue Jan 17 17:04:49 2023 -0700

    cmp

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit 4d4ef96948afe3d6a00c4521aeb5bc74274f5737
Author: James Cherry <cherry@parallaxsw.com>
Date:   Tue Jan 17 16:08:50 2023 -0700

    rvo, const

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit bb584e4264af2bea867b17d07e8d38c0e9eb0025
Author: James Cherry <cherry@parallaxsw.com>
Date:   Tue Jan 17 15:05:00 2023 -0700

    const

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit a08fe558bca6b769b2728882258bd85aed990a27
Author: James Cherry <cherry@parallaxsw.com>
Date:   Tue Jan 17 14:57:33 2023 -0700

    LibertyPortPair no ptrs

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit 4d3bd60c109d1ce9d0589d746f4968fa7bebd90d
Author: James Cherry <cherry@parallaxsw.com>
Date:   Tue Jan 17 14:13:07 2023 -0700

    cleanup

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit dc25ff77771cfbe26f9318bad2b3c45879614783
Author: James Cherry <cherry@parallaxsw.com>
Date:   Tue Jan 17 14:06:13 2023 -0700

    const

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit 06e81586ce11a0cc06948ed78fef99353077d69e
Author: James Cherry <cherry@parallaxsw.com>
Date:   Tue Jan 17 14:01:10 2023 -0700

    sortByName

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit 9d8592aff5b246f83e47e1b94490e3cef8d8e119
Author: James Cherry <cherry@parallaxsw.com>
Date:   Tue Jan 17 11:57:17 2023 -0700

    sort pred

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit 462a8e14df8b561ddfc842addc62c4b8435b6347
Author: James Cherry <cherry@parallaxsw.com>
Date:   Tue Jan 17 11:09:57 2023 -0700

    const

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit 69f71505b684e88b22d395510429497e87bf1015
Author: James Cherry <cherry@parallaxsw.com>
Date:   Tue Jan 17 10:45:14 2023 -0700

    flush ConstPortSeq

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit 6429d578b78eac3fe7e99fcd67a120789932b2eb
Author: James Cherry <cherry@parallaxsw.com>
Date:   Tue Jan 17 09:19:15 2023 -0700

    rm ConstNetSet

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit f247930b16e40560b957a36af68947249ed1ef04
Author: James Cherry <cherry@parallaxsw.com>
Date:   Tue Jan 17 08:50:50 2023 -0700

    sortPathNames

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit 4ca2b0e0af7252c7bcbc65cf141d0ce40634d329
Author: James Cherry <cherry@parallaxsw.com>
Date:   Mon Jan 16 10:14:05 2023 -0700

    const

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit 3d18640d2ebc4aae3098c7e7242a554fcb64fd42
Author: James Cherry <cherry@parallaxsw.com>
Date:   Mon Jan 16 09:41:27 2023 -0700

    set_input/ouput_delay -reference_pin

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit d4a0854dd2102f46f96a94fb9eb8749f1593a85f
Author: James Cherry <cherry@parallaxsw.com>
Date:   Mon Jan 16 09:13:46 2023 -0700

    PinPairSet no malloc

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit a6f1583fc6a856c5ecc0dcb15a1d8b1f61e30718
Author: James Cherry <cherry@parallaxsw.com>
Date:   Mon Jan 16 08:53:33 2023 -0700

    no malloc for EdgePins

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit c8e4b92e8b619109d6aa3c141c720646067ccb4b
Author: James Cherry <cherry@parallaxsw.com>
Date:   Mon Jan 16 06:31:08 2023 +0000

    leak

commit abab99e0fc3e466d914f6c1705aa08cdc204df51
Author: James Cherry <cherry@parallaxsw.com>
Date:   Mon Jan 16 06:07:36 2023 +0000

    leaks

commit d1913b554bb6e98b89673d80d2295f552eb4ffca
Author: James Cherry <cherry@parallaxsw.com>
Date:   Sun Jan 15 19:48:39 2023 -0700

    LibertyCell::checkCornerCell

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit bcc172237d48deed647374f9592bac70bd2d5425
Author: James Cherry <cherry@parallaxsw.com>
Date:   Sun Jan 15 18:19:47 2023 -0700

    rvo

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit 8ef9800b87f5e5548055a13afc21397f28a6bcf7
Author: James Cherry <cherry@parallaxsw.com>
Date:   Sun Jan 15 18:07:46 2023 -0700

    sdc net id

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit d7235abed04ced4e2d84e91bf9968e621268567d
Author: James Cherry <cherry@parallaxsw.com>
Date:   Sun Jan 15 16:00:27 2023 -0700

    range iter

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit a22f91a3c54c644574339d1126821d9bc8045bd6
Author: James Cherry <cherry@parallaxsw.com>
Date:   Sun Jan 15 15:52:50 2023 -0700

    range iter

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit 762615ce3de91d950eeaaa4680549a45b13e0e0a
Author: James Cherry <cherry@parallaxsw.com>
Date:   Sun Jan 15 15:42:19 2023 -0700

    range iter

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit 7e0c531613d343d23f064c24873bf5a498f6f4ce
Author: James Cherry <cherry@parallaxsw.com>
Date:   Sun Jan 15 12:26:49 2023 -0700

    rm removeLoadCaps, removeNetLoadCaps

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit f2e88c6082e2d4605e9849348008bf4065401fc8
Author: James Cherry <cherry@parallaxsw.com>
Date:   Sun Jan 15 12:21:03 2023 -0700

    sdc rm map ptrs

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit b5939666188c0b94dfe957e22bbd8a92f4786125
Author: James Cherry <cherry@parallaxsw.com>
Date:   Sun Jan 15 11:36:16 2023 -0700

    sdc rm map ptrs

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit a435081bafe10260743319f53a59cbe2ed0388b7
Author: James Cherry <cherry@parallaxsw.com>
Date:   Sun Jan 15 08:43:37 2023 -0700

    sdc rm map ptrs

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit acfb247559db7b726d47f203613488df0f7add53
Author: James Cherry <cherry@parallaxsw.com>
Date:   Sun Jan 15 08:38:07 2023 -0700

    sdc rm map ptrs

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit 7541b71da92ea15085615988a1e6ea1d4d53d8d6
Author: James Cherry <cherry@parallaxsw.com>
Date:   Sun Jan 15 08:00:55 2023 -0700

    sdc rm map ptrs

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit d033210132656ea68fa834228575b9def1d02d90
Author: James Cherry <cherry@parallaxsw.com>
Date:   Sun Jan 15 07:52:03 2023 -0700

    sdc rm map ptrs

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit ca6e9ecb7821b83ab024c4fee6df8f7fc8fc2ce2
Author: James Cherry <cherry@parallaxsw.com>
Date:   Sun Jan 15 07:38:12 2023 -0700

    instance_pvt_maps_

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit 631e4209b596386f5818045d521784db5239f58d
Author: James Cherry <cherry@parallaxsw.com>
Date:   Sun Jan 15 07:26:42 2023 -0700

    rm GroupPathIterator

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit 059c32afa87617fff530c9afa1ef8005a136739d
Author: James Cherry <cherry@parallaxsw.com>
Date:   Sat Jan 14 20:07:44 2023 -0700

    rm ClockIterator

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit c65fe873a6a6696220bbb44c4ecac87d5ca978ac
Author: James Cherry <cherry@parallaxsw.com>
Date:   Sat Jan 14 19:45:58 2023 -0700

    rvo

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit ce15c9a0cc78915acddc2f03749573d989ae96d6
Author: James Cherry <cherry@parallaxsw.com>
Date:   Sun Jan 15 01:04:03 2023 +0000

    leaks

commit f97955a0c7e70b65ceb3f697ff47c0524a9b3cd4
Author: James Cherry <cherry@parallaxsw.com>
Date:   Sat Jan 14 01:17:58 2023 +0000

    leaks

commit 7cdd65684adeb14e02827f5d93e7fab3b19af5dd
Author: James Cherry <cherry@parallaxsw.com>
Date:   Fri Jan 13 16:07:47 2023 -0700

    leaks

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit ee97c7e50394a3927458e7ef09c5dbeb27719d15
Author: James Cherry <cherry@parallaxsw.com>
Date:   Fri Jan 13 11:52:48 2023 -0700

    swig rm Tmp collections

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit c49935da8704e41459280971b7645fccd97e3d13
Author: James Cherry <cherry@parallaxsw.com>
Date:   Fri Jan 13 11:18:36 2023 -0700

    swig rm Tmp types

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit 4320b00ce700914843006f592126cd8cc1c4657a
Author: James Cherry <cherry@parallaxsw.com>
Date:   Fri Jan 13 10:55:10 2023 -0700

    swig rm TmpPinSet, TmpPinSeq

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit ff6004910980c9b09b41f63a553a4481404cc539
Author: James Cherry <cherry@parallaxsw.com>
Date:   Fri Jan 13 10:45:06 2023 -0700

    swig rm Tmp collections

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit 9a5bf5c1a3e5a6d2996b3ab327fa2f3015f2ff20
Author: James Cherry <cherry@parallaxsw.com>
Date:   Fri Jan 13 10:15:29 2023 -0700

    swig rm one TmpPinSet

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit f441116b56e23849485b2393b30e7086c33165a8
Author: James Cherry <cherry@parallaxsw.com>
Date:   Fri Jan 13 09:16:56 2023 -0700

    leak

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit 050b08df8618340b568d9cd41fd3d5f052e2c680
Author: James Cherry <cherry@parallaxsw.com>
Date:   Fri Jan 13 09:10:53 2023 -0700

    leak

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit be8c17f3a715ab53140748dc1d94698209965cf9
Author: James Cherry <cherry@parallaxsw.com>
Date:   Fri Jan 13 08:59:06 2023 -0700

    leak

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit e43b82f8fb52eaeda90e3c7e76cf350ae6735ebd
Author: James Cherry <cherry@parallaxsw.com>
Date:   Thu Jan 12 18:57:49 2023 -0700

    range iter

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit 8db56209de7805ac2574fd2f76170bf68afd156d
Author: James Cherry <cherry@parallaxsw.com>
Date:   Thu Jan 12 18:08:54 2023 -0700

    GroupPathSet net id

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit cb7917f9827c2ea3afebd735cd4508405a0d77d4
Author: James Cherry <cherry@parallaxsw.com>
Date:   Thu Jan 12 12:00:15 2023 -0700

    DataCheckLess net id

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit d9da3c62d7a76699c6ad62cebb1f5c39f89722fa
Author: James Cherry <cherry@parallaxsw.com>
Date:   Thu Jan 12 11:42:27 2023 -0700

    rm hashPtr uses

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit 5bbea162bb1e023aba813598c7992c740ddf9d0b
Author: James Cherry <cherry@parallaxsw.com>
Date:   Thu Jan 12 11:30:12 2023 -0700

    EdgePins has use net id

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit df38405e2ebaabdd7bbf99f3b19d78b25bd95720
Author: James Cherry <cherry@parallaxsw.com>
Date:   Thu Jan 12 09:51:38 2023 -0700

    ExceptionPath hash use net id

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit 9a6dcfa54c54c9f50b14248a2449c70c20a0d977
Author: James Cherry <cherry@parallaxsw.com>
Date:   Thu Jan 12 08:56:49 2023 -0700

    ClockInsertion, ClockLatency net id

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit dbb6dc0b8c93812458df31e93f08e0dbd74e8105
Author: James Cherry <cherry@parallaxsw.com>
Date:   Thu Jan 12 08:34:03 2023 -0700

    ExceptionStateSet obj id

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit 70b8721c48ec0816289ee09b664c332ee095875f
Author: James Cherry <cherry@parallaxsw.com>
Date:   Thu Jan 12 08:14:37 2023 -0700

    ClockGroups cmp

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit 4c6c4ca191a99cd8541e106fec3202ee14968f39
Author: James Cherry <cherry@parallaxsw.com>
Date:   Thu Jan 12 07:38:17 2023 -0700

    ClockGroup typedef to ClockSet

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit 66f425315e16deee5f00b05c0a505766e7afbf01
Author: James Cherry <cherry@parallaxsw.com>
Date:   Wed Jan 11 20:32:38 2023 -0700

    set cmps

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit a94866c7828af5b6714e3e4fffc13bdaf5155c0e
Author: James Cherry <cherry@parallaxsw.com>
Date:   Wed Jan 11 19:08:09 2023 -0700

    net use id

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit 6348320908f42ebb5262117182e13d0024f65537
Author: James Cherry <cherry@parallaxsw.com>
Date:   Wed Jan 11 11:52:13 2023 -0700

    exception id cmp

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit 0edfca41b6d6408ac17f8dfe10e697c55146c1ef
Author: James Cherry <cherry@parallaxsw.com>
Date:   Wed Jan 11 10:47:02 2023 -0700

    range iter

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit 44ad77985da9f0b9e7f4780e3f233c8d94fa7db7
Author: James Cherry <cherry@parallaxsw.com>
Date:   Wed Jan 11 08:27:58 2023 -0700

    non-ptr set cmp

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit 36de7d88c3fa683465604a9e16b2fc1f6bc5fdd0
Author: James Cherry <cherry@parallaxsw.com>
Date:   Wed Jan 11 08:00:54 2023 -0700

    range iteration

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit 4a31a2c8d9bdae58b09af8c05a64702ea3ac6c15
Author: James Cherry <cherry@parallaxsw.com>
Date:   Tue Jan 10 16:43:54 2023 -0700

    tcl types

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit 056a7447b494a4c8ecc9764650d78a5bed3d87e8
Author: James Cherry <cherry@parallaxsw.com>
Date:   Tue Jan 10 16:10:36 2023 -0700

    tcl types

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit 97239554c7625ba50ee729260f08eda7dec02365
Author: James Cherry <cherry@parallaxsw.com>
Date:   Tue Jan 10 13:10:42 2023 -0700

    use RVO

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit c3247d8937d483102e3e1f2b69d7ac1d331ba9d4
Author: James Cherry <cherry@parallaxsw.com>
Date:   Mon Jan 9 22:41:20 2023 -0700

    swig template seq's

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit 5431c06feb256adb46858819fcf5d513cfa6b5ec
Author: James Cherry <cherry@parallaxsw.com>
Date:   Mon Jan 9 20:50:24 2023 -0700

    swig set in template

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit 592ad641bf01d3beb862314a0d8986f66e258642
Author: James Cherry <cherry@parallaxsw.com>
Date:   Mon Jan 9 17:27:25 2023 -0700

    network return containers

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit c95f8b77e0d6bd5ffa5ba8102413c70883c756e1
Author: James Cherry <cherry@parallaxsw.com>
Date:   Mon Jan 9 12:15:37 2023 -0700

    PinSeq const

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit 702e7f9ba2f901066a38f32e67b35602b6c7bbdf
Author: James Cherry <cherry@parallaxsw.com>
Date:   Mon Jan 9 12:02:29 2023 -0700

    InstanceSeq const

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit 44fc25ba4a15e4ae570d74af27c9435872a126e0
Author: James Cherry <cherry@parallaxsw.com>
Date:   Mon Jan 9 12:01:45 2023 -0700

    NetSeq const

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit 03b2725c81f5d52c33c875b55056c11d482144f1
Author: James Cherry <cherry@parallaxsw.com>
Date:   Mon Jan 9 11:33:18 2023 -0700

    rm PortPair

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit 3fb82a7344dc053171c9883a113764ba691ab827
Author: James Cherry <cherry@parallaxsw.com>
Date:   Mon Jan 9 11:20:53 2023 -0700

    PinSet id

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit 3dd31f027e15d40d62a11d0a88ef2a115f01fb73
Author: James Cherry <cherry@parallaxsw.com>
Date:   Sun Jan 8 15:03:33 2023 -0700

    InstanceSet id

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit a91dea5cc0af3bede36b3faed13adb05239ff907
Author: James Cherry <cherry@parallaxsw.com>
Date:   Sun Jan 8 11:40:15 2023 -0700

    NetSet id

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit b91e4b6410134eccae7969ddcfb0b27933b2e746
Author: James Cherry <cherry@parallaxsw.com>
Date:   Sun Jan 8 10:44:47 2023 -0700

    CellSet, PortSet id

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit 6f891f77fae5a6b19c1454a1a4b4e3dfae0b5c50
Author: James Cherry <cherry@parallaxsw.com>
Date:   Sun Jan 8 10:29:25 2023 -0700

    network object sets

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit eb8c627a57ecc6e7c5846a01d62b090ff91c08bf
Author: James Cherry <cherry@parallaxsw.com>
Date:   Sun Jan 8 10:09:00 2023 -0700

    PinSet1

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit 8e864ecbdf87000fbb3c3097c39f06173c941e35
Author: James Cherry <cherry@parallaxsw.com>
Date:   Sat Jan 7 17:13:03 2023 -0700

    concrete network object id

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

Signed-off-by: James Cherry <cherry@parallaxsw.com>
2023-01-19 11:23:45 -07:00

665 lines
26 KiB
C++

// OpenSTA, Static Timing Analyzer
// Copyright (c) 2022, Parallax Software, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#pragma once
#include <functional>
#include "Map.hh"
#include "StringUtil.hh"
#include "LibertyClass.hh"
#include "VertexId.hh"
#include "NetworkClass.hh"
#include "StaState.hh"
namespace sta {
class Report;
class PatternMatch;
class PinVisitor;
typedef Map<const char*, LibertyLibrary*, CharPtrLess> LibertyLibraryMap;
// Link network function returns top level instance.
// Return nullptr if link fails.
typedef Instance *(LinkNetworkFunc)(const char *top_cell_name,
bool make_black_boxes,
Report *report,
NetworkReader *network);
typedef Map<const Net*, PinSet*> NetDrvrPinsMap;
// The Network class defines the network API used by sta.
// The interface to a network implementation is constructed by
// deriving a class from it. This interface class is known as a
// ADAPTER/DELEGATE. An instance of the adapter is used to
// translate calls in the sta to a target network implementation.
// Network data types:
// Libraries are collections of cells.
// Cells are masters (ala verilog module or liberty cell).
// Ports define the connections to a cell.
// There are four different sub-classes of ports:
// Simple non-bus ports such as "enable".
// Bundles of simple or single bit ports, such as D bundling D0, D1.
// Buses such as D[3:0]
// Bus bit ports, which are one bit of a bus port such as D[0].
// Bus bit ports are always members of a bus.
// Instances are calls of cells in the design hierarchy
// Hierarchical and leaf instances are in the network.
// At the top of the hierarchy is a top level instance that
// has instances for the top level netlist.
// Pins are a connection between an instance and a net corresponding
// to a port. Ports on the top level instance also have pins in
// the network.
// Terminals are a connection between a net and a pin on the parent
// instance.
// Nets connect pins at a level of hierarchy. Both hierarchical
// instance pins and leaf instance pins are connected by net.
//
// The network API only contains pointers/handles to these data types.
// The adapter casts these handles to its native data types and calls
// the appropriate code to implement the member functions of the Network
// class.
//
// Pattern arguments used by lookup find*Matching functions
// use a simple unix shell or tcl "string match" style pattern matching:
// '*' matches zero or more characters
// '?' matches any character
//
// Note that some of the network member functions are not virtual because
// they can be implemented in terms of the other functions.
// Only the pure virtual functions MUST be implemented by a derived class.
class Network : public StaState
{
public:
Network();
virtual ~Network();
virtual void clear();
// Linking the hierarchy creates the instance/pin/net network hierarchy.
// Most network functions are only useful after the hierarchy
// has been linked. When the network interfaces to an external database,
// linking is not necessary because the network has already been expanded.
// Return true if successful.
virtual bool linkNetwork(const char *top_cell_name,
bool make_black_boxes,
Report *report) = 0;
virtual bool isLinked() const;
virtual bool isEditable() const { return false; }
////////////////////////////////////////////////////////////////
// Library functions.
virtual const char *name(const Library *library) const = 0;
virtual ObjectId id(const Library *library) const = 0;
virtual LibraryIterator *libraryIterator() const = 0;
virtual LibertyLibraryIterator *libertyLibraryIterator() const = 0;
virtual Library *findLibrary(const char *name) = 0;
virtual LibertyLibrary *findLiberty(const char *name) = 0;
// Find liberty library by filename.
virtual LibertyLibrary *findLibertyFilename(const char *filename);
virtual Cell *findCell(const Library *library,
const char *name) const = 0;
// Search the design (non-liberty) libraries for cells matching pattern.
virtual CellSeq findCellsMatching(const Library *library,
const PatternMatch *pattern) const = 0;
// Search liberty libraries for cell name.
virtual LibertyCell *findLibertyCell(const char *name) const;
virtual LibertyLibrary *makeLibertyLibrary(const char *name,
const char *filename) = 0;
// Hook for network after reading liberty library.
virtual void readLibertyAfter(LibertyLibrary *library);
// First liberty library read is used to look up defaults.
// This corresponds to a link_path of '*'.
LibertyLibrary *defaultLibertyLibrary() const;
void setDefaultLibertyLibrary(LibertyLibrary *library);
// Check liberty cells used by the network to make sure they exist
// for all the defined corners.
void checkNetworkLibertyCorners();
// Check liberty cells to make sure they exist for all the defined corners.
void checkLibertyCorners();
////////////////////////////////////////////////////////////////
// Cell functions.
virtual const char *name(const Cell *cell) const = 0;
virtual ObjectId id(const Cell *cell) const = 0;
virtual Library *library(const Cell *cell) const = 0;
virtual LibertyLibrary *libertyLibrary(const Cell *cell) const;
// Find the corresponding liberty cell.
virtual const LibertyCell *libertyCell(const Cell *cell) const = 0;
virtual LibertyCell *libertyCell(Cell *cell) const = 0;
virtual const Cell *cell(const LibertyCell *cell) const = 0;
virtual Cell *cell(LibertyCell *cell) const = 0;
// Filename may return null.
virtual const char *filename(const Cell *cell) = 0;
// Name can be a simple, bundle, bus, or bus bit name.
virtual Port *findPort(const Cell *cell,
const char *name) const = 0;
virtual PortSeq findPortsMatching(const Cell *cell,
const PatternMatch *pattern) const = 0;
virtual bool isLeaf(const Cell *cell) const = 0;
virtual CellPortIterator *portIterator(const Cell *cell) const = 0;
// Iterate over port bits (expanded buses).
virtual CellPortBitIterator *portBitIterator(const Cell *cell) const = 0;
// Port bit count (expanded buses).
virtual int portBitCount(const Cell *cell) const = 0;
////////////////////////////////////////////////////////////////
// Port functions
virtual const char *name(const Port *port) const = 0;
virtual ObjectId id(const Port *port) const = 0;
virtual Cell *cell(const Port *port) const = 0;
virtual LibertyPort *libertyPort(const Port *port) const = 0;
virtual PortDirection *direction(const Port *port) const = 0;
// Bus port functions.
virtual bool isBus(const Port *port) const = 0;
virtual bool isBundle(const Port *port) const = 0;
// Size is the bus/bundle member count (1 for non-bus/bundle ports).
virtual int size(const Port *port) const = 0;
// Bus range bus[from:to].
virtual const char *busName(const Port *port) const = 0;
// Bus member, bus[subscript].
virtual Port *findBusBit(const Port *port,
int index) const = 0;
virtual int fromIndex(const Port *port) const = 0;
virtual int toIndex(const Port *port) const = 0;
// Predicate to determine if index is within bus range.
// (toIndex > fromIndex) && fromIndex <= index <= toIndex
// || (fromIndex > toIndex) && fromIndex >= index >= toIndex
bool busIndexInRange(const Port *port,
int index);
// Find Bundle/bus member by index.
virtual Port *findMember(const Port *port,
int index) const = 0;
// Iterate over the bits of a bus port or members of a bundle.
// from_index -> to_index
virtual PortMemberIterator *memberIterator(const Port *port) const = 0;
// A port has members if it is a bundle or bus.
virtual bool hasMembers(const Port *port) const;
////////////////////////////////////////////////////////////////
// Instance functions
// Name local to containing cell/instance.
virtual const char *name(const Instance *instance) const = 0;
virtual ObjectId id(const Instance *instance) const = 0;
// Top level instance of the design (defined after link).
virtual Instance *topInstance() const = 0;
virtual bool isTopInstance(const Instance *inst) const;
virtual Instance *findInstance(const char *path_name) const;
// Find instance relative to hierarchical instance.
Instance *findInstanceRelative(const Instance *inst,
const char *path_name) const;
// Default implementation uses linear search.
virtual InstanceSeq findInstancesMatching(const Instance *context,
const PatternMatch *pattern) const;
virtual InstanceSeq findInstancesHierMatching(const Instance *instance,
const PatternMatch *pattern) const;
// Hierarchical path name.
virtual const char *pathName(const Instance *instance) const;
bool pathNameLess(const Instance *inst1,
const Instance *inst2) const;
int pathNameCmp(const Instance *inst1,
const Instance *inst2) const;
// Path from instance up to top level (last in the sequence).
void path(const Instance *inst,
// Return value.
InstanceSeq &path) const;
virtual Cell *cell(const Instance *instance) const = 0;
virtual const char *cellName(const Instance *instance) const;
virtual LibertyLibrary *libertyLibrary(const Instance *instance) const;
virtual LibertyCell *libertyCell(const Instance *instance) const;
virtual Instance *parent(const Instance *instance) const = 0;
virtual bool isLeaf(const Instance *instance) const = 0;
virtual bool isHierarchical(const Instance *instance) const;
virtual Instance *findChild(const Instance *parent,
const char *name) const = 0;
virtual void findChildrenMatching(const Instance *parent,
const PatternMatch *pattern,
// Return value.
InstanceSeq &matches) const;
// Is inst inside of hier_inst?
bool isInside(const Instance *inst,
const Instance *hier_inst) const;
// Iterate over all of the leaf instances in the hierarchy
// This iterator is not virtual because it can be written in terms of
// the other primitives.
LeafInstanceIterator *leafInstanceIterator() const;
LeafInstanceIterator *leafInstanceIterator(const Instance *hier_inst) const;
// Iterate over the children of an instance.
virtual InstanceChildIterator *
childIterator(const Instance *instance) const = 0;
// Iterate over the pins on an instance.
virtual InstancePinIterator *
pinIterator(const Instance *instance) const = 0;
// Iterate over the nets in an instance.
// This should include nets that are connected to the
// instance parent thru pins.
virtual InstanceNetIterator *
netIterator(const Instance *instance) const = 0;
int instanceCount();
int instanceCount(Instance *inst);
int leafInstanceCount();
////////////////////////////////////////////////////////////////
// Pin functions
// Name is instance_name/port_name (the same as path name).
virtual const char *name(const Pin *pin) const;
virtual ObjectId id(const Pin *pin) const = 0;
virtual Pin *findPin(const char *path_name) const;
virtual Pin *findPin(const Instance *instance,
const char *port_name) const = 0;
virtual Pin *findPin(const Instance *instance,
const Port *port) const;
virtual Pin *findPin(const Instance *instance,
const LibertyPort *port) const;
// Find pin relative to hierarchical instance.
Pin *findPinRelative(const Instance *inst,
const char *path_name) const;
// Default implementation uses linear search.
virtual PinSeq findPinsMatching(const Instance *instance,
const PatternMatch *pattern) const;
// Traverse the hierarchy from instance down and find pins matching
// pattern of the form instance_name/port_name.
virtual PinSeq findPinsHierMatching(const Instance *instance,
const PatternMatch *pattern) const;
virtual const char *portName(const Pin *pin) const;
// Path name is instance_name/port_name.
virtual const char *pathName(const Pin *pin) const;
bool pathNameLess(const Pin *pin1,
const Pin *pin2) const;
int pathNameCmp(const Pin *pin1,
const Pin *pin2) const;
virtual Port *port(const Pin *pin) const = 0;
virtual LibertyPort *libertyPort(const Pin *pin) const;
virtual Instance *instance(const Pin *pin) const = 0;
virtual Net *net(const Pin *pin) const = 0;
virtual Term *term(const Pin *pin) const = 0;
virtual PortDirection *direction(const Pin *pin) const = 0;
virtual bool isLeaf(const Pin *pin) const;
bool isHierarchical(const Pin *pin) const;
bool isTopLevelPort(const Pin *pin) const;
// Is pin inside the instance hier_pin is attached to?
bool isInside(const Pin *pin,
const Pin *hier_pin) const;
// Is pin inside of hier_inst?
bool isInside(const Pin *pin,
const Instance *hier_inst) const;
bool isDriver(const Pin *pin) const;
bool isLoad(const Pin *pin) const;
// Has register/latch rise/fall edges from pin.
bool isRegClkPin(const Pin *pin) const;
// Pin clocks a timing check.
bool isCheckClk(const Pin *pin) const;
bool isLatchData(const Pin *pin) const;
// Iterate over all of the pins connected to a pin and the parent
// and child nets it is hierarchically connected to (port, leaf and
// hierarchical pins).
virtual PinConnectedPinIterator *connectedPinIterator(const Pin *pin) const;
virtual void visitConnectedPins(const Pin *pin,
PinVisitor &visitor) const;
// Find driver pins for the net connected to pin.
// Return value is owned by the network.
virtual PinSet *drivers(const Pin *pin);
virtual bool pinLess(const Pin *pin1,
const Pin *pin2) const;
// Return the id of the pin graph vertex.
virtual VertexId vertexId(const Pin *pin) const = 0;
virtual void setVertexId(Pin *pin,
VertexId id) = 0;
// Return the physical X/Y coordinates of the pin.
virtual void location(const Pin *pin,
// Return values.
double &x,
double &y,
bool &exists) const;
int pinCount();
int pinCount(Instance *inst);
int leafPinCount();
////////////////////////////////////////////////////////////////
// Terminal functions
// Name is instance_name/port_name (the same as path name).
virtual const char *name(const Term *term) const;
virtual ObjectId id(const Term *term) const = 0;
virtual const char *portName(const Term *term) const;
// Path name is instance_name/port_name (pin name).
virtual const char *pathName(const Term *term) const;
virtual Net *net(const Term *term) const = 0;
virtual Pin *pin(const Term *term) const = 0;
////////////////////////////////////////////////////////////////
// Net functions
virtual const char *name(const Net *net) const = 0; // no hierarchy prefix
virtual ObjectId id(const Net *net) const = 0;
virtual Net *findNet(const char *path_name) const;
// Find net relative to hierarchical instance.
Net *findNetRelative(const Instance *inst,
const char *path_name) const;
// Default implementation uses linear search.
virtual NetSeq findNetsMatching(const Instance *context,
const PatternMatch *pattern) const;
virtual Net *findNet(const Instance *instance,
const char *net_name) const = 0;
// Traverse the hierarchy from instance down and find nets matching
// pattern of the form instance_name/net_name.
virtual NetSeq findNetsHierMatching(const Instance *instance,
const PatternMatch *pattern) const;
// Primitive used by findNetsMatching.
virtual void findInstNetsMatching(const Instance *instance,
const PatternMatch *pattern,
NetSeq &matches) const = 0;
virtual const char *pathName(const Net *net) const;
bool pathNameLess(const Net *net1,
const Net *net2) const;
int pathNameCmp(const Net *net1,
const Net *net2) const;
virtual Instance *instance(const Net *net) const = 0;
// Is net inside of hier_inst?
virtual bool isInside(const Net *net,
const Instance *hier_inst) const;
// Is pin connected to net anywhere in the hierarchy?
virtual bool isConnected(const Net *net,
const Pin *pin) const;
// Is net1 connected to net2 anywhere in the hierarchy?
virtual bool isConnected(const Net *net1,
const Net *net2) const;
virtual Net *highestNetAbove(Net *net) const;
virtual const Net *highestConnectedNet(Net *net) const;
virtual void connectedNets(Net *net,
NetSet *nets) const;
virtual void connectedNets(const Pin *pin,
NetSet *nets) const;
virtual bool isPower(const Net *net) const = 0;
virtual bool isGround(const Net *net) const = 0;
// Iterate over the pins connected to a net (port, leaf and hierarchical).
virtual NetPinIterator *pinIterator(const Net *net) const = 0;
// Iterate over the terminals connected to a net.
virtual NetTermIterator *termIterator(const Net *net) const = 0;
// Iterate over all of the pins connected to a net and the parent
// and child nets it is hierarchically connected to (port, leaf and
// hierarchical pins).
virtual NetConnectedPinIterator *connectedPinIterator(const Net *net) const;
virtual void visitConnectedPins(const Net *net,
PinVisitor &visitor) const;
// Find driver pins for net.
// Return value is owned by the network.
virtual PinSet *drivers(const Net *net);
int netCount();
int netCount(Instance *inst);
// Iterate over pins connected to nets tied off to logic zero and one.
virtual ConstantPinIterator *constantPinIterator() = 0;
////////////////////////////////////////////////////////////////
// Parse path into first/tail (first hierarchy divider separated token).
// first and tail are both null if there are no dividers in path.
// Caller must delete first and tail.
void pathNameFirst(const char *path_name,
char *&first,
char *&tail) const;
// Parse path into head/last (last hierarchy divider separated token).
// head and last are both null if there are no dividers in path.
// Caller must delete head and last.
void pathNameLast(const char *path_name,
char *&head,
char *&last) const;
// Divider between instance names in a hierarchical path name.
virtual char pathDivider() const { return divider_; }
virtual void setPathDivider(char divider);
// Escape prefix for path dividers in path names.
virtual char pathEscape() const { return escape_; }
virtual void setPathEscape(char escape);
protected:
Pin *findPinLinear(const Instance *instance,
const char *port_name) const;
void findInstancesMatching1(const Instance *context,
size_t context_name_length,
const PatternMatch *pattern,
InstanceSeq &insts) const;
void findInstancesHierMatching1(const Instance *instance,
const PatternMatch *pattern,
InstanceSeq &matches) const;
void findNetsMatching(const Instance *context,
const PatternMatch *pattern,
NetSeq &matches) const;
void findNetsHierMatching(const Instance *instance,
const PatternMatch *pattern,
NetSeq &matches) const;
void findPinsHierMatching(const Instance *instance,
const PatternMatch *pattern,
// Return value.
PinSeq &matches) const;
bool isConnected(const Net *net,
const Pin *pin,
NetSet &nets) const;
bool isConnected(const Net *net1,
const Net *net2,
NetSet &nets) const;
int hierarchyLevel(const Net *net) const;
virtual void visitConnectedPins(const Net *net,
PinVisitor &visitor,
NetSet &visited_nets) const;
// Default implementation uses linear search.
virtual void findInstPinsMatching(const Instance *instance,
const PatternMatch *pattern,
// Return value.
PinSeq &matches) const;
void findInstPinsHierMatching(const Instance *parent,
const PatternMatch *pattern,
// Return value.
PinSeq &matches) const;
// findNet using linear search.
Net *findNetLinear(const Instance *instance,
const char *net_name) const;
// findNetsMatching using linear search.
NetSeq findNetsMatchingLinear(const Instance *instance,
const PatternMatch *pattern) const;
// Connect/disconnect net/pins should clear the net->drvrs map.
// Incrementally maintaining the map is expensive because
// nets may be connected across hierarchy levels.
void clearNetDrvrPinMap();
LibertyLibrary *default_liberty_;
char divider_;
char escape_;
NetDrvrPinsMap net_drvr_pin_map_;
};
// Network API to support network edits.
class NetworkEdit : public Network
{
public:
NetworkEdit();
virtual bool isEditable() const { return true; }
virtual Instance *makeInstance(LibertyCell *cell,
const char *name,
Instance *parent) = 0;
virtual void makePins(Instance *inst) = 0;
virtual void replaceCell(Instance *inst,
Cell *cell) = 0;
// Deleting instance also deletes instance pins.
virtual void deleteInstance(Instance *inst) = 0;
// Connect the port on an instance to a net.
virtual Pin *connect(Instance *inst,
Port *port,
Net *net) = 0;
virtual Pin *connect(Instance *inst,
LibertyPort *port,
Net *net) = 0;
// makePin/connectPin replaced by connect.
virtual void connectPin(Pin *pin,
Net *net) __attribute__ ((deprecated));
// Disconnect pin from net.
virtual void disconnectPin(Pin *pin) = 0;
virtual void deletePin(Pin *pin) = 0;
virtual Net *makeNet(const char *name,
Instance *parent) = 0;
// Deleting net disconnects (but does not delete) net pins.
virtual void deleteNet(Net *net) = 0;
virtual void mergeInto(Net *net,
Net *into_net) = 0;
virtual Net *mergedInto(Net *net) = 0;
};
// Network API to support the Parallax readers.
class NetworkReader : public NetworkEdit
{
public:
NetworkReader() {}
// Called before reading a netlist to delete any previously linked network.
virtual void readNetlistBefore() = 0;
virtual void setLinkFunc(LinkNetworkFunc *link) = 0;
virtual Library *makeLibrary(const char *name,
const char *filename) = 0;
virtual void deleteLibrary(Library *library) = 0;
// Search the libraries in read order for a cell by name.
virtual Cell *findAnyCell(const char *name) = 0;
virtual Cell *makeCell(Library *library,
const char *name,
bool is_leaf,
const char *filename) = 0;
virtual void deleteCell(Cell *cell) = 0;
virtual void setName(Cell *cell,
const char *name) = 0;
virtual void setIsLeaf(Cell *cell,
bool is_leaf) = 0;
virtual Port *makePort(Cell *cell,
const char *name) = 0;
virtual Port *makeBusPort(Cell *cell,
const char *name,
int from_index,
int to_index) = 0;
virtual void groupBusPorts(Cell *cell,
std::function<bool(const char*)> port_msb_first) = 0;
virtual Port *makeBundlePort(Cell *cell,
const char *name,
PortSeq *members) = 0;
virtual Instance *makeInstance(Cell *cell,
const char *name,
Instance *parent) = 0;
virtual Pin *makePin(Instance *inst,
Port *port,
Net *net) = 0;
virtual Term *makeTerm(Pin *pin,
Net *net) = 0;
virtual void setDirection(Port *port,
PortDirection *dir) = 0;
// Instance is the network view for cell.
virtual void setCellNetworkView(Cell *cell,
Instance *inst) = 0;
virtual Instance *cellNetworkView(Cell *cell) = 0;
virtual void deleteCellNetworkViews() = 0;
virtual void addConstantNet(Net *net,
LogicValue const_value) = 0;
using NetworkEdit::makeInstance;
};
Instance *
linkReaderNetwork(Cell *top_cell,
bool make_black_boxes,
Report *report,
NetworkReader *network);
// Abstract class for Network::constantPinIterator().
class ConstantPinIterator
{
public:
ConstantPinIterator() {}
virtual ~ConstantPinIterator() {}
virtual bool hasNext() = 0;
virtual void next(const Pin *&pin,
LogicValue &value) = 0;
};
// Implementation class for Network::constantPinIterator().
class NetworkConstantPinIterator : public ConstantPinIterator
{
public:
NetworkConstantPinIterator(const Network *network,
NetSet &zero_nets,
NetSet &one_nets);
~NetworkConstantPinIterator();
virtual bool hasNext();
virtual void next(const Pin *&pin, LogicValue &value);
private:
void findConstantPins(NetSet &nets,
PinSet &pins);
const Network *network_;
PinSet constant_pins_[2];
LogicValue value_;
PinSet::Iterator *pin_iter_;
};
// Abstract base class for visitDrvrLoadsThruHierPin visitor.
class HierPinThruVisitor
{
public:
HierPinThruVisitor() {}
virtual ~HierPinThruVisitor() {}
virtual void visit(const Pin *drvr,
const Pin *load) = 0;
};
class PinVisitor
{
public:
virtual ~PinVisitor() {}
virtual void operator()(const Pin *pin) = 0;
};
class FindNetDrvrLoads : public PinVisitor
{
public:
FindNetDrvrLoads(const Pin *drvr_pin,
PinSet &visited_drvrs,
PinSeq &loads,
PinSeq &drvrs,
const Network *network);
virtual void operator()(const Pin *pin);
protected:
const Pin *drvr_pin_;
PinSet &visited_drvrs_;
PinSeq &loads_;
PinSeq &drvrs_;
const Network *network_;
};
// Visit driver/loads pins through a hierarcial pin.
void
visitDrvrLoadsThruHierPin(const Pin *hpin,
const Network *network,
HierPinThruVisitor *visitor);
void
visitDrvrLoadsThruNet(const Net *net,
const Network *network,
HierPinThruVisitor *visitor);
char
logicValueString(LogicValue value);
} // namespace