Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions bazel/bzl_fmt_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@ TOOL="$(cd "$(dirname "$1")" && pwd)/$(basename "$1")"
[ -L MODULE.bazel ] || { echo "MODULE.bazel missing from runfiles" >&2; exit 1; }
WORKSPACE="$(dirname "$(readlink MODULE.bazel)")"
cd "$WORKSPACE"
# `git ls-files` skips submodule contents (src/sta, third-party/abc).
# `-c submodule.recurse=false` keeps git ls-files from descending into
# submodules (src/sta, third-party/abc, third-party/slang-elab and the
# fmt sub-submodule nested in it) — we never want to reformat files
# owned by another repo. The override is needed because CI sets
# submodule.recurse=true globally.
# Explicit -mode=check -lint=off separates format errors from lint warnings,
# and overrides the repo-root .buildifier.json default (mode: fix).
git ls-files '*.bazel' '*.bzl' '**/BUILD' 'BUILD' '**/WORKSPACE' 'WORKSPACE' -z \
git -c submodule.recurse=false ls-files \
'*.bazel' '*.bzl' '**/BUILD' 'BUILD' '**/WORKSPACE' 'WORKSPACE' -z \
| xargs -0 "$TOOL" -mode=check -lint=off
10 changes: 7 additions & 3 deletions bazel/bzl_lint_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ TOOL="$(cd "$(dirname "$1")" && pwd)/$(basename "$1")"
[ -L MODULE.bazel ] || { echo "MODULE.bazel missing from runfiles" >&2; exit 1; }
WORKSPACE="$(dirname "$(readlink MODULE.bazel)")"
cd "$WORKSPACE"
# `git ls-files` skips submodule contents (src/sta, third-party/abc), so
# we never try to reformat files owned by another repo.
# `-c submodule.recurse=false` keeps git ls-files from descending into
# submodules (src/sta, third-party/abc, third-party/slang-elab and the
# fmt sub-submodule nested in it) — we never want to reformat files
# owned by another repo. The override is needed because CI sets
# submodule.recurse=true globally.
# Explicit -mode=check overrides the repo-root .buildifier.json default.
git ls-files '*.bazel' '*.bzl' '**/BUILD' 'BUILD' '**/WORKSPACE' 'WORKSPACE' -z \
git -c submodule.recurse=false ls-files \
'*.bazel' '*.bzl' '**/BUILD' 'BUILD' '**/WORKSPACE' 'WORKSPACE' -z \
| xargs -0 "$TOOL" -mode=check -lint=warn
10 changes: 7 additions & 3 deletions bazel/bzl_tidy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
set -euo pipefail
TOOL="$(cd "$(dirname "$1")" && pwd)/$(basename "$1")"
cd "${BUILD_WORKSPACE_DIRECTORY:-$PWD}"
# `git ls-files` skips submodule contents (src/sta, third-party/abc),
# so we never rewrite files owned by another repo.
git ls-files '*.bazel' '*.bzl' '**/BUILD' 'BUILD' '**/WORKSPACE' 'WORKSPACE' -z \
# `-c submodule.recurse=false` keeps git ls-files from descending into
# submodules (src/sta, third-party/abc, third-party/slang-elab and the
# fmt sub-submodule nested in it) — we never want to rewrite files
# owned by another repo. The override is needed because CI sets
# submodule.recurse=true globally.
git -c submodule.recurse=false ls-files \
'*.bazel' '*.bzl' '**/BUILD' 'BUILD' '**/WORKSPACE' 'WORKSPACE' -z \
| xargs -0 "$TOOL" -mode=fix -lint=fix
2 changes: 0 additions & 2 deletions src/syn/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ cc_library(
srcs = [
"src/flow/abc.cc",
"src/flow/bitblast.cc",
"src/flow/bitblast.h",
"src/flow/combinational_mapper.cc",
"src/flow/combinational_mapper.h",
"src/flow/combinational_mapper_npn.cc",
"src/flow/combinational_mapper_npn.h",
"src/flow/constant_fold.cc",
Expand Down
5 changes: 5 additions & 0 deletions src/syn/include/syn/synthesis.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,15 @@ class Synthesis : public sta::dbStaState
// Free-function entry points re-declared here so tests don't need to
// pull in the private flow/ headers. The Synthesis methods of the same
// names forward to these.
void bitblast(Graph& g, bool blast_arith = true);
void mapSequentials(Graph& g,
sta::Network* network,
utl::Logger* logger,
const Synthesis& syn);
void mapCombinationals(Graph& g,
sta::Network* network,
utl::Logger* logger,
const Synthesis& syn);
void abcRoundtrip(Graph& g, const std::string& commands, utl::Logger* logger);
void livenessOpt(Graph& g,
utl::Logger* logger,
Expand Down
2 changes: 1 addition & 1 deletion src/syn/src/flow/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ add_library(syn_flow
)

set(_syn_flow_stage ${CMAKE_CURRENT_BINARY_DIR}/include/flow)
foreach(_h bitblast.h combinational_mapper.h combinational_mapper_npn.h export.h import.h opt_gatefusion.h)
foreach(_h combinational_mapper_npn.h export.h import.h opt_gatefusion.h)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${_h} ${_syn_flow_stage}/${_h} COPYONLY)
endforeach()

Expand Down
3 changes: 1 addition & 2 deletions src/syn/src/flow/bitblast.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
// Bitblast pass: converts arithmetic operations and muxes
// to And/Andnot/Or/Xor/Not gates.

#include "flow/bitblast.h"

#include <algorithm>
#include <cassert>
#include <cstddef>
Expand All @@ -22,6 +20,7 @@
#include "syn/ir/Graph.h"
#include "syn/ir/Instance.h"
#include "syn/ir/Net.h"
#include "syn/synthesis.h"

namespace syn {

Expand Down
12 changes: 0 additions & 12 deletions src/syn/src/flow/bitblast.h

This file was deleted.

6 changes: 2 additions & 4 deletions src/syn/src/flow/combinational_mapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
// standard cells from a liberty library using cut-based technology
// mapping with NPN canonicalization.

#include "flow/combinational_mapper.h"

#include <algorithm>
#include <cassert>
#include <cmath>
Expand Down Expand Up @@ -677,8 +675,8 @@ void Mapping::prepareMatches(const int npriority_cuts,
int psSlot = 0;
ClassMatch* matchBuf = allocMatches(nmatches_max);

for (int i = -1; i < cache[n1->fid].ps.size(); i++) {
for (int j = -1; j < cache[n2->fid].ps.size(); j++) {
for (int i = -1; i < (int) cache[n1->fid].ps.size(); i++) {
for (int j = -1; j < (int) cache[n2->fid].ps.size(); j++) {
Comment on lines +678 to +679
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops - sorry about that

Net* n1Cut = ((i == -1) ? t1 : cache[n1->fid].ps[i].cut);
Net* n2Cut = ((j == -1) ? t2 : cache[n2->fid].ps[j].cut);
int n1CutLen = (i == -1) ? 1 : cutLen(n1Cut);
Expand Down
24 changes: 0 additions & 24 deletions src/syn/src/flow/combinational_mapper.h

This file was deleted.

8 changes: 7 additions & 1 deletion src/syn/src/ir/Parse.cc
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,13 @@ class Parser
error("unknown cell keyword: " + keyword);
}

(void) id;
const uint32_t expected_slots = std::max(width, 1u);
if (g->tableSize() != id + expected_slots) {
error("'" + keyword + "' declared output width " + std::to_string(width)
+ " but produced " + std::to_string(g->tableSize() - id) + " slot"
+ (g->tableSize() - id == 1 ? "" : "s"));
}
Comment on lines +542 to +547
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The calculation g->tableSize() - id is repeated multiple times in this block. Storing this value in a local variable (e.g., actual_slots) would improve code readability and maintainability by making the validation logic more explicit and avoiding redundant calculations.

Suggested change
const uint32_t expected_slots = std::max(width, 1u);
if (g->tableSize() != id + expected_slots) {
error("'" + keyword + "' declared output width " + std::to_string(width)
+ " but produced " + std::to_string(g->tableSize() - id) + " slot"
+ (g->tableSize() - id == 1 ? "" : "s"));
}
const uint32_t actual_slots = g->tableSize() - id;
const uint32_t expected_slots = std::max(width, 1u);
if (actual_slots != expected_slots) {
error("'" + keyword + "' declared output width " + std::to_string(width)
+ " but produced " + std::to_string(actual_slots) + " slot"
+ (actual_slots == 1 ? "" : "s"));
}


expectNewline();
}

Expand Down
2 changes: 0 additions & 2 deletions src/syn/src/synthesis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

#include "db_sta/dbSta.hh"
#include "elab/driver.h"
#include "flow/bitblast.h"
#include "flow/combinational_mapper.h"
#include "flow/constant_fold.h"
#include "flow/export.h"
#include "flow/import.h"
Expand Down
16 changes: 16 additions & 0 deletions src/syn/test/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,22 @@ cc_test(
],
)

cc_test(
name = "cm_test",
srcs = [
"cm_test.cc",
"equivalence_check.h",
],
data = ["cm_test_cells.lib"],
features = ["-layering_check"],
deps = [
"//src/syn",
"//src/syn/src/ir",
"//src/tst",
"@googletest//:gtest",
],
)

cc_test(
name = "abc_test",
srcs = ["abc_test.cc"],
Expand Down
2 changes: 1 addition & 1 deletion src/syn/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ target_link_libraries(liveness_test GTest::gtest syn_flow syn_ir utl_lib)
gtest_discover_tests(liveness_test WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
add_dependencies(build_and_test liveness_test)

foreach(_t abc_test sm_test)
foreach(_t abc_test sm_test cm_test)
add_executable(${_t} ${_t}.cc)
target_link_libraries(${_t} ${_syn_test_libs} syn_lib syn_flow syn_ir tst)
gtest_discover_tests(${_t} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
Expand Down
3 changes: 1 addition & 2 deletions src/syn/test/bitblast_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "syn/ir/Graph.h"
#include "syn/ir/Instance.h"
#include "syn/ir/Net.h"
#include "syn/synthesis.h"

int main(int argc, char** argv)
{
Expand All @@ -18,8 +19,6 @@ int main(int argc, char** argv)

namespace syn {

void bitblast(Graph& g, bool blast_arith = true);

// Rule 11 (Substitution): a & ~(a & b) → a & ~b (= andnot)
TEST(BitblastTest, Rule11_Substitution)
{
Expand Down
Loading
Loading