stp project

master
panhomyoung 2024-06-03 15:56:21 +08:00
parent eb9f925632
commit d95f10767a
3 changed files with 53 additions and 18 deletions

View File

@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.8) cmake_minimum_required(VERSION 3.8)
project("phyLS" LANGUAGES CXX) project(phyLS LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)

View File

@ -28,6 +28,13 @@ class if_command : public command {
public: public:
explicit if_command(const environment::ptr &env) explicit if_command(const environment::ptr &env)
: command(env, "performs FPGA mapping of the AIG") { : command(env, "performs FPGA mapping of the AIG") {
add_option("-k,--klut", LutSize, "the number of LUT inputs (2 < k < 8), Default=4");
add_option("-c,--cut", CutSize,
"the max number of priority cuts (0 < c < 2^12), Default=8");
add_flag("--minimization, -m",
"enables cut minimization by removing vacuous variables");
add_flag("--delay, -y", "delay optimization with recorded library");
add_option("-f,--file", filename, "recorded library");
add_flag("--verbose, -v", "print the information"); add_flag("--verbose, -v", "print the information");
} }
@ -45,23 +52,42 @@ class if_command : public command {
If_Par_t Pars, *pPars = &Pars; If_Par_t Pars, *pPars = &Pars;
If_ManSetDefaultPars(pPars); If_ManSetDefaultPars(pPars);
pPars->pLutLib = (If_LibLut_t *)Abc_FrameReadLibLut(); pPars->pLutLib = (If_LibLut_t *)Abc_FrameReadLibLut();
if (pPars->nLutSize == -1) {
if (pPars->pLutLib == NULL) { if (is_set("klut")) pPars->nLutSize = LutSize;
printf("The LUT library is not given.\n"); if (is_set("cut")) pPars->nCutsMax = CutSize;
return; if (is_set("minimization")) pPars->fCutMin ^= 1;
if (is_set("delay")) {
pPars->fUserRecLib ^= 1;
pPars->fTruth = 1;
pPars->fCutMin = 1;
pPars->fExpRed = 0;
pPars->fUsePerm = 1;
pPars->pLutLib = NULL;
int nVars = 6;
int nCuts = 32;
int fFuncOnly = 0;
int fVerbose = 0;
char *FileName, *pTemp;
FILE *pFile;
Gia_Man_t *pGia = NULL;
FileName = filename.data();
for (pTemp = FileName; *pTemp; pTemp++)
if (*pTemp == '>') *pTemp = '\\';
if ((pFile = fopen(FileName, "r")) == NULL) {
printf("Cannot open input file \"%s\". ", FileName);
if ((FileName = Extra_FileGetSimilarName(FileName, ".aig", NULL, NULL,
NULL, NULL)))
printf("Did you mean \"%s\"?", FileName);
printf("\n");
} }
pPars->nLutSize = pPars->pLutLib->LutMax; fclose(pFile);
pGia = Gia_AigerRead(FileName, 0, 1, 0);
if (pGia == NULL) {
printf("Reading AIGER has failed.\n");
}
Abc_NtkRecStart3(pGia, nVars, nCuts, fFuncOnly, fVerbose);
} }
if (pPars->nLutSize < 2 || pPars->nLutSize > IF_MAX_LUTSIZE) {
printf("Incorrect LUT size (%d).\n", pPars->nLutSize);
return;
}
if (pPars->nCutsMax < 1 || pPars->nCutsMax >= (1 << 12)) {
printf("Incorrect number of cuts.\n");
return;
}
if (!Abc_NtkIsStrash(pNtk)) { if (!Abc_NtkIsStrash(pNtk)) {
// strash and balance the network // strash and balance the network
pNtk = Abc_NtkStrash(pNtk, 0, 0, 0); pNtk = Abc_NtkStrash(pNtk, 0, 0, 0);
@ -106,6 +132,9 @@ class if_command : public command {
} }
private: private:
uint32_t LutSize = 4u;
uint32_t CutSize = 8u;
string filename;
}; };
ALICE_ADD_COMMAND(if, "ABC") ALICE_ADD_COMMAND(if, "ABC")

View File

@ -24,7 +24,8 @@ class write_command : public command {
public: public:
explicit write_command(const environment::ptr &env) explicit write_command(const environment::ptr &env)
: command(env, "writes the current network into file by ABC parser") { : command(env, "writes the current network into file by ABC parser") {
add_option("filename,-f", file_name, "name of output file"); add_option("--filename,-f", file_name, "name of output file");
add_flag("--verilog, -v", "writes the current network in Verilog format");
} }
protected: protected:
@ -35,9 +36,14 @@ class write_command : public command {
std::cerr << "Error: Empty network.\n"; std::cerr << "Error: Empty network.\n";
else { else {
auto pNtk = store<pabc::Abc_Ntk_t *>().current(); auto pNtk = store<pabc::Abc_Ntk_t *>().current();
if (is_set("verilog")) {
pabc::Io_Write(pNtk, (char *)(file_name.c_str()), pabc::IO_FILE_VERILOG);
} else {
pabc::Io_Write(pNtk, (char *)(file_name.c_str()), pabc::Io_Write(pNtk, (char *)(file_name.c_str()),
pabc::Io_ReadFileType((char *)(file_name.c_str()))); pabc::Io_ReadFileType((char *)(file_name.c_str())));
} }
}
} }
private: private: