Skip to content

Commit 9eac0a1

Browse files
authored
Merge pull request #705 from os-fpga/pln_add_primitives_h_cpp
blif_checker: added pln_primitives.cpp,h
2 parents c3f6a22 + 1e9ccc7 commit 9eac0a1

File tree

5 files changed

+144
-13
lines changed

5 files changed

+144
-13
lines changed

stars/src/RS/rsCheck.cpp

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ bool do_check(const rsOpts& opts) {
4646
return false;
4747
}
4848

49-
lprintf(" (blif_file) #inputs= %u #outputs= %u\n",
50-
bfile.numInputs(), bfile.numOutputs());
49+
lprintf(" (blif_file) #inputs= %u #outputs= %u topModel= %s\n",
50+
bfile.numInputs(), bfile.numOutputs(), bfile.topModel_.c_str());
5151

5252
if (tr >= 4) {
5353
lputs();
@@ -60,15 +60,24 @@ bool do_check(const rsOpts& opts) {
6060
ls << ">>>>> checking BLIF " << fn1 << " ..." << endl;
6161

6262
bool chk_ok = bfile.checkBlif();
63+
assert(chk_ok == bfile.chk_ok_);
6364

64-
ls << ">>>>> chk_ok: " << int(chk_ok) << endl;
65+
lprintf(">>>>> passed: %s\n", chk_ok ? "YES" : "NO");
66+
67+
ls << ">>>>> topModel: " << bfile.topModel_ << endl;
68+
ls << ">>>>> file: " << bfile.fnm_ << endl;
69+
if (bfile.num_MOGs_) {
70+
ls << ">>>>> [NOTE] num_MOGs_ = " << bfile.num_MOGs_ << endl;
71+
}
72+
73+
flush_out(true);
6574
if (chk_ok) {
6675
ls << " === BLIF is OK." << endl;
6776
return true;
6877
}
6978

70-
ls << " !!! BLIF is not OK: " << endl;
71-
ls << " !!! " << bfile.err_msg_ << endl;
79+
ls << "[Error] !!! BLIF is not OK !!!" << endl;
80+
ls << "[Error] !!! " << bfile.err_msg_ << endl;
7281

7382
return false;
7483
}

stars/src/file_readers/pln_blif_file.h

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#define _pln_frd_BLIF_FILE_H_e6f4ecdf41a2f915079_
44

55
#include "file_readers/pinc_Fio.h"
6+
#include "file_readers/pln_primitives.h"
67

78
namespace pln {
89

@@ -21,17 +22,16 @@ struct BLIF_file : public fio::MMapReader
2122
uint depth_ = 0;
2223
vector<uint> chld_;
2324

24-
string kw_; // keyword: .names, .subckt, etc.
25-
vector<string> data_; // everything on the line ater kw, tokenized
25+
string kw_; // keyword: .names, .subckt, etc.
26+
vector<string> data_; // everything on the line ater kw, tokenized
2627

27-
// vector<string> mog_outs_; // pin names O, Y, Q are considered to be outputs.
28-
// // MOG-nodes are transformed to bunches of SOG-nodes.
29-
30-
string out_; // SOG output (real or virtual)
28+
string out_; // SOG output (real or virtual)
3129

3230
uint virtualOrigin_ = 0; // node-ID from which this virtual MOG is created
3331

34-
int16_t is_top_ = 0; // -1:top input 1:top output
32+
Prim_t ptype_ = A_ZERO;
33+
34+
int16_t is_top_ = 0; // -1:top input 1:top output
3535
bool is_mog_ = false;
3636

3737
public:
@@ -76,8 +76,12 @@ struct BLIF_file : public fio::MMapReader
7676
string firstInputPin() const noexcept;
7777

7878
CStr cOut() const noexcept { return out_.empty() ? "{e}" : out_.c_str(); }
79+
7980
CStr cType() const noexcept { return data_.empty() ? "{e}" : data_.front().c_str(); }
8081

82+
// cPrimType() will replace cType()
83+
CStr cPrimType() const noexcept { return primt_name(ptype_); }
84+
8185
struct CmpOut {
8286
bool operator()(const Node* a, const Node* b) const noexcept {
8387
return a->out_ < b->out_;
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#include "file_readers/pln_primitives.h"
2+
3+
namespace pln {
4+
5+
6+
CStr primt_name(Prim_t enu) noexcept {
7+
// enumNames are sorted and Prim_t is sorted, it ensures
8+
// correct ID -> name mapping. Always keep them in sorted order.
9+
static const char* enumNames[] = {
10+
"A_ZERO",
11+
"BOOT_CLOCK",
12+
"CARRY_CHAIN",
13+
"CLK_BUF",
14+
"DFFRE",
15+
"DSP19X2",
16+
"DSP38",
17+
"FIFO18KX2",
18+
"FIFO36K",
19+
"I_BUF",
20+
"I_BUF_DS",
21+
"I_DDR",
22+
"I_DELAY",
23+
"IO_BUF",
24+
"IO_BUF_DS",
25+
"I_SERDES",
26+
"LUT1",
27+
"LUT2",
28+
"LUT3",
29+
"LUT4",
30+
"LUT5",
31+
"LUT6",
32+
"O_BUF",
33+
"O_BUF_DS",
34+
"O_BUFT",
35+
"O_BUFT_DS",
36+
"O_DDR",
37+
"O_DELAY",
38+
"O_SERDES",
39+
"O_SERDES_CLK",
40+
"PLL",
41+
"TDP_RAM18KX2",
42+
"TDP_RAM36K",
43+
"X_UNKNOWN",
44+
"Y_UPPER_GUARD"
45+
};
46+
static_assert(sizeof(enumNames) / sizeof(enumNames[0]) == Y_UPPER_GUARD + 1);
47+
48+
uint i = enu;
49+
assert(i <= Prim_MAX_ID);
50+
51+
return enumNames[i];
52+
}
53+
54+
55+
}
56+
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#pragma once
2+
#ifndef _pln_frd_primitives_H_e192faa77f7aec_
3+
#define _pln_frd_primitives_H_e192faa77f7aec_
4+
5+
#include "util/pln_log.h"
6+
7+
namespace pln {
8+
9+
enum Prim_t {
10+
11+
A_ZERO = 0,
12+
13+
BOOT_CLOCK = 1,
14+
CARRY_CHAIN = 2,
15+
CLK_BUF = 3,
16+
DFFRE = 4,
17+
DSP19X2 = 5,
18+
DSP38 = 6,
19+
FIFO18KX2 = 7,
20+
FIFO36K = 8,
21+
I_BUF = 9,
22+
I_BUF_DS = 10,
23+
I_DDR = 11,
24+
I_DELAY = 12,
25+
IO_BUF = 13,
26+
IO_BUF_DS = 14,
27+
I_SERDES = 15,
28+
LUT1 = 16,
29+
LUT2 = 17,
30+
LUT3 = 18,
31+
LUT4 = 19,
32+
LUT5 = 20,
33+
LUT6 = 21,
34+
O_BUF = 22,
35+
O_BUF_DS = 23,
36+
O_BUFT = 24,
37+
O_BUFT_DS = 25,
38+
O_DDR = 26,
39+
O_DELAY = 27,
40+
O_SERDES = 28,
41+
O_SERDES_CLK = 29,
42+
PLL = 30,
43+
TDP_RAM18KX2 = 31,
44+
TDP_RAM36K = 32,
45+
46+
X_UNKNOWN = 33,
47+
48+
Y_UPPER_GUARD = 34
49+
};
50+
51+
// valid IDs are from 1 to Prim_MAX_ID inclusive
52+
//
53+
constexpr uint Prim_MAX_ID = X_UNKNOWN;
54+
55+
56+
// enum -> string
57+
CStr primt_name(Prim_t enu) noexcept;
58+
59+
}
60+
61+
#endif
62+

stars/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 = "pln0222";
1+
static const char* _pln_VERSION_STR = "pln0223";
22

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

0 commit comments

Comments
 (0)