Skip to content

Commit

Permalink
Move DriveBitWire implementation to .cc
Browse files Browse the repository at this point in the history
  • Loading branch information
RCoeurjoly committed May 22, 2024
1 parent 49618f0 commit 8da0fb0
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 21 deletions.
24 changes: 24 additions & 0 deletions kernel/drivertools.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,30 @@

YOSYS_NAMESPACE_BEGIN

DriveBitWire::DriveBitWire(Wire *wire, int offset) : wire(wire), offset(offset) {}

bool DriveBitWire::operator==(const DriveBitWire &other) const
{
return wire == other.wire && offset == other.offset;
}

bool DriveBitWire::operator<(const DriveBitWire &other) const
{
if (wire != other.wire)
return wire->name < other.wire->name;
return offset < other.offset;
}

unsigned int DriveBitWire::hash() const
{
return mkhash_add(wire->name.hash(), offset);
}

DriveBitWire::operator SigBit() const
{
return SigBit(wire, 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 @@ -57,32 +57,18 @@ enum class DriveType : unsigned char

struct DriveBitWire
{
Wire *wire;
int offset;
Wire *wire;
int offset;

DriveBitWire(Wire *wire, int offset) : wire(wire), offset(offset) {}
DriveBitWire(Wire *wire, int offset);

bool operator==(const DriveBitWire &other) const
{
return wire == other.wire && offset == other.offset;
}
bool operator==(const DriveBitWire &other) const;

bool operator<(const DriveBitWire &other) const
{
if (wire != other.wire)
return wire->name < other.wire->name;
return offset < other.offset;
}
bool operator<(const DriveBitWire &other) const;

unsigned int hash() const
{
return mkhash_add(wire->name.hash(), offset);
}
unsigned int hash() const;

operator SigBit() const
{
return SigBit(wire, offset);
}
operator SigBit() const;
};

struct DriveBitPort
Expand Down

0 comments on commit 8da0fb0

Please sign in to comment.