Skip to content

Commit

Permalink
Merge branch 'std-update' of https://github.com/kactus2/kactus2dev in…
Browse files Browse the repository at this point in the history
…to std-update
  • Loading branch information
hagantsa committed Oct 18, 2023
2 parents 2d8e313 + cb4dfeb commit 4e872ce
Show file tree
Hide file tree
Showing 134 changed files with 2,562 additions and 1,536 deletions.
19 changes: 18 additions & 1 deletion Help/componenteditor/mode2022.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,16 @@ <h3>Condition</h3>
<p>
The condition defines when the mode is active. If the condition expression evaluates
to true, the component is operating in the defined mode. The condition may depend
on run-time value of a port, register field and other modes.
on run-time value of a port, register field and other modes. The expression accepts
the following special functions:
<ul>
<li><b>$ipxact_port_value</b>( [port slice name] )</li>
<li><b>$ipxact_field_value</b>( [field slice name] )</li>
<li><b>$ipxact_mode_condition</b>( [mode name] )</li>
</ul>
The functions refer to a port input value, a value stored in a bitfield or
another mode condition value, respectively. The port slices and field slices
are defined below.
</p>

<h3>Condition ports</h3>
Expand Down Expand Up @@ -73,5 +82,13 @@ <h3>Condition fields</h3>
<b>Description</b> is an optional field for textual description of the <i>port</i>.
</p>

<hr>
<p>
EXAMPLE. The mode named reset is active when the value of the bit 0 in the physical port
button_in i.e. button_in[0:0] is equal to 1.
<br>
<br>
<img src="../images/modeExample.png" alt="Example of a reset condition">
</p>
</body>
</html>
4 changes: 2 additions & 2 deletions Help/componenteditor/params.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ <h2>Parameters editor</h2>
which is resolved to a 64-bit integer value.</li>

<li><b>shortreal</b> indicates that the value shall resolve to a System Verilog
shorint, which is resolved to a 32-bit floating point value. Both standard and
shortint, which is resolved to a 32-bit floating point value. Both standard and
scientific format (e.g 0.002 and 2e-3) are supported. This type applies also to
<b>minimum value</b> and <b>maximum value</b>.</li>

<li><b>real</b> indicates that the value shall resolve to a System Verilog shortreal,
<li><b>real</b> indicates that the value shall resolve to a System Verilog real,
which is resolved to a 64-bit floating point value. Both standard and scientific
format (e.g. 0.002 and 2e-3) are supported. This type applies also to
<b>minimum value</b> and <b>maximum value</b>.</li>
Expand Down
Binary file added Help/images/modeExample.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 1 addition & 3 deletions IPXACTmodels/Component/ComponentReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,11 @@ void ComponentReader::parseRemapStates(QDomNode const& componentNode, QSharedPoi

if (!remapStateElement.isNull())
{
RemapStateReader remapStateReader;

QDomNodeList remapNodeList = remapStateElement.elementsByTagName(QStringLiteral("ipxact:remapState"));
for (int remapStateIndex = 0; remapStateIndex < remapNodeList.count(); ++remapStateIndex)
{
QDomNode remapStateNode = remapNodeList.at(remapStateIndex);
QSharedPointer<RemapState> newRemapState = remapStateReader.createRemapStateFrom(remapStateNode);
QSharedPointer<RemapState> newRemapState = RemapStateReader::createRemapStateFrom(remapStateNode);

newComponent->getRemapStates()->append(newRemapState);
}
Expand Down
8 changes: 3 additions & 5 deletions IPXACTmodels/Component/ComponentWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void ComponentWriter::writeComponent(QXmlStreamWriter& writer, QSharedPointer<Co
//-----------------------------------------------------------------------------
void ComponentWriter::writePowerDomains(QXmlStreamWriter& writer, QSharedPointer<Component> component) const
{
if (component->getPowerDomains()->isEmpty())
if (component->getRevision() != Document::Revision::Std22 || component->getPowerDomains()->isEmpty())
{
return;
}
Expand Down Expand Up @@ -190,13 +190,11 @@ void ComponentWriter::writeRemapStates(QXmlStreamWriter& writer, QSharedPointer<
{
if (component->getRevision() == Document::Revision::Std14 && !component->getRemapStates()->isEmpty())
{
RemapStateWriter remapStateWriter;

writer.writeStartElement(QStringLiteral("ipxact:remapStates"));

foreach (QSharedPointer<RemapState> remapState, *component->getRemapStates())
for (QSharedPointer<RemapState> remapState : *component->getRemapStates())
{
remapStateWriter.writeRemapState(writer, remapState);
RemapStateWriter::writeRemapState(writer, remapState);
}

writer.writeEndElement(); // ipxact:remapStates
Expand Down
4 changes: 3 additions & 1 deletion IPXACTmodels/Component/FieldSlice.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ class IPXACTMODELS_EXPORT FieldSlice : public NameGroup, public FieldReference,

public:

using List = QSharedPointer<QList<QSharedPointer<FieldSlice> > >;

//! The default constructor.
FieldSlice(QString const& name = QString());
explicit FieldSlice(QString const& name = QString());

//! Copy constructor
FieldSlice(const FieldSlice& other);
Expand Down
7 changes: 5 additions & 2 deletions IPXACTmodels/Component/Mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ Extendable()
//-----------------------------------------------------------------------------
Mode::Mode( const Mode& other ):
NameGroup(other),
Extendable(other)
Extendable(other),
condition_(other.condition_)
{
for (auto portSlice : *other.portSlices_)
{
Expand Down Expand Up @@ -56,6 +57,8 @@ Mode& Mode::operator=( const Mode& other )
{
NameGroup::operator=(other);
Extendable::operator=(other);

condition_ = other.condition_;

portSlices_->clear();
for (auto portSlice : *other.portSlices_)
Expand Down Expand Up @@ -91,7 +94,7 @@ void Mode::setCondition(QString const& conditionExpression)
//-----------------------------------------------------------------------------
// Function: Mode::getPortSlices()
//-----------------------------------------------------------------------------
QSharedPointer<QList<QSharedPointer<PortSlice> > > Mode::getPortSlices() const
PortSlice::List Mode::getPortSlices() const
{
return portSlices_;
}
Expand Down
12 changes: 6 additions & 6 deletions IPXACTmodels/Component/Mode.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <QString>
#include <QMap>


//-----------------------------------------------------------------------------
//! Mode describes the location and size of an area in memory.
//-----------------------------------------------------------------------------
Expand All @@ -32,6 +33,8 @@ class IPXACTMODELS_EXPORT Mode : public NameGroup, public Extendable

public:

using List = QSharedPointer<QList<QSharedPointer<Mode> > >;

/*!
* The default constructor.
*
Expand Down Expand Up @@ -67,7 +70,7 @@ class IPXACTMODELS_EXPORT Mode : public NameGroup, public Extendable
*
* @return The port slices.
*/
QSharedPointer<QList<QSharedPointer<PortSlice> > > getPortSlices() const;
PortSlice::List getPortSlices() const;


QSharedPointer<QList<QSharedPointer<FieldSlice> > > getFieldSlices() const;
Expand All @@ -78,13 +81,10 @@ class IPXACTMODELS_EXPORT Mode : public NameGroup, public Extendable
QString condition_;

//! The port slices available in the condition.
QSharedPointer<QList<QSharedPointer<PortSlice> > > portSlices_ =
QSharedPointer<QList<QSharedPointer<PortSlice> > >(new QList<QSharedPointer<PortSlice> >());

PortSlice::List portSlices_ = PortSlice::List(new QList<QSharedPointer<PortSlice> >());

//! The field slices available in the condition.
QSharedPointer<QList<QSharedPointer<FieldSlice> > > fieldSlices_ =
QSharedPointer<QList<QSharedPointer<FieldSlice> > >(new QList<QSharedPointer<FieldSlice> >());
FieldSlice::List fieldSlices_ = FieldSlice::List(new QList<QSharedPointer<FieldSlice> >());

};

Expand Down
28 changes: 20 additions & 8 deletions IPXACTmodels/Component/ModeReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,30 @@ QSharedPointer<Mode> ModeReader::createModeFrom(QDomNode const& modeNode)

NameGroupReader::parseNameGroup(modeNode, newMode);

Details::parseCondition(modeNode, newMode);

Details::parsePortSlices(modeNode, newMode);

Details::parseFieldSlices(modeNode, newMode);

return newMode;
}

//-----------------------------------------------------------------------------
// Function: ModeReader::Details::parseCondition()
//-----------------------------------------------------------------------------
void ModeReader::Details::parseCondition(QDomNode const& modeNode, QSharedPointer<Mode> newMode)
{
auto conditionElement = modeNode.firstChildElement(QStringLiteral("ipxact:condition"));
newMode->setCondition(conditionElement.firstChild().nodeValue());
}

//-----------------------------------------------------------------------------
// Function: ModeReader::parsePortSlices()
//-----------------------------------------------------------------------------
void ModeReader::Details::parsePortSlices(QDomNode const& modeNode, QSharedPointer<Mode> newMode)
{
QDomNodeList sliceNodeList = modeNode.toElement().elementsByTagName(QStringLiteral("ipxact:portSlice"));
auto sliceNodeList = modeNode.toElement().elementsByTagName(QStringLiteral("ipxact:portSlice"));

const int SLICE_COUNT = sliceNodeList.count();
for (int i = 0; i < SLICE_COUNT; ++i)
Expand All @@ -54,8 +65,9 @@ void ModeReader::Details::parsePortSlices(QDomNode const& modeNode, QSharedPoint
auto portRef = portRefElement.attribute(QStringLiteral("portRef"));
newSlice->setPortRef(portRef);

QDomNode partSelectNode = portSliceElement.firstChildElement(QStringLiteral("ipxact:partSelect"));
if (!partSelectNode.isNull())

if (QDomNode partSelectNode = portSliceElement.firstChildElement(QStringLiteral("ipxact:partSelect"));
!partSelectNode.isNull())
{
QSharedPointer<PartSelect> newPartSelect = CommonItemsReader::parsePartSelect(partSelectNode);
newSlice->setPartSelect(newPartSelect);
Expand All @@ -70,7 +82,7 @@ void ModeReader::Details::parsePortSlices(QDomNode const& modeNode, QSharedPoint
//-----------------------------------------------------------------------------
void ModeReader::Details::parseFieldSlices(QDomNode const& modeNode, QSharedPointer<Mode> newMode)
{
QDomNodeList sliceNodeList = modeNode.toElement().elementsByTagName(QStringLiteral("ipxact:fieldSlice"));
auto sliceNodeList = modeNode.toElement().elementsByTagName(QStringLiteral("ipxact:fieldSlice"));

const int SLICE_COUNT = sliceNodeList.count();
for (int i = 0; i < SLICE_COUNT; ++i)
Expand All @@ -95,13 +107,13 @@ void ModeReader::Details::parseFieldSlices(QDomNode const& modeNode, QSharedPoin
//-----------------------------------------------------------------------------
void ModeReader::Details::parseRange(QDomElement const& element, QSharedPointer<Range> range)
{
QDomElement rangeElement = element.firstChildElement(QStringLiteral("ipxact:range"));
auto rangeElement = element.firstChildElement(QStringLiteral("ipxact:range"));
if (!rangeElement.isNull())
{
QString leftRange = rangeElement.firstChildElement(QStringLiteral("ipxact:left")).firstChild().nodeValue();
QString rightRange = rangeElement.firstChildElement(QStringLiteral("ipxact:right")).firstChild().nodeValue();
auto leftRange = rangeElement.firstChildElement(QStringLiteral("ipxact:left")).firstChild().nodeValue();
auto rightRange = rangeElement.firstChildElement(QStringLiteral("ipxact:right")).firstChild().nodeValue();

range->setLeft(leftRange);
range->setRight(rightRange);
}
}
}
13 changes: 9 additions & 4 deletions IPXACTmodels/Component/ModeReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ namespace ModeReader
namespace Details
{

/*!
* Parses the mode condition.
*
* @param [in] modeNode XML description of the nodet.
* @param [in] newMode The selected mode item.
*
*/
void parseCondition(QDomNode const& modeNode, QSharedPointer<Mode> newMode);

/*!
* Read the remap ports.
*
Expand All @@ -66,11 +75,7 @@ namespace ModeReader
*
*/
void parseRange(QDomElement const& element, QSharedPointer<Range> range);


}


};

#endif // VIEWREADER_H
11 changes: 10 additions & 1 deletion IPXACTmodels/Component/ModeWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include <IPXACTmodels/common/NameGroupWriter.h>
#include <IPXACTmodels/Component/FieldReferenceWriter.h>


//-----------------------------------------------------------------------------
// Function: ModeWriter::writeMode()
//-----------------------------------------------------------------------------
Expand All @@ -27,13 +26,23 @@ void ModeWriter::writeMode(QXmlStreamWriter& writer, QSharedPointer<Mode> mode)

NameGroupWriter::writeNameGroup(writer, mode, Document::Revision::Std22);

Details::writeCondition(writer, mode);

Details::writePortSlices(writer, mode);

Details::writeFieldSlices(writer, mode);

writer.writeEndElement(); // ipxact:mode
}

//-----------------------------------------------------------------------------
// Function: ModeWriter::Details::writeCondition()
//-----------------------------------------------------------------------------
void ModeWriter::Details::writeCondition(QXmlStreamWriter& writer, QSharedPointer<Mode> mode)
{
CommonItemsWriter::writeNonEmptyElement(writer, QStringLiteral("ipxact:condition"), mode->getCondition());
}

//-----------------------------------------------------------------------------
// Function: ModeWriter::Details::writePortSlices()
//-----------------------------------------------------------------------------
Expand Down
21 changes: 21 additions & 0 deletions IPXACTmodels/Component/ModeWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,28 @@ namespace ModeWriter

namespace Details
{
/*!
* Write the mode condition to an XML file.
*
* @param [in] writer The used xml writer.
* @param [in] view The mode whose condition to write.
*/
void writeCondition(QXmlStreamWriter& writer, QSharedPointer<Mode> mode);

/*!
* Write the mode port slices to an XML file.
*
* @param [in] writer The used xml writer.
* @param [in] view The mode whose port slices to write.
*/
void writePortSlices(QXmlStreamWriter& writer, QSharedPointer<Mode> mode);

/*!
* Write the mode field slices to an XML file.
*
* @param [in] writer The used xml writer.
* @param [in] view The mode whose field slices to write.
*/
void writeFieldSlices(QXmlStreamWriter& writer, QSharedPointer<Mode> mode);
}
};
Expand Down
2 changes: 2 additions & 0 deletions IPXACTmodels/Component/PortSlice.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class IPXACTMODELS_EXPORT PortSlice : public NameGroup

public:

using List = QSharedPointer<QList<QSharedPointer<PortSlice> > >;

/*!
* The default constructor.
*/
Expand Down
Loading

0 comments on commit 4e872ce

Please sign in to comment.