Skip to content

Commit dc09770

Browse files
nanocohxtofalex
andauthored
Scope Extraction (#71)
* verilog support * updates * Update regress.yml * Update regress.yml * Update regress.yml * Update regress.yml * snl to naja_if * snl to naja_if * unit test fix * Update README.md * Update usage instructions for kepler_formal * fix usage print * Update README to include Verilog support * Add example section to README Added an example section with a link to the repository. * Update README.md * Update Verilog command with pre-edited file * Update README.md * yaml support * update testing * update testing * yaml dep * spdlog dep * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * test update * update logs * Update README.md * Fix README formatting for kepler_formal commands * Update README.md * Update README with config file usage for kepler_formal Added command to run kepler_formal with a config file. * Update README.md * Update regress.yml * regress update * wf update * wf update * fix wf + const ref * yaml support (#25) * yaml support * update testing * update testing * yaml dep * spdlog dep * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * test update * update logs * Update README.md * Update README with config file usage for kepler_formal Added command to run kepler_formal with a config file. * Update README.md * Update regress.yml * regress update * wf update * wf update * fix wf + const ref * Update README.md * sync (#27) * yaml support (#25) * yaml support * update testing * update testing * yaml dep * spdlog dep * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * test update * update logs * Update README.md * Update README with config file usage for kepler_formal Added command to run kepler_formal with a config file. * Update README.md * Update regress.yml * regress update * wf update * wf update * fix wf + const ref * Update README.md * ct * Update README.md * ct (#28) * yaml support * update testing * update testing * yaml dep * spdlog dep * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * test update * update logs * Update README.md * Update README with config file usage for kepler_formal Added command to run kepler_formal with a config file. * Update README.md * Update regress.yml * regress update * wf update * wf update * fix wf + const ref * sync (#27) * yaml support (#25) * yaml support * update testing * update testing * yaml dep * spdlog dep * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * test update * update logs * Update README.md * Update README with config file usage for kepler_formal Added command to run kepler_formal with a config file. * Update README.md * Update regress.yml * regress update * wf update * wf update * fix wf + const ref * Update README.md * ct * Update README.md * tests under option * sync (#29) * ct (#28) * yaml support * update testing * update testing * yaml dep * spdlog dep * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * test update * update logs * Update README.md * Update README with config file usage for kepler_formal Added command to run kepler_formal with a config file. * Update README.md * Update regress.yml * regress update * wf update * wf update * fix wf + const ref * sync (#27) * yaml support (#25) * yaml support * update testing * update testing * yaml dep * spdlog dep * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * test update * update logs * Update README.md * Update README with config file usage for kepler_formal Added command to run kepler_formal with a config file. * Update README.md * Update regress.yml * regress update * wf update * wf update * fix wf + const ref * Update README.md * ct * Update README.md * tests under option --------- Co-authored-by: xtof <christophe.alexandre@keplertech.io> * prints * remove prints * sync (#30) * ct (#28) * yaml support * update testing * update testing * yaml dep * spdlog dep * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * test update * update logs * Update README.md * Update README with config file usage for kepler_formal Added command to run kepler_formal with a config file. * Update README.md * Update regress.yml * regress update * wf update * wf update * fix wf + const ref * sync (#27) * yaml support (#25) * yaml support * update testing * update testing * yaml dep * spdlog dep * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * test update * update logs * Update README.md * Update README with config file usage for kepler_formal Added command to run kepler_formal with a config file. * Update README.md * Update regress.yml * regress update * wf update * wf update * fix wf + const ref * Update README.md * ct * Update README.md * tests under option --------- Co-authored-by: xtof <christophe.alexandre@keplertech.io> * sync (#33) * clean debug prints (#32) * yaml support * update testing * update testing * yaml dep * spdlog dep * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * test update * update logs * Update README.md * Update README with config file usage for kepler_formal Added command to run kepler_formal with a config file. * Update README.md * Update regress.yml * regress update * wf update * wf update * fix wf + const ref * sync (#27) * yaml support (#25) * yaml support * update testing * update testing * yaml dep * spdlog dep * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * test update * update logs * Update README.md * Update README with config file usage for kepler_formal Added command to run kepler_formal with a config file. * Update README.md * Update regress.yml * regress update * wf update * wf update * fix wf + const ref * Update README.md * ct * sync (#29) * ct (#28) * yaml support * update testing * update testing * yaml dep * spdlog dep * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * test update * update logs * Update README.md * Update README with config file usage for kepler_formal Added command to run kepler_formal with a config file. * Update README.md * Update regress.yml * regress update * wf update * wf update * fix wf + const ref * sync (#27) * yaml support (#25) * yaml support * update testing * update testing * yaml dep * spdlog dep * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * test update * update logs * Update README.md * Update README with config file usage for kepler_formal Added command to run kepler_formal with a config file. * Update README.md * Update regress.yml * regress update * wf update * wf update * fix wf + const ref * Update README.md * ct * Update README.md * tests under option --------- Co-authored-by: xtof <christophe.alexandre@keplertech.io> * prints * remove prints * sync (#30) * ct (#28) * yaml support * update testing * update testing * yaml dep * spdlog dep * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * test update * update logs * Update README.md * Update README with config file usage for kepler_formal Added command to run kepler_formal with a config file. * Update README.md * Update regress.yml * regress update * wf update * wf update * fix wf + const ref * sync (#27) * yaml support (#25) * yaml support * update testing * update testing * yaml dep * spdlog dep * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * test update * update logs * Update README.md * Update README with config file usage for kepler_formal Added command to run kepler_formal with a config file. * Update README.md * Update regress.yml * regress update * wf update * wf update * fix wf + const ref * Update README.md * ct * Update README.md * tests under option --------- Co-authored-by: xtof <christophe.alexandre@keplertech.io> --------- Co-authored-by: xtof <christophe.alexandre@keplertech.io> * ignore with warning unparallel observation points * Update regress.yml * Update README.md * Fix typos in README for kepler-formal commands * logfile command * update naja for gz liberty parser --------- Co-authored-by: xtof <christophe.alexandre@keplertech.io> * scope extraction * scope extraction * sync (#38) * clean debug prints (#32) * yaml support * update testing * update testing * yaml dep * spdlog dep * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * test update * update logs * Update README.md * Update README with config file usage for kepler_formal Added command to run kepler_formal with a config file. * Update README.md * Update regress.yml * regress update * wf update * wf update * fix wf + const ref * sync (#27) * yaml support (#25) * yaml support * update testing * update testing * yaml dep * spdlog dep * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * test update * update logs * Update README.md * Update README with config file usage for kepler_formal Added command to run kepler_formal with a config file. * Update README.md * Update regress.yml * regress update * wf update * wf update * fix wf + const ref * Update README.md * ct * sync (#29) * ct (#28) * yaml support * update testing * update testing * yaml dep * spdlog dep * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * test update * update logs * Update README.md * Update README with config file usage for kepler_formal Added command to run kepler_formal with a config file. * Update README.md * Update regress.yml * regress update * wf update * wf update * fix wf + const ref * sync (#27) * yaml support (#25) * yaml support * update testing * update testing * yaml dep * spdlog dep * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * test update * update logs * Update README.md * Update README with config file usage for kepler_formal Added command to run kepler_formal with a config file. * Update README.md * Update regress.yml * regress update * wf update * wf update * fix wf + const ref * Update README.md * ct * Update README.md * tests under option --------- Co-authored-by: xtof <christophe.alexandre@keplertech.io> * prints * remove prints * sync (#30) * ct (#28) * yaml support * update testing * update testing * yaml dep * spdlog dep * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * test update * update logs * Update README.md * Update README with config file usage for kepler_formal Added command to run kepler_formal with a config file. * Update README.md * Update regress.yml * regress update * wf update * wf update * fix wf + const ref * sync (#27) * yaml support (#25) * yaml support * update testing * update testing * yaml dep * spdlog dep * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * test update * update logs * Update README.md * Update README with config file usage for kepler_formal Added command to run kepler_formal with a config file. * Update README.md * Update regress.yml * regress update * wf update * wf update * fix wf + const ref * Update README.md * ct * Update README.md * tests under option --------- Co-authored-by: xtof <christophe.alexandre@keplertech.io> --------- Co-authored-by: xtof <christophe.alexandre@keplertech.io> * ignore with warning unparallel observation points * Update regress.yml * Update README.md * Fix typos in README for kepler-formal commands * logfile command * fix * Fixes (#36) * update naja for gz liberty parser * fix (#35) * Update README.md * Update Ubuntu installation instructions in README Added additional dependencies for installation on Ubuntu. --------- Co-authored-by: xtof <christophe.alexandre@keplertech.io> * Rename CmakeLists.txt to CMakeLists.txt * cleaning * updates * cov * cov * clean scopes * revert changes to example files * revert changes to example files * revert changes to example files * full scope extraction flow * fixes * fixes * fix * fix * comment * mt + fix + under a switch * update (#63) * cov (#60) * fix * gitignore for build (#62) * fix (#61) * Add .gitignore for build * Add .gitignore for build * testing se * testing se * merge * unify work for logic cone * fixes --------- Co-authored-by: xtof <christophe.alexandre@keplertech.io>
1 parent c26508e commit dc09770

19 files changed

Lines changed: 932 additions & 90 deletions
2.95 MB
Binary file not shown.
36.5 KB
Binary file not shown.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
################################################################################
2+
# Fri Jan 2 15:15:16 2026
3+
# SNL manifest
4+
# naja version: 0.3.2
5+
# Git hash: 220af8e
6+
################################################################################
7+
V 0 1 0

src/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ add_subdirectory(bin)
55
add_subdirectory(formal)
66
add_subdirectory(strategies)
77
add_subdirectory(clauses)
8-
add_subdirectory(utils)
8+
add_subdirectory(utils)
9+
add_subdirectory(scope)

src/bin/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ target_link_libraries(kepler-formal
1111
naja_dnl
1212
naja_opt
1313
formal_strategies
14+
scope_extraction
1415
yaml-cpp
1516
${SPDLOG_TARGET}
1617
)

src/bin/KeplerFormal.cpp

Lines changed: 67 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "SNLVRLConstructor.h"
2424
#include "SNLVRLDumper.h"
2525
#include "SNLUtils.h"
26+
#include "ScopeExtraction.h"
2627

2728
static void print_usage(const char* prog) {
2829
std::printf(
@@ -43,7 +44,7 @@ static std::vector<std::string> yamlToVector(const YAML::Node& node) {
4344

4445
int main(int argc, char** argv) {
4546
using namespace std::chrono;
46-
enum class FormatType { VERILOG, SNL };
47+
enum class FormatType { VERILOG, NAJA_IF };
4748

4849
// Default values
4950
FormatType inputFormatType = FormatType::VERILOG;
@@ -62,6 +63,9 @@ int main(int argc, char** argv) {
6263

6364
std::string logFileName;
6465

66+
bool useScopes = false;
67+
bool cleanScopes = false;
68+
6569
for (int i = 1; i < argc; ++i) {
6670
std::string a = argv[i];
6771
if (a == "--config" || a == "-c") {
@@ -77,7 +81,7 @@ int main(int argc, char** argv) {
7781
if (cfg["format"] && cfg["format"].IsScalar()) {
7882
std::string fmt = cfg["format"].as<std::string>();
7983
if (fmt == "naja_if" || fmt == "naja-if" || fmt == "snl")
80-
inputFormatType = FormatType::SNL;
84+
inputFormatType = FormatType::NAJA_IF;
8185
else if (fmt == "verilog" || fmt == "v")
8286
inputFormatType = FormatType::VERILOG;
8387
else {
@@ -101,6 +105,16 @@ int main(int argc, char** argv) {
101105
if (cfg["log_file"] && cfg["log_file"].IsScalar()) {
102106
logFileName = cfg["log_file"].as<std::string>();
103107
}
108+
109+
// use_scopes
110+
if (cfg["use_scopes"] && cfg["use_scopes"].IsScalar()) {
111+
useScopes = cfg["use_scopes"].as<bool>();
112+
}
113+
114+
// clean_scopes
115+
if (cfg["clean_scopes"] && cfg["clean_scopes"].IsScalar()) {
116+
cleanScopes = cfg["clean_scopes"].as<bool>();
117+
}
104118

105119
usedConfig = true;
106120
} catch (const std::exception& e) {
@@ -121,7 +135,7 @@ int main(int argc, char** argv) {
121135

122136
std::string formatType = argv[1];
123137
if (formatType == "-naja_if" || formatType == "-naja-if") {
124-
inputFormatType = FormatType::SNL;
138+
inputFormatType = FormatType::NAJA_IF;
125139
} else if (formatType == "-verilog") {
126140
inputFormatType = FormatType::VERILOG;
127141
} else {
@@ -162,7 +176,7 @@ int main(int argc, char** argv) {
162176
spdlog::set_level(spdlog::level::info);
163177

164178
std::printf("KEPLER FORMAL: Run.\n");
165-
std::printf("Input format: %s\n", (inputFormatType == FormatType::SNL) ? "SNL" : "VERILOG");
179+
std::printf("Input format: %s\n", (inputFormatType == FormatType::NAJA_IF) ? "SNL" : "VERILOG");
166180
std::printf("Netlist 1: %s\n", inputPaths[0].c_str());
167181
std::printf("Netlist 2: %s\n", inputPaths[1].c_str());
168182
if (!libertyFiles.empty()) {
@@ -274,18 +288,56 @@ int main(int argc, char** argv) {
274288
// --------------------------------------------------------------------------
275289
// 4. Hand off to the rest of the editing/analysis workflow
276290
// --------------------------------------------------------------------------
277-
try {
278-
KEPLER_FORMAL::MiterStrategy MiterS(top0, top1, logFileName);
279-
if (MiterS.run()) {
280-
SPDLOG_INFO("No difference was found.");
281-
} else {
282-
SPDLOG_INFO("Difference was found. Please refer to the log(miter_log_x.txt) for details.");
291+
if (inputFormatType == FormatType::NAJA_IF && useScopes) {
292+
KEPLER_FORMAL::MiterStrategy MiterS(top0, top1);
293+
MiterS.init();
294+
ScopeExtraction extractor(top0, top1);
295+
extractor.collectVerificationScopes();
296+
if (cleanScopes) {
297+
extractor.cleanVerificationScopes(MiterS.getPIs0(), MiterS.getPIs1());
298+
}
299+
for (auto scopes : extractor.getScopesToVerify()) {
300+
SPDLOG_INFO("Looking at scope: {} ",
301+
scopes.first->getName().getString());
302+
// std::string scopeLogFile = (logFileName.empty() ? "kf_" : logFileName) + "_" +
303+
// scopes.first->getName().getString() + ".txt";
304+
try {
305+
KEPLER_FORMAL::MiterStrategy MiterScope(scopes.first, scopes.second, logFileName);
306+
MiterScope.init();
307+
if (MiterScope.run()) {
308+
SPDLOG_INFO("No difference was found for scope: {} , {}",
309+
scopes.first->getName().getString(),
310+
scopes.second->getName().getString());
311+
} else {
312+
SPDLOG_INFO("Difference was found for scope: {} , {}. Please refer to the log(miter_log_x.txt) for details.",
313+
scopes.first->getName().getString(),
314+
scopes.second->getName().getString());
315+
}
316+
} catch (const std::exception& e) {
317+
// LCOV_EXCL_START
318+
SPDLOG_ERROR("Workflow failed for scope: {} , {}: {}",
319+
scopes.first->getName().getString(),
320+
scopes.second->getName().getString(),
321+
e.what());
322+
return EXIT_FAILURE;
323+
// LCOV_EXCL_STOP
324+
}
325+
}
326+
} else {
327+
try {
328+
KEPLER_FORMAL::MiterStrategy MiterS(top0, top1, logFileName);
329+
MiterS.init();
330+
if (MiterS.run()) {
331+
SPDLOG_INFO("No difference was found.");
332+
} else {
333+
SPDLOG_INFO("Difference was found. Please refer to the log(miter_log_x.txt) for details.");
334+
}
335+
} catch (const std::exception& e) {
336+
// LCOV_EXCL_START
337+
SPDLOG_ERROR("Workflow failed: {}", e.what());
338+
return EXIT_FAILURE;
339+
// LCOV_EXCL_STOP
283340
}
284-
} catch (const std::exception& e) {
285-
// LCOV_EXCL_START
286-
SPDLOG_ERROR("Workflow failed: {}", e.what());
287-
return EXIT_FAILURE;
288-
// LCOV_EXCL_STOP
289341
}
290342

291343
return EXIT_SUCCESS;

src/scope/CMakeLists.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright 2024-2025 keplertech.io
2+
# SPDX-License-Identifier: GPL-3.0-only
3+
4+
cmake_minimum_required(VERSION 3.10)
5+
project(scope_extraction_lib)
6+
7+
set(CMAKE_CXX_STANDARD 20)
8+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
9+
10+
# Create a static library target
11+
add_library(scope_extraction STATIC
12+
ScopeExtraction.cpp
13+
)
14+
15+
# Make headers accessible to other targets
16+
target_include_directories(scope_extraction PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
17+
target_link_libraries(scope_extraction PUBLIC naja_nl naja_dnl naja_opt kepler_formal_utils)

0 commit comments

Comments
 (0)