Skip to content

Commit

Permalink
Give better error message when channel metadata not found.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 524114791
  • Loading branch information
grebe authored and copybara-github committed Apr 13, 2023
1 parent 6fb7985 commit 759cf11
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
13 changes: 13 additions & 0 deletions xls/codegen/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
)

Expand Down
26 changes: 23 additions & 3 deletions xls/codegen/ram_rewrite_pass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,32 @@
#include <string>
#include <vector>

#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 {

Expand All @@ -38,13 +53,18 @@ absl::StatusOr<Channel*> 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;
}
Expand Down

0 comments on commit 759cf11

Please sign in to comment.