Skip to content

Commit

Permalink
Move DriveBitPort implementation to .cc
Browse files Browse the repository at this point in the history
  • Loading branch information
RCoeurjoly committed May 22, 2024
1 parent 8da0fb0 commit 4771782
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 21 deletions.
22 changes: 22 additions & 0 deletions kernel/drivertools.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
28 changes: 7 additions & 21 deletions kernel/drivertools.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 4771782

Please sign in to comment.