Skip to content

Commit

Permalink
modified core
Browse files Browse the repository at this point in the history
  • Loading branch information
tsung-wei-huang committed Aug 15, 2018
1 parent cdf24b2 commit e10ced9
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 23 deletions.
24 changes: 14 additions & 10 deletions benchmark/simple.spef
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,23 @@
*R_UNIT 1 KOHM
*L_UNIT 1 UH

*D_NET inp1 5.4
*NAME_MAP
*1 inp1
*2 u1:a

*D_NET *1 5.4
*CONN
*P inp1 I
*I u1:a I
*P *1 I
*I *2 I
*CAP
1 inp1 1.2
2 inp1:1 1.3
3 inp1:2 1.4
4 u1:a 1.5
1 *1 1.2
2 *1:1 1.3
3 *1:2 1.4
4 *2 1.5
*RES
1 inp1 inp1:1 3.4
2 inp1:1 inp1:2 3.5
3 inp1:2 u1:a 3.6
1 *1 *1:1 3.4
2 *1:1 *1:2 3.5
3 *1:2 *2 3.6
*END

*D_NET inp2 2.0
Expand Down
32 changes: 21 additions & 11 deletions example/simple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,33 @@ int main(int argc, char* argv[]){
std::cout << spef.capacitance_unit << '\n';
std::cout << spef.resistance_unit << '\n';
std::cout << spef.inductance_unit << '\n';
std::cout << '\n';

for(const auto& [k, v] : spef.name_map){
std::cout << k << ' ' << v << '\n';
spef.expand_name();

if(!spef.name_map.empty()) {
std::cout << "*NAME_MAP\n";
for(const auto& [k, v] : spef.name_map){
std::cout << '*' << k << ' ' << v << '\n';
}
std::cout << '\n';
}

for(const auto &p : spef.ports){
std::cout << p.name << ' ';
switch(p.direction){
case spef::ConnectionDirection::INPUT: std::cout << 'I' << '\n'; break;
case spef::ConnectionDirection::OUTPUT: std::cout << 'O' << '\n'; break;
case spef::ConnectionDirection::INOUT: std::cout << 'B' << '\n'; break;

if(!spef.ports.empty()) {
std::cout << "*PORTS\n";
for(const auto &p : spef.ports){
std::cout << p.name << ' ';
switch(p.direction){
case spef::ConnectionDirection::INPUT: std::cout << 'I' << '\n'; break;
case spef::ConnectionDirection::OUTPUT: std::cout << 'O' << '\n'; break;
case spef::ConnectionDirection::INOUT: std::cout << 'B' << '\n'; break;
}
}
std::cout << '\n';
}

for(const auto &n : spef.nets){
std::cout << n.name << ' ' << n.lcap << '\n';
std::cout << "*D_NET " << n.name << ' ' << n.lcap << '\n';
// *CONN
std::cout << "*CONN\n";
for(const auto& c : n.connections){
Expand Down Expand Up @@ -88,7 +99,6 @@ int main(int argc, char* argv[]){
auto& [node1, node2, value] = r;
std::cout << node1 << ' ' << node2 << ' ' << value << '\n';
}

std::cout << "*END\n\n";
}

Expand Down
14 changes: 12 additions & 2 deletions parser-spef.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ namespace spef{
// Parser-SPEF stores the data to the folloing data structures.
// ------------------------------------------------------------------------------------------------

// Visit https://en.wikipedia.org/wiki/Standard_Parasitic_Exchange_Format
// first to understand what are essential field in a SPEF.

// ConnectionType:
// EXTERNAL: connection to a external port (*P)
// INTERNAL: connection to a cell instance (*I)
Expand Down Expand Up @@ -63,19 +66,20 @@ struct Connection {
};

// Net: the data in a *D_NET section
// - Capacitor can be ground (one node) or coupled (two nodes)
struct Net {
std::string name;
float lcap;
std::vector<Connection> connections;
std::vector<std::tuple<std::string, std::string, float>> caps;
std::vector<std::tuple<std::string, std::string, float>> caps;
std::vector<std::tuple<std::string, std::string, float>> ress;

Net() = default;
Net(const std::string& s, const float f): name{s}, lcap{f} {}
};

// Spef: the data in a SPEF.
// There are four parts: header, name map, ports, nets.
// There are four parts: header, name map, ports, nets.
struct Spef {

struct Error {
Expand Down Expand Up @@ -1090,9 +1094,15 @@ inline void expand_string(std::string& str,

// Procedure: expand all mappings in the SPEF file
inline void Spef::expand_name(){

if(name_map.empty()) {
return;
}

for(auto &p: ports){
expand_name(p);
}

for(auto &n: nets){
expand_name(n);
}
Expand Down

0 comments on commit e10ced9

Please sign in to comment.