Skip to content

Commit 3e46dc2

Browse files
committed
checker: improve prim-DB
1 parent 8a8d01c commit 3e46dc2

File tree

4 files changed

+157
-43
lines changed

4 files changed

+157
-43
lines changed

planning/src/file_io/pln_blif_file.cpp

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ bool BLIF_file::checkBlif() noexcept {
444444
}
445445
if (trace_ >= 4) {
446446
lputs("(clock-data separation) checked OK.");
447-
if (trace_ >= 5) {
447+
if (trace_ >= 6) {
448448
flush_out(true);
449449
pg_.print(ls, " [[ final pinGraph ]]");
450450
flush_out(true);
@@ -456,6 +456,29 @@ bool BLIF_file::checkBlif() noexcept {
456456
flush_out(true);
457457
}
458458

459+
// -- write yaml file to check prim-DB:
460+
if (trace_ >= 5) {
461+
//string written = pr_write_yaml(LUT1);
462+
//string written = pr_write_yaml(LUT5);
463+
//string written = pr_write_yaml(DFFRE);
464+
//string written = pr_write_yaml( DSP19X2 );
465+
string written = pr_write_yaml( DSP38 );
466+
flush_out(true);
467+
if (written.empty()) {
468+
lprintf("\t\t FAIL: pr_write_yaml() FAILED\n\n");
469+
} else {
470+
lprintf("\t written: %s\n\n", written.c_str());
471+
if (0) {
472+
lprintf("\n ");
473+
for (int bb = 17; bb >= 0; bb--) {
474+
lprintf(" \"B[%i]\",", bb);
475+
}
476+
lputs();
477+
lputs();
478+
}
479+
}
480+
}
481+
459482
chk_ok_ = true;
460483
return true;
461484
}

planning/src/file_io/pln_primitives.cpp

Lines changed: 97 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ using std::string;
1818
"DFFRE",
1919
"DSP19X2",
2020
"DSP38",
21+
"FCLK_BUF",
2122
"FIFO18KX2",
2223
"FIFO36K",
2324
"I_BUF",
@@ -64,6 +65,8 @@ using std::string;
6465

6566
{ "Z", "DLY_B" }, // DSP38
6667

68+
{ "O" }, // FCLK_BUF
69+
6770
// FIFO18KX2
6871
{ "RD_DATA1", "EMPTY1", "FULL1", "ALMOST_EMPTY1", "ALMOST_FULL1",
6972
"PROG_EMPTY1", "PROG_FULL1", "OVERFLOW1", "UNDERFLOW1",
@@ -138,11 +141,24 @@ using std::string;
138141

139142
{ "D", "R", "E", "C" }, // DFFRE
140143

141-
// DSP19X2
142-
{ "CLK", "RESET", "LOAD_ACC", "UNSIGNED_A", "UNSIGNED_B",
143-
"SATURATE", "ROUND", "SUBTRACT" }, // TMP. INCOMPLETE.
144-
145-
{ }, // DSP38
144+
// DSP19X2
145+
{
146+
"A1[8]", "A1[7]", "A1[6]", "A1[5]", "A1[4]", "A1[3]", "A1[2]", "A1[1]", "A1[0]",
147+
"B1[9]", "B1[8]", "B1[7]", "B1[6]", "B1[5]", "B1[4]", "B1[3]", "B1[2]", "B1[1]", "B1[0]",
148+
"CLK", "RESET", "LOAD_ACC", "UNSIGNED_A", "UNSIGNED_B",
149+
"SATURATE", "ROUND", "SUBTRACT"
150+
},
151+
152+
// DSP38
153+
{
154+
"A[19]", "A[18]", "A[17]", "A[16]", "A[15]", "A[14]", "A[13]", "A[12]", "A[11]", "A[10]",
155+
"A[9]", "A[8]", "A[7]", "A[6]", "A[5]", "A[4]", "A[3]", "A[2]", "A[1]", "A[0]",
156+
"B[17]", "B[16]", "B[15]", "B[14]", "B[13]", "B[12]", "B[11]", "B[10]", "B[9]", "B[8]",
157+
"B[7]", "B[6]", "B[5]", "B[4]", "B[3]", "B[2]", "B[1]", "B[0]",
158+
"CLK",
159+
},
160+
161+
{ "I" }, // FCLK_BUF
146162

147163
// FIFO18KX2
148164
{ },
@@ -225,6 +241,8 @@ using std::string;
225241

226242
{ "CLK" }, // DSP38
227243

244+
{ "I", "O" }, // FCLK_BUF
245+
228246
// FIFO18KX2
229247
{ "WR_CLK1", "RD_CLK1",
230248
"WR_CLK2", "RD_CLK2" },
@@ -339,7 +357,7 @@ uint pr_num_clocks(Prim_t pt) noexcept {
339357
return V.size();
340358
}
341359

342-
void pr_get_inputs(Prim_t pt, std::vector<std::string>& INP) {
360+
void pr_get_inputs(Prim_t pt, vector<string>& INP) {
343361
INP.clear();
344362
uint i = pt;
345363
assert(i <= Prim_MAX_ID);
@@ -348,6 +366,15 @@ void pr_get_inputs(Prim_t pt, std::vector<std::string>& INP) {
348366
INP = _id2inputs[i];
349367
}
350368

369+
void pr_get_outputs(Prim_t pt, vector<string>& OUT) {
370+
OUT.clear();
371+
uint i = pt;
372+
assert(i <= Prim_MAX_ID);
373+
if (i == 0 or i > Prim_MAX_ID)
374+
return;
375+
OUT = _id2outputs[i];
376+
}
377+
351378
// "A_"
352379
static inline bool starts_w_A(CStr z) noexcept {
353380
assert(z);
@@ -379,7 +406,7 @@ static inline bool starts_w_CAR(CStr z) noexcept {
379406
return z[0] == 'C' and z[1] == 'A' and z[2] == 'R';
380407
}
381408

382-
bool is_I_SERDES_output_term(const std::string& term) noexcept {
409+
bool is_I_SERDES_output_term(const string& term) noexcept {
383410
assert(!term.empty());
384411
if (term.empty()) return false;
385412

@@ -402,7 +429,7 @@ bool is_I_SERDES_output_term(const std::string& term) noexcept {
402429
return b;
403430
}
404431

405-
bool is_O_SERDES_output_term(const std::string& term) noexcept {
432+
bool is_O_SERDES_output_term(const string& term) noexcept {
406433
assert(!term.empty());
407434
if (term.empty()) return false;
408435

@@ -425,7 +452,7 @@ bool is_O_SERDES_output_term(const std::string& term) noexcept {
425452
return b;
426453
}
427454

428-
bool is_TDP_RAM36K_output_term(const std::string& term) noexcept {
455+
bool is_TDP_RAM36K_output_term(const string& term) noexcept {
429456
assert(!term.empty());
430457
if (term.empty()) return false;
431458

@@ -449,7 +476,7 @@ bool is_TDP_RAM36K_output_term(const std::string& term) noexcept {
449476
return b;
450477
}
451478

452-
bool is_TDP_RAM18KX_output_term(const std::string& term) noexcept {
479+
bool is_TDP_RAM18KX_output_term(const string& term) noexcept {
453480
assert(!term.empty());
454481
if (term.empty()) return false;
455482

@@ -474,7 +501,7 @@ R"(RDATA_A1=|RDATA_A1\[\d+\]=|RDATA_A2=|RDATA_A2\[\d+\]=|RDATA_B1=|RDATA_B1\[\d+
474501
return b;
475502
}
476503

477-
bool is_PLL_output_term(const std::string& term) noexcept {
504+
bool is_PLL_output_term(const string& term) noexcept {
478505
assert(!term.empty());
479506
if (term.empty()) return false;
480507

@@ -524,5 +551,64 @@ Prim_t pr_str2enum(CStr name) noexcept {
524551
return A_ZERO;
525552
}
526553

554+
// ==== DEBUG:
555+
556+
string pr_write_yaml(Prim_t pt) noexcept {
557+
using std::endl;
558+
CStr primName = pr_enum2str(pt);
559+
assert(primName);
560+
assert(primName[0]);
561+
if (!primName or !primName[0])
562+
return {};
563+
564+
string fn = str::concat(primName, "_pln.yaml");
565+
566+
flush_out(true);
567+
lprintf(" pr_write_yaml( %s ) to file: %s\n", primName, fn.c_str());
568+
569+
std::ofstream fos(fn);
570+
if (not fos.is_open()) {
571+
flush_out(true);
572+
lprintf("pr_write_yaml: could not open file for writing: %s\n\n", fn.c_str());
573+
return {};
574+
}
575+
576+
fos << "name: " << primName << endl;
577+
fos << "desc: ";
578+
if (pt >= LUT1 and pt <= LUT6)
579+
os_printf(fos, "%u-input lookup table (LUT)", pr_num_inputs(pt));
580+
fos << endl;
581+
582+
fos << "category: core_fabric" << endl;
583+
fos << endl;
584+
585+
fos << "ports:" << endl;
586+
587+
vector<string> V;
588+
589+
pr_get_inputs(pt, V);
590+
for (const string& port : V) {
591+
os_printf(fos, " %s:\n", port.c_str());
592+
os_printf(fos, " dir: input\n");
593+
os_printf(fos, " desc:");
594+
if (pr_pin_is_clock(pt, port))
595+
fos << " Clock";
596+
fos << endl;
597+
}
598+
pr_get_outputs(pt, V);
599+
for (const string& port : V) {
600+
os_printf(fos, " %s:\n", port.c_str());
601+
os_printf(fos, " dir: output\n");
602+
os_printf(fos, " desc:");
603+
if (pr_pin_is_clock(pt, port))
604+
fos << " Clock";
605+
fos << endl;
606+
}
607+
608+
fos << endl;
609+
610+
return fn;
611+
}
612+
527613
}}
528614

planning/src/file_io/pln_primitives.h

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -22,36 +22,37 @@ enum Prim_t {
2222
DFFRE = 5,
2323
DSP19X2 = 6,
2424
DSP38 = 7,
25-
FIFO18KX2 = 8,
26-
FIFO36K = 9,
27-
I_BUF = 10,
28-
I_BUF_DS = 11,
29-
I_DDR = 12,
30-
I_DELAY = 13,
31-
IO_BUF = 14,
32-
IO_BUF_DS = 15,
33-
I_SERDES = 16,
34-
LUT1 = 17,
35-
LUT2 = 18,
36-
LUT3 = 19,
37-
LUT4 = 20,
38-
LUT5 = 21,
39-
LUT6 = 22,
40-
O_BUF = 23,
41-
O_BUF_DS = 24,
42-
O_BUFT = 25,
43-
O_BUFT_DS = 26,
44-
O_DDR = 27,
45-
O_DELAY = 28,
46-
O_SERDES = 29,
47-
O_SERDES_CLK = 30,
48-
PLL = 31,
49-
TDP_RAM18KX2 = 32,
50-
TDP_RAM36K = 33,
51-
52-
X_UNKNOWN = 34,
53-
54-
Y_UPPER_GUARD = 35
25+
FCLK_BUF = 8,
26+
FIFO18KX2 = 9,
27+
FIFO36K = 10,
28+
I_BUF = 11,
29+
I_BUF_DS = 12,
30+
I_DDR = 13,
31+
I_DELAY = 14,
32+
IO_BUF = 15,
33+
IO_BUF_DS = 16,
34+
I_SERDES = 17,
35+
LUT1 = 18,
36+
LUT2 = 19,
37+
LUT3 = 20,
38+
LUT4 = 21,
39+
LUT5 = 22,
40+
LUT6 = 23,
41+
O_BUF = 24,
42+
O_BUF_DS = 25,
43+
O_BUFT = 26,
44+
O_BUFT_DS = 27,
45+
O_DDR = 28,
46+
O_DELAY = 29,
47+
O_SERDES = 30,
48+
O_SERDES_CLK = 31,
49+
PLL = 32,
50+
TDP_RAM18KX2 = 33,
51+
TDP_RAM36K = 34,
52+
53+
X_UNKNOWN = 35,
54+
55+
Y_UPPER_GUARD = 36
5556
};
5657

5758
// valid IDs are from 1 to Prim_MAX_ID inclusive
@@ -81,6 +82,7 @@ uint pr_num_outputs(Prim_t pt) noexcept;
8182
uint pr_num_clocks(Prim_t pt) noexcept;
8283

8384
void pr_get_inputs(Prim_t pt, std::vector<std::string>& INP);
85+
void pr_get_outputs(Prim_t pt, std::vector<std::string>& OUT);
8486

8587
bool is_I_SERDES_output_term(const std::string& term) noexcept;
8688
bool is_O_SERDES_output_term(const std::string& term) noexcept;
@@ -90,6 +92,9 @@ bool is_TDP_RAM18KX_output_term(const std::string& term) noexcept;
9092

9193
bool is_PLL_output_term(const std::string& term) noexcept;
9294

95+
// DEBUG:
96+
std::string pr_write_yaml(Prim_t pt) noexcept;
97+
9398
}}
9499

95100
#endif

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 = "pln0311";
1+
static const char* _pln_VERSION_STR = "pln0312";
22

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

0 commit comments

Comments
 (0)