Updates from clangformat

Signed-off-by: Clifford Wolf <clifford@clifford.at>
This commit is contained in:
Clifford Wolf 2018-06-17 16:14:27 +02:00
parent 19b665177e
commit 105cde328b
2 changed files with 25 additions and 22 deletions

View File

@ -82,19 +82,24 @@ Chip::Chip(ChipArgs args) : args(args)
{
#ifdef ICE40_HX1K_ONLY
if (args.type == ChipArgs::HX1K) {
chip_info = reinterpret_cast<RelPtr<ChipInfoPOD>*>(chipdb_blob_1k)->get();
chip_info =
reinterpret_cast<RelPtr<ChipInfoPOD> *>(chipdb_blob_1k)->get();
} else {
log_error("Unsupported iCE40 chip type.\n");
}
#else
if (args.type == ChipArgs::LP384) {
chip_info = reinterpret_cast<RelPtr<ChipInfoPOD>*>(chipdb_blob_384)->get();
chip_info =
reinterpret_cast<RelPtr<ChipInfoPOD> *>(chipdb_blob_384)->get();
} else if (args.type == ChipArgs::LP1K || args.type == ChipArgs::HX1K) {
chip_info = reinterpret_cast<RelPtr<ChipInfoPOD>*>(chipdb_blob_1k)->get();
chip_info =
reinterpret_cast<RelPtr<ChipInfoPOD> *>(chipdb_blob_1k)->get();
} else if (args.type == ChipArgs::UP5K) {
chip_info = reinterpret_cast<RelPtr<ChipInfoPOD>*>(chipdb_blob_5k)->get();
chip_info =
reinterpret_cast<RelPtr<ChipInfoPOD> *>(chipdb_blob_5k)->get();
} else if (args.type == ChipArgs::LP8K || args.type == ChipArgs::HX8K) {
chip_info = reinterpret_cast<RelPtr<ChipInfoPOD>*>(chipdb_blob_8k)->get();
chip_info =
reinterpret_cast<RelPtr<ChipInfoPOD> *>(chipdb_blob_8k)->get();
} else {
log_error("Unsupported iCE40 chip type.\n");
}
@ -190,7 +195,8 @@ WireId Chip::getWireBelPin(BelId bel, PortPin pin) const
assert(bel != BelId());
int num_bel_wires = chip_info->bel_data[bel.index].num_bel_wires;
const BelWirePOD *bel_wires = chip_info->bel_data[bel.index].bel_wires.get();
const BelWirePOD *bel_wires =
chip_info->bel_data[bel.index].bel_wires.get();
for (int i = 0; i < num_bel_wires; i++)
if (bel_wires[i].port == pin) {

View File

@ -74,29 +74,26 @@ PortPin portPinFromId(IdString id);
/**** Everything in this section must be kept in sync with chipdb.py ****/
template <typename T>
struct RelPtr {
template <typename T> struct RelPtr
{
int32_t offset;
// void set(const T *ptr) {
// offset = reinterpret_cast<const char*>(ptr) - reinterpret_cast<const char*>(this);
// offset = reinterpret_cast<const char*>(ptr) -
// reinterpret_cast<const char*>(this);
// }
const T*get() const {
return reinterpret_cast<const T*>(reinterpret_cast<const char*>(this) + offset);
const T *get() const
{
return reinterpret_cast<const T *>(
reinterpret_cast<const char *>(this) + offset);
}
const T&operator[](size_t index) const {
return get()[index];
}
const T &operator[](size_t index) const { return get()[index]; }
const T&operator*() const {
return *(get());
}
const T &operator*() const { return *(get()); }
const T*operator->() const {
return get();
}
const T *operator->() const { return get(); }
};
struct BelWirePOD
@ -566,8 +563,8 @@ struct Chip
BelPinRange range;
assert(wire != WireId());
range.b.ptr = chip_info->wire_data[wire.index].bels_downhill.get();
range.e.ptr =
range.b.ptr + chip_info->wire_data[wire.index].num_bels_downhill;
range.e.ptr = range.b.ptr +
chip_info->wire_data[wire.index].num_bels_downhill;
return range;
}