1 ///////////////////////////////////////////////////////////////////////////////
2 // BSD 3-Clause License
3 //
4 // Copyright (c) 2019, Nefelus Inc
5 // All rights reserved.
6 //
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions are met:
9 //
10 // * Redistributions of source code must retain the above copyright notice, this
11 //   list of conditions and the following disclaimer.
12 //
13 // * Redistributions in binary form must reproduce the above copyright notice,
14 //   this list of conditions and the following disclaimer in the documentation
15 //   and/or other materials provided with the distribution.
16 //
17 // * Neither the name of the copyright holder nor the names of its
18 //   contributors may be used to endorse or promote products derived from
19 //   this software without specific prior written permission.
20 //
21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 // POSSIBILITY OF SUCH DAMAGE.
32 
33 #pragma once
34 
35 #include <cstdint>
36 
37 #include "dbCore.h"
38 #include "dbDatabase.h"
39 #include "dbId.h"
40 #include "dbTypes.h"
41 #include "odb.h"
42 
43 namespace odb {
44 
45 class _dbNet;
46 class _dbBox;
47 class _dbBlock;
48 class _dbBPin;
49 class _dbITerm;
50 class _dbDatabase;
51 class dbIStream;
52 class dbOStream;
53 class dbDiff;
54 
55 struct _dbBTermFlags
56 {
57   dbIoType::Value _io_type : 4;
58   dbSigType::Value _sig_type : 4;
59   uint _orient : 4;  // This field is not used anymore. Replaced by bpin...
60   uint _status : 4;  // This field is not used anymore. Replaced by bpin...
61   uint _spef : 1;
62   uint _special : 1;
63   uint _mark : 1;
64   uint _spare_bits : 13;
65 };
66 
67 //
68 // block terminal
69 //
70 class _dbBTerm : public _dbObject
71 {
72  public:
73   enum Field  // dbJournalField name
74   {
75     FLAGS
76   };
77   // PERSISTANT-MEMBERS
78   _dbBTermFlags _flags;
79   uint _ext_id;
80   char* _name;
81   dbId<_dbBTerm> _next_entry;
82   dbId<_dbNet> _net;
83   dbId<_dbBTerm> _next_bterm;
84   dbId<_dbBTerm> _prev_bterm;
85   dbId<_dbBlock> _parent_block;  // Up hierarchy: TWG
86   dbId<_dbITerm> _parent_iterm;  // Up hierarchy: TWG
87   dbId<_dbBPin> _bpins;          // Up hierarchy: TWG
88   dbId<_dbBTerm> _ground_pin;
89   dbId<_dbBTerm> _supply_pin;
90   std::uint32_t _sta_vertex_id;  // not saved
91 
92   _dbBTerm(_dbDatabase*);
93   _dbBTerm(_dbDatabase*, const _dbBTerm& b);
94   ~_dbBTerm();
95 
96   void connectNet(_dbNet* net, _dbBlock* block);
97   void disconnectNet(_dbBTerm* bterm, _dbBlock* block);
98   bool operator==(const _dbBTerm& rhs) const;
99   bool operator!=(const _dbBTerm& rhs) const { return !operator==(rhs); }
100   bool operator<(const _dbBTerm& rhs) const;
101   void differences(dbDiff& diff, const char* field, const _dbBTerm& rhs) const;
102   void out(dbDiff& diff, char side, const char* field) const;
103 };
104 
105 dbOStream& operator<<(dbOStream& stream, const _dbBTerm& bterm);
106 dbIStream& operator>>(dbIStream& stream, _dbBTerm& bterm);
107 
108 }  // namespace odb
109