From 759cf1120528ed26396d2699e182147ab61e077a Mon Sep 17 00:00:00 2001 From: Paul Rigge Date: Thu, 13 Apr 2023 15:11:42 -0700 Subject: [PATCH] Give better error message when channel metadata not found. PiperOrigin-RevId: 524114791 --- xls/codegen/BUILD | 13 +++++++++++++ xls/codegen/ram_rewrite_pass.cc | 26 +++++++++++++++++++++++--- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/xls/codegen/BUILD b/xls/codegen/BUILD index 3264353488..4cd7f8fb36 100644 --- a/xls/codegen/BUILD +++ b/xls/codegen/BUILD @@ -953,14 +953,27 @@ cc_library( deps = [ ":block_conversion", ":codegen_pass", + ":module_signature", ":ram_configuration", + "@com_google_absl//absl/container:flat_hash_map", "@com_google_absl//absl/status", "@com_google_absl//absl/status:statusor", "@com_google_absl//absl/strings", "@com_google_absl//absl/strings:str_format", + "@com_google_absl//absl/types:span", + "//xls/common:casts", + "//xls/common/logging", + "//xls/common/status:ret_check", "//xls/common/status:status_macros", "//xls/ir", + "//xls/ir:bits", + "//xls/ir:channel", + "//xls/ir:op", + "//xls/ir:register", + "//xls/ir:source_location", "//xls/ir:type", + "//xls/ir:value", + "//xls/passes:pass_base", ], ) diff --git a/xls/codegen/ram_rewrite_pass.cc b/xls/codegen/ram_rewrite_pass.cc index f50ac394a0..5d805c15c1 100644 --- a/xls/codegen/ram_rewrite_pass.cc +++ b/xls/codegen/ram_rewrite_pass.cc @@ -19,17 +19,32 @@ #include #include +#include "absl/container/flat_hash_map.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" #include "absl/strings/string_view.h" +#include "absl/types/span.h" #include "xls/codegen/block_conversion.h" +#include "xls/codegen/codegen_pass.h" +#include "xls/codegen/module_signature.h" #include "xls/codegen/ram_configuration.h" +#include "xls/common/casts.h" +#include "xls/common/logging/logging.h" +#include "xls/common/status/ret_check.h" #include "xls/common/status/status_macros.h" +#include "xls/ir/bits.h" #include "xls/ir/block.h" +#include "xls/ir/channel.h" +#include "xls/ir/node.h" #include "xls/ir/nodes.h" +#include "xls/ir/op.h" +#include "xls/ir/register.h" +#include "xls/ir/source_location.h" #include "xls/ir/type.h" +#include "xls/ir/value.h" +#include "xls/passes/pass_base.h" namespace xls::verilog { @@ -38,13 +53,18 @@ absl::StatusOr GetStreamingChannel(Block* block, std::string_view channel_name) { XLS_ASSIGN_OR_RETURN(Channel * channel, block->package()->GetChannel(channel_name)); - XLS_RET_CHECK(channel->GetDataPortName().has_value()); + XLS_RET_CHECK_EQ(channel->kind(), ChannelKind::kStreaming) + << absl::StreamFormat("Channel %s must be a streaming channel.", + channel_name); + XLS_RET_CHECK(channel->GetDataPortName().has_value()) + << "data port not found- channel " << channel->name() + << " should be streaming with ready/valid flow control."; XLS_RET_CHECK(channel->GetValidPortName().has_value()) << "valid port not found- channel " << channel->name() << " should be streaming with ready/valid flow control."; XLS_RET_CHECK(channel->GetReadyPortName().has_value()) - << "ready port not found- channels should be streaming with " - "ready/valid flow control."; + << "ready port not found- channel " << channel->name() + << " should be streaming with ready/valid flow control."; return channel; }