Permalink
Browse files

Added an example showing how to query routing guides. See ExampleServ…

…ice::doSomething().
  • Loading branch information...
gaflach committed Dec 28, 2017
1 parent e20a212 commit 421bd0d8d5ff97f21ea2e1467fb661a437486c5d
View
@@ -51,3 +51,8 @@ Select file "rsyn-x/ispd18/sample/ispd18_sample/ispd18_sample.rsyn"
![Rsyn](https://github.com/rsyn/rsyn-x/blob/master/ispd18/media/rsyn-screenshot-01.png)
## Routing Guides
See ExampleService::doSomething() to check how to access routing guides from the code.
@@ -26,8 +26,14 @@ bool ExampleProcess::run(const Rsyn::Json &params) {
msg.replace("label", "world");
msg.print();
// Start service if not running yet.
if (!session.isServiceRunning("example.service")) {
session.startService("example.service");
} // end if
// Get the service and do something.
ExampleService *service = session.getService("example.service");
service->doNothing();
service->doSomething();
return true;
} // end method
@@ -16,6 +16,7 @@
#include "rsyn/core/Rsyn.h"
#include "rsyn/session/Session.h"
#include "rsyn/phy/PhysicalService.h"
#include "rsyn/ispd18/RoutingGuide.h"
#include "ispd18/demo/ExampleService.h"
// -----------------------------------------------------------------------------
@@ -26,10 +27,10 @@ void ExampleService::start(const Rsyn::Json &params) {
design = session.getDesign();
module = design.getTopModule();
Rsyn::PhysicalService *physical = session.getService("rsyn.physical");
physicalService = session.getService("rsyn.physical");
guideService = session.getService("rsyn.routingGuide");
Rsyn::PhysicalDesign phDesign;
phDesign = physical->getPhysicalDesign();
physicalDesign = physicalService->getPhysicalDesign();
{ // helloWorld command
ScriptParsing::CommandDescriptor dscp;
@@ -61,6 +62,43 @@ void ExampleService::stop() {
// -----------------------------------------------------------------------------
void ExampleService::doNothing() {
std::cout << "Doing nothing...\n";
void ExampleService::doSomething() {
const int N = 10;
int counter;
// Traverse nets and their routing guides.
std::cout << "Nets:\n";
counter = 0;
for (Rsyn::Net net : module.allNets()) {
std::cout << net.getName() << "\n";
const Rsyn::NetGuide &netGuide = guideService->getGuide(net);
for (const Rsyn::LayerGuide &layerGuide : netGuide.allLayerGuides()) {
std::cout << " " << layerGuide.getBounds() << " " << layerGuide.getLayer().getName() << "\n";
} // end for
if (++counter >= N) {
break;
} // end if
} // end if
// Traverse cells and print their width and height.
std::cout << "Cells:\n";
counter = 0;
for (Rsyn::Instance instance : module.allInstances()) {
if (instance.getType() != Rsyn::CELL)
continue;
Rsyn::Cell cell = instance.asCell();
Rsyn::PhysicalCell physicalCell = physicalDesign.getPhysicalCell(cell);
std::cout << cell.getName() << " (" << physicalCell.getWidth() << ", "
<< physicalCell.getHeight() << ")\n";
if (++counter >= N) {
break;
} // end if
} // end for
} // end method
@@ -24,6 +24,8 @@
namespace Rsyn {
class Session;
class PhysicalService;
class RoutingGuide;
};
class ExampleService : public Rsyn::Service {
@@ -32,13 +34,18 @@ class ExampleService : public Rsyn::Service {
virtual void start(const Rsyn::Json &params);
virtual void stop();
void doNothing();
void doSomething();
private:
Rsyn::Design design;
Rsyn::Module module; // top module
Rsyn::PhysicalDesign physicalDesign;
Rsyn::PhysicalService *physicalService = nullptr;
Rsyn::RoutingGuide *guideService = nullptr;
}; // end class
#endif
@@ -25,7 +25,7 @@
// Registration
namespace Rsyn {
static Startup registerMessages([]{
static Startup registerServices([]{
Rsyn::Session session;
session.registerService<ExampleService>("example.service");
});

0 comments on commit 421bd0d

Please sign in to comment.