From d95f10767aad7a00e434fdad9b9b93ddf7a680c1 Mon Sep 17 00:00:00 2001 From: panhomyoung Date: Mon, 3 Jun 2024 15:56:21 +0800 Subject: [PATCH] stp project --- CMakeLists.txt | 2 +- src/commands/abc/if.hpp | 57 ++++++++++++++++++++++++++++---------- src/commands/abc/write.hpp | 12 ++++++-- 3 files changed, 53 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 85341a4..9f874b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.8) -project("phyLS" LANGUAGES CXX) +project(phyLS LANGUAGES CXX) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) diff --git a/src/commands/abc/if.hpp b/src/commands/abc/if.hpp index 8e18b06..004f04a 100644 --- a/src/commands/abc/if.hpp +++ b/src/commands/abc/if.hpp @@ -28,6 +28,13 @@ class if_command : public command { public: explicit if_command(const environment::ptr &env) : 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"); } @@ -45,23 +52,42 @@ class if_command : public command { If_Par_t Pars, *pPars = &Pars; If_ManSetDefaultPars(pPars); pPars->pLutLib = (If_LibLut_t *)Abc_FrameReadLibLut(); - if (pPars->nLutSize == -1) { - if (pPars->pLutLib == NULL) { - printf("The LUT library is not given.\n"); - return; + + if (is_set("klut")) pPars->nLutSize = LutSize; + if (is_set("cut")) pPars->nCutsMax = CutSize; + 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)) { // strash and balance the network pNtk = Abc_NtkStrash(pNtk, 0, 0, 0); @@ -106,6 +132,9 @@ class if_command : public command { } private: + uint32_t LutSize = 4u; + uint32_t CutSize = 8u; + string filename; }; ALICE_ADD_COMMAND(if, "ABC") diff --git a/src/commands/abc/write.hpp b/src/commands/abc/write.hpp index 71e8f2b..ef27a90 100644 --- a/src/commands/abc/write.hpp +++ b/src/commands/abc/write.hpp @@ -24,7 +24,8 @@ class write_command : public command { public: explicit write_command(const environment::ptr &env) : 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: @@ -35,8 +36,13 @@ class write_command : public command { std::cerr << "Error: Empty network.\n"; else { auto pNtk = store().current(); - pabc::Io_Write(pNtk, (char *)(file_name.c_str()), - pabc::Io_ReadFileType((char *)(file_name.c_str()))); + 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_ReadFileType((char *)(file_name.c_str()))); + } + } }