MatchLib
Static Public Member Functions | List of all members
Minmax< ArrT, ElemT, IdxT, is_max, Width > Class Template Reference

Compile-time minmax tree. More...

#include <comptrees.h>

Static Public Member Functions

static IdxT minmax (ArrT inputs, IdxT start, IdxT end)
 

Detailed Description

template<typename ArrT, typename ElemT, typename IdxT, bool is_max, unsigned Width>
class Minmax< ArrT, ElemT, IdxT, is_max, Width >

Compile-time minmax tree.

Template Parameters
ArrTArray type
ElemTElement type
IdxTtype of the index. This is to restrict the index's bitwidth
is_maxtrue if this is a max function, false for min
WidthThe width of this minmax tree, that is, the number of elements this instance of the tree is comparing. This must be a power of 2, but this is not (necessarily) the same as the size of the input array. This is mostly to define a base condition for the metaprogramming recursion (which is when Width=2)
Overview
This returns the index of either the largest or smallest element in the input array, which must be sized to a power of two.

This specialization is for arrays implemented as a bitvector in which each element is of the same bitwidth as that of ElemT. As SC datatypes do not have a slice operator, we use bitshifts to access the corresponding element.

A Simple Example
#include <comptrees.h>
...
typedef NVUINTW(ASSOC_LOG2) lru_t;
typedef NVUINTW(ASSOC_LOG2 * ASSOC) lru_set_t;
typedef NVUINTW(ASSOC_LOG2) way_idx_t;
typedef Minmax<lru_set_t, lru_t, way_idx_t, true, ASSOC> LruMinmaxTree;
lru_set_t lru_set;
way_idx_t way = LruMinmaxTree::minmax(lru_set, 0, ASSOC - 1);
...

Definition at line 73 of file comptrees.h.


The documentation for this class was generated from the following file: