diff --git a/chamsin/src/analogic/ChoiceParameter.h b/chamsin/src/analogic/ChoiceParameter.h new file mode 100644 index 00000000..87905f80 --- /dev/null +++ b/chamsin/src/analogic/ChoiceParameter.h @@ -0,0 +1,21 @@ +#ifndef CHOICEPARAMETER_H +#define CHOICEPARAMETER_H + +#include "DeviceParameter.h" + +class ChoiceParameter : public DeviceParameter { + public: + typedef vector 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 diff --git a/chamsin/src/analogic/Device.cpp b/chamsin/src/analogic/Device.cpp new file mode 100644 index 00000000..4c6bc969 --- /dev/null +++ b/chamsin/src/analogic/Device.cpp @@ -0,0 +1 @@ +#include "Device.h" diff --git a/chamsin/src/analogic/Device.h b/chamsin/src/analogic/Device.h new file mode 100644 index 00000000..526c2178 --- /dev/null +++ b/chamsin/src/analogic/Device.h @@ -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 { + bool operator()(const DeviceParameter& dp1, const DeviceParameter& dp2) const { + return dp1._id < dp2._id; + } + }; + typedef set 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 diff --git a/chamsin/src/analogic/DeviceParameter.h b/chamsin/src/analogic/DeviceParameter.h new file mode 100644 index 00000000..0181ae91 --- /dev/null +++ b/chamsin/src/analogic/DeviceParameter.h @@ -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 diff --git a/chamsin/src/analogic/StepParameter.h b/chamsin/src/analogic/StepParameter.h new file mode 100644 index 00000000..d2b76cde --- /dev/null +++ b/chamsin/src/analogic/StepParameter.h @@ -0,0 +1,24 @@ +#ifndef STEPPARAMETER_H +#define STEPPARAMETER_H + +template +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 StepIntParameter; + +#endif // STEPPARAMETER_H diff --git a/chamsin/src/analogic/Transistor.cpp b/chamsin/src/analogic/Transistor.cpp index 2fbd0b61..ae0cacaf 100644 --- a/chamsin/src/analogic/Transistor.cpp +++ b/chamsin/src/analogic/Transistor.cpp @@ -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); diff --git a/chamsin/src/analogic/Transistor.h b/chamsin/src/analogic/Transistor.h index 36a099c3..a4e9abed 100644 --- a/chamsin/src/analogic/Transistor.h +++ b/chamsin/src/analogic/Transistor.h @@ -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: