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
7 changes: 3 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -565,9 +565,8 @@ if(CIRCT_SLANG_FRONTEND_ENABLED)
FetchContent_Declare(
slang
GIT_REPOSITORY https://github.com/MikePopoloski/slang.git
GIT_TAG dd16a7947e0586d0541477f1b4b60eda7c986e35
# Shallow check-out doesn't work if the tag is ref spec is far from HEAD.
# GIT_SHALLOW ON
GIT_TAG v9.1
GIT_SHALLOW ON
)
set(FETCHCONTENT_TRY_FIND_PACKAGE_MODE "NEVER")

Expand Down Expand Up @@ -612,7 +611,7 @@ if(CIRCT_SLANG_FRONTEND_ENABLED)
set_property(GLOBAL APPEND PROPERTY CIRCT_EXPORTS slang_slang)
install(TARGETS slang_slang EXPORT CIRCTTargets)
else()
find_package(slang 9.0 REQUIRED)
find_package(slang 9.1 REQUIRED)
endif()
endif()

Expand Down
42 changes: 17 additions & 25 deletions lib/Conversion/ImportVerilog/Structure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -562,13 +562,12 @@ struct ModuleVisitor : public BaseVisitor {
return success();

// If the block has a name, add it to the list of block name prefices.
SmallString<64> prefixBuffer;
auto prefix = blockNamePrefix;
if (!genNode.name.empty()) {
prefixBuffer += blockNamePrefix;
prefixBuffer += genNode.name;
prefixBuffer += '.';
prefix = prefixBuffer;
SmallString<64> prefix = blockNamePrefix;
if (!genNode.name.empty() ||
genNode.getParentScope()->asSymbol().kind !=
slang::ast::SymbolKind::GenerateBlockArray) {
prefix += genNode.getExternalName();
prefix += '.';
}

// Visit each member of the generate block.
Expand All @@ -582,27 +581,20 @@ struct ModuleVisitor : public BaseVisitor {
LogicalResult visit(const slang::ast::GenerateBlockArraySymbol &genArrNode) {
// If the block has a name, add it to the list of block name prefices and
// prepare to append the array index and a `.` in each iteration.
SmallString<64> prefixBuffer;
if (!genArrNode.name.empty()) {
prefixBuffer += blockNamePrefix;
prefixBuffer += genArrNode.name;
}
auto prefixBufferBaseLen = prefixBuffer.size();
SmallString<64> prefix = blockNamePrefix;
prefix += genArrNode.getExternalName();
prefix += '_';
auto prefixBaseLen = prefix.size();

// Visit each iteration entry of the generate block.
for (const auto *entry : genArrNode.entries) {
// Append the index to the prefix if this block has a name.
auto prefix = blockNamePrefix;
if (prefixBufferBaseLen > 0) {
prefixBuffer.resize(prefixBufferBaseLen);
prefixBuffer += '_';
if (entry->arrayIndex)
prefixBuffer += entry->arrayIndex->toString();
else
Twine(entry->constructIndex).toVector(prefixBuffer);
prefixBuffer += '.';
prefix = prefixBuffer;
}
// Append the index to the prefix.
prefix.resize(prefixBaseLen);
if (entry->arrayIndex)
prefix += entry->arrayIndex->toString();
else
Twine(entry->constructIndex).toVector(prefix);
prefix += '.';

// Visit this iteration entry.
if (failed(entry->asSymbol().visit(ModuleVisitor(context, loc, prefix))))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#define LIB_CIRCT_TOOLS_CIRCT_VERILOG_LSP_SERVER_LSPDIAGNOSTICCLIENT_H_

#include "VerilogDocument.h"
#include "slang/diagnostics/DiagnosticClient.h"

namespace circt {
namespace lsp {
Expand Down
8 changes: 4 additions & 4 deletions test/Conversion/ImportVerilog/basic.sv
Original file line number Diff line number Diff line change
Expand Up @@ -1879,25 +1879,25 @@ module GenerateConstructs;
// CHECK: [[TMP:%.+]] = moore.constant 0
// CHECK: dbg.variable "i", [[TMP]]
// CHECK: [[TMP:%.+]] = moore.constant 0
// CHECK: g1 = moore.variable [[TMP]]
// CHECK: %genblk1_0.g1 = moore.variable [[TMP]]
// CHECK: [[TMP:%.+]] = moore.constant 1
// CHECK: dbg.variable "i", [[TMP]]
// CHECK: [[TMP:%.+]] = moore.constant 1
// CHECK: g1 = moore.variable [[TMP]]
// CHECK: %genblk1_1.g1 = moore.variable [[TMP]]
for (i = 0; i < 2; i = i + 1) begin
integer g1 = i;
end

// CHECK: [[TMP:%.+]] = moore.constant 2 : i32
// CHECK: g2 = moore.variable [[TMP]] : <i32>
// CHECK: %genblk2.g2 = moore.variable [[TMP]] : <i32>
if (p == 2) begin
int g2 = 2;
end else begin
int g2 = 3;
end

// CHECK: [[TMP:%.+]] = moore.constant 2 : i32
// CHECK: g3 = moore.variable [[TMP]] : <i32>
// CHECK: %genblk3.g3 = moore.variable [[TMP]] : <i32>
case (p)
2: begin
int g3 = 2;
Expand Down