mirror of https://github.com/openXC7/prjxray.git
Add seg_int database
Signed-off-by: Clifford Wolf <clifford@clifford.at> Signed-off-by: Tim 'mithro' Ansell <mithro@mithis.com>
This commit is contained in:
parent
612e5b10cd
commit
fea6a9efb0
|
|
@ -1,2 +1,2 @@
|
||||||
/specimen_[0-9][0-9][0-9]/
|
/specimen_[0-9][0-9][0-9]/
|
||||||
/seg_clbl[lm].segbits
|
/seg_int.segbits
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,16 @@
|
||||||
|
|
||||||
N := 5
|
N := 15
|
||||||
SPECIMENS := $(addprefix specimen_,$(shell seq -f '%03.0f' $(N)))
|
SPECIMENS := $(addprefix specimen_,$(shell seq -f '%03.0f' $(N)))
|
||||||
SPECIMENS_OK := $(addsuffix /OK,$(SPECIMENS))
|
SPECIMENS_OK := $(addsuffix /OK,$(SPECIMENS))
|
||||||
|
|
||||||
database: database/clbll database/clblm
|
database: $(SPECIMENS_OK)
|
||||||
|
../../tools/segmatch -m 5 -M 15 -o seg_int.segbits \
|
||||||
|
$(addsuffix /segdata_clbll.txt,$(SPECIMENS)) \
|
||||||
|
$(addsuffix /segdata_clblm.txt,$(SPECIMENS))
|
||||||
|
|
||||||
pushdb: pushdb/clbll pushdb/clblm
|
pushdb:
|
||||||
|
bash ../../utils/mergedb.sh seg_int.segbits \
|
||||||
database/%: $(SPECIMENS_OK)
|
../../database/$(XRAY_DATABASE)/seg_int.segbits
|
||||||
../../tools/segmatch -o seg_$(notdir $@).segbits \
|
|
||||||
$(addsuffix /segdata_$(notdir $@).txt,$(SPECIMENS))
|
|
||||||
|
|
||||||
pushdb/%:
|
|
||||||
bash ../../utils/mergedb.sh seg_$(notdir $@).segbits \
|
|
||||||
../../database/$(XRAY_DATABASE)/seg_$(notdir $@).segbits
|
|
||||||
|
|
||||||
$(SPECIMENS_OK):
|
$(SPECIMENS_OK):
|
||||||
bash generate.sh $(subst /OK,,$@)
|
bash generate.sh $(subst /OK,,$@)
|
||||||
|
|
|
||||||
|
|
@ -41,9 +41,9 @@ for tile, pips_srcs_dsts in tiledata.items():
|
||||||
|
|
||||||
for pip, src_dst in pipdata.items():
|
for pip, src_dst in pipdata.items():
|
||||||
if pip in pips:
|
if pip in pips:
|
||||||
segmk.addtag(tile, pip, 1)
|
segmk.addtag(tile, "%s.%s" % (src_dst[1], src_dst[0]), 1)
|
||||||
elif src_dst[1] not in dsts:
|
elif src_dst[1] not in dsts:
|
||||||
segmk.addtag(tile, pip, 0)
|
segmk.addtag(tile, "%s.%s" % (src_dst[1], src_dst[0]), 0)
|
||||||
|
|
||||||
segmk.compile()
|
segmk.compile()
|
||||||
segmk.write()
|
segmk.write()
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
|
#include <algorithm>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
|
|
@ -140,14 +141,21 @@ void andc_masks(vector<bool> &dst_mask, const vector<bool> &src_mask)
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
const char *outfile = nullptr;
|
const char *outfile = nullptr;
|
||||||
|
int min_each = 0, min_total = 0;
|
||||||
|
|
||||||
int opt;
|
int opt;
|
||||||
while ((opt = getopt(argc, argv, "io:")) != -1)
|
while ((opt = getopt(argc, argv, "io:m:M:")) != -1)
|
||||||
switch (opt)
|
switch (opt)
|
||||||
{
|
{
|
||||||
case 'o':
|
case 'o':
|
||||||
outfile = optarg;
|
outfile = optarg;
|
||||||
break;
|
break;
|
||||||
|
case 'm':
|
||||||
|
min_each = atoi(optarg);
|
||||||
|
break;
|
||||||
|
case 'M':
|
||||||
|
min_total = atoi(optarg);
|
||||||
|
break;
|
||||||
case 'i':
|
case 'i':
|
||||||
mode_inv = true;
|
mode_inv = true;
|
||||||
break;
|
break;
|
||||||
|
|
@ -163,6 +171,12 @@ help:
|
||||||
fprintf(stderr, " -o <filename>\n");
|
fprintf(stderr, " -o <filename>\n");
|
||||||
fprintf(stderr, " set output file\n");
|
fprintf(stderr, " set output file\n");
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
|
fprintf(stderr, " -m <int>\n");
|
||||||
|
fprintf(stderr, " min number of set/cleared samples each\n");
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
fprintf(stderr, " -M <int>\n");
|
||||||
|
fprintf(stderr, " min number of set/cleared samples total\n");
|
||||||
|
fprintf(stderr, "\n");
|
||||||
fprintf(stderr, " -i\n");
|
fprintf(stderr, " -i\n");
|
||||||
fprintf(stderr, " add inverted tags\n");
|
fprintf(stderr, " add inverted tags\n");
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
|
|
@ -200,10 +214,12 @@ help:
|
||||||
int max_candidates = 0;
|
int max_candidates = 0;
|
||||||
float avg_candidates = 0;
|
float avg_candidates = 0;
|
||||||
|
|
||||||
|
std::vector<std::string> out_lines;
|
||||||
|
|
||||||
for (int tag_idx = 0; tag_idx < num_tags; tag_idx++)
|
for (int tag_idx = 0; tag_idx < num_tags; tag_idx++)
|
||||||
{
|
{
|
||||||
vector<bool> mask(num_bits, true);
|
vector<bool> mask(num_bits, true);
|
||||||
bool got1 = false, got0 = false;
|
int count1 = 0, count0 = 0;
|
||||||
|
|
||||||
for (auto &segdat : segdata)
|
for (auto &segdat : segdata)
|
||||||
{
|
{
|
||||||
|
|
@ -214,36 +230,54 @@ help:
|
||||||
assert(!tag1 || !tag0);
|
assert(!tag1 || !tag0);
|
||||||
|
|
||||||
if (tag1) {
|
if (tag1) {
|
||||||
got1 = true;
|
count1++;
|
||||||
and_masks(mask, segdata_bits(sd));
|
and_masks(mask, segdata_bits(sd));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tag0) {
|
if (tag0) {
|
||||||
got0 = true;
|
count0++;
|
||||||
andc_masks(mask, segdata_bits(sd));
|
andc_masks(mask, segdata_bits(sd));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(got1 || got0);
|
assert(count1 || count0);
|
||||||
|
|
||||||
fprintf(f, "%s", tag_ids_r.at(tag_idx).c_str());
|
std::string out_line = tag_ids_r.at(tag_idx);
|
||||||
|
|
||||||
if (!got1) {
|
if (count1 < min_each) {
|
||||||
fprintf(f, " <const0>\n");
|
char buffer[64];
|
||||||
|
snprintf(buffer, 64, " <m1 %d>", count1);
|
||||||
|
out_line += buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count0 < min_each) {
|
||||||
|
char buffer[64];
|
||||||
|
snprintf(buffer, 64, " <m0 %d>", count0);
|
||||||
|
out_line += buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count1 + count0 < min_total) {
|
||||||
|
char buffer[64];
|
||||||
|
snprintf(buffer, 64, " <M %d %d>", count1, count0);
|
||||||
|
out_line += buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!count1) {
|
||||||
|
out_lines.push_back(out_line + " <const0>");
|
||||||
cnt_const0 += 1;
|
cnt_const0 += 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!got0) {
|
if (!count0) {
|
||||||
fprintf(f, " <const1>");
|
out_line += " <const1>";
|
||||||
cnt_const1 += 1;
|
cnt_const1 += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int num_candidates = std::accumulate(mask.begin(), mask.end(), 0);
|
int num_candidates = std::accumulate(mask.begin(), mask.end(), 0);
|
||||||
|
|
||||||
if (got0) {
|
if (count0) {
|
||||||
min_candidates = std::min(min_candidates, num_candidates);
|
min_candidates = std::min(min_candidates, num_candidates);
|
||||||
max_candidates = std::max(max_candidates, num_candidates);
|
max_candidates = std::max(max_candidates, num_candidates);
|
||||||
avg_candidates += num_candidates;
|
avg_candidates += num_candidates;
|
||||||
|
|
@ -251,15 +285,27 @@ help:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 < num_candidates && num_candidates <= 4) {
|
if (0 < num_candidates && num_candidates <= 4) {
|
||||||
|
std::vector<std::string> out_tags;
|
||||||
for (int bit_idx = 0; bit_idx < num_bits; bit_idx++)
|
for (int bit_idx = 0; bit_idx < num_bits; bit_idx++)
|
||||||
if (mask.at(bit_idx))
|
if (mask.at(bit_idx))
|
||||||
fprintf(f, " %s", bit_ids_r.at(bit_idx).c_str());
|
out_tags.push_back(bit_ids_r.at(bit_idx));
|
||||||
fprintf(f, "\n");
|
std::sort(out_tags.begin(), out_tags.end());
|
||||||
|
for (auto &tag : out_tags)
|
||||||
|
out_line += " " + tag;
|
||||||
} else {
|
} else {
|
||||||
fprintf(f, " <%d candidates>\n", num_candidates);
|
char buffer[64];
|
||||||
|
snprintf(buffer, 64, " <%d candidates>", num_candidates);
|
||||||
|
out_line += buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
out_lines.push_back(out_line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::sort(out_lines.begin(), out_lines.end());
|
||||||
|
|
||||||
|
for (auto &line : out_lines)
|
||||||
|
fprintf(f, "%s\n", line.c_str());
|
||||||
|
|
||||||
if (cnt_candidates)
|
if (cnt_candidates)
|
||||||
avg_candidates /= cnt_candidates;
|
avg_candidates /= cnt_candidates;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,5 +4,5 @@ test $# = 2
|
||||||
test -e "$1"
|
test -e "$1"
|
||||||
touch "$2"
|
touch "$2"
|
||||||
tmp=`mktemp -p .`
|
tmp=`mktemp -p .`
|
||||||
sort -u "$1" "$2" > "$tmp"
|
sort -u "$1" "$2" | grep -v '<.*>' > "$tmp"
|
||||||
mv "$tmp" "$2"
|
mv "$tmp" "$2"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue