Skip to content

Commit 253d51e

Browse files
authored
Merge pull request #802 from os-fpga/pinc_moved_blif_to_pin_loc
pin_c: moved read_blif() to pin_loc
2 parents dd00f2e + c05b9fb commit 253d51e

File tree

6 files changed

+82
-114
lines changed

6 files changed

+82
-114
lines changed

planning/src/file_io/blif_reader.cpp

Lines changed: 0 additions & 80 deletions
This file was deleted.

planning/src/file_io/blif_reader.h

Lines changed: 0 additions & 28 deletions
This file was deleted.

planning/src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
static const char* _pln_VERSION_STR = "pln0315";
1+
static const char* _pln_VERSION_STR = "pln0316";
22

33
#include "RS/rsEnv.h"
44
#include "util/pln_log.h"

planning/src/pin_loc/pin_placer.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
#include "pin_loc/pin_placer.h"
2-
3-
#include "file_io/blif_reader.h"
42
#include "file_io/pln_csv_reader.h"
53
#include "file_io/pln_Fio.h"
64
#include "util/cmd_line.h"

planning/src/pin_loc/pin_placer.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,18 @@ struct PinPlacer {
8787
};
8888
};
8989

90+
struct BlifReader {
91+
vector<string> inputs_;
92+
vector<string> outputs_;
93+
94+
BlifReader() noexcept = default;
95+
BlifReader(const string& f) { read_blif(f); }
96+
bool read_blif(const string& f);
97+
98+
const vector<string>& get_inputs() const noexcept { return inputs_; }
99+
const vector<string>& get_outputs() const noexcept { return outputs_; }
100+
};
101+
90102
private:
91103

92104
cmd_line cl_;

planning/src/pin_loc/read_ports.cpp

Lines changed: 69 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#include "pin_loc/pin_placer.h"
2-
#include "file_io/blif_reader.h"
3-
#include "file_io/pln_Fio.h"
2+
#include "file_io/pln_blif_file.h"
43
#include "file_io/nlohmann3_11_2_json.h"
5-
#include "util/cmd_line.h"
64
#include <filesystem>
75

86
namespace pln {
@@ -1081,5 +1079,73 @@ string PinPlacer::translatePinName(const string& pinName, bool is_input) const n
10811079
}
10821080
}
10831081

1082+
bool PinPlacer::BlifReader::read_blif(const string& blif_fn) {
1083+
flush_out(true);
1084+
inputs_.clear();
1085+
outputs_.clear();
1086+
1087+
CStr cfn = blif_fn.c_str();
1088+
uint16_t tr = ltrace();
1089+
auto& ls = lout();
1090+
1091+
BLIF_file bfile(blif_fn);
1092+
1093+
if (tr >= 4)
1094+
bfile.setTrace(3);
1095+
1096+
bool exi = false;
1097+
exi = bfile.fileExists();
1098+
if (tr >= 8)
1099+
ls << int(exi) << endl;
1100+
if (not exi) {
1101+
flush_out(true); err_puts();
1102+
lprintf2("[Error] BLIF file '%s' does not exist\n", cfn);
1103+
err_puts(); flush_out(true);
1104+
return false;
1105+
}
1106+
1107+
exi = bfile.fileAccessible();
1108+
if (tr >= 8)
1109+
ls << int(exi) << endl;
1110+
if (not exi) {
1111+
flush_out(true); err_puts();
1112+
lprintf2("[Error] BLIF file '%s' is not accessible\n", cfn);
1113+
err_puts(); flush_out(true);
1114+
return false;
1115+
}
1116+
1117+
bool rd_ok = bfile.readBlif();
1118+
if (tr >= 8)
1119+
ls << int(rd_ok) << endl;
1120+
if (not rd_ok) {
1121+
flush_out(true); err_puts();
1122+
lprintf2("[Error] failed reading BLIF file '%s'\n", cfn);
1123+
err_puts(); flush_out(true);
1124+
return false;
1125+
}
1126+
1127+
lprintf(" (blif_file) #inputs= %u #outputs= %u topModel= %s\n",
1128+
bfile.numInputs(), bfile.numOutputs(), bfile.topModel_.c_str());
1129+
1130+
if (tr >= 5) {
1131+
flush_out(true);
1132+
bfile.printInputs(ls);
1133+
flush_out(true);
1134+
bfile.printOutputs(ls);
1135+
}
1136+
1137+
std::swap(inputs_, bfile.inputs_);
1138+
std::swap(outputs_, bfile.outputs_);
1139+
if (tr >= 3) {
1140+
flush_out(true);
1141+
lprintf("pin_c: finished read_blif(). #inputs= %zu #outputs= %zu\n",
1142+
inputs_.size(), outputs_.size());
1143+
}
1144+
1145+
flush_out(true);
1146+
1147+
return true;
1148+
}
1149+
10841150
}
10851151

0 commit comments

Comments
 (0)