Skip to content

Commit

Permalink
Added an example showing how to query routing guides. See ExampleServ…
Browse files Browse the repository at this point in the history
…ice::doSomething().
  • Loading branch information
gaflach committed Dec 28, 2017
1 parent e20a212 commit 421bd0d
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 8 deletions.
5 changes: 5 additions & 0 deletions ispd18/README.md
Expand Up @@ -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) ![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.


8 changes: 7 additions & 1 deletion ispd18/src/ispd18/demo/ExampleProcess.cpp
Expand Up @@ -26,8 +26,14 @@ bool ExampleProcess::run(const Rsyn::Json &params) {
msg.replace("label", "world"); msg.replace("label", "world");
msg.print(); 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"); ExampleService *service = session.getService("example.service");
service->doNothing(); service->doSomething();


return true; return true;
} // end method } // end method
48 changes: 43 additions & 5 deletions ispd18/src/ispd18/demo/ExampleService.cpp
Expand Up @@ -16,6 +16,7 @@
#include "rsyn/core/Rsyn.h" #include "rsyn/core/Rsyn.h"
#include "rsyn/session/Session.h" #include "rsyn/session/Session.h"
#include "rsyn/phy/PhysicalService.h" #include "rsyn/phy/PhysicalService.h"
#include "rsyn/ispd18/RoutingGuide.h"
#include "ispd18/demo/ExampleService.h" #include "ispd18/demo/ExampleService.h"


// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
Expand All @@ -26,10 +27,10 @@ void ExampleService::start(const Rsyn::Json &params) {
design = session.getDesign(); design = session.getDesign();
module = design.getTopModule(); module = design.getTopModule();


Rsyn::PhysicalService *physical = session.getService("rsyn.physical"); physicalService = session.getService("rsyn.physical");
guideService = session.getService("rsyn.routingGuide");


Rsyn::PhysicalDesign phDesign; physicalDesign = physicalService->getPhysicalDesign();
phDesign = physical->getPhysicalDesign();


{ // helloWorld command { // helloWorld command
ScriptParsing::CommandDescriptor dscp; ScriptParsing::CommandDescriptor dscp;
Expand Down Expand Up @@ -61,6 +62,43 @@ void ExampleService::stop() {


// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------


void ExampleService::doNothing() { void ExampleService::doSomething() {
std::cout << "Doing nothing...\n"; 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 } // end method
9 changes: 8 additions & 1 deletion ispd18/src/ispd18/demo/ExampleService.h
Expand Up @@ -24,6 +24,8 @@


namespace Rsyn { namespace Rsyn {
class Session; class Session;
class PhysicalService;
class RoutingGuide;
}; };


class ExampleService : public Rsyn::Service { class ExampleService : public Rsyn::Service {
Expand All @@ -32,13 +34,18 @@ class ExampleService : public Rsyn::Service {
virtual void start(const Rsyn::Json &params); virtual void start(const Rsyn::Json &params);
virtual void stop(); virtual void stop();


void doNothing(); void doSomething();


private: private:


Rsyn::Design design; Rsyn::Design design;
Rsyn::Module module; // top module Rsyn::Module module; // top module


Rsyn::PhysicalDesign physicalDesign;

Rsyn::PhysicalService *physicalService = nullptr;
Rsyn::RoutingGuide *guideService = nullptr;

}; // end class }; // end class


#endif #endif
2 changes: 1 addition & 1 deletion ispd18/src/ispd18/setup/service.cpp
Expand Up @@ -25,7 +25,7 @@


// Registration // Registration
namespace Rsyn { namespace Rsyn {
static Startup registerMessages([]{ static Startup registerServices([]{
Rsyn::Session session; Rsyn::Session session;
session.registerService<ExampleService>("example.service"); session.registerService<ExampleService>("example.service");
}); });
Expand Down

0 comments on commit 421bd0d

Please sign in to comment.