Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions xls/dslx/ir_convert/channel_scope.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,10 @@ absl::StatusOr<ChannelOrArray> ChannelScope::DefineChannelOrArrayInternal(
std::string base_channel_name;
if (convert_options_.lower_to_proc_scoped_channels) {
// When using proc scoped channels the channel names do not have to be
// mangled with the full call stack and module, just uniquified.
// mangled with the full call stack and module, just uniquified with a
// leading underscore.
base_channel_name =
channel_name_uniquer_.GetSanitizedUniqueName(short_name);
"_" + channel_name_uniquer_.GetSanitizedUniqueName(short_name);
} else {
XLS_ASSIGN_OR_RETURN(base_channel_name, CreateBaseChannelName(short_name));
}
Expand Down
24 changes: 12 additions & 12 deletions xls/dslx/ir_convert/channel_scope_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ TEST_P(ChannelScopeTest, DefineChannel) {
EXPECT_TRUE(std::holds_alternative<Channel*>(result));
Channel* channel = std::get<Channel*>(result);
if (GetParam()) {
EXPECT_EQ(channel->name(), "the_channel");
EXPECT_EQ(channel->name(), "_the_channel");
} else {
EXPECT_EQ(channel->name(), "the_package__the_channel");
}
Expand All @@ -169,7 +169,7 @@ TEST_P(ChannelScopeTest, DefineChannelWithDefaultFifoConfig) {
EXPECT_TRUE(std::holds_alternative<Channel*>(result));
Channel* channel = std::get<Channel*>(result);
if (GetParam()) {
EXPECT_EQ(channel->name(), "the_channel");
EXPECT_EQ(channel->name(), "_the_channel");
} else {
EXPECT_EQ(channel->name(), "the_package__the_channel");
}
Expand Down Expand Up @@ -199,7 +199,7 @@ TEST_P(ChannelScopeTest, DefineBoundaryChannel) {
EXPECT_TRUE(std::holds_alternative<Channel*>(result));
if (GetParam()) {
EXPECT_THAT(conv_.interface.channels(), ElementsAre(EqualsProto(R"pb(
name: "the_channel"
name: "_the_channel"
type { type_enum: BITS bit_count: 32 }
direction: IN
)pb")));
Expand All @@ -222,12 +222,12 @@ TEST_P(ChannelScopeTest, DefineBoundaryInputChannelArray) {
if (GetParam()) {
EXPECT_THAT(conv_.interface.channels(),
ElementsAre(EqualsProto(R"pb(
name: "the_channel__0"
name: "_the_channel__0"
type { type_enum: BITS bit_count: 32 }
direction: IN
)pb"),
EqualsProto(R"pb(
name: "the_channel__1"
name: "_the_channel__1"
type { type_enum: BITS bit_count: 32 }
direction: IN
)pb")));
Expand Down Expand Up @@ -256,12 +256,12 @@ TEST_P(ChannelScopeTest, DefineBoundaryOutputChannelArray) {
if (GetParam()) {
EXPECT_THAT(conv_.interface.channels(),
ElementsAre(EqualsProto(R"pb(
name: "the_channel__0"
name: "_the_channel__0"
type { type_enum: BITS bit_count: 32 }
direction: OUT
)pb"),
EqualsProto(R"pb(
name: "the_channel__1"
name: "_the_channel__1"
type { type_enum: BITS bit_count: 32 }
direction: OUT
)pb")));
Expand Down Expand Up @@ -363,11 +363,11 @@ TEST_P(ChannelScopeTest, AssociateWithExistingChannelArrayDifferentProcIds) {
XLS_ASSERT_OK_AND_ASSIGN(ChannelRef test_channel1_ref,
scope_->GetChannelForArrayIndex(
proc_id1, CreateIndexOp(ch_ref, {"2"})));
EXPECT_EQ(std::get<Channel*>(test_channel1_ref)->name(), "arr1__2");
EXPECT_EQ(std::get<Channel*>(test_channel1_ref)->name(), "_arr1__2");
XLS_ASSERT_OK_AND_ASSIGN(ChannelRef test_channel2_ref,
scope_->GetChannelForArrayIndex(
proc_id2, CreateIndexOp(ch_ref, {"2"})));
EXPECT_EQ(std::get<Channel*>(test_channel2_ref)->name(), "arr2__2");
EXPECT_EQ(std::get<Channel*>(test_channel2_ref)->name(), "_arr2__2");
} else {
XLS_ASSERT_OK_AND_ASSIGN(ChannelRef test_channel1_ref,
scope_->GetChannelForArrayIndex(
Expand All @@ -392,7 +392,7 @@ TEST_P(ChannelScopeTest, HandleChannelIndex1DValid) {
ChannelRef channel_ref,
scope_->GetChannelForArrayIndex(ProcId{}, CreateIndexOp(decl, {"2"})));
if (GetParam()) {
EXPECT_EQ(std::get<Channel*>(channel_ref)->name(), "the_channel__2");
EXPECT_EQ(std::get<Channel*>(channel_ref)->name(), "_the_channel__2");
} else {
EXPECT_EQ(std::get<Channel*>(channel_ref)->name(),
"the_package__the_channel__2");
Expand All @@ -409,7 +409,7 @@ TEST_P(ChannelScopeTest, HandleChannelIndex2DValid) {
scope_->GetChannelForArrayIndex(
ProcId{}, CreateIndexOp(decl, {"4", "1"})));
if (GetParam()) {
EXPECT_EQ(std::get<Channel*>(channel_ref)->name(), "the_channel__4_1");
EXPECT_EQ(std::get<Channel*>(channel_ref)->name(), "_the_channel__4_1");
} else {
EXPECT_EQ(std::get<Channel*>(channel_ref)->name(),
"the_package__the_channel__4_1");
Expand Down Expand Up @@ -471,7 +471,7 @@ TEST_P(ChannelScopeTest, HandleSubarrayIndex) {
scope_->GetChannelForArrayIndex(
ProcId{}, CreateIndexOp(subarray_ref, {"1"})));
if (GetParam()) {
EXPECT_EQ(std::get<Channel*>(channel_ref)->name(), "the_channel__4_1");
EXPECT_EQ(std::get<Channel*>(channel_ref)->name(), "_the_channel__4_1");
} else {
EXPECT_EQ(std::get<Channel*>(channel_ref)->name(),
"the_package__the_channel__4_1");
Expand Down
31 changes: 16 additions & 15 deletions xls/dslx/ir_convert/ir_converter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7127,7 +7127,8 @@ proc main {
XLS_ASSERT_OK_AND_ASSIGN(
xls::Proc * test_proc,
conv.package->GetProc("__test_module__test_proc_0__3_4_next"));
XLS_ASSERT_OK_AND_ASSIGN(Channel * my_chan, test_proc->GetChannel("my_chan"));
XLS_ASSERT_OK_AND_ASSIGN(Channel * my_chan,
test_proc->GetChannel("_my_chan"));
ASSERT_EQ(my_chan->kind(), ChannelKind::kStreaming);
EXPECT_EQ(down_cast<StreamingChannel*>(my_chan)->GetFifoDepth(), 7);
}
Expand Down Expand Up @@ -7176,8 +7177,8 @@ proc main {
conv.package->GetProc("__test_module__main_0_next"));
std::vector<Channel*> channels = {proc->channels().begin(),
proc->channels().end()};
EXPECT_THAT(channels, AllOf(Contains(m::Channel("my_chan")),
Contains(m::Channel("my_chan__1"))));
EXPECT_THAT(channels, AllOf(Contains(m::Channel("_my_chan")),
Contains(m::Channel("_my_chan__1"))));
}

TEST_F(IrConverterTest, ChannelArrayDestructureWithWildcard) {
Expand Down Expand Up @@ -7211,10 +7212,10 @@ TEST_F(IrConverterTest, ChannelArrayDestructureWithWildcard) {
conv.package->GetProc("__test_module__SomeProc_0_next"));
std::vector<Channel*> channels = {proc->channels().begin(),
proc->channels().end()};
EXPECT_THAT(channels, UnorderedElementsAre(m::Channel("the_chan_array__0"),
m::Channel("the_chan_array__1"),
m::Channel("the_chan_array__2"),
m::Channel("the_chan_array__3")));
EXPECT_THAT(channels, UnorderedElementsAre(m::Channel("_the_chan_array__0"),
m::Channel("_the_chan_array__1"),
m::Channel("_the_chan_array__2"),
m::Channel("_the_chan_array__3")));
}

TEST_F(IrConverterTest, ChannelArrayDestructureWithRestOfTuple) {
Expand Down Expand Up @@ -7248,10 +7249,10 @@ TEST_F(IrConverterTest, ChannelArrayDestructureWithRestOfTuple) {
conv.package->GetProc("__test_module__SomeProc_0_next"));
std::vector<Channel*> channels = {proc->channels().begin(),
proc->channels().end()};
EXPECT_THAT(channels, UnorderedElementsAre(m::Channel("the_chan_array__0"),
m::Channel("the_chan_array__1"),
m::Channel("the_chan_array__2"),
m::Channel("the_chan_array__3")));
EXPECT_THAT(channels, UnorderedElementsAre(m::Channel("_the_chan_array__0"),
m::Channel("_the_chan_array__1"),
m::Channel("_the_chan_array__2"),
m::Channel("_the_chan_array__3")));
}

TEST_F(IrConverterTest, DealOutChannelArrayElementsToSpawnee) {
Expand Down Expand Up @@ -7315,10 +7316,10 @@ TEST_F(IrConverterTest, DealOutChannelArrayElementsToSpawnee) {
procA->channels().end()};
EXPECT_THAT(channels,
UnorderedElementsAre(
m::Channel("toward_a__0_0"), m::Channel("toward_a__0_1"),
m::Channel("toward_a__1_0"), m::Channel("toward_a__1_1"),
m::Channel("toward_b__0_0"), m::Channel("toward_b__0_1"),
m::Channel("toward_b__1_0"), m::Channel("toward_b__1_1")));
m::Channel("_toward_a__0_0"), m::Channel("_toward_a__0_1"),
m::Channel("_toward_a__1_0"), m::Channel("_toward_a__1_1"),
m::Channel("_toward_b__0_0"), m::Channel("_toward_b__0_1"),
m::Channel("_toward_b__1_0"), m::Channel("_toward_b__1_1")));
}

TEST_F(IrConverterTest, MultipleNonLeafSpawnsOfSameProc) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ package test_module

file_number 0 "test_module.x"

top proc __test_module__foo_0_next<in_0: bits[32] in, in_1: bits[32] in, output: bits[32] out>(__state: (), init={()}) {
chan_interface in_0(direction=receive, kind=streaming, strictness=proven_mutually_exclusive, flow_control=ready_valid, flop_kind=none)
chan_interface in_1(direction=receive, kind=streaming, strictness=proven_mutually_exclusive, flow_control=ready_valid, flop_kind=none)
chan_interface output(direction=send, kind=streaming, strictness=proven_mutually_exclusive, flow_control=ready_valid, flop_kind=none)
top proc __test_module__foo_0_next<_in_0: bits[32] in, _in_1: bits[32] in, _output: bits[32] out>(__state: (), init={()}) {
chan_interface _in_0(direction=receive, kind=streaming, strictness=proven_mutually_exclusive, flow_control=ready_valid, flop_kind=none)
chan_interface _in_1(direction=receive, kind=streaming, strictness=proven_mutually_exclusive, flow_control=ready_valid, flop_kind=none)
chan_interface _output(direction=send, kind=streaming, strictness=proven_mutually_exclusive, flow_control=ready_valid, flop_kind=none)
after_all.5: token = after_all(id=5)
literal.3: bits[1] = literal(value=1, id=3)
receive.6: (token, bits[32]) = receive(after_all.5, predicate=literal.3, channel=in_0, id=6)
receive.6: (token, bits[32]) = receive(after_all.5, predicate=literal.3, channel=_in_0, id=6)
tok: token = tuple_index(receive.6, index=0, id=8)
receive.10: (token, bits[32]) = receive(tok, predicate=literal.3, channel=in_1, id=10)
receive.10: (token, bits[32]) = receive(tok, predicate=literal.3, channel=_in_1, id=10)
a: bits[32] = tuple_index(receive.6, index=1, id=9)
b: bits[32] = tuple_index(receive.10, index=1, id=13)
tok__1: token = tuple_index(receive.10, index=0, id=12)
Expand All @@ -21,6 +21,6 @@ top proc __test_module__foo_0_next<in_0: bits[32] in, in_1: bits[32] in, output:
tuple.4: () = tuple(id=4)
tuple_index.7: token = tuple_index(receive.6, index=0, id=7)
tuple_index.11: token = tuple_index(receive.10, index=0, id=11)
tok__2: token = send(tok__1, add.14, predicate=literal.3, channel=output, id=15)
tok__2: token = send(tok__1, add.14, predicate=literal.3, channel=_output, id=15)
next_value.17: () = next_value(param=__state, value=tuple.16, id=17)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ package test_module

file_number 0 "test_module.x"

top proc __test_module__main_0_next<in_chans__0: bits[32] in, in_chans__1: bits[32] in, in_chans__2: bits[32] in, out_chan: bits[16] out>(__state: (), init={()}) {
chan_interface in_chans__0(direction=receive, kind=streaming, strictness=proven_mutually_exclusive, flow_control=ready_valid, flop_kind=none)
chan_interface in_chans__1(direction=receive, kind=streaming, strictness=proven_mutually_exclusive, flow_control=ready_valid, flop_kind=none)
chan_interface in_chans__2(direction=receive, kind=streaming, strictness=proven_mutually_exclusive, flow_control=ready_valid, flop_kind=none)
chan_interface out_chan(direction=send, kind=streaming, strictness=proven_mutually_exclusive, flow_control=ready_valid, flop_kind=none)
top proc __test_module__main_0_next<_in_chans__0: bits[32] in, _in_chans__1: bits[32] in, _in_chans__2: bits[32] in, _out_chan: bits[16] out>(__state: (), init={()}) {
chan_interface _in_chans__0(direction=receive, kind=streaming, strictness=proven_mutually_exclusive, flow_control=ready_valid, flop_kind=none)
chan_interface _in_chans__1(direction=receive, kind=streaming, strictness=proven_mutually_exclusive, flow_control=ready_valid, flop_kind=none)
chan_interface _in_chans__2(direction=receive, kind=streaming, strictness=proven_mutually_exclusive, flow_control=ready_valid, flop_kind=none)
chan_interface _out_chan(direction=send, kind=streaming, strictness=proven_mutually_exclusive, flow_control=ready_valid, flop_kind=none)
literal.8: token = literal(value=token, id=8)
literal.3: bits[1] = literal(value=1, id=3)
literal.5: token = literal(value=token, id=5)
literal.6: bits[16] = literal(value=42, id=6)
receive.9: (token, bits[32]) = receive(literal.8, predicate=literal.3, channel=in_chans__1, id=9)
receive.9: (token, bits[32]) = receive(literal.8, predicate=literal.3, channel=_in_chans__1, id=9)
__state: () = state_read(state_element=__state, id=2)
tuple.11: () = tuple(id=11)
__token: token = literal(value=token, id=1)
tuple.4: () = tuple(id=4)
send.7: token = send(literal.5, literal.6, predicate=literal.3, channel=out_chan, id=7)
send.7: token = send(literal.5, literal.6, predicate=literal.3, channel=_out_chan, id=7)
tuple_index.10: token = tuple_index(receive.9, index=0, id=10)
next_value.12: () = next_value(param=__state, value=tuple.11, id=12)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package test_module
file_number 0 "test_module.x"

top proc __test_module__main_0_next<>(__state: (), init={()}) {
chan data_0__0(bits[32], id=0, kind=streaming, ops=send_receive, flow_control=ready_valid, strictness=proven_mutually_exclusive)
chan_interface data_0__0(direction=send, kind=streaming, strictness=proven_mutually_exclusive, flow_control=none, flop_kind=none)
chan_interface data_0__0(direction=receive, kind=streaming, strictness=proven_mutually_exclusive, flow_control=none, flop_kind=none)
chan data_0__1(bits[32], id=1, kind=streaming, ops=send_receive, flow_control=ready_valid, strictness=proven_mutually_exclusive)
chan_interface data_0__1(direction=send, kind=streaming, strictness=proven_mutually_exclusive, flow_control=none, flop_kind=none)
chan_interface data_0__1(direction=receive, kind=streaming, strictness=proven_mutually_exclusive, flow_control=none, flop_kind=none)
chan _data_0__0(bits[32], id=0, kind=streaming, ops=send_receive, flow_control=ready_valid, strictness=proven_mutually_exclusive)
chan_interface _data_0__0(direction=send, kind=streaming, strictness=proven_mutually_exclusive, flow_control=none, flop_kind=none)
chan_interface _data_0__0(direction=receive, kind=streaming, strictness=proven_mutually_exclusive, flow_control=none, flop_kind=none)
chan _data_0__1(bits[32], id=1, kind=streaming, ops=send_receive, flow_control=ready_valid, strictness=proven_mutually_exclusive)
chan_interface _data_0__1(direction=send, kind=streaming, strictness=proven_mutually_exclusive, flow_control=none, flop_kind=none)
chan_interface _data_0__1(direction=receive, kind=streaming, strictness=proven_mutually_exclusive, flow_control=none, flop_kind=none)
__state: () = state_read(state_element=__state, id=2)
__token: token = literal(value=token, id=1)
literal.3: bits[1] = literal(value=1, id=3)
Expand Down
Loading