atpg-ls/main.cpp

47 lines
1.1 KiB
C++
Raw Normal View History

#include <cstdio>
#include <cstdlib>
2023-02-12 16:22:32 +08:00
#include <assert.h>
#include "circuit.h"
int main(int args, char* argv[]) {
if(args != 2) {
printf("usage: ./atpg <XXX.bench>\n");
exit(1);
}
2023-02-16 18:51:31 +08:00
srand(19260817);
2023-02-20 13:08:25 +08:00
Circuit* circuit = new Circuit();
2023-02-16 18:51:31 +08:00
printf("parsing file %s ...", argv[1]);
2023-02-20 13:08:25 +08:00
circuit->parse_from_file(argv[1]);
circuit->init_stems();
circuit->init_topo_index();
2023-02-16 18:51:31 +08:00
printf(" Done.\n");
printf("====== Circuit Statistics ====== \n");
2023-02-20 13:08:25 +08:00
printf("PI:\t%ld\n", circuit->PIs.size());
printf("PO:\t%ld\n", circuit->POs.size());
printf("Gate:\t%ld\n", circuit->name2gate.size());
printf("Stem:\t%ld\n", circuit->stems.size());
2023-02-16 18:51:31 +08:00
printf("================================ \n");
2023-02-12 16:22:32 +08:00
2023-02-16 18:51:31 +08:00
std::vector<Fault*> faults;
2023-02-12 18:14:12 +08:00
2023-02-16 18:51:31 +08:00
// init faults
2023-02-20 13:08:25 +08:00
for(auto stem : circuit->stems) {
2023-02-16 18:51:31 +08:00
faults.push_back(new Fault(stem, Fault::SA0));
faults.push_back(new Fault(stem, Fault::SA1));
2023-02-12 16:22:32 +08:00
}
2023-02-20 13:08:25 +08:00
auto pattern = circuit->local_search(faults);
2023-02-12 18:14:12 +08:00
2023-02-19 19:42:50 +08:00
printf("checking valid circuit ...");
2023-02-20 13:08:25 +08:00
printf(" result: %d.\n", circuit->is_valid_circuit());
2023-02-19 19:42:50 +08:00
return 0;
}