diff --git a/kernel/drivertools.cc b/kernel/drivertools.cc index f0dda51a8b8..720125e1070 100644 --- a/kernel/drivertools.cc +++ b/kernel/drivertools.cc @@ -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) { @@ -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. @@ -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); } diff --git a/kernel/drivertools.h b/kernel/drivertools.h index cb562b016a1..b440afddaa2 100644 --- a/kernel/drivertools.h +++ b/kernel/drivertools.h @@ -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; } @@ -723,6 +723,7 @@ struct DriveChunk switch (type_) { case DriveType::NONE: + none_ = width; break; case DriveType::CONSTANT: constant_.~Const(); @@ -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_; @@ -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_); @@ -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; }