Use NEXTPNR_NAMESPACE macro's now that headers are seperated.

Signed-off-by: Keith Rothman <537074+litghost@users.noreply.github.com>
This commit is contained in:
Keith Rothman 2021-03-15 10:25:46 -07:00 committed by gatecat
parent a8e35062c6
commit 351ca3b5ea
14 changed files with 35 additions and 29 deletions

View File

@ -19,10 +19,13 @@
*/
#include "bits.h"
#include <limits>
#include <stdexcept>
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<unsigned int>::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

View File

@ -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 */

View File

@ -17,18 +17,19 @@
*
*/
#ifndef DYNAMIC_BITARRAY_H
#define DYNAMIC_BITARRAY_H
#include <cstdint>
#include <limits>
#include <vector>
#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<uint8_t>.
#ifndef DYNAMIC_BITARRAY_H
#define DYNAMIC_BITARRAY_H
namespace nextpnr {
template <typename Storage = std::vector<uint8_t>> class DynamicBitarray
{
public:
@ -76,6 +77,6 @@ template <typename Storage = std::vector<uint8_t>> class DynamicBitarray
Storage storage;
};
}; // namespace nextpnr
NEXTPNR_NAMESPACE_END
#endif /* DYNAMIC_BITARRAY_H */

View File

@ -111,10 +111,10 @@ template <size_t StateCount, typename StateType = int8_t, typename CountType = u
// Check whether the state group is now unselected or satified.
auto value = selected_states.to_ulong();
auto number_selected = nextpnr::Bits::popcount(value);
auto number_selected = Bits::popcount(value);
if (number_selected == 1) {
// Group is no longer overconstrained.
state = nextpnr::Bits::ctz(value);
state = Bits::ctz(value);
NPNR_ASSERT(selected_states[state]);
} else if (number_selected == 0) {
// Group is unselected.

View File

@ -144,7 +144,7 @@ class SAPlacer
{
log_break();
nextpnr::ScopeLock<Context> lock(ctx);
ScopeLock<Context> lock(ctx);
size_t placed_cells = 0;
std::vector<CellInfo *> autoplaced;

View File

@ -151,7 +151,7 @@ class HeAPPlacer
{
auto startt = std::chrono::high_resolution_clock::now();
nextpnr::ScopeLock<Context> lock(ctx);
ScopeLock<Context> lock(ctx);
place_constraints();
build_fast_bels();
seed_placement();

View File

@ -806,7 +806,7 @@ bool router1(Context *ctx, const Router1Cfg &cfg)
try {
log_break();
log_info("Routing..\n");
nextpnr::ScopeLock<Context> lock(ctx);
ScopeLock<Context> lock(ctx);
auto rstart = std::chrono::high_resolution_clock::now();
log_info("Setting up routing queue.\n");

View File

@ -1218,7 +1218,7 @@ struct Router2
ThreadContext st;
int iter = 1;
nextpnr::ScopeLock<Context> lock(ctx);
ScopeLock<Context> lock(ctx);
for (size_t i = 0; i < nets_by_udata.size(); i++)
route_queue.push_back(i);

View File

@ -22,7 +22,9 @@
#include <stdexcept>
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 <typename LockingObject> class ScopeLock
bool locked_;
};
}; // namespace nextpnr
NEXTPNR_NAMESPACE_END
#endif /* SCOPE_LOCK_H */

View File

@ -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();

View File

@ -1737,7 +1737,7 @@ struct Arch : ArchAPI<ArchRanges>
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();
};

View File

@ -25,7 +25,7 @@
NEXTPNR_NAMESPACE_BEGIN
bool rotate_and_merge_lut_equation(std::vector<LogicLevel> *result, const LutBel &lut_bel,
const nextpnr::DynamicBitarray<> &old_equation, const std::vector<int32_t> &pin_map,
const DynamicBitarray<> &old_equation, const std::vector<int32_t> &pin_map,
uint32_t used_pins)
{
// pin_map maps pin indicies from the old pin to the new pin.

View File

@ -46,7 +46,7 @@ struct LutCell
std::vector<IdString> pins;
std::unordered_set<IdString> lut_pins;
std::unordered_set<IdString> 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<LogicLevel> *result, const LutBel &lut_bel,
const nextpnr::DynamicBitarray<> &old_equation, const std::vector<size_t> &pin_map,
const DynamicBitarray<> &old_equation, const std::vector<size_t> &pin_map,
uint32_t used_pins);
NEXTPNR_NAMESPACE_END

2
tests

@ -1 +1 @@
Subproject commit 34c511444eff51291fa732369e434ff687de310f
Subproject commit a751e0d9081477e33c620b5224ccd2026f2fa0cf