diff options
author | Clifford Wolf <clifford@clifford.at> | 2018-06-17 13:32:38 +0200 |
---|---|---|
committer | Clifford Wolf <clifford@clifford.at> | 2018-06-17 13:32:38 +0200 |
commit | 84defd3fee71ab48c46fa1ba7c4acd49fba3cc5f (patch) | |
tree | 704b423a2e4232de7619e41ac2df7d7192bd03f0 /ice40/chip.h | |
parent | 69e5bc5030f43d24683c677d93b8fc1e27b48972 (diff) | |
download | nextpnr-84defd3fee71ab48c46fa1ba7c4acd49fba3cc5f.tar.gz nextpnr-84defd3fee71ab48c46fa1ba7c4acd49fba3cc5f.tar.bz2 nextpnr-84defd3fee71ab48c46fa1ba7c4acd49fba3cc5f.zip |
Minor refactoring of BinaryBlobAssembler, fix alignments
Signed-off-by: Clifford Wolf <clifford@clifford.at>
Diffstat (limited to 'ice40/chip.h')
-rw-r--r-- | ice40/chip.h | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/ice40/chip.h b/ice40/chip.h index f57f9983..196d169d 100644 --- a/ice40/chip.h +++ b/ice40/chip.h @@ -72,27 +72,30 @@ PortPin portPinFromId(IdString id); // ----------------------------------------------------------------------- +/**** Everything in this section must be kept in sync with chipdb.py ****/ + template <typename T> struct RelPtr { - int offset; + int32_t offset; - // RelPtr(const T *ptr) : offset(reinterpret_cast<const char*>(ptr) - - // reinterpret_cast<const char*>(this)) {} + // void set(const T *ptr) { + // 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&operator[](size_t index) const { - return reinterpret_cast<const T*>(reinterpret_cast<const char*>(this) + offset)[index]; + return get()[index]; } const T&operator*() const { - return *reinterpret_cast<const T*>(reinterpret_cast<const char*>(this) + offset); + return *(get()); } const T*operator->() const { - return reinterpret_cast<const T*>(reinterpret_cast<const char*>(this) + offset); - } - - const T*ptr() const { - return reinterpret_cast<const T*>(reinterpret_cast<const char*>(this) + offset); + return get(); } }; @@ -109,7 +112,7 @@ struct BelInfoPOD int32_t num_bel_wires; RelPtr<BelWirePOD> bel_wires; int8_t x, y, z; - int8_t filler_0; + int8_t padding_0; } __attribute__((packed)); struct BelPortPOD @@ -222,6 +225,8 @@ extern ChipInfoPOD chip_info_1k; extern ChipInfoPOD chip_info_5k; extern ChipInfoPOD chip_info_8k; +/************************ End of chipdb section. ************************/ + // ----------------------------------------------------------------------- struct BelId @@ -481,7 +486,7 @@ struct Chip IdString getBelName(BelId bel) const { assert(bel != BelId()); - return chip_info.bel_data[bel.index].name.ptr(); + return chip_info.bel_data[bel.index].name.get(); } void bindBel(BelId bel, IdString cell) |