Skip to content

Commit

Permalink
Merge pull request #6 from HEP-SoC/field_node_methods
Browse files Browse the repository at this point in the history
Field node methods made public for external bit manipulation.
  • Loading branch information
Risto97 authored May 31, 2024
2 parents 755c68a + c85dadf commit 23eac1a
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions src/peakrdl_halcpp/include/field_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,11 @@ namespace halcpp
*/
static constexpr uint32_t get_abs_addr() { return PARENT_TYPE().get_abs_addr(); }

protected:
using parent_type = PARENT_TYPE;

static constexpr uint32_t start_bit = START_BIT;
static constexpr uint32_t end_bit = END_BIT;
static constexpr uint32_t width = END_BIT - START_BIT + 1;

using dataType = typename std::conditional<width <= 8, uint8_t,
typename std::conditional<width <= 16, uint16_t, uint32_t>::type>::type;
/**
* @brief Return the width of the field noe.
*
*/
static constexpr uint32_t get_width() { return width; }

/**
* @brief Calculate the field mask.
Expand All @@ -59,6 +55,18 @@ namespace halcpp
{
return (((1u << (width)) - 1));
}



protected:
using parent_type = PARENT_TYPE;

static constexpr uint32_t start_bit = START_BIT;
static constexpr uint32_t end_bit = END_BIT;
static constexpr uint32_t width = END_BIT - START_BIT + 1;

using dataType = typename std::conditional<width <= 8, uint8_t,
typename std::conditional<width <= 16, uint16_t, uint32_t>::type>::type;
};

/**
Expand Down

0 comments on commit 23eac1a

Please sign in to comment.