Skip to content

Commit

Permalink
Implemented rsyn service to manage routing guides from ispd18 contest
Browse files Browse the repository at this point in the history
  • Loading branch information
jucemarmonteiro authored and gaflach committed Dec 26, 2017
1 parent 1f82e3f commit 205c6c1
Show file tree
Hide file tree
Showing 4 changed files with 195 additions and 0 deletions.
67 changes: 67 additions & 0 deletions rsyn/src/rsyn/ispd18/Guide.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/* Copyright 2014-2017 Rsyn
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

/*
* File: Guide.h
* Author: jucemar
*
* Created on 21 de Dezembro de 2016, 17:58
*/

#ifndef ISPD18_GUIDE
#define ISPD18_GUIDE

#include <vector>
#include "rsyn/phy/PhysicalDesign.h"

namespace Rsyn {

class LayerGuide {
friend class RoutingGuide;
friend class NetGuide;
protected:
Rsyn::PhysicalLayer clsPhLayer;
Bounds clsBounds;
public:
LayerGuide() = default;
const Bounds & getBounds() const {
return clsBounds;
} // end method
Rsyn::PhysicalLayer getLayer() const {
return clsPhLayer;
} // end method
}; // end class

class NetGuide {
friend class RoutingGuide;
protected:
std::vector<LayerGuide> clsLayerGuides;
public:
NetGuide() = default;
const std::vector<LayerGuide> & allLayerGuides() const {
return clsLayerGuides;
} // end method
}; // end class

} // end namespace


#endif /* ISPD18_ROUTINGGUIDE */
64 changes: 64 additions & 0 deletions rsyn/src/rsyn/ispd18/RoutingGuide.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/* Copyright 2014-2017 Rsyn
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* File: RoutingGuide.cpp
* Author: jucemar
*
* Created on 21 de Dezembro de 2016, 17:47
*/

#include "RoutingGuide.h"
#include "rsyn/phy/PhysicalService.h"

namespace Rsyn {

void RoutingGuide::start(const Rsyn::Json &params) {
if(clsInitialized)
return;
clsDesign = clsSession.getDesign();
clsModule = clsDesign.getTopModule();
clsGuides = clsDesign.createAttribute();

Rsyn::PhysicalService* phService = clsSession.getService("rsyn.physical");
clsPhDesign = phService->getPhysicalDesign();
clsInitialized = true;
} // end method

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

void RoutingGuide::stop() {
} // end method

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

void RoutingGuide::loadGuides(const GuideDscp & dscp) {
for (const GuideNetDscp & netDscp : dscp.clsNetGuides) {
Rsyn::Net net = clsDesign.findNetByName(netDscp.clsNetName);
NetGuide & netGuide = clsGuides[net];
std::vector<LayerGuide> & layerGuides= netGuide.clsLayerGuides;
layerGuides.reserve(netDscp.clsLayerDscps.size());
for(const GuideLayerDscp & layerDscp : netDscp.clsLayerDscps) {
layerGuides.push_back(LayerGuide());
LayerGuide & layerGuide = layerGuides.back();
layerGuide.clsBounds = layerDscp.clsLayerGuide;
layerGuide.clsPhLayer = clsPhDesign.getPhysicalLayerByName(layerDscp.clsLayer);
} // end for
} // end for
} // end method

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

} // end namespace
62 changes: 62 additions & 0 deletions rsyn/src/rsyn/ispd18/RoutingGuide.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/* Copyright 2014-2017 Rsyn
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

/*
* File: RoutingGuide.h
* Author: jucemar
*
* Created on 21 de Dezembro de 2016, 17:47
*/

#ifndef ISPD18_ROUTINGGUIDE
#define ISPD18_ROUTINGGUIDE

#include "rsyn/session/Service.h"
#include "rsyn/session/Session.h"
#include "rsyn/ispd18/Guide.h"
#include "rsyn/io/parser/guide-ispd18/GuideDescriptor.h"

namespace Rsyn {

class RoutingGuide : public Rsyn::Service {
protected:
Rsyn::Session clsSession;
Rsyn::Design clsDesign;
Rsyn::Module clsModule;
Rsyn::PhysicalDesign clsPhDesign;
Rsyn::Attribute<Rsyn::Net, Rsyn::NetGuide> clsGuides;
bool clsInitialized = false;
public:
RoutingGuide() = default;
void start(const Rsyn::Json &params);
void stop();

void loadGuides(const GuideDscp & dscp);

const NetGuide & getGuide(Rsyn::Net net) const {
return clsGuides[net];
}
}; // end class

} // end namespace


#endif /* ISPD18_ROUTINGGUIDE */
2 changes: 2 additions & 0 deletions rsyn/src/rsyn/setup/service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "rsyn/io/Writer.h"
#include "rsyn/io/Graphics.h"
#include "rsyn/io/WebLogger.h"
#include "rsyn/ispd18/RoutingGuide.h"

// Registration
namespace Rsyn {
Expand All @@ -52,6 +53,7 @@ void Session::registerServices() {
registerService<Rsyn::Report>("rsyn.report");
registerService<Rsyn::Writer>("rsyn.writer");
registerService<Rsyn::Graphics>("rsyn.graphics");
registerService<Rsyn::RoutingGuide>("rsyn.routingGuide");
//registerService<Rsyn::WebLogger>("rsyn.webLogger");
} // end method
} // end namespace
Expand Down

0 comments on commit 205c6c1

Please sign in to comment.