1 #include "BlockParameterWishbone.h"
\r
3 BlockParameterWishbone::BlockParameterWishbone() : BlockParameter() {
\r
4 userValue = defaultValue;
\r
6 wbAccess = BlockParameter::Read;
\r
8 wbDuration = BlockParameter::Permanent;
\r
11 BlockParameterWishbone::BlockParameterWishbone(AbstractBlock* _owner, const QString& _name , const QString& _type, const QString& _width, const QString& _value, int _wbAccess, QString _wbValue, int _wbDuration) : BlockParameter (_owner, _name, _type, _value) {
\r
14 wbAccess = _wbAccess;
\r
16 wbDuration = _wbDuration;
\r
19 QVariant BlockParameterWishbone::getValue() {
\r
23 return defaultValue;
\r
26 bool BlockParameterWishbone::isWishboneParameter() {
\r
30 void BlockParameterWishbone::setValue(const QString& _value) {
\r
31 userValue = QVariant(_value);
\r
34 bool BlockParameterWishbone::isValueSet() {
\r
35 if (userValue.isNull()) return false;
\r
39 bool BlockParameterWishbone::isDefaultValue() {
\r
40 if (userValue == defaultValue) return true;
\r
44 BlockParameter* BlockParameterWishbone::clone() {
\r
45 BlockParameter* block = new BlockParameterWishbone(owner,name,getTypeString(),width,defaultValue.toString(),wbAccess,wbValue,wbDuration);
\r
49 QString BlockParameterWishbone::toVHDL(int context, int flags) {
\r
53 if ((context == BlockParameter::Entity) || (context == BlockParameter::Component)) {
\r
55 QString formatBool = "%1 : %2 std_logic";
\r
56 QString formatVector = "%1 : %2 std_logic_vector(%3 downto %4)";
\r
57 if ((flags & BlockParameter::NoComma) == 0) {
\r
58 formatBool.append(";");
\r
59 formatVector.append(";");
\r
61 QString orientation="";
\r
62 if (wbAccess == Read) {
\r
63 orientation = "out";
\r
68 if (type == Boolean) {
\r
69 ret = formatVector.arg(name).arg(orientation);
\r
71 else if (type == Natural) {
\r
72 int w = width.toInt(&ok);
\r
74 ret = formatVector.arg(name).arg(orientation).arg("INVALID SIZE").arg("0");
\r
78 ret = formatVector.arg(name).arg(orientation).arg(w).arg("0");
\r
81 else if (type == Expression) {
\r
82 QString w = width.remove('$');
\r
84 ret = formatVector.arg(name).arg(orientation).arg(w).arg("0");
\r