diff --git a/common/bits.cc b/common/bits.cc index 36c7539a..b20c2e86 100644 --- a/common/bits.cc +++ b/common/bits.cc @@ -19,10 +19,13 @@ */ #include "bits.h" + #include #include -namespace nextpnr { +#include "log.h" + +NEXTPNR_NAMESPACE_BEGIN int Bits::generic_popcount(unsigned int v) { @@ -37,7 +40,7 @@ int Bits::generic_popcount(unsigned int v) int Bits::generic_ctz(unsigned int x) { if (x == 0) { - throw std::runtime_error("Cannot call ctz with arg = 0"); + log_error("Cannot call ctz with arg = 0"); } for (size_t i = 0; i < std::numeric_limits::digits; ++i) { @@ -47,7 +50,7 @@ int Bits::generic_ctz(unsigned int x) } // Unreachable! - throw std::runtime_error("Unreachable!"); + log_error("Unreachable!"); } -}; // namespace nextpnr +NEXTPNR_NAMESPACE_END diff --git a/common/bits.h b/common/bits.h index d1598a8e..1d6bb8be 100644 --- a/common/bits.h +++ b/common/bits.h @@ -37,9 +37,9 @@ #pragma intrinsic(_BitScanForward, _BitScanReverse, __popcnt) #endif -// Uses plain nextpnr namespace to avoid header inclusion nightmare that is -// "nextpnr.h". -namespace nextpnr { +#include "nextpnr_namespaces.h" + +NEXTPNR_NAMESPACE_BEGIN struct Bits { @@ -71,6 +71,6 @@ struct Bits } }; -}; // namespace nextpnr +NEXTPNR_NAMESPACE_END #endif /* BITS_H */ diff --git a/common/dynamic_bitarray.h b/common/dynamic_bitarray.h index 2b5ab2bc..605d59d5 100644 --- a/common/dynamic_bitarray.h +++ b/common/dynamic_bitarray.h @@ -17,18 +17,19 @@ * */ +#ifndef DYNAMIC_BITARRAY_H +#define DYNAMIC_BITARRAY_H + #include #include #include +#include "nextpnr_namespaces.h" + +NEXTPNR_NAMESPACE_BEGIN + // This class implements a simple dynamic bitarray, backed by some resizable // random access storage. The default is to use a std::vector. - -#ifndef DYNAMIC_BITARRAY_H -#define DYNAMIC_BITARRAY_H - -namespace nextpnr { - template > class DynamicBitarray { public: @@ -76,6 +77,6 @@ template > class DynamicBitarray Storage storage; }; -}; // namespace nextpnr +NEXTPNR_NAMESPACE_END #endif /* DYNAMIC_BITARRAY_H */ diff --git a/common/exclusive_state_groups.h b/common/exclusive_state_groups.h index cd3f0bfa..68ce7c4e 100644 --- a/common/exclusive_state_groups.h +++ b/common/exclusive_state_groups.h @@ -111,10 +111,10 @@ template lock(ctx); + ScopeLock lock(ctx); size_t placed_cells = 0; std::vector autoplaced; diff --git a/common/placer_heap.cc b/common/placer_heap.cc index 3ee8503c..97c9c4e5 100644 --- a/common/placer_heap.cc +++ b/common/placer_heap.cc @@ -151,7 +151,7 @@ class HeAPPlacer { auto startt = std::chrono::high_resolution_clock::now(); - nextpnr::ScopeLock lock(ctx); + ScopeLock lock(ctx); place_constraints(); build_fast_bels(); seed_placement(); diff --git a/common/router1.cc b/common/router1.cc index bffbc9f9..30ebc113 100644 --- a/common/router1.cc +++ b/common/router1.cc @@ -806,7 +806,7 @@ bool router1(Context *ctx, const Router1Cfg &cfg) try { log_break(); log_info("Routing..\n"); - nextpnr::ScopeLock lock(ctx); + ScopeLock lock(ctx); auto rstart = std::chrono::high_resolution_clock::now(); log_info("Setting up routing queue.\n"); diff --git a/common/router2.cc b/common/router2.cc index ccce5205..27f8ec0d 100644 --- a/common/router2.cc +++ b/common/router2.cc @@ -1218,7 +1218,7 @@ struct Router2 ThreadContext st; int iter = 1; - nextpnr::ScopeLock lock(ctx); + ScopeLock lock(ctx); for (size_t i = 0; i < nets_by_udata.size(); i++) route_queue.push_back(i); diff --git a/common/scope_lock.h b/common/scope_lock.h index 7b6c9dcd..2f0f767c 100644 --- a/common/scope_lock.h +++ b/common/scope_lock.h @@ -22,7 +22,9 @@ #include -namespace nextpnr { +#include "nextpnr_namespaces.h" + +NEXTPNR_NAMESPACE_BEGIN // Provides a simple RAII locking object. ScopeLock takes a lock when // constructed, and releases the lock on destruction or if "unlock_early" is @@ -60,6 +62,6 @@ template class ScopeLock bool locked_; }; -}; // namespace nextpnr +NEXTPNR_NAMESPACE_END #endif /* SCOPE_LOCK_H */ diff --git a/fpga_interchange/arch.cc b/fpga_interchange/arch.cc index e9dee580..3839f579 100644 --- a/fpga_interchange/arch.cc +++ b/fpga_interchange/arch.cc @@ -1267,7 +1267,7 @@ void Arch::report_invalid_bel(BelId bel, CellInfo *cell) const nameOfBel(bel), mapping); } -void Arch::read_lut_equation(nextpnr::DynamicBitarray<> *equation, const Property &equation_parameter) const +void Arch::read_lut_equation(DynamicBitarray<> *equation, const Property &equation_parameter) const { equation->fill(false); std::string eq_str = equation_parameter.as_string(); diff --git a/fpga_interchange/arch.h b/fpga_interchange/arch.h index a171ba55..05bc1a94 100644 --- a/fpga_interchange/arch.h +++ b/fpga_interchange/arch.h @@ -1737,7 +1737,7 @@ struct Arch : ArchAPI std::regex raw_bin_constant; std::regex verilog_bin_constant; std::regex verilog_hex_constant; - void read_lut_equation(nextpnr::DynamicBitarray<> *equation, const Property &equation_parameter) const; + void read_lut_equation(DynamicBitarray<> *equation, const Property &equation_parameter) const; bool route_vcc_to_unused_lut_pins(); }; diff --git a/fpga_interchange/luts.cc b/fpga_interchange/luts.cc index 49f934a4..6e24847f 100644 --- a/fpga_interchange/luts.cc +++ b/fpga_interchange/luts.cc @@ -25,7 +25,7 @@ NEXTPNR_NAMESPACE_BEGIN bool rotate_and_merge_lut_equation(std::vector *result, const LutBel &lut_bel, - const nextpnr::DynamicBitarray<> &old_equation, const std::vector &pin_map, + const DynamicBitarray<> &old_equation, const std::vector &pin_map, uint32_t used_pins) { // pin_map maps pin indicies from the old pin to the new pin. diff --git a/fpga_interchange/luts.h b/fpga_interchange/luts.h index 333df36e..3500c9d3 100644 --- a/fpga_interchange/luts.h +++ b/fpga_interchange/luts.h @@ -46,7 +46,7 @@ struct LutCell std::vector pins; std::unordered_set lut_pins; std::unordered_set vcc_pins; - nextpnr::DynamicBitarray<> equation; + DynamicBitarray<> equation; }; struct LutBel @@ -94,7 +94,7 @@ struct LutMapper // // If a conflict arises, return false and result is in an indeterminate state. bool rotate_and_merge_lut_equation(std::vector *result, const LutBel &lut_bel, - const nextpnr::DynamicBitarray<> &old_equation, const std::vector &pin_map, + const DynamicBitarray<> &old_equation, const std::vector &pin_map, uint32_t used_pins); NEXTPNR_NAMESPACE_END diff --git a/tests b/tests index 34c51144..a751e0d9 160000 --- a/tests +++ b/tests @@ -1 +1 @@ -Subproject commit 34c511444eff51291fa732369e434ff687de310f +Subproject commit a751e0d9081477e33c620b5224ccd2026f2fa0cf