dom/source/ABC.cpp

72 lines
2.2 KiB
C++
Raw Normal View History

2019-09-26 14:00:28 +08:00
#include "ABC.h"
2019-12-04 21:26:52 +08:00
map<string, string> alias;
void abc_initialize() {
alias["b"] = "balance;";
alias["rw"] = "rewrite;";
alias["rwz"] = "rewrite -z;";
alias["rf"] = "refactor;";
alias["rfz"] = "refactor -z;";
alias["resyn"] = alias["b"] + alias["rw"] + alias["rwz"] + alias["b"] + alias["rwz"] + alias["b"];
alias["resyn2"] = alias["b"] + alias["rw"] + alias["rf"] + alias["b"] + alias["rw"] + alias["rwz"]
+ alias["b"] + alias["rfz"] + alias["rwz"] + alias["b"];
alias["choice"] = "fraig_store;" + alias["resyn"] + "fraig_store;" + alias["resyn2"] + "fraig_store;"
+ "fraig_restore;";
2019-09-26 14:00:28 +08:00
}
2019-12-04 21:26:52 +08:00
void execute_command(string s) {
2019-10-23 21:13:43 +08:00
void *pAbc;
2019-12-04 21:26:52 +08:00
char command[10000];
2019-09-26 14:00:28 +08:00
2019-10-23 21:13:43 +08:00
Abc_Start();
pAbc = Abc_FrameGetGlobalFrame();
2019-09-26 14:00:28 +08:00
2019-12-04 21:26:52 +08:00
sprintf(command, s.c_str());
if (Cmd_CommandExecute(pAbc, command)) {
fprintf( stdout, "Cannot execute command \"%s\".\n", command);
2019-10-23 21:13:43 +08:00
}
2019-09-26 14:00:28 +08:00
2019-10-23 21:13:43 +08:00
Abc_Stop();
2019-09-26 14:00:28 +08:00
}
2019-12-04 21:26:52 +08:00
void abc_check_equivalence(string in_file, string out_file) {
abc_initialize();
2019-12-04 21:48:24 +08:00
string command = "cec " + in_file + " " + out_file + ";";
2019-12-04 21:26:52 +08:00
execute_command(command);
}
2019-10-23 21:13:43 +08:00
2019-12-04 21:26:52 +08:00
void abc_synthesize(string in_file, string write_cmd, string out_file) {
abc_initialize();
string command = "read " + in_file + ";";
command += alias["resyn"] + alias["resyn2"];
command += write_cmd + " " + out_file + ";";
execute_command(command);
}
2019-12-04 21:26:52 +08:00
void abc_map(string in_file, string write_cmd, string out_file, string lib) {
abc_initialize();
string command = "read_library abclib/" + lib + ";";
2019-12-08 15:03:29 +08:00
command += "read " + in_file + ";";
command += alias["resyn"] + alias["resyn2"];
2019-12-04 21:26:52 +08:00
command += "map -a;"; // area-only mapping
command += write_cmd + " " + out_file + ";";
execute_command(command);
}
2019-12-04 21:26:52 +08:00
void abc_lutpack(string in_file, string write_cmd, string out_file, string lib) {
abc_initialize();
string command = "read_lut abclib/" + lib + ";";
2019-12-10 19:34:44 +08:00
command += "read " + in_file + ";";
command += alias["resyn"] + alias["resyn2"];
2019-12-04 21:26:52 +08:00
command += "if;";
for (int i = 0; i < 4; ++i) {
command += alias["choice"] + "if;mfs;";
}
2019-12-04 21:26:52 +08:00
for (int i = 0; i < 2; ++i) {
command += "lutpack;";
}
command += write_cmd + " " + out_file + ";";
execute_command(command);
}