Device Parameters in progress

This commit is contained in:
Christophe Alexandre 2008-07-04 07:54:41 +00:00
parent 287145f3c0
commit 98d3004a22
7 changed files with 97 additions and 3 deletions

View File

@ -0,0 +1,21 @@
#ifndef CHOICEPARAMETER_H
#define CHOICEPARAMETER_H
#include "DeviceParameter.h"
class ChoiceParameter : public DeviceParameter {
public:
typedef vector<string> Choices;
ChoiceParameter(string id, Choices& choices, unsigned value):
DeviceParameter(id), _choices(), _value(value) {
if (_value > choices.size()) {
throw Error("");
}
}
private:
Choices _choices;
unsigned _value;
};
#endif // CHOICEPARAMETER_H

View File

@ -0,0 +1 @@
#include "Device.h"

View File

@ -0,0 +1,27 @@
#ifndef DEVICE_H
#define DEVICE_H
#include "DeviceParameter.h"
#include "hurricane/Cell.h"
class Device : public Cell {
public:
struct DeviceParameterCompare:
public std::binary_function<const DeviceParameter&, const DeviceParameter&, bool> {
bool operator()(const DeviceParameter& dp1, const DeviceParameter& dp2) const {
return dp1._id < dp2._id;
}
};
typedef set<DeviceParameter, DeviceParameterCompare> DeviceParameterSet;
DeviceParameter& getParameter(const string& parameterId) const;
protected:
Device(Library* library, const Name& name): Cell(library, name) {}
void addParameter(const DeviceParameter& deviceParameter) {
_parameterSet.insert(deviceParameter);
}
private:
DeviceParameterSet _parameterSet;
};
#endif // DEVICE_H

View File

@ -0,0 +1,13 @@
#ifndef DEVICEPARAMETER_H
#define DEVICEPARAMETER_H
class DeviceParameter {
public:
const string _id;
string _getString() const;
Record* _getRecord() const;
protected:
DeviceParameter(string id): _id(id) {}
};
#endif // DEVICEPARAMETER_H

View File

@ -0,0 +1,24 @@
#ifndef STEPPARAMETER_H
#define STEPPARAMETER_H
template <Type>
class StepParameter : public DeviceParameter {
public:
StepParameter(Type min, Type max, Type step):
_min(min), _max(max), _step(step) {}
Type getMin() const { return _min; }
Type getMax() const { return _max, }
Type getStep() const { return _step; }
Type getValue() const { return _value, }
void setValue(Type value);
private:
Type _min;
Type _max;
Type _step;
Type _value;
};
typedef StepParameter<int> StepIntParameter;
#endif // STEPPARAMETER_H

View File

@ -6,6 +6,7 @@ using namespace Hurricane;
#include "AEnv.h"
#include "ATechnology.h"
#include "ChoiceParameter.h"
#include "Transistor.h"
namespace {
@ -85,7 +86,7 @@ Record* Transistor::AbutmentType::_getRecord() const {
Transistor::Transistor(Library* library, const Name& name,
const Polarity& polarity, DbU::Unit l, DbU::Unit w,
const AbutmentType& abutmentType):
Cell(library, name),
Device(library, name),
_drain(NULL),
_source(NULL),
_grid(NULL),
@ -115,6 +116,12 @@ Transistor* Transistor::create(Library* library, const Name& name,
void Transistor::_postCreate() {
Inherit::_postCreate();
ChoiceParameter::Choices choices;
choices.push_back(string("N"));
choices.push_back(string("P"));
addParameter(ChoiceParameter("polarity", choices, 0));
DataBase* db = DataBase::getDB();
Technology* technology = db->getTechnology();
_drain = Net::create(this, DrainName);

View File

@ -2,12 +2,13 @@
#define TRANSISTOR_H
#include "hurricane/Name.h"
#include "hurricane/Cell.h"
using namespace Hurricane;
#include "Device.h"
namespace Hurricane {
class Transistor : public Cell {
class Transistor : public Device {
public:
class Polarity {
public: