2023-02-11 21:52:59 +08:00
|
|
|
#include <cstdio>
|
|
|
|
#include <cstdlib>
|
2023-02-12 16:22:32 +08:00
|
|
|
#include <assert.h>
|
2023-02-11 21:52:59 +08:00
|
|
|
|
|
|
|
#include "circuit.h"
|
2023-03-17 05:37:29 +00:00
|
|
|
#include "clause.h"
|
2023-03-21 08:14:37 +00:00
|
|
|
#include "CCAnr/ccanr.h"
|
2023-02-11 21:52:59 +08:00
|
|
|
|
|
|
|
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-11 21:52:59 +08:00
|
|
|
|
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_topo_index();
|
2023-02-16 18:51:31 +08:00
|
|
|
printf(" Done.\n");
|
|
|
|
|
2023-02-11 21:52:59 +08:00
|
|
|
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-03-13 05:44:49 +00:00
|
|
|
circuit->global_fault_undetected_count = circuit->gates.size() * 2;
|
2023-02-11 21:52:59 +08:00
|
|
|
|
2023-03-21 08:36:53 +00:00
|
|
|
CCAnr::module_init();
|
|
|
|
|
2023-03-17 05:37:29 +00:00
|
|
|
// init clause local search
|
|
|
|
ClauseLS::init_data_structs(circuit);
|
|
|
|
|
2023-02-23 11:00:24 +08:00
|
|
|
while(true) {
|
2023-03-13 05:44:49 +00:00
|
|
|
bool ls = circuit->local_search();
|
2023-02-26 03:47:26 +00:00
|
|
|
bool is_valid = circuit->is_valid_circuit();
|
2023-02-23 11:00:24 +08:00
|
|
|
printf("checking valid circuit ...");
|
2023-02-26 03:47:26 +00:00
|
|
|
printf(" result: %d.\n", is_valid);
|
2023-02-23 11:00:24 +08:00
|
|
|
if(!ls) break;
|
2023-02-26 03:47:26 +00:00
|
|
|
if(!is_valid) break;
|
2023-03-13 05:44:49 +00:00
|
|
|
if(circuit->global_fault_undetected_count == 0) break;
|
2023-02-23 11:00:24 +08:00
|
|
|
}
|
2023-02-19 19:42:50 +08:00
|
|
|
|
2023-02-11 21:52:59 +08:00
|
|
|
return 0;
|
|
|
|
}
|