Skip to content

Commit 4d1423f

Browse files
grebecopybara-github
authored andcommitted
Fix incorrect serialization of channel fifo config.
`register_push_outputs` and `register_pop_outputs` were swapped! PiperOrigin-RevId: 694686860
1 parent 9552b36 commit 4d1423f

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

xls/ir/channel.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ std::string Channel::ToString() const {
116116
"fifo_depth=%d, bypass=%s, "
117117
"register_push_outputs=%s, register_pop_outputs=%s, ",
118118
fifo_config->depth(), fifo_config->bypass() ? "true" : "false",
119-
fifo_config->register_pop_outputs() ? "true" : "false",
120-
fifo_config->register_push_outputs() ? "true" : "false");
119+
fifo_config->register_push_outputs() ? "true" : "false",
120+
fifo_config->register_pop_outputs() ? "true" : "false");
121121
}
122122
}
123123

xls/ir/channel_test.cc

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,45 @@ TEST(ChannelTest, StreamingChannelWithFifoDepth) {
156156
EXPECT_EQ(ch.GetStrictness(), ChannelStrictness::kProvenMutuallyExclusive);
157157
}
158158

159+
TEST(ChannelTest, StreamingChannelWithFifoConfigSerializesFifoConfigCorrectly) {
160+
Package p("my_package");
161+
162+
auto ch_with_fifo_config = [&](FifoConfig fifo_config) {
163+
return StreamingChannel(
164+
"my_channel", 42, ChannelOps::kSendReceive, p.GetBitsType(32), {},
165+
/*fifo_config=*/fifo_config, FlowControl::kNone,
166+
ChannelStrictness::kProvenMutuallyExclusive, ChannelMetadataProto());
167+
};
168+
EXPECT_THAT(ch_with_fifo_config(FifoConfig(/*depth=*/123, /*bypass=*/false,
169+
/*register_push_outputs=*/false,
170+
/*register_pop_outputs=*/false))
171+
.ToString(),
172+
AllOf(HasSubstr("fifo_depth=123"), HasSubstr("bypass=false"),
173+
HasSubstr("register_push_outputs=false"),
174+
HasSubstr("register_pop_outputs=false")));
175+
EXPECT_THAT(ch_with_fifo_config(FifoConfig(/*depth=*/123, /*bypass=*/true,
176+
/*register_push_outputs=*/false,
177+
/*register_pop_outputs=*/false))
178+
.ToString(),
179+
AllOf(HasSubstr("fifo_depth=123"), HasSubstr("bypass=true"),
180+
HasSubstr("register_push_outputs=false"),
181+
HasSubstr("register_pop_outputs=false")));
182+
EXPECT_THAT(ch_with_fifo_config(FifoConfig(/*depth=*/123, /*bypass=*/false,
183+
/*register_push_outputs=*/true,
184+
/*register_pop_outputs=*/false))
185+
.ToString(),
186+
AllOf(HasSubstr("fifo_depth=123"), HasSubstr("bypass=false"),
187+
HasSubstr("register_push_outputs=true"),
188+
HasSubstr("register_pop_outputs=false")));
189+
EXPECT_THAT(ch_with_fifo_config(FifoConfig(/*depth=*/123, /*bypass=*/false,
190+
/*register_push_outputs=*/false,
191+
/*register_pop_outputs=*/true))
192+
.ToString(),
193+
AllOf(HasSubstr("fifo_depth=123"), HasSubstr("bypass=false"),
194+
HasSubstr("register_push_outputs=false"),
195+
HasSubstr("register_pop_outputs=true")));
196+
}
197+
159198
TEST(ChannelTest, StreamingToStringParses) {
160199
Package p("my_package");
161200
std::vector<Value> initial_values = {

0 commit comments

Comments
 (0)