diff options
Diffstat (limited to 'ice40/chip.cc')
-rw-r--r-- | ice40/chip.cc | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/ice40/chip.cc b/ice40/chip.cc index 88fcc512..918a7fb4 100644 --- a/ice40/chip.cc +++ b/ice40/chip.cc @@ -52,27 +52,25 @@ BelType belTypeFromId(IdString id) // ----------------------------------------------------------------------- -IdString portPinToId(PortPin type) +void IdString::initialize_chip() { -#define X(t) \ - if (type == PIN_##t) \ - return #t; - +#define X(t) initialize_add(#t, PIN_##t); #include "portpins.inc" - #undef X - return IdString(); } -PortPin portPinFromId(IdString id) +IdString portPinToId(PortPin type) { -#define X(t) \ - if (id == #t) \ - return PIN_##t; - -#include "portpins.inc" + IdString ret; + if (type > 0 && type < PIN_MAXIDX) + ret.index = type; + return ret; +} -#undef X +PortPin portPinFromId(IdString id) +{ + if (id.index > 0 && id.index < PIN_MAXIDX) + return PortPin(id.index); return PIN_NONE; } |