-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
51 remove size limitation from capnpreaderoptions to allow parsing of…
… big inputs2 (#53) * adding test and fix * dump verilog in test * cleaning and adding long tests * more testing * more coverage * add faulty script
- Loading branch information
Showing
19 changed files
with
302 additions
and
41 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
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,60 @@ | ||
// SPDX-FileCopyrightText: 2023 The Naja authors <https://github.com/najaeda/naja/blob/main/AUTHORS> | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#include "gtest/gtest.h" | ||
|
||
#include "SNLUniverse.h" | ||
#include "SNLScalarTerm.h" | ||
#include "SNLPyLoader.h" | ||
#include "SNLException.h" | ||
using namespace naja::SNL; | ||
|
||
#ifndef SNL_PRIMITIVES_TEST_PATH | ||
#define SNL_PRIMITIVES_TEST_PATH "Undefined" | ||
#endif | ||
|
||
class SNLPyDesignLoaderTest0: public ::testing::Test { | ||
protected: | ||
void SetUp() override { | ||
auto universe = SNLUniverse::create(); | ||
auto db = SNLDB::create(universe); | ||
primitives_ = SNLLibrary::create(db, SNLLibrary::Type::Primitives, SNLName("primitives")); | ||
auto primitive = SNLDesign::create(primitives_, SNLDesign::Type::Primitive, SNLName("primitive")); | ||
auto pi = SNLScalarTerm::create(primitive, SNLTerm::Direction::Input, SNLName("i")); | ||
auto po = SNLScalarTerm::create(primitive, SNLTerm::Direction::Output, SNLName("o")); | ||
auto designsLibrary = SNLLibrary::create(db, SNLName("designs")); | ||
design_ = SNLDesign::create(designsLibrary, SNLName("design")); | ||
} | ||
void TearDown() override { | ||
if (SNLUniverse::get()) { | ||
SNLUniverse::get()->destroy(); | ||
} | ||
} | ||
SNLLibrary* primitives_; | ||
SNLDesign* design_; | ||
}; | ||
|
||
TEST_F(SNLPyDesignLoaderTest0, test) { | ||
auto scriptPath = std::filesystem::path(SNL_PRIMITIVES_TEST_PATH); | ||
scriptPath /= "scripts"; | ||
scriptPath /= "design_loader.py"; | ||
SNLPyLoader::loadDesign(design_, scriptPath); | ||
|
||
//ASSERT_EQ(2, db->getLibraries().size()); | ||
} | ||
|
||
TEST_F(SNLPyDesignLoaderTest0, testDesignLoadingError) { | ||
auto scriptPath = std::filesystem::path(SNL_PRIMITIVES_TEST_PATH); | ||
scriptPath /= "scripts"; | ||
scriptPath /= "design_faulty.py"; | ||
EXPECT_THROW(SNLPyLoader::loadDesign(design_, scriptPath), SNLException); | ||
} | ||
|
||
TEST_F(SNLPyDesignLoaderTest0, testPrimitiveLoadingError) { | ||
auto design = SNLDesign::create(primitives_, SNLDesign::Type::Primitive, SNLName("top")); | ||
auto scriptPath = std::filesystem::path(SNL_PRIMITIVES_TEST_PATH); | ||
scriptPath /= "scripts"; | ||
scriptPath /= "design_loader.py"; | ||
EXPECT_THROW(SNLPyLoader::loadDesign(design, scriptPath), SNLException); | ||
} |
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,71 @@ | ||
// SPDX-FileCopyrightText: 2023 The Naja authors <https://github.com/najaeda/naja/blob/main/AUTHORS> | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#include "gtest/gtest.h" | ||
|
||
#include "SNLUniverse.h" | ||
#include "SNLScalarTerm.h" | ||
#include "SNLException.h" | ||
#include "SNLPyLoader.h" | ||
#include "SNLCapnP.h" | ||
#include "SNLVRLDumper.h" | ||
using namespace naja::SNL; | ||
|
||
#ifndef SNL_PYEDIT_TEST_PATH | ||
#define SNL_PYEDIT_TEST_PATH "Undefined" | ||
#endif | ||
#ifndef SNL_DUMP_PATH | ||
#define SNL_DUMP_PATH "Undefined" | ||
#endif | ||
|
||
class SNLPyHugeMatrixTest: public ::testing::Test { | ||
protected: | ||
void SetUp() override { | ||
SNLUniverse::create(); | ||
auto db = SNLDB::create(SNLUniverse::get()); | ||
auto primitivesLibrary = SNLLibrary::create(db, SNLLibrary::Type::Primitives, SNLName("primitives")); | ||
auto square = SNLDesign::create(primitivesLibrary, SNLDesign::Type::Primitive, SNLName("square")); | ||
auto n = SNLScalarTerm::create(square, SNLTerm::Direction::Output, SNLName("n")); | ||
auto e = SNLScalarTerm::create(square, SNLTerm::Direction::Output, SNLName("e")); | ||
auto s = SNLScalarTerm::create(square, SNLTerm::Direction::Input, SNLName("s")); | ||
auto w = SNLScalarTerm::create(square, SNLTerm::Direction::Input, SNLName("w")); | ||
designsLibrary_ = SNLLibrary::create(db, SNLName("designs")); | ||
} | ||
void TearDown() override { | ||
if (SNLUniverse::get()) { | ||
SNLUniverse::get()->destroy(); | ||
} | ||
} | ||
SNLLibrary* designsLibrary_; | ||
}; | ||
|
||
TEST_F(SNLPyHugeMatrixTest, test) { | ||
auto db = SNLDB::create(SNLUniverse::get()); | ||
auto scriptPath = std::filesystem::path(SNL_PYEDIT_TEST_PATH); | ||
scriptPath /= "scripts"; | ||
scriptPath /= "huge_matrix.py"; | ||
auto top = SNLDesign::create(designsLibrary_, SNLName("top")); | ||
SNLPyLoader::loadDesign(top, scriptPath); | ||
|
||
//dump the design | ||
auto dumpPath = std::filesystem::path(SNL_DUMP_PATH); | ||
dumpPath /= "huge_matrix"; | ||
if (std::filesystem::exists(dumpPath)) { | ||
std::filesystem::remove_all(dumpPath); | ||
} | ||
SNLCapnP::dump(top->getDB(), dumpPath); | ||
|
||
//dump verilog | ||
auto outPath = std::filesystem::path(SNL_DUMP_PATH); | ||
SNLVRLDumper dumper; | ||
dumper.setTopFileName(top->getName().getString() + ".v"); | ||
dumper.setSingleFile(true); | ||
dumper.dumpDesign(top, outPath); | ||
|
||
SNLUniverse::get()->destroy(); | ||
top = nullptr; | ||
designsLibrary_ = nullptr; | ||
|
||
SNLCapnP::load(dumpPath); | ||
} |
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,12 @@ | ||
# SPDX-FileCopyrightText: 2023 The Naja authors <https://github.com/najaeda/naja/blob/main/AUTHORS> | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import snl | ||
|
||
def construct(design): | ||
ERROR | ||
pass | ||
|
||
def constructDB(design): | ||
construct(design) |
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,21 @@ | ||
# SPDX-FileCopyrightText: 2023 The Naja authors <https://github.com/najaeda/naja/blob/main/AUTHORS> | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import snl | ||
|
||
def construct(design): | ||
universe = snl.SNLUniverse.get() | ||
db = universe.getDB(1) | ||
if db is None: | ||
raise Exception("Cannot find the db containing the primitives and top") | ||
primitives = db.getLibrary("primitives") | ||
if primitives is None: | ||
raise Exception("Cannot find the primitives library") | ||
prim = primitives.getDesign("primitive") | ||
if prim is None: | ||
raise Exception("Cannot find the primitive design") | ||
snl.SNLInstance.create(design, prim, "myins") | ||
|
||
def constructDB(db): | ||
construct(db) |
Oops, something went wrong.