Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Netlist streaming #16

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
99ff607
Adding netlist streaming APIs
xtofalex Sep 21, 2022
aa75358
serialization and streaming of netlist
xtofalex Sep 21, 2022
083fb99
save current modifications
xtofalex Oct 5, 2022
55f881c
Merge remote-tracking branch 'origin/main' into netlist_streaming
xtofalex Oct 5, 2022
7a0edfa
merged change
xtofalex Oct 5, 2022
6570de5
Merge branch 'main' into netlist_streaming
xtofalex Feb 9, 2023
3c6f8ea
Merge branch 'main' into netlist_streaming
xtofalex Mar 10, 2023
8d58238
Merge branch 'main' into netlist_streaming
xtofalex Apr 1, 2023
8996379
Streaming testing in progress
xtofalex Apr 3, 2023
5f15cce
Trying to test SNL streaming
xtofalex Apr 4, 2023
d308380
Fix typo
xtofalex Apr 4, 2023
604018d
Typo again
xtofalex Apr 4, 2023
2400445
SNL streaming testing
xtofalex Apr 4, 2023
87547c0
Merge branch 'netlist_streaming' of https://github.com/xtofalex/naja …
xtofalex Apr 4, 2023
e5df95f
More time
xtofalex Apr 4, 2023
6e812ef
try to wait more
xtofalex Apr 4, 2023
b09dbce
Merge branch 'netlist_streaming' of https://github.com/xtofalex/naja …
xtofalex Apr 5, 2023
35fc4cc
disable streaming test for the moment
xtofalex Apr 5, 2023
152b494
Merge branch 'main' into netlist_streaming
xtofalex May 4, 2023
93d785a
Merge branch 'main' into netlist_streaming
xtofalex May 9, 2023
255ab10
Merge branch 'main' into netlist_streaming
xtofalex Jun 21, 2023
4e9f682
Merge branch 'main' into netlist_streaming
xtofalex Aug 2, 2023
ed2a80e
save current state
xtofalex Oct 17, 2023
cb297d3
Merge branch 'netlist_streaming' of https://github.com/xtofalex/naja …
xtofalex Oct 17, 2023
427576f
Merge remote-tracking branch 'origin/main' into netlist_streaming
xtofalex Oct 17, 2023
c929cab
use latest thirdparty
xtofalex Oct 17, 2023
999a294
use latest thirdparty
xtofalex Oct 17, 2023
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
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ add_subdirectory(test)
find_package(Doxygen)
if(DOXYGEN_FOUND)
add_subdirectory(docs)
endif(DOXYGEN_FOUND)
endif(DOXYGEN_FOUND)
2 changes: 1 addition & 1 deletion docs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ if(DOXYGEN_FOUND)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html DESTINATION doc OPTIONAL)
else (DOXYGEN_FOUND)
message("Doxygen need to be installed to generate the doxygen documentation")
endif (DOXYGEN_FOUND)
endif (DOXYGEN_FOUND)
2 changes: 1 addition & 1 deletion src/snl/snippets/app/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
#
# SPDX-License-Identifier: Apache-2.0

add_executable(snl_app SNLSnippet.cpp)
add_executable(snl_app SNLSnippet.cpp SNLUniverseSnippet.cpp)
target_include_directories(snl_app SYSTEM BEFORE PUBLIC ${Boost_INCLUDE_DIR})
target_link_libraries(snl_app Naja::SNL)
69 changes: 69 additions & 0 deletions src/snl/snippets/app/src/SNLReceiver.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#include <iostream>

#include "SNLDB.h"
#include "SNLCapnP.h"

using namespace naja::SNL;

namespace {

void displayDesign(const SNLDesign* design) {
std::cout << design->getDescription() << std::endl;
for (auto term: design->getTerms()) {
std::cout << term->getDescription() << std::endl;
}
for (auto net: design->getNets()) {
std::cout << net->getDescription() << std::endl;
}
for (auto instance: design->getInstances()) {
std::cout << instance->getDescription() << std::endl;
}
}

void displayLibrary(const SNLLibrary* lib) {
std::cout << lib->getDescription() << std::endl;
for (auto design: lib->getDesigns()) {
displayDesign(design);
}
}

void displayDB(const SNLDB* db) {
std::cout << db->getDescription() << std::endl;
for (auto lib: db->getLibraries()) {
displayLibrary(lib);
}
}

}

int main(int argc, char* argv[]) {
if (argc != 2) {
exit(34);
}
int port = std::stoi(argv[1]);

SNLDB* db = SNLCapnP::receive(port);
if (db) {
std::cout << "Received " << db->getString() << std::endl;
displayDB(db);
} else {
std::cout << "No DB received" << std::endl;
}
return 0;
/*
auto topIns1 = top->getInstance(SNLName("ins1"));
std::cout << topIns1->getName().getString() << " instance terminals:" << std::endl;
for (auto instTerm: topIns1->getInstTerms()) {
std::cout << " - " << instTerm->getTerm()->getName().getString() << std::endl;
}

auto topNet1 = top->getScalarNet(0); // net1 is an anonymous net at ID 0
std::cout << topNet1->getString() << " components:" << std::endl;
for (auto component: topNet1->getComponents()) {
std::cout << " - " << component->getString() << std::endl;
}

*/

return 0;
}
41 changes: 41 additions & 0 deletions src/snl/snippets/app/src/SNLSender.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#include <iostream>

#include "SNLUniverse.h"
#include "SNLCapnP.h"
#include "SNLUniverseSnippet.h"

using namespace naja::SNL;

int main(int argc, char* argv[]) {
if (argc != 3) {
exit(34);
}
std::string ipAddress = argv[1];
int port = std::stoi(argv[2]);

SNLUniverseSnippet::create();
auto universe = SNLUniverse::get();
assert(universe);
auto db = universe->getDB(1);
assert(db);

std::cout << "Sending " << db->getString() << std::endl;
SNLCapnP::send(db, ipAddress, port);
return 0;
/*
auto topIns1 = top->getInstance(SNLName("ins1"));
std::cout << topIns1->getName().getString() << " instance terminals:" << std::endl;
for (auto instTerm: topIns1->getInstTerms()) {
std::cout << " - " << instTerm->getTerm()->getName().getString() << std::endl;
}

auto topNet1 = top->getScalarNet(0); // net1 is an anonymous net at ID 0
std::cout << topNet1->getString() << " components:" << std::endl;
for (auto component: topNet1->getComponents()) {
std::cout << " - " << component->getString() << std::endl;
}

*/

return 0;
}
74 changes: 2 additions & 72 deletions src/snl/snippets/app/src/SNLSnippet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,79 +2,9 @@
//
// SPDX-License-Identifier: Apache-2.0

#include <iostream>

#include "SNLUniverse.h"
#include "SNLScalarNet.h"
#include "SNLScalarTerm.h"
#include "SNLBusTerm.h"
#include "SNLBusTermBit.h"
#include "SNLInstTerm.h"

using namespace naja::SNL;
#include "SNLUniverseSnippet.h"

int main() {
SNLUniverse::create();
auto db = SNLDB::create(SNLUniverse::get());
auto primLib = SNLLibrary::create(db, SNLLibrary::Type::Primitives, SNLName("primitives"));
auto prim0 = SNLDesign::create(primLib, SNLDesign::Type::Primitive);
auto prim1 = SNLDesign::create(primLib, SNLDesign::Type::Primitive);

auto mylib = SNLLibrary::create(db, SNLName("mylib"));

auto model1 = SNLDesign::create(mylib, SNLName("Model1"));
{
SNLScalarTerm::create(model1, SNLTerm::Direction::Input, SNLName("i0"));
SNLScalarTerm::create(model1, SNLTerm::Direction::Input, SNLName("i1"));
SNLScalarTerm::create(model1, SNLTerm::Direction::Output, SNLName("o"));
SNLParameter::create(model1, SNLName("PARAM0"), SNLParameter::Type::Decimal, "18");
SNLParameter::create(model1, SNLName("PARAM1"), SNLParameter::Type::String, "OPTION2");
SNLInstance::create(model1, prim0); // anonymous
SNLInstance::create(model1, prim1, SNLName("ins"));
}

std::cout << model1->getName().getString() << " terms:" << std::endl;
for (auto term: model1->getTerms()) {
std::cout << " - " << term->getString() << std::endl;
}

auto model2 = SNLDesign::create(mylib, SNLName("Model2"));
SNLBusTerm::create(model2, SNLTerm::Direction::Input, 4, 0, SNLName("i0"));
SNLScalarTerm::create(model2, SNLTerm::Direction::Input, SNLName("i1"));
SNLBusTerm::create(model2, SNLTerm::Direction::Output, 31, 0, SNLName("o"));
std::cout << model2->getName().getString() << " terms:" << std::endl;
for (auto term: model2->getTerms()) {
std::cout << " - " << term->getString() << std::endl;
}

auto top = SNLDesign::create(mylib, SNLName("top"));
{
auto i = SNLScalarTerm::create(top, SNLTerm::Direction::Input, SNLName("i"));
auto o = SNLScalarTerm::create(top, SNLTerm::Direction::Input, SNLName("o"));
auto ins1 = SNLInstance::create(top, model1, SNLName("ins1"));
auto ins2 = SNLInstance::create(top, model2, SNLName("ins2"));
auto net1 = SNLScalarNet::create(top); //anonymous
auto net2 = SNLScalarNet::create(top); //anonymous
auto net3 = SNLScalarNet::create(top, SNLName("n"));
i->setNet(net1);
ins1->getInstTerm(ins1->getModel()->getScalarTerm(SNLName("i0")))->setNet(net1);
ins1->getInstTerm(ins1->getModel()->getScalarTerm(SNLName("i1")))->setNet(net3);
ins2->getInstTerm(ins2->getModel()->getScalarTerm(SNLName("i1")))->setNet(net3);
ins2->getInstTerm(ins2->getModel()->getBusTerm(SNLName("o"))->getBit(0))->setNet(net3);
o->setNet(net2);
}

auto topIns1 = top->getInstance(SNLName("ins1"));
std::cout << topIns1->getName().getString() << " instance terminals:" << std::endl;
for (auto instTerm: topIns1->getInstTerms()) {
std::cout << " - " << instTerm->getTerm()->getName().getString() << std::endl;
}

auto topNet1 = top->getScalarNet(0); // net1 is an anonymous net at ID 0
std::cout << topNet1->getString() << " components:" << std::endl;
for (auto component: topNet1->getComponents()) {
std::cout << " - " << component->getString() << std::endl;
}

SNLUniverseSnippet::create();
return 0;
}
76 changes: 76 additions & 0 deletions src/snl/snippets/app/src/SNLUniverseSnippet.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#include "SNLUniverseSnippet.h"

#include <iostream>

#include "SNLUniverse.h"
#include "SNLScalarTerm.h"
#include "SNLBusTerm.h"
#include "SNLBusTermBit.h"
#include "SNLScalarNet.h"
#include "SNLInstTerm.h"

using namespace naja::SNL;

void SNLUniverseSnippet::create() {
SNLUniverse::create();
auto db = SNLDB::create(SNLUniverse::get());
auto primLib = SNLLibrary::create(db, SNLLibrary::Type::Primitives, SNLName("primitives"));
auto prim0 = SNLDesign::create(primLib, SNLDesign::Type::Primitive);
auto prim1 = SNLDesign::create(primLib, SNLDesign::Type::Primitive);

auto mylib = SNLLibrary::create(db, SNLName("mylib"));

auto model1 = SNLDesign::create(mylib, SNLName("Model1"));
{
SNLScalarTerm::create(model1, SNLTerm::Direction::Input, SNLName("i0"));
SNLScalarTerm::create(model1, SNLTerm::Direction::Input, SNLName("i1"));
SNLScalarTerm::create(model1, SNLTerm::Direction::Output, SNLName("o"));
SNLParameter::create(model1, SNLName("PARAM0"), SNLParameter::Type::Decimal, "18");
SNLParameter::create(model1, SNLName("PARAM1"), SNLParameter::Type::String, "OPTION2");
SNLInstance::create(model1, prim0); // anonymous
SNLInstance::create(model1, prim1, SNLName("ins"));
}

std::cout << model1->getName().getString() << " terms:" << std::endl;
for (auto term: model1->getTerms()) {
std::cout << " - " << term->getString() << std::endl;
}

auto model2 = SNLDesign::create(mylib, SNLName("Model2"));
SNLBusTerm::create(model2, SNLTerm::Direction::Input, 4, 0, SNLName("i0"));
SNLScalarTerm::create(model2, SNLTerm::Direction::Input, SNLName("i1"));
SNLBusTerm::create(model2, SNLTerm::Direction::Output, 31, 0, SNLName("o"));
std::cout << model2->getName().getString() << " terms:" << std::endl;
for (auto term: model2->getTerms()) {
std::cout << " - " << term->getString() << std::endl;
}

auto top = SNLDesign::create(mylib, SNLName("top"));
{
auto i = SNLScalarTerm::create(top, SNLTerm::Direction::Input, SNLName("i"));
auto o = SNLScalarTerm::create(top, SNLTerm::Direction::Input, SNLName("o"));
auto ins1 = SNLInstance::create(top, model1, SNLName("ins1"));
auto ins2 = SNLInstance::create(top, model2, SNLName("ins2"));
auto net1 = SNLScalarNet::create(top); //anonymous
auto net2 = SNLScalarNet::create(top); //anonymous
auto net3 = SNLScalarNet::create(top, SNLName("n"));
i->setNet(net1);
ins1->getInstTerm(ins1->getModel()->getScalarTerm(SNLName("i0")))->setNet(net1);
ins1->getInstTerm(ins1->getModel()->getScalarTerm(SNLName("i1")))->setNet(net3);
ins2->getInstTerm(ins2->getModel()->getScalarTerm(SNLName("i1")))->setNet(net3);
ins2->getInstTerm(ins2->getModel()->getBusTerm(SNLName("o"))->getBit(0))->setNet(net3);
o->setNet(net2);
}

auto topIns1 = top->getInstance(SNLName("ins1"));
std::cout << topIns1->getName().getString() << " instance terminals:" << std::endl;
for (auto instTerm: topIns1->getInstTerms()) {
std::cout << " - " << instTerm->getTerm()->getName().getString() << std::endl;
}

auto topNet1 = top->getScalarNet(0); // net1 is an anonymous net at ID 0
std::cout << topNet1->getString() << " components:" << std::endl;
for (auto component: topNet1->getComponents()) {
std::cout << " - " << component->getString() << std::endl;
}
}
9 changes: 9 additions & 0 deletions src/snl/snippets/app/src/SNLUniverseSnippet.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifndef __SNL_UNIVERSE_SNIPPET_H_
#define __SNL_UNIVERSE_SNIPPET_H_

class SNLUniverseSnippet {
public:
static void create();
};

#endif /* __SNL_UNIVERSE_SNIPPET_H_ */
18 changes: 16 additions & 2 deletions src/snl/snippets/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,19 @@
#
# SPDX-License-Identifier: Apache-2.0

add_executable(snl_snippet ${PROJECT_SOURCE_DIR}/src/snl/snippets/app/src/SNLSnippet.cpp)
target_link_libraries(snl_snippet naja_snl)
add_executable(snl_snippet
${PROJECT_SOURCE_DIR}/src/snl/snippets/app/src/SNLUniverseSnippet.cpp
${PROJECT_SOURCE_DIR}/src/snl/snippets/app/src/SNLSnippet.cpp
)
add_executable(snl_receiver
${PROJECT_SOURCE_DIR}/src/snl/snippets/app/src/SNLUniverseSnippet.cpp
${PROJECT_SOURCE_DIR}/src/snl/snippets/app/src/SNLReceiver.cpp
)
add_executable(snl_sender
${PROJECT_SOURCE_DIR}/src/snl/snippets/app/src/SNLUniverseSnippet.cpp
${PROJECT_SOURCE_DIR}/src/snl/snippets/app/src/SNLSender.cpp
)

target_link_libraries(snl_snippet naja_snl)
target_link_libraries(snl_receiver naja_snl_dump)
target_link_libraries(snl_sender naja_snl_dump)
16 changes: 16 additions & 0 deletions src/snl/snl/kernel/SNLDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "SNLUniverse.h"
#include "SNLDB0.h"
#include "SNLException.h"
#include "SNLMacros.h"

namespace naja { namespace SNL {

Expand Down Expand Up @@ -173,6 +174,15 @@ SNLID SNLDB::getSNLID() const {
return SNLID(id_);
}

void SNLDB::setID(SNLID::DBID id) {
if (SNLUniverse::get()->isDB0(this)) {
//error
}
SNLUniverse::get()->removeDB(this);
id_ = id;
SNLUniverse::get()->addDB(this);
}

bool SNLDB::isTopDB() const {
return SNLUniverse::get()->getTopDB() == this;
}
Expand All @@ -192,6 +202,12 @@ void SNLDB::setTopDesign(SNLDesign* design) {
topDesign_ = design;
}

bool SNLDB::deepCompare(const SNLDB* other, std::string& reason) const {
//don't compare SNLDB ID
DEEP_COMPARE_MEMBER(Libraries)
return true;
}

void SNLDB::mergeAssigns() {
for (auto library: getLibraries()) {
if (not library->isPrimitives()) {
Expand Down
9 changes: 9 additions & 0 deletions src/snl/snl/kernel/SNLDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ class SNLDB final: public SNLObject {
SNLID::DBID getID() const { return id_; }
SNLID getSNLID() const;

///\brief Change the SNLDB id. Main purpose: compare DBs after save and load.
///\param id new DBID
///\warning use with caution: all DB objects SNLIDs will be modified, as the DB id part of SNLID will
///be modified.
void setID(SNLID::DBID id);

///\return the SNLLibrary in this SNLDB with SNLID::LibraryID:id
SNLLibrary* getLibrary(SNLID::LibraryID id) const;
///\return the SNLLibrary in this SNLDB with SNLName:name
Expand Down Expand Up @@ -62,6 +68,9 @@ class SNLDB final: public SNLObject {
bool operator<(const SNLDB &rdb) const {
return getSNLID() < rdb.getSNLID();
}

bool deepCompare(const SNLDB* db, std::string& reason) const;

private:
SNLDB() = default;
SNLDB(SNLID::DBID id);
Expand Down
Loading