OdbDesign
OdbDesign ODB++ Parser - C++ library, gRPC/REST server, CLI, tests
 
Loading...
Searching...
No Matches
OdbDesignApp.cpp
Go to the documentation of this file.
1// OdbDesignApp.cpp : Defines the entry point for the application.
2//
3#include "OdbDesignApp.h"
4#include "OdbDesign.h"
5#include "macros.h"
6#include "ExitCode.h"
7#include <iostream>
8#include <cstdlib>
9#include <filesystem>
12
13
15bool TestSampleDesign();
16
17
18int main()
19{
20 std::cout << "OdbDesignApp v0.1.0" << std::endl << std::endl;
21
22 //OdbDesign::Lib::helloLib();
23
24 auto success = TestRigidFlexDesign();
25 if (!success)
26 {
28 }
29
30 //std::cout << "success!" << std::endl;
31
32 success = TestSampleDesign();
33 if (!success)
34 {
36 }
37
38 //std::cout << "success!" << std::endl;
39
40 return (int) Utils::ExitCode::Success;
41}
42
43// Resolve a test design archive by filename from the ODB_TEST_DATA_DIR
44// directory (same convention as the test suite). Returns an empty path when
45// the environment variable is not set.
46static std::string getTestDataPath(const std::string& filename)
47{
48 const char* testDataDir = std::getenv("ODB_TEST_DATA_DIR");
49 if (testDataDir == nullptr || testDataDir[0] == '\0')
50 {
51 std::cout << "ODB_TEST_DATA_DIR is not set; cannot resolve '" << filename << "'" << std::endl;
52 return {};
53 }
54 return (std::filesystem::path(testDataDir) / filename).string();
55}
56
58{
59 auto sampleDesignPath = getTestDataPath("sample_design.tgz");
60 if (sampleDesignPath.empty())
61 {
62 return false;
63 }
64
65 std::cout << "Processing " << sampleDesignPath << "... " << std::endl;
66
67 Odb::Lib::FileModel::Design::FileArchive sampleOdbDesign(sampleDesignPath);
68 auto success = sampleOdbDesign.ParseFileModel();
69 if (! success)
70 {
71 return false;
72 }
73
74 return true;
75}
76
78{
79 auto rigidFlexDesignPath = getTestDataPath("designodb_rigidflex.tgz");
80 if (rigidFlexDesignPath.empty())
81 {
82 return false;
83 }
84
85 std::cout << "Processing " << rigidFlexDesignPath << "... " << std::endl;
86
87 Odb::Lib::FileModel::Design::FileArchive rigidFlexOdbDesign(rigidFlexDesignPath);
88 auto success = rigidFlexOdbDesign.ParseFileModel();
89 if (!success)
90 {
91 return false;
92 }
93
94 const auto& findStep = rigidFlexOdbDesign.GetStepsByName().find("cellular_flip-phone");
95 if (findStep != rigidFlexOdbDesign.GetStepsByName().end())
96 {
97 // step
98 auto& pStep = findStep->second;
99 auto name = pStep->GetName();
100
101 // eda data
102 auto& edaData = pStep->GetEdaDataFile();
103 auto& netRecords = edaData.GetNetRecords();
104 if (netRecords.size() > 20)
105 {
106 auto& pNetRecord = netRecords[20];
107 if (pNetRecord->m_subnetRecords.size() > 44)
108 {
109 auto& pSubnetRecord = pNetRecord->m_subnetRecords[44];
110 auto subnetType = pSubnetRecord->type;
112 {
113 //auto pToeprintSubnetRecord = pSubnetRecord;
114 //auto viaType = pToeprintSubnetRecord->type;
115 //if (viaType == Odb::Lib::FileModel::Design::EdaDataFile::NetRecord::ToeprintSubnetRecord::Type::Via)
116 //{
117
118 //}
119 }
120 }
121 }
122
123 auto& packageRecords = edaData.GetPackageRecords();
124 if (packageRecords.size() > 0)
125 {
126 auto& pPackageRecord = packageRecords[0];
127 auto packageName = pPackageRecord->name;
128 }
129
130 // layers
131 auto& layersByName = pStep->GetLayersByName();
133 if (layerFind != layersByName.end())
134 {
135 auto& pLayer = layerFind->second;
136 auto layerName = pLayer->GetName();
137 }
138
139 // netlist
140 const auto& netlistsByName = pStep->GetNetlistsByName();
141 auto netlistFind = netlistsByName.find("cadnet");
142 if (netlistFind != netlistsByName.end())
143 {
144 // auto& pNetlist = netlistFind->second;
145 // auto netlistName = pNetlist->GetName();
146 // auto& netListNetRecords = pNetlist->GetNetRecords();
147 // for (auto& pNetRecord : netListNetRecords)
148 // {
149
150 // }
151 }
152 }
153
154 return true;
155}
bool TestSampleDesign()
bool TestRigidFlexDesign()
int main()
static constexpr const char * TOP_COMPONENTS_LAYER_NAME
const StepDirectory::StringMap & GetStepsByName() const