Skip to content

Commit cf626c4

Browse files
dplassgitcopybara-github
authored andcommitted
[Proc-scoped channels] Update scheduling options to properly map IO constraints to channel interfaces of proc-scoped channels.
Update custom schedule codegen to use proc-scoped channels. PiperOrigin-RevId: 841947015
1 parent 47738c0 commit cf626c4

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

xls/examples/BUILD

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ xls_dslx_opt_ir(
171171
name = "custom_schedule",
172172
srcs = ["custom_schedule.x"],
173173
dslx_top = "Accumulator",
174+
ir_conv_args = {
175+
"lower_to_proc_scoped_channels": "true",
176+
},
174177
)
175178

176179
xls_dslx_fmt_test(
@@ -196,11 +199,14 @@ xls_dslx_verilog(
196199
"streaming_channel_data_suffix": "_data",
197200
"streaming_channel_ready_suffix": "_ready",
198201
"streaming_channel_valid_suffix": "_valid",
199-
"io_constraints": "custom_schedule__data_in:recv:custom_schedule__old_state:send:0:0,custom_schedule__data_in:recv:custom_schedule__data_out:send:4:4,custom_schedule__data_in:recv:custom_schedule__activate:recv:8:8",
202+
"io_constraints": "data_in:recv:old_state:send:0:0,data_in:recv:data_out:send:4:4,data_in:recv:activate:recv:8:8",
200203
"worst_case_throughput": "9",
201204
"pipeline_stages": "9",
202205
},
203206
dslx_top = "Accumulator",
207+
ir_conv_args = {
208+
"lower_to_proc_scoped_channels": "true",
209+
},
204210
library = ":custom_schedule",
205211
verilog_file = "custom_schedule.sv",
206212
)

xls/scheduling/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ cc_library(
9595
"//xls/estimators/delay_model:delay_estimator",
9696
"//xls/estimators/delay_model:delay_estimators",
9797
"//xls/ir",
98+
"//xls/ir:channel",
9899
"//xls/passes:optimization_pass",
99100
"//xls/tools:scheduling_options_flags_cc_proto",
100101
"@com_google_absl//absl/container:flat_hash_map",

xls/scheduling/scheduling_options.cc

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "xls/common/status/status_macros.h"
3131
#include "xls/estimators/delay_model/delay_estimator.h"
3232
#include "xls/estimators/delay_model/delay_estimators.h"
33+
#include "xls/ir/channel.h"
3334
#include "xls/ir/package.h"
3435
#include "xls/tools/scheduling_options_flags.pb.h"
3536

@@ -152,6 +153,34 @@ absl::StatusOr<SchedulingOptions> OptionsFromFlagProto(
152153
for (const SchedulingConstraint& c : scheduling_options.constraints()) {
153154
if (std::holds_alternative<IOConstraint>(c)) {
154155
IOConstraint io_constr = std::get<IOConstraint>(c);
156+
if (p->ChannelsAreProcScoped()) {
157+
XLS_ASSIGN_OR_RETURN(Proc * top, p->GetTopAsProc());
158+
if (!top->GetChannelInterface(
159+
io_constr.SourceChannel(),
160+
(io_constr.SourceDirection() == IODirection::kSend)
161+
? ChannelDirection::kSend
162+
: ChannelDirection::kReceive)
163+
.ok()) {
164+
return absl::InvalidArgumentError(absl::StrFormat(
165+
"Invalid source channel name in IO constraint: %s; "
166+
"this name did not correspond to any channel interface in the "
167+
"top proc %s",
168+
io_constr.SourceChannel(), top->name()));
169+
}
170+
if (!top->GetChannelInterface(
171+
io_constr.TargetChannel(),
172+
(io_constr.TargetDirection() == IODirection::kSend)
173+
? ChannelDirection::kSend
174+
: ChannelDirection::kReceive)
175+
.ok()) {
176+
return absl::InvalidArgumentError(
177+
absl::StrFormat("Invalid channel name in IO constraint: %s; "
178+
"this name did not correspond to any channel "
179+
"interface in the top proc %s",
180+
io_constr.TargetChannel(), top->name()));
181+
}
182+
continue;
183+
}
155184
if (!p->GetChannel(io_constr.SourceChannel()).ok()) {
156185
return absl::InvalidArgumentError(absl::StrFormat(
157186
"Invalid channel name in IO constraint: %s; "

0 commit comments

Comments
 (0)