Skip to content

Commit

Permalink
drivertools: Various fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jix committed Apr 11, 2024
1 parent b4af536 commit 6e58712
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
21 changes: 9 additions & 12 deletions kernel/drivertools.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ bool DriveChunkWire::try_append(DriveChunkWire const &chunk)
return true;
}

bool DriveChunkPort::can_append(DriveBitPort const &bit) const { return bit.cell == cell && bit.port == port && bit.offset == offset + width; }
bool DriveChunkPort::can_append(DriveBitPort const &bit) const
{
return bit.cell == cell && bit.port == port && bit.offset == offset + width;
}

bool DriveChunkPort::try_append(DriveBitPort const &bit)
{
Expand Down Expand Up @@ -683,15 +686,9 @@ void DriverMap::add(DriveBit const &a, DriveBit const &b)
connect_directed_merge(b_id, a_id);
// If either bit requires a driven value and has a unique driver, merge
// and use the other end as representative bit.
else if (a_mode == BitMode::DRIVEN_UNIQUE)
connect_directed_merge(a_id, b_id);
else if (b_mode == BitMode::DRIVEN_UNIQUE)
connect_directed_merge(b_id, a_id);
// If either bit requires a driven value and may have multiple drivers,
// store a directed connection from the other bit.
else if (a_mode == BitMode::DRIVEN)
else if (a_mode == BitMode::DRIVEN_UNIQUE && !(b_mode == BitMode::DRIVEN_UNIQUE || b_mode == BitMode::DRIVEN))
connect_directed_buffer(a_id, b_id);
else if (b_mode == BitMode::DRIVEN)
else if (b_mode == BitMode::DRIVEN_UNIQUE && !(b_mode == BitMode::DRIVEN_UNIQUE || b_mode == BitMode::DRIVEN))
connect_directed_buffer(b_id, a_id);
// If either bit only drives a value, store a directed connection from
// it to the other bit.
Expand Down Expand Up @@ -933,15 +930,15 @@ const char *log_signal(DriveSpec const &spec)
return log_signal(chunks[0]);

std::string str;
const char *sep = "{";
const char *sep = "{ ";

for (auto i = chunks.rbegin(), end = chunks.rend(); i != end; ++i)
{
str += sep;
sep = ", ";
sep = " ";
str += log_signal(*i);
}
str += "}";
str += " }";

return log_str(str);
}
Expand Down
9 changes: 5 additions & 4 deletions kernel/drivertools.h
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ struct DriveBit

DriveType type() const { return type_; }

bool is_undriven() const { return type_ == DriveType::NONE; }
bool is_none() const { return type_ == DriveType::NONE; }
bool is_constant() const { return type_ == DriveType::CONSTANT; }
bool is_wire() const { return type_ == DriveType::WIRE; }
bool is_port() const { return type_ == DriveType::PORT; }
Expand Down Expand Up @@ -723,6 +723,7 @@ struct DriveChunk
switch (type_)
{
case DriveType::NONE:
none_ = width;
break;
case DriveType::CONSTANT:
constant_.~Const();
Expand All @@ -749,7 +750,7 @@ struct DriveChunk
switch (other.type_)
{
case DriveType::NONE:
set_none();
set_none(other.none_);
break;
case DriveType::CONSTANT:
*this = other.constant_;
Expand All @@ -775,7 +776,7 @@ struct DriveChunk
switch (other.type_)
{
case DriveType::NONE:
set_none();
set_none(other.none_);
break;
case DriveType::CONSTANT:
*this = std::move(other.constant_);
Expand Down Expand Up @@ -989,7 +990,7 @@ struct DriveChunk

DriveType type() const { return type_; }

bool is_undriven() const { return type_ == DriveType::NONE; }
bool is_none() const { return type_ == DriveType::NONE; }
bool is_constant() const { return type_ == DriveType::CONSTANT; }
bool is_wire() const { return type_ == DriveType::WIRE; }
bool is_port() const { return type_ == DriveType::PORT; }
Expand Down

0 comments on commit 6e58712

Please sign in to comment.