Skip to content

Commit

Permalink
Merge e2620ae into e2054f2
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardt committed Aug 17, 2020
2 parents e2054f2 + e2620ae commit 5920a21
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
5 changes: 3 additions & 2 deletions include/verilogAST.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -580,8 +580,9 @@ class InlineVerilog : public StructuralStatement {
~InlineVerilog(){};
};

typedef std::vector<
std::pair<std::unique_ptr<Identifier>, std::unique_ptr<Expression>>>
typedef std::vector<std::pair<
std::variant<std::unique_ptr<Identifier>, std::unique_ptr<Vector>>,
std::unique_ptr<Expression>>>
Parameters;

typedef std::vector<std::pair<std::string, std::unique_ptr<Expression>>>
Expand Down
4 changes: 2 additions & 2 deletions src/verilogAST.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ std::string Module::emitModuleHeader() {
module_header_str += " #(\n ";
std::vector<std::string> param_strs;
for (auto &it : parameters) {
param_strs.push_back("parameter " + it.first->toString() + " = " +
param_strs.push_back("parameter " + variant_to_string(it.first) + " = " +
it.second->toString());
}
module_header_str += join(param_strs, ",\n ");
Expand Down Expand Up @@ -389,7 +389,7 @@ std::string ModuleInstantiation::toString() {
module_inst_str += " #(\n ";
std::vector<std::string> param_strs;
for (auto &it : parameters) {
param_strs.push_back("." + it.first->toString() + "(" +
param_strs.push_back("." + variant_to_string(it.first) + "(" +
it.second->toString() + ")");
}
module_inst_str += join(param_strs, ",\n ");
Expand Down
8 changes: 7 additions & 1 deletion tests/basic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,11 +330,17 @@ TEST(BasicTests, TestModule) {
std::string name = "test_module";

vAST::Parameters parameters;
parameters.push_back(std::make_pair(
std::make_unique<vAST::Vector>(vAST::make_id("param1"),
vAST::make_num("3"), vAST::make_num("0")),
vAST::make_num("1")));
vAST::Module module(name, make_simple_ports(), make_simple_body(),
std::move(parameters));

std::string expected_str =
"module test_module (\n"
"module test_module #(\n"
" parameter [3:0] param1 = 1\n"
") (\n"
" input i,\n"
" output o\n"
");\n"
Expand Down

0 comments on commit 5920a21

Please sign in to comment.