Skip to content

Commit

Permalink
Merge 133ed8b into 14b66e6
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanghongce committed Oct 24, 2021
2 parents 14b66e6 + 133ed8b commit 951039b
Show file tree
Hide file tree
Showing 131 changed files with 8,258 additions and 11,381 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v2

- name: Install Dependent Packages
run: sudo apt install bison flex z3 libz3-dev
run: sudo apt install bison flex z3 libz3-dev libfl-dev

- name: Create Build Environment
run: cmake -E make_directory ${{runner.workspace}}/build
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@
[submodule "extern/smt-switch"]
path = extern/smt-switch
url = https://github.com/makaimann/smt-switch.git
[submodule "extern/vexpparser"]
path = extern/vexpparser
url = https://github.com/zhanghongce/vexpparser.git
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ jobs:
- bison
- z3
- libz3-dev
- libfl-dev
- g++-7
before_install:
- echo -n | openssl s_client -connect https://scan.coverity.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/ssl/certs/ca-
Expand All @@ -77,6 +78,7 @@ addons:
- bison
- z3
- libz3-dev
- libfl-dev
- g++-7

notifications:
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ configuration:

install:
- sudo apt update --yes
- sudo apt install --yes z3 libz3-dev bison flex gcc g++
- sudo apt install --yes z3 libz3-dev bison libfl-dev flex gcc g++

build_script:
- cd $APPVEYOR_BUILD_FOLDER
Expand Down
11 changes: 11 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ jobs:
sudo apt-get install flex
sudo apt-get install z3
sudo apt-get install libz3-dev
sudo apt-get install libfl-dev
sudo apt-get install g++-7
displayName: 'package'
- script: |
Expand All @@ -86,6 +87,7 @@ jobs:
sudo apt-get install flex
sudo apt-get install z3
sudo apt-get install libz3-dev
sudo apt-get install libfl-dev
sudo apt-get install g++-8
displayName: 'package'
- script: |
Expand Down Expand Up @@ -140,6 +142,15 @@ jobs:
cmake --build . --target install
displayName: 'vlog-parser'
- script: |
cd extern
cd vexpparser
md build
cd build
cmake .. -DCMAKE_CXX_FLAGS=/I\ %ProgramData%\\chocolatey\\lib\\winflexbison3\\tools
cmake --build . --target install
displayName: 'vexpparser'
- script: |
md build
cd build
Expand Down
1 change: 1 addition & 0 deletions cmake/config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ find_dependency(glog REQUIRED)
find_dependency(nlohmann_json REQUIRED)
find_dependency(verilogparser REQUIRED)
find_dependency(vcdparser REQUIRED)
find_dependency(vexpparser REQUIRED)
find_dependency(smtparser REQUIRED)
find_dependency(fmt REQUIRED)
find_dependency(Z3 REQUIRED)
Expand Down
33 changes: 33 additions & 0 deletions extern/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,39 @@ if(NOT VERILOGPARSER_FOUND)
endif() # VERILOGPARSER_FOUND


# ---------------------------------------------------------------------------- #
# Verilog Expression Parser
#
# TARGET vexpparser::vexpparser
# SOURCE https://github.com/zhanghongce/vexpparser.git
# PATH extern/vexpparser
# ---------------------------------------------------------------------------- #
# find installed package
find_package(vexpparser 1.1.0 QUIET)

# embed to build tree if not installed
if(NOT VEXP_PARSER_FOUND)

# fetch from git
if(${ILANG_FETCH_DEPS})

execute_process(
COMMAND ${GIT_EXECUTABLE} submodule update --init vexpparser
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE GIT_SUBMOD_RESULT
)

if(NOT GIT_SUBMOD_RESULT EQUAL "0")
message(FATAL_ERROR "Submodule update failed with ${GIT_SUBMOD_RESULT}")
endif()

endif() # ILANG_FETCH_DEPS

# embedded build
add_subdirectory(vexpparser)

endif() # VERILOGPARSER_FOUND

# ---------------------------------------------------------------------------- #
# Template-based ILA Synthesis
#
Expand Down
1 change: 1 addition & 0 deletions extern/vexpparser
Submodule vexpparser added at 0aeb63
23 changes: 23 additions & 0 deletions include/ilang/ilang++.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#endif // SMTSWITCH_INTERFACE

#include <ilang/config.h>
#include <ilang/rtl_verify.h>

/// \namespace ilang
/// Defines the core data structure and APIs for constructing and storing ILA.
Expand Down Expand Up @@ -745,6 +746,28 @@ class IlaZ3Unroller {

}; // class IlaZ3Unroller


/// \brief The wrapper of Rtl verification target generator
class IlaVerilogRefinemetChecker {

public:
// ------------------------- CONSTRUCTOR/DESTRUCTOR ----------------------- //
/// Default constructor
IlaVerilogRefinemetChecker(
const Ila& ila,
const std::vector<std::string>& implementation_include_path,
const std::vector<std::string>& implementation_srcs,
const std::string& implementation_top_module,
const std::string& refinement_variable_mapping,
const std::string& refinement_conditions,
const std::string& output_path,
ModelCheckerSelection backend,
const RtlVerifyConfig& vtg_config = RtlVerifyConfig() );
/// Default virtual destructor.
~IlaVerilogRefinemetChecker() {};

}; // class RtlVerifier

#ifdef SMTSWITCH_INTERFACE

/// \brief Reset the solver and generate the SMT Term (for smt-switch).
Expand Down
38 changes: 38 additions & 0 deletions include/ilang/rfmap-in/rfexpr_shortcut.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/// \file rfexpr_shortcut.h Refinement map expression
/// construction
/// Hongce Zhang (zhanghongce@126.com)

#ifndef ILANG_RFEXPR_SHORTCUT_H__
#define ILANG_RFEXPR_SHORTCUT_H__

#include <ilang/rfmap-in/rfmap_typecheck.h>

namespace ilang {

rfmap::RfExpr rfmap_reduce_or(const rfmap::RfExpr& in);
rfmap::RfExpr rfmap_imply(const rfmap::RfExpr& l, const rfmap::RfExpr& r);
rfmap::RfExpr rfmap_and(const rfmap::RfExpr& l, const rfmap::RfExpr& r);
rfmap::RfExpr rfmap_or(const rfmap::RfExpr& l, const rfmap::RfExpr& r);
rfmap::RfExpr rfmap_and(const std::vector<rfmap::RfExpr>& v);
rfmap::RfExpr rfmap_or(const std::vector<rfmap::RfExpr>& v);

rfmap::RfExpr rfmap_ite(const rfmap::RfExpr& c, const rfmap::RfExpr& l,
const rfmap::RfExpr& r);

rfmap::RfExpr rfmap_eq(const rfmap::RfExpr& l, const rfmap::RfExpr& r);
rfmap::RfExpr rfmap_le(const rfmap::RfExpr& l, const rfmap::RfExpr& r);

rfmap::RfExpr rfmap_not(const rfmap::RfExpr& l);

rfmap::RfExpr rfmap_true();
rfmap::RfExpr rfmap_false();
rfmap::RfExpr rfmap_const(unsigned b, unsigned w, unsigned v);
/// if it is RTL. or ILA. then will use MakeVar
/// otherwise will use MakeSpecial
/// will not determine its type
/// ReplExpr will determine the type
rfmap::RfExpr rfmap_var(const std::string& v);

} // namespace ilang

#endif // ILANG_RFEXPR_SHORTCUT_H__
58 changes: 58 additions & 0 deletions include/ilang/rfmap-in/rfexpr_to_smt.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/// \file rfexpr_to_smt.cc Refinement map to smt-lib2
/// Hongce Zhang (hongcez@princeton.edu)

#ifndef ILANG_RFEXPR_TO_SMT_H__
#define ILANG_RFEXPR_TO_SMT_H__

#include <ilang/rfmap-in/rfmap_typecheck.h>

namespace ilang {
namespace rfmap {

struct SmtType : public RfMapVarType {
bool bool_or_bv;

SmtType() : RfMapVarType(1), bool_or_bv(true) {}
SmtType(unsigned w) : RfMapVarType(w), bool_or_bv(false) {}
SmtType(unsigned a, unsigned d) : RfMapVarType(a, d), bool_or_bv(false) {}
SmtType(const RfMapVarType& r, bool request_bool)
: RfMapVarType(r), bool_or_bv(request_bool) {}

bool is_bool() const { return bool_or_bv && (RfMapVarType::is_bv()); }
bool is_bv() const { return (!bool_or_bv) && (RfMapVarType::is_bv()); }
bool operator==(const SmtType& r) const {
if (bool_or_bv != r.bool_or_bv)
return false;
if (type != r.type)
return false;
if (type == TYPE::BV)
return width == r.width;
if (type == TYPE::MEM)
return data_width == r.data_width && addr_width == r.addr_width;
return false; // unknown type , unknown
} // operator=

std::string type_to_smt2() const;

}; // SmtType

struct RfExpr2Smt {

public:
static std::string to_smt2(const RfExpr& in, SmtType expected_type);

protected:
// helper function
static std::string
to_smt2_const(const std::shared_ptr<verilog_expr::VExprAstConstant>& in,
SmtType expected_type);
static std::string
to_smt2_var(const std::shared_ptr<verilog_expr::VExprAstVar>& in,
SmtType expected_type);

}; // struct RfExpr2Smt

} // namespace rfmap
} // namespace ilang

#endif // ILANG_RFEXPR_TO_SMT_H__

0 comments on commit 951039b

Please sign in to comment.