Skip to content

Commit

Permalink
Merge branch 'master' into if
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardt committed Jun 24, 2020
2 parents d6af7b9 + 9a94ff5 commit a86e887
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/verilogAST.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ std::string NumericLiteral::toString() {
if (size_str == "32" && !always_codegen_size) {
size_str = "";
}
if (size_str != "" && radix_str == "") {
// verilator needs decimal explicitly
radix_str = "d";
}

std::string separator = "";
if (size_str + signed_str + radix_str != "") {
Expand Down
8 changes: 4 additions & 4 deletions tests/basic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace {

TEST(BasicTests, TestNumericLiteral) {
vAST::NumericLiteral n0("23", 16, false, vAST::DECIMAL);
EXPECT_EQ(n0.toString(), "16'23");
EXPECT_EQ(n0.toString(), "16'd23");

vAST::NumericLiteral n1("DEADBEEF", 32, false, vAST::HEX);
EXPECT_EQ(n1.toString(), "'hDEADBEEF");
Expand All @@ -20,16 +20,16 @@ TEST(BasicTests, TestNumericLiteral) {
EXPECT_EQ(n3.toString(), "24'o764");

vAST::NumericLiteral n4("764", 8, false);
EXPECT_EQ(n4.toString(), "8'764");
EXPECT_EQ(n4.toString(), "8'd764");

vAST::NumericLiteral n5("764", 8);
EXPECT_EQ(n5.toString(), "8'764");
EXPECT_EQ(n5.toString(), "8'd764");

vAST::NumericLiteral n6("764");
EXPECT_EQ(n6.toString(), "764");

vAST::NumericLiteral n7("764", 8, true);
EXPECT_EQ(n7.toString(), "8's764");
EXPECT_EQ(n7.toString(), "8'sd764");

vAST::NumericLiteral n8("z", vAST::Radix::HEX);
EXPECT_EQ(n8.toString(), "'hz");
Expand Down

0 comments on commit a86e887

Please sign in to comment.