MatchLib
All Classes Namespaces Files Functions Modules Pages
Classes | Public Types | Public Member Functions | Public Attributes | Static Public Attributes | List of all members
ScratchpadClass< T, N, CAPACITY_IN_WORDS > Class Template Reference

Parameterized banked scratchpad memory implemented as a C++ class (i.e. not a SystemC module) More...

#include <Scratchpad.h>

Classes

struct  bank_req_t
 

Public Types

typedef cli_req_t< T, ADDR_WIDTH, N > req_t
 
typedef cli_rsp_t< T, N > rsp_t
 

Public Member Functions

typedef NVUINTW (NBANKS_LOG2) bank_sel_t
 
typedef NVUINTW (ADDR_WIDTH - NBANKS_LOG2) bank_addr_t
 
void store (req_t req)
 
rsp_t load (req_t req)
 
void load_store (req_t curr_cli_req, rsp_t &load_rsp)
 

Public Attributes

mem_array_sep< T, CAPACITY_IN_WORDS, N > banks
 
bank_req_t input_reqs [N]
 
bool input_reqs_valid [N]
 
bank_req_t bank_reqs [N]
 
bool bank_reqs_valid [N]
 
bank_rsps_data [N]
 
bool bank_rsps_valid [N]
 
bool load_rsps_valid [N]
 
cli_rsp_t< T, N > load_rsp
 
bank_sel_t bank_src_lane [N]
 
bank_sel_t bank_dst_lane [N]
 

Static Public Attributes

static const int ADDR_WIDTH = nvhls::nbits<CAPACITY_IN_WORDS - 1>::val
 
static const int NBANKS_LOG2 = nvhls::nbits<N - 1>::val
 

Detailed Description

template<typename T, int N, int CAPACITY_IN_WORDS>
class ScratchpadClass< T, N, CAPACITY_IN_WORDS >

Parameterized banked scratchpad memory implemented as a C++ class (i.e. not a SystemC module)

Template Parameters
TEntryType
NNumber of requests
CAPACITY_IN_WORDSTotal number of words of type T in memory
Overview
-Assumptions: All N requests are guaranteed conflict-free. An assertion message will be emitted if there are any bank conflicts.
Available Member Functions
void store(req_t req); // Stores (ie writes) N request to banked memory
rsp_t load(req_t req); // Loads (ie reads) N requests from banked memory
A Simple Example
#include <Scratchpad.h>
...
...
local_mem::mem_class_t scratchpad1; // instantiate a ScratchpadClass
local_mem::scratchpad_req_t sp_req; // local scratchpad request type
// copy incoming request to scratchpad request
#pragma hls_unroll yes
for (int i=0 ; i < local_mem::num_inputs; i++)
sp_req.set(i, req1.addr + i, req1.data[i]);
if (req1.is_load) {
// if it is a load (i.e. read) operation, get the read data from the RAM
local_mem::base_rsp_t rsp = scratchpad1.load(sp_req);
// compute MAC
local_mem::word_type sum=0;
#pragma hls_unroll yes
for (int i=0; i < local_mem::num_inputs; i++) {
sum += rsp.data[i] * req1.data[i];
}
// Push out the sum
out1.Push(sum);
}
else
{
// if it is a store (i.e. write) operation, write the data to the RAM
scratchpad1.store(sp_req);
}
Traits class for Scratchpad and ScratchpadClass.
Definition Scratchpad.h:396
Usage Guidelines

This class sets the stall mode to flush by default to mitigate possible RTL bugs that can occur in the default stall mode. If you are confident that this class of bugs will not occur in your use case, you can change the stall mode via TCL directive:

directive set /path/to/ScratchpadClass/run/while -PIPELINE_STALL_MODE stall
Parameterized banked scratchpad memory implemented as a C++ class (i.e. not a SystemC module)
Definition Scratchpad.h:101

This may reduce area/power.

Definition at line 101 of file Scratchpad.h.

Member Typedef Documentation

◆ req_t

template<typename T , int N, int CAPACITY_IN_WORDS>
typedef cli_req_t<T, ADDR_WIDTH, N> ScratchpadClass< T, N, CAPACITY_IN_WORDS >::req_t

Definition at line 116 of file Scratchpad.h.

◆ rsp_t

template<typename T , int N, int CAPACITY_IN_WORDS>
typedef cli_rsp_t<T, N> ScratchpadClass< T, N, CAPACITY_IN_WORDS >::rsp_t

Definition at line 117 of file Scratchpad.h.

Member Function Documentation

◆ store()

template<typename T , int N, int CAPACITY_IN_WORDS>
void ScratchpadClass< T, N, CAPACITY_IN_WORDS >::store ( req_t  req)
inline

Definition at line 132 of file Scratchpad.h.

◆ load()

template<typename T , int N, int CAPACITY_IN_WORDS>
rsp_t ScratchpadClass< T, N, CAPACITY_IN_WORDS >::load ( req_t  req)
inline

Definition at line 138 of file Scratchpad.h.

◆ load_store()

template<typename T , int N, int CAPACITY_IN_WORDS>
void ScratchpadClass< T, N, CAPACITY_IN_WORDS >::load_store ( req_t  curr_cli_req,
rsp_t load_rsp 
)
inline

Definition at line 145 of file Scratchpad.h.

Member Data Documentation

◆ ADDR_WIDTH

template<typename T , int N, int CAPACITY_IN_WORDS>
const int ScratchpadClass< T, N, CAPACITY_IN_WORDS >::ADDR_WIDTH = nvhls::nbits<CAPACITY_IN_WORDS - 1>::val
static

Definition at line 104 of file Scratchpad.h.

◆ NBANKS_LOG2

template<typename T , int N, int CAPACITY_IN_WORDS>
const int ScratchpadClass< T, N, CAPACITY_IN_WORDS >::NBANKS_LOG2 = nvhls::nbits<N - 1>::val
static

Definition at line 107 of file Scratchpad.h.

◆ banks

template<typename T , int N, int CAPACITY_IN_WORDS>
mem_array_sep<T, CAPACITY_IN_WORDS, N> ScratchpadClass< T, N, CAPACITY_IN_WORDS >::banks

Definition at line 120 of file Scratchpad.h.

◆ input_reqs

template<typename T , int N, int CAPACITY_IN_WORDS>
bank_req_t ScratchpadClass< T, N, CAPACITY_IN_WORDS >::input_reqs[N]

Definition at line 121 of file Scratchpad.h.

◆ input_reqs_valid

template<typename T , int N, int CAPACITY_IN_WORDS>
bool ScratchpadClass< T, N, CAPACITY_IN_WORDS >::input_reqs_valid[N]

Definition at line 122 of file Scratchpad.h.

◆ bank_reqs

template<typename T , int N, int CAPACITY_IN_WORDS>
bank_req_t ScratchpadClass< T, N, CAPACITY_IN_WORDS >::bank_reqs[N]

Definition at line 123 of file Scratchpad.h.

◆ bank_reqs_valid

template<typename T , int N, int CAPACITY_IN_WORDS>
bool ScratchpadClass< T, N, CAPACITY_IN_WORDS >::bank_reqs_valid[N]

Definition at line 124 of file Scratchpad.h.

◆ bank_rsps_data

template<typename T , int N, int CAPACITY_IN_WORDS>
T ScratchpadClass< T, N, CAPACITY_IN_WORDS >::bank_rsps_data[N]

Definition at line 125 of file Scratchpad.h.

◆ bank_rsps_valid

template<typename T , int N, int CAPACITY_IN_WORDS>
bool ScratchpadClass< T, N, CAPACITY_IN_WORDS >::bank_rsps_valid[N]

Definition at line 126 of file Scratchpad.h.

◆ load_rsps_valid

template<typename T , int N, int CAPACITY_IN_WORDS>
bool ScratchpadClass< T, N, CAPACITY_IN_WORDS >::load_rsps_valid[N]

Definition at line 127 of file Scratchpad.h.

◆ load_rsp

template<typename T , int N, int CAPACITY_IN_WORDS>
cli_rsp_t<T, N> ScratchpadClass< T, N, CAPACITY_IN_WORDS >::load_rsp

Definition at line 128 of file Scratchpad.h.

◆ bank_src_lane

template<typename T , int N, int CAPACITY_IN_WORDS>
bank_sel_t ScratchpadClass< T, N, CAPACITY_IN_WORDS >::bank_src_lane[N]

Definition at line 129 of file Scratchpad.h.

◆ bank_dst_lane

template<typename T , int N, int CAPACITY_IN_WORDS>
bank_sel_t ScratchpadClass< T, N, CAPACITY_IN_WORDS >::bank_dst_lane[N]

Definition at line 130 of file Scratchpad.h.


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