-
Notifications
You must be signed in to change notification settings - Fork 67
[svdconv] Generate position/mask macros for dim fields #2545
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
efd0d22
[svdconv] Generate position/mask macros for dim fields
thorstendb-ARM 0fbf77d
[svdconv] Improve dim field position/mask coverage
thorstendb-ARM 155ca4a
[svdconv] Restore dimension expression null check
thorstendb-ARM 88585c3
Rename SVDConv test directory
thorstendb-ARM c9ffd4a
Rename SVDConv unit test directory
thorstendb-ARM File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
|
|
||
| <device schemaVersion="1.3" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="CMSIS-SVD.xsd"> | ||
| <vendor>ARM Ltd.</vendor> | ||
| <vendorID>ARM</vendorID> | ||
| <name>PosMaskDim</name> | ||
| <series>ARM Cortex M3</series> | ||
| <version>1.0</version> | ||
| <description>Test device for dim fields in pos/mask generation.</description> | ||
|
|
||
| <cpu> | ||
| <name>CM3</name> | ||
| <revision>r2p1</revision> | ||
| <endian>little</endian> | ||
| <mpuPresent>true</mpuPresent> | ||
| <fpuPresent>false</fpuPresent> | ||
| <vtorPresent>true</vtorPresent> | ||
| <nvicPrioBits>3</nvicPrioBits> | ||
| <vendorSystickConfig>false</vendorSystickConfig> | ||
| </cpu> | ||
|
|
||
| <addressUnitBits>8</addressUnitBits> | ||
| <width>32</width> | ||
| <size>32</size> | ||
| <access>read-write</access> | ||
| <resetValue>0x00000000</resetValue> | ||
| <resetMask>0xFFFFFFFF</resetMask> | ||
|
|
||
| <peripherals> | ||
| <peripheral> | ||
| <name>TIM</name> | ||
| <description>Timer.</description> | ||
| <baseAddress>0x40000000</baseAddress> | ||
| <addressBlock> | ||
| <offset>0x0</offset> | ||
| <size>0x400</size> | ||
| <usage>registers</usage> | ||
| </addressBlock> | ||
| <registers> | ||
| <register> | ||
| <name>DATA[%s]</name> | ||
| <description>Data register.</description> | ||
| <addressOffset>0x0</addressOffset> | ||
| <dim>256</dim> | ||
| <dimIncrement>4</dimIncrement> | ||
| <size>32</size> | ||
| <fields> | ||
| <field> | ||
| <name>PIN%s</name> | ||
| <description>Pin data.</description> | ||
| <bitOffset>0</bitOffset> | ||
| <bitWidth>1</bitWidth> | ||
| <dim>8</dim> | ||
| <dimIncrement>1</dimIncrement> | ||
| <dimIndex>0-7</dimIndex> | ||
| <enumeratedValues> | ||
| <enumeratedValue> | ||
| <name>Disabled</name> | ||
| <description>Channel disabled.</description> | ||
| <value>0</value> | ||
| </enumeratedValue> | ||
| <enumeratedValue> | ||
| <name>Enabled</name> | ||
| <description>Channel enabled.</description> | ||
| <value>1</value> | ||
| </enumeratedValue> | ||
| </enumeratedValues> | ||
| </field> | ||
| </fields> | ||
| </register> | ||
| </registers> | ||
| </peripheral> | ||
| </peripherals> | ||
| </device> |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| /* | ||
| * Copyright (c) 2010-2021 Arm Limited. All rights reserved. | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
| #include "CodeGenerator.h" | ||
| #include "HeaderData.h" | ||
| #include "SvdDimension.h" | ||
| #include "SvdField.h" | ||
| #include "SvdRegister.h" | ||
|
|
||
| #include "gtest/gtest.h" | ||
| #include <memory> | ||
| #include <string> | ||
|
|
||
| using namespace std; | ||
|
|
||
|
|
||
| TEST(CodeGenerator, Check) { | ||
| #if 0 | ||
| CodeGenerator gen; | ||
| const string text = "This is a %i printf %s"; | ||
| int num = 42; | ||
| const char* textInsert = "insertion test"; | ||
|
|
||
| const string& res = gen.FormatStr(text, num, textInsert); | ||
|
|
||
| ASSERT_EQ("This is a 42 printf insertion test", res); | ||
| #endif | ||
| } | ||
|
|
||
|
|
||
| namespace { | ||
|
|
||
| class RootItem : public SvdItem { | ||
| public: | ||
| RootItem() : SvdItem(nullptr) {} | ||
|
|
||
| const string& GetPrependToName() override { return m_empty; } | ||
| const string& GetAppendToName() override { return m_empty; } | ||
|
|
||
| private: | ||
| const string m_empty; | ||
| }; | ||
|
|
||
| class TestHeaderData : public HeaderData { | ||
| public: | ||
| using HeaderData::HeaderData; | ||
| using HeaderData::CreateRegisterPosMask; | ||
| }; | ||
|
|
||
| SvdField* AddField(SvdItem* parent, const string& name, uint32_t offset) { | ||
| const auto field = new SvdField(parent); | ||
| field->SetName(name); | ||
| field->SetOffset(offset); | ||
| field->SetBitWidth(1); | ||
| parent->AddItem(field); | ||
| return field; | ||
| } | ||
|
|
||
| } // namespace | ||
|
|
||
|
|
||
| TEST(HeaderData, CreateRegisterPosMaskHandlesDimensionVariants) { | ||
| SvdOptions options; | ||
| FileHeaderInfo fileHeaderInfo; | ||
| TestHeaderData headerData(fileHeaderInfo, options); | ||
|
|
||
| auto root = make_unique<RootItem>(); | ||
| const auto reg = new SvdRegister(root.get()); | ||
| reg->SetName("CTRL"); | ||
| root->AddItem(reg); | ||
|
|
||
| const auto fields = new SvdFieldContainer(reg); | ||
| reg->AddItem(fields); | ||
| AddField(fields, "PLAIN", 0); | ||
|
|
||
| const auto arrayField = AddField(fields, "ARRAY", 1); | ||
| const auto arrayDim = new SvdDimension(arrayField); | ||
| arrayDim->GetExpression()->SetType(SvdTypes::Expression::ARRAY); | ||
| arrayField->SetDimension(arrayDim); | ||
|
|
||
| const auto extendField = AddField(fields, "EXTEND%s", 2); | ||
| const auto extendDim = new SvdDimension(extendField); | ||
| extendDim->GetExpression()->SetType(SvdTypes::Expression::EXTEND); | ||
| extendField->SetDimension(extendDim); | ||
|
|
||
| AddField(extendDim, "EXTEND0", 2); | ||
| const auto invalidField = AddField(extendDim, "EXTEND1", 3); | ||
| invalidField->SetValid(false); | ||
| extendDim->AddItem(new SvdItem(extendDim)); | ||
|
|
||
| PosMaskNames names; | ||
| names.name = "TEST"; | ||
| EXPECT_TRUE(headerData.CreateRegisterPosMask(reg, &names)); | ||
| } | ||
|
|
||
|
|
||
|
|
File renamed without changes.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.