-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
12 najaverilogverilogexception parser error syntax error unexpected e…
…xpecting (#13) * Adding failing associated test * Adding support for defparam, working on tests * More testing * Exclude coverage from non constant number * remove throw from coverage
- Loading branch information
Showing
11 changed files
with
1,029 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// SPDX-FileCopyrightText: 2024 The Naja verilog authors <https://github.com/najaeda/naja-verilog/blob/main/AUTHORS> | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#include "gtest/gtest.h" | ||
|
||
#include <filesystem> | ||
#include <fstream> | ||
|
||
#include "VerilogConstructor.h" | ||
|
||
using namespace naja::verilog; | ||
|
||
#include "VerilogConstructorTest.h" | ||
|
||
#ifndef NAJA_VERILOG_BENCHMARKS | ||
#define NAJA_VERILOG_BENCHMARKS "Undefined" | ||
#endif | ||
|
||
TEST(NajaVerilogTest12, test) { | ||
VerilogConstructorTest constructor; | ||
std::filesystem::path test12Path( | ||
std::filesystem::path(NAJA_VERILOG_BENCHMARKS) | ||
/ std::filesystem::path("benchmarks") | ||
/ std::filesystem::path("test12.v")); | ||
|
||
constructor.setFirstPass(true); | ||
constructor.parse(test12Path); | ||
ASSERT_EQ(1, constructor.modules_.size()); | ||
auto test = constructor.modules_[0]; | ||
EXPECT_TRUE(test->ports_.empty()); | ||
EXPECT_TRUE(test->nets_.empty()); | ||
EXPECT_TRUE(test->assigns_.empty()); | ||
EXPECT_TRUE(test->instances_.empty()); | ||
|
||
constructor.setFirstPass(false); | ||
constructor.parse(test12Path); | ||
ASSERT_EQ(1, constructor.modules_.size()); | ||
EXPECT_TRUE(test->ports_.empty()); | ||
EXPECT_TRUE(test->assigns_.empty()); | ||
ASSERT_EQ(2, test->nets_.size()); | ||
ASSERT_EQ(3, test->instances_.size()); | ||
|
||
auto ins1 = test->instances_[0]; | ||
EXPECT_EQ("ins1", ins1.identifier_.name_); | ||
EXPECT_FALSE(ins1.identifier_.escaped_); | ||
EXPECT_EQ("CFG1", ins1.model_.name_); | ||
EXPECT_TRUE(ins1.parameterAssignments_.empty()); | ||
|
||
auto mem = test->instances_[1]; | ||
EXPECT_EQ("mem_regfile_mem_regfile_0_0", mem.identifier_.name_); | ||
EXPECT_FALSE(mem.identifier_.escaped_); | ||
EXPECT_EQ("RAM64x18", mem.model_.name_); | ||
EXPECT_TRUE(mem.parameterAssignments_.empty()); | ||
|
||
auto ins2 = test->instances_[2]; | ||
EXPECT_EQ("$$ins2@@", ins2.identifier_.name_); | ||
EXPECT_FALSE(ins2.identifier_.escaped_); | ||
EXPECT_EQ("CFG1", ins2.model_.name_); | ||
EXPECT_TRUE(ins2.parameterAssignments_.empty()); | ||
|
||
EXPECT_EQ(3, test->defParameterAssignments_.size()); | ||
auto def0Path = test->defParameterAssignments_[0].first; | ||
auto def0Value = test->defParameterAssignments_[0].second; | ||
EXPECT_EQ(2, def0Path.size()); | ||
EXPECT_EQ("ins1", def0Path[0].name_); | ||
EXPECT_FALSE(def0Path[0].escaped_); | ||
EXPECT_EQ("INIT", def0Path[1].name_); | ||
EXPECT_FALSE(def0Path[1].escaped_); | ||
EXPECT_EQ("2'h1", def0Value.getString()); | ||
EXPECT_EQ(Expression::Type::NUMBER ,def0Value.value_.index()); | ||
|
||
auto def1Path = test->defParameterAssignments_[1].first; | ||
auto def1Value = test->defParameterAssignments_[1].second; | ||
EXPECT_EQ(2, def1Path.size()); | ||
EXPECT_EQ("mem_regfile_mem_regfile_0_0", def1Path[0].name_); | ||
EXPECT_FALSE(def1Path[0].escaped_); | ||
EXPECT_EQ("RAMINDEX", def1Path[1].name_); | ||
EXPECT_FALSE(def1Path[1].escaped_); | ||
EXPECT_EQ(Expression::Type::STRING ,def1Value.value_.index()); | ||
EXPECT_EQ("mem_regfile[7:0]%32%8%SPEED%0%0%MICRO_RAM", def1Value.getString()); | ||
|
||
auto def2Path = test->defParameterAssignments_[2].first; | ||
auto def2Value = test->defParameterAssignments_[2].second; | ||
EXPECT_EQ(2, def2Path.size()); | ||
EXPECT_EQ("$$ins2@@", def2Path[0].name_); | ||
EXPECT_TRUE(def2Path[0].escaped_); | ||
EXPECT_EQ("INIT", def2Path[1].name_); | ||
EXPECT_FALSE(def2Path[1].escaped_); | ||
EXPECT_EQ(Expression::Type::NUMBER ,def2Value.value_.index()); | ||
EXPECT_EQ("2'h2", def2Value.getString()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// SPDX-FileCopyrightText: 2024 The Naja verilog authors <https://github.com/najaeda/naja-verilog/blob/main/AUTHORS> | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#include "gtest/gtest.h" | ||
|
||
#include <filesystem> | ||
#include <fstream> | ||
|
||
#include "VerilogConstructor.h" | ||
|
||
using namespace naja::verilog; | ||
|
||
#include "VerilogConstructorTest.h" | ||
|
||
#ifndef NAJA_VERILOG_BENCHMARKS | ||
#define NAJA_VERILOG_BENCHMARKS "Undefined" | ||
#endif | ||
|
||
TEST(NajaVerilogTest13, test) { | ||
VerilogConstructorTest constructor; | ||
std::filesystem::path test13Path( | ||
std::filesystem::path(NAJA_VERILOG_BENCHMARKS) | ||
/ std::filesystem::path("benchmarks") | ||
/ std::filesystem::path("test13.v")); | ||
|
||
constructor.setFirstPass(true); | ||
constructor.parse(test13Path); | ||
ASSERT_EQ(1, constructor.modules_.size()); | ||
auto test = constructor.modules_[0]; | ||
ASSERT_EQ(27, test->ports_.size()); | ||
EXPECT_TRUE(test->nets_.empty()); | ||
EXPECT_TRUE(test->assigns_.empty()); | ||
EXPECT_TRUE(test->instances_.empty()); | ||
|
||
constructor.setFirstPass(false); | ||
constructor.parse(test13Path); | ||
ASSERT_EQ(1, constructor.modules_.size()); | ||
ASSERT_EQ(27, test->ports_.size()); | ||
ASSERT_EQ(67, test->nets_.size()); | ||
EXPECT_TRUE(test->assigns_.empty()); | ||
EXPECT_EQ(69, test->instances_.size()); | ||
#if 0 | ||
EXPECT_EQ("ins", instance.identifier_.name_); | ||
EXPECT_EQ("MOD", instance.model_.name_); | ||
EXPECT_EQ(2, instance.parameterAssignments_.size()); | ||
using Parameters = std::vector<std::pair<std::string, std::string>>; | ||
Parameters parameters; | ||
for (const auto& [parameter, value]: instance.parameterAssignments_) { | ||
parameters.push_back({parameter, value}); | ||
} | ||
EXPECT_EQ("elem10", parameters[0].first); | ||
EXPECT_EQ("'o0", parameters[0].second); | ||
EXPECT_EQ("elem11", parameters[1].first); | ||
EXPECT_EQ("8'o84", parameters[1].second); | ||
#endif | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.