Skip to content

Commit

Permalink
Fix incorrect serialization of channel fifo config.
Browse files Browse the repository at this point in the history
`register_push_outputs` and `register_pop_outputs` were swapped!

PiperOrigin-RevId: 694686860
  • Loading branch information
grebe authored and copybara-github committed Nov 9, 2024
1 parent 9552b36 commit 4d1423f
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
4 changes: 2 additions & 2 deletions xls/ir/channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ std::string Channel::ToString() const {
"fifo_depth=%d, bypass=%s, "
"register_push_outputs=%s, register_pop_outputs=%s, ",
fifo_config->depth(), fifo_config->bypass() ? "true" : "false",
fifo_config->register_pop_outputs() ? "true" : "false",
fifo_config->register_push_outputs() ? "true" : "false");
fifo_config->register_push_outputs() ? "true" : "false",
fifo_config->register_pop_outputs() ? "true" : "false");
}
}

Expand Down
39 changes: 39 additions & 0 deletions xls/ir/channel_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,45 @@ TEST(ChannelTest, StreamingChannelWithFifoDepth) {
EXPECT_EQ(ch.GetStrictness(), ChannelStrictness::kProvenMutuallyExclusive);
}

TEST(ChannelTest, StreamingChannelWithFifoConfigSerializesFifoConfigCorrectly) {
Package p("my_package");

auto ch_with_fifo_config = [&](FifoConfig fifo_config) {
return StreamingChannel(
"my_channel", 42, ChannelOps::kSendReceive, p.GetBitsType(32), {},
/*fifo_config=*/fifo_config, FlowControl::kNone,
ChannelStrictness::kProvenMutuallyExclusive, ChannelMetadataProto());
};
EXPECT_THAT(ch_with_fifo_config(FifoConfig(/*depth=*/123, /*bypass=*/false,
/*register_push_outputs=*/false,
/*register_pop_outputs=*/false))
.ToString(),
AllOf(HasSubstr("fifo_depth=123"), HasSubstr("bypass=false"),
HasSubstr("register_push_outputs=false"),
HasSubstr("register_pop_outputs=false")));
EXPECT_THAT(ch_with_fifo_config(FifoConfig(/*depth=*/123, /*bypass=*/true,
/*register_push_outputs=*/false,
/*register_pop_outputs=*/false))
.ToString(),
AllOf(HasSubstr("fifo_depth=123"), HasSubstr("bypass=true"),
HasSubstr("register_push_outputs=false"),
HasSubstr("register_pop_outputs=false")));
EXPECT_THAT(ch_with_fifo_config(FifoConfig(/*depth=*/123, /*bypass=*/false,
/*register_push_outputs=*/true,
/*register_pop_outputs=*/false))
.ToString(),
AllOf(HasSubstr("fifo_depth=123"), HasSubstr("bypass=false"),
HasSubstr("register_push_outputs=true"),
HasSubstr("register_pop_outputs=false")));
EXPECT_THAT(ch_with_fifo_config(FifoConfig(/*depth=*/123, /*bypass=*/false,
/*register_push_outputs=*/false,
/*register_pop_outputs=*/true))
.ToString(),
AllOf(HasSubstr("fifo_depth=123"), HasSubstr("bypass=false"),
HasSubstr("register_push_outputs=false"),
HasSubstr("register_pop_outputs=true")));
}

TEST(ChannelTest, StreamingToStringParses) {
Package p("my_package");
std::vector<Value> initial_values = {
Expand Down

0 comments on commit 4d1423f

Please sign in to comment.