From 47717822a20262b44f2ecf26a4c551e98541398c Mon Sep 17 00:00:00 2001 From: Roland Coeurjoly Date: Wed, 22 May 2024 23:23:05 +0200 Subject: [PATCH] Move DriveBitPort implementation to .cc --- kernel/drivertools.cc | 22 ++++++++++++++++++++++ kernel/drivertools.h | 28 +++++++--------------------- 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/kernel/drivertools.cc b/kernel/drivertools.cc index 31e3c98ffbf..304edd5769d 100644 --- a/kernel/drivertools.cc +++ b/kernel/drivertools.cc @@ -45,6 +45,28 @@ DriveBitWire::operator SigBit() const return SigBit(wire, offset); } +DriveBitPort::DriveBitPort(Cell *cell, IdString port, int offset) + : cell(cell), port(port), offset(offset) {} + +bool DriveBitPort::operator==(const DriveBitPort &other) const +{ + return cell == other.cell && port == other.port && offset == other.offset; +} + +bool DriveBitPort::operator<(const DriveBitPort &other) const +{ + if (cell != other.cell) + return cell->name < other.cell->name; + if (port != other.port) + return port < other.port; + return offset < other.offset; +} + +unsigned int DriveBitPort::hash() const +{ + return mkhash_add(mkhash(cell->name.hash(), port.hash()), offset); +} + DriveBit::DriveBit(SigBit const &bit) { if (bit.is_wire()) diff --git a/kernel/drivertools.h b/kernel/drivertools.h index 5930101b795..946dc33b1f7 100644 --- a/kernel/drivertools.h +++ b/kernel/drivertools.h @@ -73,33 +73,19 @@ struct DriveBitWire struct DriveBitPort { - Cell *cell; - IdString port; - int offset; + Cell *cell; + IdString port; + int offset; - DriveBitPort(Cell *cell, IdString port, int offset) : cell(cell), port(port), offset(offset) {} + DriveBitPort(Cell *cell, IdString port, int offset); - bool operator==(const DriveBitPort &other) const - { - return cell == other.cell && port == other.port && offset == other.offset; - } + bool operator==(const DriveBitPort &other) const; - bool operator<(const DriveBitPort &other) const - { - if (cell != other.cell) - return cell->name < other.cell->name; - if (port != other.port) - return port < other.port; - return offset < other.offset; - } + bool operator<(const DriveBitPort &other) const; - unsigned int hash() const - { - return mkhash_add(mkhash(cell->name.hash(), port.hash()), offset); - } + unsigned int hash() const; }; - struct DriveBitMarker { int marker;