166 lines
5.7 KiB
C++
166 lines
5.7 KiB
C++
/**************************************************************/
|
|
/* dataStreamer7Utils.h Date: 2019/06/29 */
|
|
/* */
|
|
/* Copyright (c) 2019 GIS. All rights reserved. */
|
|
/* */
|
|
/**************************************************************/
|
|
|
|
#ifndef _DATASTREAMER7UTILS_H_
|
|
#define _DATASTREAMER7UTILS_H_
|
|
|
|
class dataStreamer7Utils
|
|
{
|
|
public:
|
|
const uint32_t numCmdsInBlock = 15;
|
|
|
|
// Bit offsets of data streamer commands
|
|
enum DataStreamerCmdOffsets_e {
|
|
dsCmdOffset = 0,
|
|
dsNumParamsOffset = 4,
|
|
dsRedirectOffset = 7,
|
|
dsDestOffset = 8,
|
|
dsLoopOffset = 12,
|
|
dsParam0Offset = 20
|
|
};
|
|
|
|
// Valid data streamer commands
|
|
enum dataStreamerCmds_e {
|
|
rdDataPaddr = 0x0,
|
|
rdDataVaddr = 0x1,
|
|
loadAddrMap = 0x2,
|
|
loadCmdQVaddr = 0x3,
|
|
loadCmdQPaddr = 0x4,
|
|
nop = 0xf
|
|
};
|
|
|
|
// Valid data streamer destinations. Note cmdQueueDest is only for load command qwueue commands
|
|
enum headDest_e {
|
|
headDest0 = 0,
|
|
headDest1 = 1,
|
|
headDest2 = 2,
|
|
headDest3 = 3,
|
|
cmdQueueDest = 0,
|
|
tlbDest = 0
|
|
};
|
|
|
|
// Constructor
|
|
dataStreamer7Utils()
|
|
{
|
|
};
|
|
|
|
protected:
|
|
|
|
// Data streamer command word construction method
|
|
inline uint32_t streamerCmd (const uint32_t cmd,
|
|
const uint32_t numParams,
|
|
const uint32_t dest,
|
|
const uint32_t loop,
|
|
const uint32_t param0,
|
|
const bool redirect = false)
|
|
{
|
|
uint32_t word;
|
|
|
|
if (cmd == loadAddrMap )
|
|
{
|
|
word = (cmd << dsCmdOffset) |
|
|
((numParams & 0x7) << dsNumParamsOffset) |
|
|
((redirect ? 1 : 0) << dsRedirectOffset) |
|
|
((dest & 0x0f) << dsDestOffset) |
|
|
((param0 & 0xfffff) << dsLoopOffset);
|
|
}
|
|
else
|
|
{
|
|
word = (cmd << dsCmdOffset) |
|
|
((numParams & 0x7) << dsNumParamsOffset) |
|
|
((redirect ? 1 : 0) << dsRedirectOffset) |
|
|
((dest & 0x0f) << dsDestOffset) |
|
|
((loop & 0xff) << dsLoopOffset) |
|
|
((param0 & 0xfff) << dsParam0Offset);
|
|
}
|
|
return word;
|
|
};
|
|
|
|
// Data streamer command write method for memory
|
|
inline void writeDsCmd (
|
|
uint32_t* &memAddr,
|
|
const uint32_t cmd,
|
|
const uint32_t dest,
|
|
const uint32_t loop,
|
|
const uint32_t param0,
|
|
const uint32_t param1,
|
|
const bool redirect = false)
|
|
{
|
|
directWriteMem ((uint32_t)(memAddr++), streamerCmd(cmd, 2, dest, loop, param0, redirect), false);
|
|
directWriteMem ((uint32_t)(memAddr++), param1, false);
|
|
}
|
|
|
|
// Data streamer command write method for data streamer command port
|
|
inline void writeDsCmd (
|
|
const CDataStreamerAuto* pDs,
|
|
const uint32_t cmd,
|
|
const uint32_t dest,
|
|
const uint32_t loop,
|
|
const uint32_t param0,
|
|
const uint32_t param1,
|
|
const bool redirect = false)
|
|
{
|
|
pDs->pCmdPort->SetCmdPort(streamerCmd(cmd, 2, dest, loop, param0, redirect));
|
|
pDs->pCmdPort->SetCmdPort(param1);
|
|
}
|
|
|
|
// -------------------------------------------------
|
|
// Method to construct a linked list of streamer
|
|
// commands in memory for a multiple of a given
|
|
// image at a given address.
|
|
//
|
|
void constructImageLinkedList(
|
|
uint32_t* &listBaseAddr,
|
|
const uint32_t imgBaseAddr,
|
|
const uint32_t numOfImages,
|
|
const uint32_t numStripesPerImg,
|
|
const uint32_t stripeSizeWords
|
|
)
|
|
{
|
|
|
|
//FILE *fp;
|
|
|
|
//fp = fopen("debug_prime.txt", "wb");
|
|
|
|
// The total stripes is the number of stripes per image
|
|
uint32_t totalStripes = numOfImages * numStripesPerImg;
|
|
|
|
for(unsigned idx = 0; idx < totalStripes; idx++)
|
|
{
|
|
//fprintf(fp, "%8d: rdDataPaddr 0x%08x 0x%08x\n", idx, (uint32_t)listBaseAddr, imgBaseAddr + (idx % numStripesPerImg) * stripeSizeWords*4);
|
|
|
|
writeDsCmd(listBaseAddr,
|
|
rdDataPaddr,
|
|
headDest0,
|
|
0,
|
|
stripeSizeWords,
|
|
imgBaseAddr + (idx % numStripesPerImg) * stripeSizeWords*4,
|
|
(idx % numStripesPerImg) == numStripesPerImg-1);
|
|
|
|
|
|
if ((idx % (numCmdsInBlock-1)) == (numCmdsInBlock-2))
|
|
{
|
|
uint32_t stripesRemaining = totalStripes - idx - 1;
|
|
|
|
if (stripesRemaining)
|
|
{
|
|
uint32_t nextBlockAddr = (uint32_t)listBaseAddr + 4*2;
|
|
|
|
//fprintf(fp, "%8d: loadCmdQPaddr 0x%08x 0x%08x\n", idx, (uint32_t)listBaseAddr, nextBlockAddr);
|
|
|
|
writeDsCmd(listBaseAddr, loadCmdQPaddr, 0, 0, (stripesRemaining < (numCmdsInBlock-1)) ? stripesRemaining * 2 : numCmdsInBlock*2, nextBlockAddr);
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
//fclose(fp);
|
|
};
|
|
|
|
};
|
|
|
|
#endif
|