FPGA_GenericIP/firmware/top/src/test/src/runTest.cpp
2020-05-18 18:19:46 +01:00

2637 lines
No EOL
92 KiB
C++

/**************************************************************/
/* runTest.cpp Date: 2018/08/9 */
/* */
/* Copyright (c) 2018-2019 GIS. All rights reserved. */
/* */
/**************************************************************/
#include "tb.h"
#include "runTest.h"
#include "utils.h"
extern "C" {
#include "VUser.h"
}
// Burst bus bits -- 9:0 start req delay,
// 10 first pulse, 11 last pulse
// 12 start request0, 13 start request1
// Vector bus bits -- 11:0 Wave seq start delay, 19:12 wave seq start addr,
// 20 wave seq start bit0,
// 21 wave seq start bit1
const uint32_t runTest::PSEQ_PATTERN0 [] = {
0x60000002, // BUS_BURST : entries 2
0x00001C02, // start print data core req0 (fetch pixels) with delay = 3 (minimum)
0x00010A20, // Length of wave sequence
0x31100A10, // VEC_SET : start wave sequence 0 at addr 0 and delay 2576
0x10000001, // TRIG_MASK : set mask for trigger 0(FP1)
0x20000001, // WAIT_TRIG : wait for FP1
0x60000001, // BUS_BURST : entries 1
0x00002C02, // start print data core req1 (fetch pixels) with delay = 3 (minimum)
0x31200A10, // VEC_SET : start wave sequence 1 at addr 0 and delay 2576
0xF0000000, // END
0x00000000, // NOP
0x00000000, // NOP
0x00000000, // NOP
0x00000000, // NOP
0x00000000, // NOP
0x00000000, // NOP
0x00000000, // NOP
0x00000000, // NOP
0x00000000, // NOP
0x00000000, // NOP
0x00000000, // NOP
0x00000000, // NOP
0x00000000, // NOP
0x00000000, // NOP
0x00000000, // NOP
0x00000000, // NOP
0x00000000, // NOP
0x00000000, // NOP
0x00000000, // NOP
0x00000000, // NOP
0x00000000 // NOP
};
// Burst bus bits -- Unused on wave sequencer
// Vector bus bits -- 0 reset_tick_bit, 1 print_all_on, 2 print_latch, 3 print_load_bit
// 4 print_gsclk_bit, 5 print_plstm2_bit, 6 print_plstm1_bit, 7 print_stb_bit
// NB: the minimum time between waveform pulses (i.e. the time between print_latch
// assertions must be 260 cycles (at 100MHz clock) in order to avoid re-asserting
// the latch signal before data has finished transferring.
const uint32_t runTest::WSEQ_PATTERN0 [] = {
0x10000001 , // TRIG_MASK : set mask for trigger 0(clocks)
0x30000004 , // VEC_SET : latch = 1
0x00000000 , // NOP : This guarantees pulse is wide enough
0x30000000 , // VEC_SET : latch = 0
0x00000000 , // NOP : Gap
0x30000008 , // VEC_SET : load = 1
0x00000000 , // NOP : This guarantees pulse is wide enough
0x30000000 , // VEC_SET : load = 0
0x00000000 , // NOP : Gap
0x30000080 , // VEC_SET : stb = 1
0x00000000 , // NOP : Gap
0x30000090 , // VEC_SET : gsclk = 1
0x00000000 , // NOP : This guarantees pulse is wide enough
0x30000080 , // VEC_SET : gsclk = 0
0x00000000 , // NOP : Gap
0x300000A0 , // VEC_SET : plstm2 = 1
0x20000168 , // TRIG_WAIT : wait for 3.6us
0x30000080 , // VEC_SET : plstm2 = 0
0x00000000 , // NOP : Gap
0x300000C0 , // VEC_SET : plstm1 = 1
0x200002D0 , // TRIG_WAIT : wait for 7.2us
0x30000080 , // VEC_SET : plstm1 = 0
0x00000000 , // NOP : Gap
0xB0001FF4 , // LOOP : Repeat 1 times from GSCLK
0x30000000 , // VEC_SET : stb = 0
0x00000000 , // NOP : Gap
0xF0000000 , // END -
0x00000000 , // NOP
0x00000000 , // NOP
0x00000000 , // NOP
0x00000000 , // NOP
0x00000000 , // NOP
0x00000000 , // NOP
0x00000000
};
// Define a default sequence for the FPM sequencer
static uint32_t fpmSeq [] = {
0x30000000, // VEC_SET now 0
0x1000000F, // Trigger mask F
0x30000000, // VEC_SET now 0
0x20000001, // Trig wait 1
0x30000294, // Vec set 0x2e794. Num stripes (bits 15:8) define the number of stripes. Update as required.
0x30000200, // Vec set 0x2e700. Num stripes (bits 15:8) define the number of stripes. Update as required.
0xC0000003
};
// Define the length of the FPM sequence
static uint32_t fpmSeqLen = 7;
const uint32_t runTest::STRIPE_1BPP0[] = {
0xa42bd927, 0x24a8cc72, 0xb901c283, 0x32325f78, 0xc6fe6c62, 0xf3fb2a4d, 0x49e1644f, 0x6d962e42,
0x1005cdc0, 0x7030d3ba, 0xa87f236a, 0xa8e1b1b5, 0x3c830c6b, 0x4d54dc5c, 0x4c40df37, 0x2d82bcf3,
0x21adc3dd, 0xad12be86, 0x6c3b9418, 0xabe9d8a8, 0x5d708a8c, 0x676c487b, 0xba19bee9, 0xec16de81,
0xbb742f49, 0x698471fa, 0xfe32f4c4, 0x89c600ba, 0xd0e1a0c0, 0xbd842192, 0x0e531133, 0x6663ab03,
0x547ec54f, 0x6ea2abae, 0xe03b4d23, 0x24a8cc72, 0xb901c283, 0x04452878, 0x32325f78, 0xc6fe6c62,
0xf3fb2a4d, 0x49e1644f, 0x6d962e42, 0x1005cdc0, 0x7030d3ba, 0xa87f236a, 0xa8e1b1b5, 0x3c830c6b,
0x4d54dc5c, 0x4c40df37, 0x2d82bcf3, 0x21adc3dd, 0xad12be86, 0x6c3b9418, 0xabe9d8a8, 0x5d708a8c,
0x676c487b, 0xba19bee9, 0xec16de81, 0xbb742f49, 0x698471fa, 0xfe32f4c4, 0xd0e1a0c0, 0xbd842192,
0x0e531133, 0x6663ab03, 0x547ec54f, 0x6ea2abae, 0xa87f236a, 0xa8e1b1b5, 0x3c830c6b, 0x4d54dc5c,
0x4c40df37, 0x2d82bcf3, 0x21adc3dd, 0x6c3b9418, 0xabe9d8a8, 0x5d708a8c, 0x676c487b, 0xba19bee9,
0xec16de81, 0xbb742f49, 0x698471fa, 0xfe32f4c4, 0xd0e1a0c0, 0x0e531133, 0x6663ab03, 0x547ec54f,
0x6ea2abae, 0xe03b4d23, 0xa87f236a, 0xa8e1b1b5, 0x3c830c6b, 0x4d54dc5c, 0x6589be5a, 0xf666098a,
0x0098aa54, 0x10008754, 0xbf097658, 0x12345679
};
// --------------------------------------------------
// Test code
// --------------------------------------------------
int runTest::start(uint32_t* coreBaseAddr, int node)
{
int error = 0;
// ------------------------------------
// Create a core object for reg access
CCoreAuto* pCore = new CCoreAuto(coreBaseAddr);
CTestAuto* pTestBench = new CTestAuto((uint32_t*)(0));
// Get the serialiser access object from the core
CPrintCtrlAuto* pPrintCtrl = pCore->pPrintCtrl;
// ------------------------------------
// Get the test bench configurations
maxOpWidth = pTestBench->pConfig->GetMaxOpWidth();
shiftDepth = pTestBench->pConfig->GetShiftDepth();
trim_ps = pTestBench->pConfig->GetTrimPs() ? true : false;
enSerdes = pTestBench->pConfig->GetEnSerdes() ? true : false;
numHeads = pTestBench->pConfig->GetNumHeads();
subHeads = pTestBench->pConfig->GetSubHeads();
clkFreqMHz = pTestBench->pConfigClkFreq->GetConfigClkFreq();
i2cFreqKHz = pTestBench->pConfigI2cFreq->GetConfigI2cFreq();
uint32_t clkTicksPerMicroSec = clkFreqMHz;
// Set a test timeout value (units are system clock ticks)
pTestBench->pTimeout->SetTimeout(50000 * clkTicksPerMicroSec); // 50ms
// ------------------------------------
// Run a sanity check to check we're
// able to access blocks and memory
// before diving into main tests
if (sanityTest(pCore, node) != 0)
{
VPrint("Error: Sanity test failure.\n");
return TEST_ERROR;
}
VPrint("\nNODE%d: Starting main tests...\n", node);
VPrint("NODE%d: Configuration: maxOpWidth=%d shiftDepth=%d trimPs=%d enSerdes=%d numHeads=%d subHeads=%d clkFreqMHz=%d i2clkFreqKHz=%d\n\n",
node, maxOpWidth, shiftDepth, trim_ps ? 1:0, enSerdes ? 1 : 0, numHeads, subHeads, clkFreqMHz, i2cFreqKHz);
// ------------------------------------
// Run the main tests
if (enable.e & avalonBus)
error |= avalon_bus_test (pCore, node);
if (enable.e & waveSeq)
error |= wave_seq_test (pCore, node);
if (enable.e & uartAddr)
error |= uart_addr_test (pCore, node);
if (enable.e & subPixel)
error |= sub_pixel_firing_test (pCore, node);
if (enable.e & dataCore)
error |= data_core_test (pCore, node);
if (enable.e & printStreamer)
error |= print_streamer_test (pCore, node);
if (enable.e & dataCore2Bpp)
error |= data_core_multi_bpp_test (pCore, 2, node);
if (enable.e & dataCore3Bpp)
error |= data_core_multi_bpp_test (pCore, 3, node);
if (enable.e & linkCrc)
error |= link_crc_test (pCore, node);
if (enable.e & linkTrain)
error |= link_train_test (pCore, node);
if (enable.e & shutdownMon)
error |= shtdn_mon_test (pCore, node);
if (enable.e & fpgaCfg)
error |= fpga_cfg_test (pCore, node);
if (enable.e & swimEntry)
error |= swim_entry_test (pCore, node);
if (enable.e & swimTxRx)
error |= swim_txrx_test (pCore, node);
if ((enable.e & all) != all)
{
pTestBench->pControl->SetPartialTest(1);
}
else
{
pTestBench->pControl->SetPartialTest(0);
}
// Return status to calling function
return error ? TEST_ERROR :
enable.e != all ? NOFAILURES :
NOERROR;
}
// --------------------------------------------------
// Sanity test
// --------------------------------------------------
int runTest::sanityTest(CCoreAuto* pCore, int node)
{
uint32_t data;
bool error = false;
VPrint("NODE%d: SanityTest()...\n\n", node);
// ------------------------------------
// Get the serialiser access object from the core
CPrintCtrlAuto* pPrintCtrl = pCore->pPrintCtrl;
// ------------------------------------
// Read back PrintCtrl ID register
if ((data = pPrintCtrl->pIpId->GetIpId()) != EXPECTED_PC_ID)
{
VPrint("Error: Unexpected PrinCtrl ID (%08x v %08x)\n", data, EXPECTED_PC_ID);
error = true;
}
else
{
VPrint("NODE%d: PrintCtrl ID = 0x%08x\n", node, data);
}
// Read back PrintCtrl version register
if ((data = pPrintCtrl->pIpVer->GetIpVer()) != EXPECTED_PC_VER)
{
error = true;
}
else
{
VPrint("NODE%d: PrintCtrl version = 0x%08x\n", node, data);
}
// ------------------------------------
// Write to memory over CSR bus
write_ext(TEST_ADDR1, TEST_VAL1);
write_ext(TEST_ADDR2, TEST_VAL2);
// ------------------------------------
// Write to memory directly
WriteRamWord(TEST_ADDR3, TEST_VAL3, 0, node);
// ------------------------------------
// Read back memory
read_ext(TEST_ADDR1, &data);
if(data != TEST_VAL1)
{
error = true;
}
else
{
VPrint("NODE%d: Memory #1 = 0x%08x\n", node, data);
}
read_ext(TEST_ADDR2, &data);
if(data != TEST_VAL2)
{
error = true;
}
else
{
VPrint("NODE%d: Memory #2 = 0x%08x\n", node, data);
}
read_ext(TEST_ADDR3, &data);
if(data != TEST_VAL3)
{
error = true;
}
else
{
VPrint("NODE%d: Memory #3 = 0x%08x\n", node, data);
}
return error ? TEST_ERROR : NOERROR;
}
// --------------------------------------------------
// SWIM entry tests
// --------------------------------------------------
int runTest::swim_entry_test (CCoreAuto* pCore, int node)
{
int error = NOERROR;
uint32_t status;
CSwim2Auto* pSwim = pCore->pSwim2;
CTestAuto* pTestBench = new CTestAuto((uint32_t*)(0));
VPrint("Starting SWIM entry tests\n");
// Set high speed mode
pSwim->pControl->SetHighSpeed(1);
// Put TB receiver in entry detection mode
pTestBench->pSwimRxCtrl->SetEntryMode(1);
// Send entry sequence, and reset to low speed
pSwim->pControl->SetHighSpeed(0);
pSwim->pControl->SetSendEntrySeq(1);
// Wait until not busy
while(pSwim->pStatus->GetTxbusy())
{
usleepSim(1);
}
// Fetch receiver values
uint32_t swimRxl = pTestBench->pSwimRxShiftLo->GetSwimRxShiftLo();
uint32_t swimRxh = pTestBench->pSwimRxShiftHigh->GetSwimRxShiftHigh();
// Check expected receiver signature for entry sequence
if (swimRxh != SWIM_ENTRY_SIGNATURE_HI and swimRxl != SWIM_ENTRY_SIGNATURE_LO)
{
VPrint("**ERROR 0 : SWIM entry failure (0x%08x%08x).\n", swimRxh, swimRxl);
error |= 1;
}
// Put TB receiver out of entry detection mode
pTestBench->pSwimRxCtrl->SetEntryMode(0);
// Send SWRST (low speed)
pSwim->pControl->SetSendSrst(1);
// Wait until not busy
while(pSwim->pStatus->GetTxbusy())
{
usleepSim(1);
}
// Fetch the receiver values and check for SWRST
struct swimRx_t swimVal;
swimRxl = pTestBench->pSwimRxShiftLo->GetSwimRxShiftLo();
swimRxh = pTestBench->pSwimRxShiftHigh->GetSwimRxShiftHigh();
swimVal = decodeswimRx(swimRxl, swimRxh);
if (swimVal.srst != SWIM_SWRST_CMD)
{
VPrint("**ERROR 1 : SWIM entry SWRST failure.\n");
error |= 1;
}
return error;
}
// --------------------------------------------------
// PWM test
// NB: note yet part of regression---no measuring
// support in test bench
// --------------------------------------------------
int runTest::pwm_test (CCoreAuto* pCore, int node)
{
int error = NOERROR;
uint32_t status;
CTestAuto* pTestBench = new CTestAuto((uint32_t*)(0));
// FAN PWM
pCore->pFanPwm->SetFanPwm(16);
pCore->pHeaterPwm->SetHd0(128);
pCore->pHeaterPwm->SetHd1(128);
pCore->pHeaterPwm->SetHd2(128);
pCore->pHeaterPwm->SetHd3(128);
pCore->pHeaterPsuPwm->SetHeaterPsuPwm(32);
usleepSim(1500);
pCore->pHeaterPsuPwm->SetHeaterPsuPwm(0);
usleepSim(500);
return error;
}
// --------------------------------------------------
// Avalon bus tests
// --------------------------------------------------
int runTest::avalon_bus_test (CCoreAuto* pCore, int node)
{
int error = NOERROR;
uint32_t status;
CTestAuto* pTestBench = new CTestAuto((uint32_t*)(0));
CFpmCtrl6Auto* pFpmCtrl = pCore->pFpmCtrl6;
CPulseGenerator3Auto* pPulseGenerator0 = pCore->pPulseGenerator30;
CPulseGenerator3Auto* pPulseGenerator1 = pCore->pPulseGenerator31;
CPulseGenerator3Auto* pPulseGenerator2 = pCore->pPulseGenerator32;
CPulseGenerator3Auto* pPulseGenerator3 = pCore->pPulseGenerator33;
VPrint("Starting Avalon bus tests\n");
bool foundError = false;
// Loop Write / Read CSR registers
for (int i = 0; i < 16; i++) {
pPulseGenerator0->pPdOffsetDir0->SetPdOffsetDir0(0xabcdef01 + i);
pPulseGenerator1->pPdOffsetDir0->SetPdOffsetDir0(0x1abcdef0 + i);
pFpmCtrl->pCoarseTimeInit->SetCoarseTimeInit(0xaa55aa55 + i);
pPulseGenerator2->pPdOffsetDir0->SetPdOffsetDir0(0x01abcdef + i);
pPulseGenerator3->pPdOffsetDir0->SetPdOffsetDir0(0xf01abcde + i);
uint32_t ret;
if ((ret = pPulseGenerator0->pPdOffsetDir0->GetPdOffsetDir0()) != (0xabcdef01 + i))
{
if (!foundError)
VPrint("**ERROR 602 : Avalon bus data failure loop %d (got = 0x%08x exp = 0x%08x).\n", i, ret, 0xabcdef01 + i);
foundError = true;
error |= 1;
}
if ((ret = pPulseGenerator1->pPdOffsetDir0->GetPdOffsetDir0()) != (0x1abcdef0 + i))
{
if (!foundError)
VPrint("**ERROR 604 : Avalon bus data failure loop %d (got = 0x%08x exp = 0x%08x).\n", i, ret, 0x1abcdef0 + i);
foundError = true;
error |= 1;
}
if ((ret = pFpmCtrl->pCoarseTimeInit->GetCoarseTimeInit()) != (0xaa55aa55 + i))
{
if (!foundError)
VPrint("**ERROR 606 : Avalon bus data failure loop %d (got = 0x%08x exp = 0x%08x).\n", i, ret, 0xaa55aa55 + i);
foundError = true;
error |= 1;
}
if ((ret = pPulseGenerator2->pPdOffsetDir0->GetPdOffsetDir0()) != (0x01abcdef + i))
{
if (!foundError)
VPrint("**ERROR 607 : Avalon bus data failure loop %d (got = 0x%08x exp = 0x%08x).\n", i, ret, 0x01abcdef + i);
foundError = true;
error |= 1;
}
if ((ret = pPulseGenerator3->pPdOffsetDir0->GetPdOffsetDir0()) != (0xf01abcde + i))
{
if (!foundError)
VPrint("**ERROR 609 : Avalon bus data failure loop %d (got = 0x%08x exp = 0x%08x).\n", i, ret, 0xf01abcde + i);
foundError = true;
error |= 1;
}
}
return error;
}
// --------------------------------------------------
// SWIM TX/RX tests
// --------------------------------------------------
int runTest::swim_txrx_test (CCoreAuto* pCore, int node)
{
int error = NOERROR;
uint32_t status;
CSwim2Auto* pSwim = pCore->pSwim2;
CTestAuto* pTestBench = new CTestAuto((uint32_t*)(0));
VPrint("Starting SWIM TX/RX tests\n");
// Send WOTF (1 byte) : addr 0x123456, byte 0x55
uint32_t addr = 0x123456;
uint32_t data = 0x55;
pSwim->pTxByte->SetTxByte((addr << 8) | data);
// Read back CSR_TX_BYTE_ADDR
if ((status = pSwim->pTxByte->GetTxByte()) != ((addr << 8) | data))
{
VPrint("**ERROR 1 : SWIM TX_BYTE register read failure on WOTF (got 0x%08x exp 0x%08x)\n", status, ((addr << 8) | data));
error |= 1;
}
// Wait
while(pSwim->pStatus->GetTxbusy())
{
usleepSim(100);
}
struct swimRx_t swimVal;
uint32_t swimRxl = pTestBench->pSwimRxShiftLo->GetSwimRxShiftLo();
uint32_t swimRxh = pTestBench->pSwimRxShiftHigh->GetSwimRxShiftHigh();
if (swimCheckValue(swimRxl, swimRxh, SWIM_WOTF_CMD, 1, addr, data, swimVal))
{
VPrint("**ERROR 2 : SWIM WOTF received data failure (0x%08x%08x).\n", swimRxh, swimRxl);
error |= 1;
}
// Send ROTF (1 byte) : addr 0x654321
addr = 0x654321;
data = 0; // don't care
pSwim->pRxByte->SetRxByte((addr << 8) | data);
// Read back CSR_RX_BYTE_ADDR
if (((status = pSwim->pRxByte->GetRxByte() ) >> 8) != addr)
{
VPrint("**ERROR 3 : SWIM RX_BYTE register read failure on ROTF (got 0x%08x exp 0x%08x)\n", status, ((addr << 8)));
error |= 1;
}
// Wait
while(pSwim->pStatus->GetRxbusy() || pSwim->pStatus->GetTxbusy())
{
usleepSim(100);
}
uint32_t expData = 0xaa;
swimRxl = pTestBench->pSwimRxShiftLo->GetSwimRxShiftLo();
swimRxh = pTestBench->pSwimRxShiftHigh->GetSwimRxShiftHigh();
// Check the received data
if (swimCheckValue(swimRxl, swimRxh, SWIM_ROTF_CMD, 1, addr, expData, swimVal))
{
VPrint("**ERROR 4 : SWIM ROTF received data failure (0x%08x%08x).\n", swimRxh, swimRxl);
error |= 1;
}
// Read RX byte
if ((status = pSwim->pRxByte->GetByte()) != expData)
{
VPrint("**ERROR 5 : SWIM RX_BYTE read failure (got 0x%02x exp 0x%02x).\n", status, expData);
error |= 1;
}
// Clear RX
pSwim->pControl->SetClrRx(1);
// Send a block write command
addr = 0x250864;
pSwim->pTxBlock->SetWaddr(addr);
// Check TX busy is set
if (!(status = pSwim->pStatus->GetTxbusy()))
{
VPrint("**ERROR 6 : SWIM TXBUSY status failure on block write.\n");
error |= 1;
}
// Wait
while(pSwim->pStatus->GetTxbusy())
{
usleepSim(100);
}
// Check count is 128
if ((status = pSwim->pBlkRemaining->GetBlkRemaining()) != 128)
{
VPrint("**ERROR 7 : BLK_REMAINING count 128 check failure (got 0x%02x exp 0x%02x).\n", status, 128);
error |= 1;
}
// Check TXBUSY is clear
if ((status = pSwim->pStatus->GetTxbusy()))
{
VPrint("**ERROR 8 : SWIM TXBUSY not clear failure.\n");
error |= 1;
}
// Send 1 byte
data = 0x5a;
pSwim->pPushByte->SetPushByte(data);
// Wait
while(pSwim->pStatus->GetTxbusy())
{
usleepSim(10);
}
swimRxl = pTestBench->pSwimRxShiftLo->GetSwimRxShiftLo();
swimRxh = pTestBench->pSwimRxShiftHigh->GetSwimRxShiftHigh();
// Check the received data
if (swimCheckValue(swimRxl, swimRxh, SWIM_WOTF_CMD, 128, addr, data, swimVal))
{
VPrint("**ERROR 9 : SWIM Block write command received data failure. (0x%08x%08x).\n", swimRxh, swimRxl);
error |= 1;
}
// Check block count is 127
if ((status = pSwim->pBlkRemaining->GetBlkRemaining()) != 127)
{
VPrint("**ERROR 10 : BLK_REMAINING count 127 check failure (got 0x%02x exp 0x%02x).\n", status, 127);
error |= 1;
}
bool foundError = false;
// Send the rest of the block data
for (int idx = 1; idx < 128; idx++)
{
// Send 1 byte
pSwim->pPushByte->SetPushByte(data + idx);
// Check block count is 127 - idx
if ((status = pSwim->pBlkRemaining->GetBlkRemaining()) != (127 - idx) && !foundError)
{
VPrint("**ERROR 11 : SWIM BLK_REMAINING count check failure (got %d exp %d).\n", status, (127 - idx));
foundError = true;
error |= 1;
}
// Wait
while(pSwim->pStatus->GetTxbusy())
{
usleepSim(10);
}
// Check receiver data
swimRxl = pTestBench->pSwimRxShiftLo->GetSwimRxShiftLo();
swimRxh = pTestBench->pSwimRxShiftHigh->GetSwimRxShiftHigh();
swimCheckValue(swimRxl, swimRxh, SWIM_WOTF_CMD, 128, addr, data + idx, swimVal);
if (swimVal.data != (data + idx) && !foundError)
{
VPrint("**ERROR 12 : SWIM received data on block write failure from idx %s.\n", idx);
foundError = true;
error |= 1;
}
}
return error;
}
// --------------------------------------------------
// Wave sequencer tests
// --------------------------------------------------
int runTest::wave_seq_test (CCoreAuto* pCore, int node)
{
int error = NOERROR;
return error;
}
// --------------------------------------------------
// FPGA configuration tests
// --------------------------------------------------
int runTest::fpga_cfg_test (CCoreAuto* pCore, int node)
{
int error = NOERROR;
uint32_t status;
bool foundError = false;
CTestAuto* pTestBench = new CTestAuto((uint32_t*)(0));
CHmbFpgaCfg5Auto* pFpgaCfg = pCore->pHmbFpgaCfg5;
VPrint("Starting FPGA configuration tests\n");
// ===================================
// CPU mode
// ===================================
// Clear receiver
pTestBench->pFpga->pClear->SetClear(1);
// Set CPU mode
pFpgaCfg->pControl->SetCpuMode(1);
// Start FPGA configuration
pFpgaCfg->pStart->SetStart(1);
// Send data
for (int blk = 0; blk < 3; blk++)
{
for (int idx = 0; idx < 32; idx++)
{
pFpgaCfg->pTxWord->SetTxWord(idx + 100 + blk*32);
}
// After two blocks written, check ok-to-write status is clear and wait for it to be processed
// (3/4 of the total processing time)
if (blk == 1)
{
if (pFpgaCfg->pStatus->GetOkToWrite())
{
VPrint("**ERROR 300 : HMB FPGA OK to write status failure\n");
error |= 1;
}
// Wait until it's okay to write the last block
while(!pFpgaCfg->pStatus->GetOkToWrite())
{
usleepSim(10);
}
}
}
// Wait for the interface to go idle
while(pFpgaCfg->pStatus->GetBusy())
{
usleepSim(10);
}
// Check the values in the CFG FPGA receiver
foundError = false;
for (int idx = 0; idx < 80; idx++)
{
uint32_t* FpgaRcvrMemBase = (uint32_t*)pTestBench->pFpga->GetCsrBaseAddr();
csrReadMem((uint32_t)(FpgaRcvrMemBase + idx), &status);
if (status != idx+100)
{
if (!foundError)
{
VPrint("**ERROR 301 : HMB FPGA configuration failure from index %d (got %d exp %d)\n", idx, status, idx+100);
foundError = true;
}
error |= 1;
}
}
// ===================================
// DMA test
// ===================================
// Clear receiver
pTestBench->pFpga->pClear->SetClear(1);
// Set DMA mode
pFpgaCfg->pControl->SetCpuMode(0);
// Fill the TB memory with a pattern
for (int idx = 0; idx < 80; idx++)
{
uint32_t addr = MEM_BASE_ADDR + idx*4;
directWriteMem (addr, idx+200, false);
}
// Set start address for cfg data
pFpgaCfg->pCfgAddr->SetCfgAddr(MEM_BASE_ADDR);
// Start FPGA configuration
pFpgaCfg->pStart->SetStart(1);
// Wait for the interface to go idle
while(pFpgaCfg->pStatus->GetBusy())
{
usleepSim(10);
}
// Check the values in the CFG FPGA receiver
foundError = false;
for (int idx = 0; idx < 80; idx++)
{
uint32_t* FpgaRcvrMemBase = (uint32_t*)pTestBench->pFpga->GetCsrBaseAddr();
csrReadMem((uint32_t)(FpgaRcvrMemBase + idx), &status);
if (status != idx+200)
{
if (!foundError)
{
VPrint("**ERROR 302 : HMB FPGA configuration failure from index %d (got %d exp %d)\n", idx, status, idx+200);
foundError = true;
}
error |= 1;
}
}
// ===================================
// Print streamer test
// ===================================
// Clear receiver
pTestBench->pFpga->pClear->SetClear(1);
// Fill the TB memory with a pattern
for (int idx = 0; idx < 128*3; idx++)
{
uint32_t addr = MEM_BASE_ADDR + idx*4;
directWriteMem (addr, idx+300, false);
}
// Set PS mode
pFpgaCfg->pControl->SetCpuMode(0);
pFpgaCfg->pControl->SetPsMode(1);
// Start FPGA configuration
pFpgaCfg->pStart->SetStart(1);
CDataStreamerAuto* pDS0 = pCore->pPrintCtrl->pPrintStreamer->pDataStreamer0;
// Send read data command for 32 words from memory to FPGA (one above top head).
for (int idx = 0; idx < 3; idx++)
{
writeDsCmd(pDS0, rdDataPaddr, 1, 0, 32, MEM_BASE_ADDR + 32*idx*4);
}
// Wait for the interface to go idle
while(pFpgaCfg->pStatus->GetBusy())
{
usleepSim(10);
}
// Check the values in the CFG FPGA receiver
foundError = false;
for (int idx = 0; idx < 80; idx++)
{
uint32_t* FpgaRcvrMemBase = (uint32_t*)pTestBench->pFpga->GetCsrBaseAddr();
csrReadMem((uint32_t)(FpgaRcvrMemBase + idx), &status);
if (status != idx+300)
{
if (!foundError)
{
VPrint("**ERROR 303 : HMB FPGA configuration failure from index %d (got %d exp %d)\n", idx, status, idx+300);
foundError = true;
}
error |= 1;
}
}
return error;
}
// --------------------------------------------------
// UART addressing tests
// --------------------------------------------------
int runTest::uart_addr_test (CCoreAuto* pCore, int node)
{
const uint32_t TEST_WORD2 = 0x19661066;
const uint32_t TEST_WORD3 = 0x18591905;
int error = NOERROR;
uint32_t status;
CTestAuto* pTestBench = new CTestAuto((uint32_t*)(0));
VPrint("Starting UART tests\n");
// Run over both UARTs
for(int sel_uart = 0; sel_uart < 3; sel_uart++)
{
VPrint(" loop %d\n", sel_uart);
// Select the uart to test
CUart1mbd3Auto* pUart = sel_uart == 2 ? pCore->pUart1mbd3Hmb1 :
sel_uart == 1 ? pCore->pUart1mbd3Hmb :
pCore->pUart1mbd3Som;
// Write different patterns to each of the two registers in uart
pUart->pOvrgEn->SetOvrgEn(TEST_WORD2);
pUart->pUnrgEn->SetUnrgEn(TEST_WORD3);
// Read back values and check
if ((status = pUart->pOvrgEn->GetOvrgEn()) != TEST_WORD2)
{
VPrint("**ERROR 400 : UART address decode UART offset 0 read back failure (got 0x%08x exp 0x%08x)\n", status, TEST_WORD2);
error |= 1;
}
if ((status = pUart->pUnrgEn->GetUnrgEn()) != TEST_WORD3)
{
VPrint("**ERROR 401 : UART address decode UART offset 0 read back failure (got 0x%08x exp 0x%08x)\n", status, TEST_WORD3);
error |= 1;
}
// Enable UART control of PIO input, and select which UART is to transmit
pTestBench->pUartTx->pControl->SetTxSel(sel_uart);
pTestBench->pUartTx->pControl->SetUartTxEn(1);
// Send out an alert command over-range at ordinal 1
pTestBench->pUartTx->pUartReg0->SetUartReg0(OVR_RNG_ALERT | 0x1);
// Wait for the transfer to complete
while(pTestBench->pUartTxStatus->GetUartTxStatus())
{
usleepSim(10);
}
// Allow the event to make its way through the filter
usleepSim(1);
// Check we got an IRQ
if (pTestBench->pUartTx->pIrq->GetIrq() == 0)
{
VPrint("**ERROR 402 : UART IRQ set status failure.\n");
error |= 1;
}
// Clear IRQ
pUart->pClrAlertInt->SetClrAlertInt(1);
// Check we cleared IRQ
if (pTestBench->pUartTx->pIrq->GetIrq() != 0)
{
VPrint("**ERROR 403 : UART IRQ clear status failure.\n");
error |= 1;
}
// Read the RX status register once (pop on read)
uint32_t rxVal = pUart->pRx->GetRx();
// Check the RX status of the UART
if ((rxVal & 0xff) != 0x61 ||
(rxVal & CSR_UART_1MBD_3_RX_PARITY_ERROR_MASK) ||
!(rxVal & CSR_UART_1MBD_3_RX_READ_DATA_VALID_MASK) ||
((rxVal & CSR_UART_1MBD_3_RX_READ_DATA_AVAIL_MASK) >> CSR_UART_1MBD_3_RX_READ_DATA_AVAIL) != 1)
{
VPrint("**ERROR 404 : UART RX register status failure (RX = 0x%08x).\n", rxVal);
error |= 1;
}
rxVal = pUart->pRx->GetRx();
// Check the RX status of the UART after the read (RX data not
// valid and no bytes available. Data is a don't care)
if ((rxVal & CSR_UART_1MBD_3_RX_PARITY_ERROR_MASK) ||
(rxVal & CSR_UART_1MBD_3_RX_READ_DATA_VALID_MASK) ||
((rxVal & CSR_UART_1MBD_3_RX_READ_DATA_AVAIL_MASK) >> CSR_UART_1MBD_3_RX_READ_DATA_AVAIL) != 0)
{
VPrint("**ERROR 405 : UART RX register status failure.\n");
error |= 1;
}
// Disable UART control of PIO input once more
pTestBench->pUartTx->pControl->SetUartTxEn(0);
}
return error;
}
// --------------------------------------------------
// Data core tests (including 'droppy')
// --------------------------------------------------
int runTest::data_core_test (CCoreAuto* pCore, int node)
{
int error = NOERROR;
uint32_t status;
uint32_t glMapValue[2];
glMapValue[0] = 0x0;
glMapValue[1] = 0x2;
// Calculate the size of a stripe in DWords
uint32_t stripSize1BppWords = (maxOpWidth*shiftDepth/32);
CPrintCtrlAuto* pPrintCtrl = pCore->pPrintCtrl;
CTestAuto* pTestBench = new CTestAuto((uint32_t*)(0));
VPrint("Starting Data Core tests\n");
// Do the data path common setup to get to a known starting point
error |= common_data_setup (pCore, node);
// All heads
for (int head = 0; head < numHeads; head++) {
// Fill the TB memory with a pattern.
for (int idx = 0; idx <= 3*stripSize1BppWords; idx++)
{
uint32_t addr = MEM_BASE_ADDR + (head * 3*stripSize1BppWords) * 4 + idx*4;
if (idx >= stripSize1BppWords && idx < stripSize1BppWords*2)
{
directWriteMem (addr, 0xdeadbeef, false);
}
else
{
directWriteMem (addr, STRIPE_1BPP0[(head * 3*stripSize1BppWords + idx) % 100], false);
}
}
}
// Get a pointer to data streamers
CDataStreamerAuto* pDs[4];
pDs[0] = pPrintCtrl->pPrintStreamer->pDataStreamer0;
pDs[1] = pPrintCtrl->pPrintStreamer->pDataStreamer1;
pDs[2] = pPrintCtrl->pPrintStreamer->pDataStreamer2;
pDs[3] = pPrintCtrl->pPrintStreamer->pDataStreamer3;
// All heads
for (int head = 0; head < numHeads; head++) {
// Check the queue space is 16
if (pDs[head]->pStatus->GetQueueSpace() != 16)
{
VPrint("**ERROR 502 : Initial queue status bad, head %d\n", head);
error |= TEST_ERROR;
}
// Create a linked list of data streamer commands at an offset in memory
uint32_t cmdListOffset = 0x6000 + head * 0x100;
// Set a pointer to the start of the linked list
uint32_t* memAddr = (uint32_t*)(MEM_BASE_ADDR + cmdListOffset);
// This command is to loop once (i.e. execute twice)
uint32_t loop = 1;
// Store RD_DATA_PADDR command for print streamer, Destination is head 0, size is 2 * 96 words
// Note: writeDsCmd to memory uses direct method and auto-increments memAddr.
writeDsCmd(memAddr, rdDataPaddr, headDest0, loop, stripSize1BppWords/2, MEM_BASE_ADDR + (head * 3*stripSize1BppWords * 4));
// Store RD_DATA_PADDR command for print streamer, Destination is head 0, size is 2 * 96 words, fetching from end of last command
writeDsCmd(memAddr, rdDataPaddr, headDest0, loop, stripSize1BppWords/2, MEM_BASE_ADDR + (head * 3*stripSize1BppWords * 4) + stripSize1BppWords *1*4);
// Store RD_DATA_PADDR command for print streamer, Destination is head 0, size is 1 * 192 words, fetching from end of last command
loop = 0;
writeDsCmd(memAddr, rdDataPaddr, headDest0, loop, stripSize1BppWords, MEM_BASE_ADDR + (head * 3*stripSize1BppWords * 4) + stripSize1BppWords *2 *4);
// Send LD_CMD_Q_PADDR command to data streamer 0 to start reading linked list commands
writeDsCmd(pDs[head], loadCmdQPaddr, cmdQueueDest, loop, 6, MEM_BASE_ADDR + cmdListOffset);
}
// Wait for transfer to complete
while(pDs[0]->pStatus->GetAutoCmdActive() || pDs[1]->pStatus->GetAutoCmdActive() || pDs[2]->pStatus->GetAutoCmdActive() || pDs[3]->pStatus->GetAutoCmdActive())
{
usleepSim(10);
}
// Clear all_on
uint32_t waveVector = constructWaveVector(
false, // STM8 trig
false, // Latch
false, // ALL ON
false); // Reset tick
pPrintCtrl->pPrintUnit0->pGenericSequencer15Wav0->pVector->SetVector(waveVector);
pPrintCtrl->pPrintUnit0->pGenericSequencer15Wav1->pVector->SetVector(waveVector);
pPrintCtrl->pPrintUnit1->pGenericSequencer15Wav0->pVector->SetVector(waveVector);
pPrintCtrl->pPrintUnit1->pGenericSequencer15Wav1->pVector->SetVector(waveVector);
pPrintCtrl->pPrintUnit2->pGenericSequencer15Wav0->pVector->SetVector(waveVector);
pPrintCtrl->pPrintUnit2->pGenericSequencer15Wav1->pVector->SetVector(waveVector);
pPrintCtrl->pPrintUnit3->pGenericSequencer15Wav0->pVector->SetVector(waveVector);
pPrintCtrl->pPrintUnit3->pGenericSequencer15Wav1->pVector->SetVector(waveVector);
CPrintRxAuto* pPrintRx[8] = { pTestBench->pPrintRxA, pTestBench->pPrintRxB, pTestBench->pPrintRxC, pTestBench->pPrintRxD,
pTestBench->pPrintRxE, pTestBench->pPrintRxF, pTestBench->pPrintRxG, pTestBench->pPrintRxH };
bool fired_early = false;
// Send out two stripes
for (int fire_num = 0; fire_num < 2; fire_num++)
{
// Reset the state in the print data receiver prior to firing the sequence
for (int shead = 0; shead < numHeads*subHeads; shead++) {
pPrintRx[shead]->pClear->SetClear(1);
pPrintRx[shead]->pLatchClear->SetLatchClear(1);
pPrintRx[shead]->pSeenLatch->SetSeenLatch(1);
}
// Send fire request from CPU. On Second iteration will be early, while previous stripe still active (but not droppy).
pPrintCtrl->pCpuFireReq->SetCpuFireReq(0);
// Wait until latch seen at head
while((pTestBench->pPrintRxA->pSeenLatch->GetSeenLatch() == 0) || (pTestBench->pPrintRxB->pSeenLatch->GetSeenLatch() == 0) ||
(pTestBench->pPrintRxC->pSeenLatch->GetSeenLatch() == 0) || (pTestBench->pPrintRxD->pSeenLatch->GetSeenLatch() == 0) ||
(pTestBench->pPrintRxE->pSeenLatch->GetSeenLatch() == 0) || (pTestBench->pPrintRxF->pSeenLatch->GetSeenLatch() == 0) ||
(pTestBench->pPrintRxG->pSeenLatch->GetSeenLatch() == 0) || (pTestBench->pPrintRxH->pSeenLatch->GetSeenLatch() == 0))
{
// Send fire request from CPU in the middle of the sequence to cause a 'droppy'
// situation. The middle stripe (deadbeef data) should be skipped.
if (!fired_early) {
VTick(500, node);
pPrintCtrl->pCpuFireReq->SetCpuFireReq(0);
fired_early = true;
}
}
// Clear 'seen latch state'
for (int shead = 0; shead < numHeads*subHeads; shead++) {
pPrintRx[shead]->pSeenLatch->SetSeenLatch(1);
}
// Get the base addresses of the latches
uint32_t* pRxLatchDataL[4];
uint32_t* pRxLatchDataR[4];
pRxLatchDataL[0] = (uint32_t*)pTestBench->pPrintRxA->GetCsrBaseAddr();
pRxLatchDataL[1] = (uint32_t*)pTestBench->pPrintRxC->GetCsrBaseAddr();
pRxLatchDataL[2] = (uint32_t*)pTestBench->pPrintRxE->GetCsrBaseAddr();
pRxLatchDataL[3] = (uint32_t*)pTestBench->pPrintRxG->GetCsrBaseAddr();
pRxLatchDataR[0] = (uint32_t*)pTestBench->pPrintRxB->GetCsrBaseAddr();
pRxLatchDataR[1] = (uint32_t*)pTestBench->pPrintRxD->GetCsrBaseAddr();
pRxLatchDataR[2] = (uint32_t*)pTestBench->pPrintRxF->GetCsrBaseAddr();
pRxLatchDataR[3] = (uint32_t*)pTestBench->pPrintRxH->GetCsrBaseAddr();
// All heads
for (int head = 0; head < numHeads; head++) {
bool foundError = false;
// Check latch values...
for (int idx = 0; idx < stripSize1BppWords; idx++)
{
uint32_t data;
// Read the next latch value.
if ((idx / (stripSize1BppWords / 2)) % 2 == 0)
csrReadMem((uint32_t)(pRxLatchDataL[head] + (idx % (stripSize1BppWords / 2))), &data);
else
csrReadMem((uint32_t)(pRxLatchDataR[head] + (idx % (stripSize1BppWords / 2))), &data);
// Compare with expected result
if (data != STRIPE_1BPP0[(head *3*stripSize1BppWords + idx + stripSize1BppWords * 2 * fire_num) % 100])
{
if (!foundError)
{
VPrint("**ERROR 503 : Data core latch value failure from idx = %d fire_num %d head %d (data = %08x exp = 0x%08x)\n",
idx,
fire_num,
head,
data,
STRIPE_1BPP0[(head *3*stripSize1BppWords + idx + stripSize1BppWords * 2 * fire_num) % 100]);
foundError = true;
}
error |= 1;
}
}
}
// Wait for sequence to finish
while (pPrintCtrl->pSeqStatusA->GetWaveSeqBusy())
{
usleepSim(10);
}
}
return error;
}
// --------------------------------------------------
// Print streamer tests
// --------------------------------------------------
// --------------------------------------------------
// Print streamer tests
// --------------------------------------------------
int runTest::print_streamer_test (CCoreAuto* pCore, int node)
{
int error = NOERROR;
uint32_t status;
// Calculate the size of a stripe in DWords
uint32_t stripeSize1BppWords = (maxOpWidth*shiftDepth/32);
CPrintCtrlAuto* pPrintCtrl = pCore->pPrintCtrl;
CTestAuto* pTestBench = new CTestAuto((uint32_t*)(0));
VPrint("Starting Print Streamer tests\n");
// Do the data path common setup to get to a known starting point
error |= common_data_setup (pCore, node);
// Fill the TB memory with a pattern straddling two pages
for(int idx = 0; idx < stripeSize1BppWords; idx++)
{
uint32_t data = STRIPE_1BPP0[idx % 100];
uint32_t addr;
if (idx < stripeSize1BppWords/2)
{
addr = MEM_BASE_ADDR + 0x00003e80 + idx * 4;
}
else
{
addr = MEM_BASE_ADDR + 0x00007000 + (idx - stripeSize1BppWords/2)*4;
}
directWriteMem(addr, data, false);
}
// Reset the pixel buffer
pPrintCtrl->pControl->SetClearPxBuf(1);
// Set 1BPP mode
pPrintCtrl->pBppMode->SetHead0(1);
pPrintCtrl->pBppMode->SetHead1(1);
pPrintCtrl->pBppMode->SetHead2(1);
pPrintCtrl->pBppMode->SetHead3(1);
// Set the vector output of the wave sequencer to reset all_on
uint32_t waveVector = constructWaveVector(
false, // STM8 trig
false, // Latch
false, // ALL ON
false); // Reset tick
pPrintCtrl->pPrintUnit0->pGenericSequencer15Wav0->pVector->SetVector(waveVector);
pPrintCtrl->pPrintUnit0->pGenericSequencer15Wav1->pVector->SetVector(waveVector);
// Get a pointer to data streamer 0
CDataStreamerAuto* pDS0 = pCore->pPrintCtrl->pPrintStreamer->pDataStreamer0;
// Clear PS commands and errors
pDS0->pControl->SetClearCmd(1);
pDS0->pControl->SetClearErrors(1);
// Construct read stripe commands in memory...
uint32_t* addr = (uint32_t*)(MEM_BASE_ADDR + 0x00001004);
uint32_t data = nop;
directWriteMem((uint32_t)(addr++), data, false);
directWriteMem((uint32_t)(addr++), data, false);
if (!trim_ps)
{
// LD_ADDR_MAP 20003:78901
writeDsCmd(addr, loadAddrMap, tlbDest, 0, 0x20003, 0x78901000);
// LD_ADDR_MAP 20007:78902
writeDsCmd(addr, loadAddrMap, tlbDest, 0, 0x20007, 0x78902000);
// RD_DATA_VADDR (MAX_OP_WIDTH*SHIFT_DEPTH/32) :78901e80
writeDsCmd(addr, rdDataVaddr, headDest0, 0, stripeSize1BppWords, 0x78901e80);
}
else
{
// RD_DATA_PADDR 96:20003
writeDsCmd(addr, rdDataPaddr, headDest0, 0, stripeSize1BppWords/2, 0x20003e80);
// RD_DATA_PADDR 96:20007
writeDsCmd(addr, rdDataPaddr, headDest0, 0, stripeSize1BppWords/2, 0x20007000);
}
// Send LD Q command to print streamer...
writeDsCmd(pDS0, loadCmdQPaddr, headDest0, 0, trim_ps ? 6 : 8, MEM_BASE_ADDR + 0x1004);
// Wait for transfer to complete
while (pDS0->pStatus->GetQueueSpace() != 16)
{
usleepSim(10);
}
// Reset the state in the print data receiver prior to firing the sequence
pTestBench->pPrintRxB->pClear->SetClear(1);
pTestBench->pPrintRxB->pLatchClear->SetLatchClear(1);
pTestBench->pPrintRxB->pClear->SetClear(1);
pTestBench->pPrintRxB->pLatchClear->SetLatchClear(1);
// Send fire request from CPU
pPrintCtrl->pCpuFireReq->SetCpuFireReq(0);
// Wait until latch seen at head
while((pTestBench->pPrintRxA->pSeenLatch->GetSeenLatch() == 0) || (pTestBench->pPrintRxA->pSeenLatch->GetSeenLatch() == 0))
{
//VTick(10);
}
// Clear 'seen latch state'
pTestBench->pPrintRxA->pSeenLatch->SetSeenLatch(1);
pTestBench->pPrintRxB->pSeenLatch->SetSeenLatch(1);
// Get the base addresses of the latches
uint32_t* pRxLatchDataL = (uint32_t*)pTestBench->pPrintRxA->GetCsrBaseAddr();
uint32_t* pRxLatchDataR = (uint32_t*)pTestBench->pPrintRxB->GetCsrBaseAddr();
bool foundError = false;
// Check intermediate latch values after first wave data...
for (int idx = 0; idx < stripeSize1BppWords; idx++)
{
uint32_t data;
// Read the next latch value.
if ((idx / (stripeSize1BppWords / 2)) % 2 == 0)
csrReadMem((uint32_t)(pRxLatchDataL + (idx % (stripeSize1BppWords / 2))), &data);
else
csrReadMem((uint32_t)(pRxLatchDataR + (idx % (stripeSize1BppWords / 2))), &data);
uint32_t expValue = STRIPE_1BPP0[idx % 100];
// Compare with expected result
if (data != expValue)
{
if (!foundError)
{
VPrint("**ERROR 800 : Print streamer wave latch value failure from idx = %d (data = %08x exp = 0x%08x)\n",
idx,
data,
expValue);
foundError = true;
}
error |= 1;
}
}
// Read empty status and check empty
if (!pDS0->pFifoStatus->GetEmpty())
{
VPrint("**ERROR 801 : Print streamer FIFO empty status failure\n");
error |= 1;
}
uint32_t test_val1 = 0x12345678;
uint32_t test_val2 = 0x89abcdef;
uint32_t loop_count = 1;
// Write a count to the fifo
pDS0->pFifoWrPort->SetFifoWrPort(1 | (loop_count << 2));
// Write a pattern to the fifo write port
pDS0->pFifoWrPort->SetFifoWrPort(test_val1);
// Read empty status and check not empty
if (pDS0->pFifoStatus->GetEmpty())
{
VPrint("**ERROR 802 : Print streamer FIFO empty status failure\n");
error |= 1;
}
// Write a pattern to the fifo write port
pDS0->pFifoWrPort->SetFifoWrPort(test_val2);
// Check the read port value.
if (pDS0->pFifoRdPort->GetFifoRdPort() != test_val1)
{
VPrint("**ERROR 803 : Print streamer FIFO read from CPU failure\n");
error |= 1;
}
// Pop the first word from cpu
pDS0->pFifoControls->SetPopRdPort(1);
// Read empty status and check not empty
if (pDS0->pFifoStatus->GetEmpty())
{
VPrint("**ERROR 804 : Print streamer FIFO empty status failure\n");
error |= 1;
}
// Check the read port value.
if (pDS0->pFifoRdPort->GetFifoRdPort() != test_val1)
{
VPrint("**ERROR 805 : Print streamer FIFO read from CPU failure\n");
error |= 1;
}
// Pop the second word from cpu
pDS0->pFifoControls->SetPopRdPort(1);
// Read empty status and check not empty
if (pDS0->pFifoStatus->GetEmpty())
{
VPrint("**ERROR 806 : Print streamer FIFO empty status failure\n");
error |= 1;
}
// Check the read port value.
if (pDS0->pFifoRdPort->GetFifoRdPort() != test_val2)
{
VPrint("**ERROR 807 : Print streamer FIFO read from CPU failure\n");
error |= 1;
}
// Pre-load the redirect register
uint32_t ds0BaseAddr = (uint32_t)pDS0->GetCsrBaseAddr();
pDS0->pFifoRdAddr->SetFifoRdAddr((ds0BaseAddr + CSR_DATA_STREAMER_FIFO_RD_PORT) | 0xf0000000);
// Send LD Q command to print streamer...
writeDsCmd(pDS0, loadCmdQPaddr, headDest0, 0, 1, 0, true);
nsleepSim(500);
// Wait for transfer to complete
while (pDS0->pStatus->GetQueueSpace() != 16)
{
usleepSim(1);
}
// Read empty status and check empty
if (!pDS0->pFifoStatus->GetEmpty())
{
VPrint("**ERROR 808 : Print streamer FIFO empty status failure\n");
error |= 1;
}
// Check print streamer handle from status reg
// This should be bits 27:16 of test value (assuming a NOP:
// i.e. bits 3:0 = 0xf)
uint32_t exp;
if ((exp = pDS0->pStatus->GetHandle()) != ((test_val2 >> 16) & 0xfff))
{
VPrint("**ERROR 809 : Print streamer status reg handle read failure (exp = 0x%08x v 0x%08x)\n", exp, (test_val2 >> 16) & 0xfff);
error |= 1;
}
// Wait for sequence to finish
while (pPrintCtrl->pSeqStatusA->GetPrintSeqBusy() || pPrintCtrl->pSeqStatusA->GetWaveSeqBusy())
{
usleepSim(10);
}
return error;
}
// --------------------------------------------------
// Data core @ 2 and 3 BPP tests
// --------------------------------------------------
int runTest::data_core_multi_bpp_test (CCoreAuto* pCore, uint32_t bpp, int node)
{
int error = NOERROR;
uint32_t status;
// Calculate the size of a stripe in DWords
uint32_t stripeSize1BppWords = (maxOpWidth*shiftDepth/32);
CPrintCtrlAuto* pPrintCtrl = pCore->pPrintCtrl;
CTestAuto* pTestBench = new CTestAuto((uint32_t*)(0));
VPrint("Starting Data Core %d BPP tests\n", bpp);
// Do the data path common setup to get to a known starting point
error |= common_data_setup (pCore, node);
// Set 2BPP mode
pPrintCtrl->pBppMode->SetHead0(bpp);
pPrintCtrl->pBppMode->SetHead1(bpp);
pPrintCtrl->pBppMode->SetHead2(bpp);
pPrintCtrl->pBppMode->SetHead3(bpp);
// Set the vector output of the wave sequencer to reset all_on
uint32_t waveVector = constructWaveVector(
false, // STM8 trig
false, // Latch
false, // ALL ON
false); // Reset tick
pPrintCtrl->pPrintUnit0->pGenericSequencer15Wav0->pVector->SetVector(waveVector);
pPrintCtrl->pPrintUnit0->pGenericSequencer15Wav1->pVector->SetVector(waveVector);
pPrintCtrl->pPrintUnit1->pGenericSequencer15Wav0->pVector->SetVector(waveVector);
pPrintCtrl->pPrintUnit1->pGenericSequencer15Wav1->pVector->SetVector(waveVector);
pPrintCtrl->pPrintUnit2->pGenericSequencer15Wav0->pVector->SetVector(waveVector);
pPrintCtrl->pPrintUnit2->pGenericSequencer15Wav1->pVector->SetVector(waveVector);
pPrintCtrl->pPrintUnit3->pGenericSequencer15Wav0->pVector->SetVector(waveVector);
pPrintCtrl->pPrintUnit3->pGenericSequencer15Wav1->pVector->SetVector(waveVector);
// reset the pixel buffer
pPrintCtrl->pControl->SetClearPxBuf(0xf);
pTestBench->pPrintRxA->pSeenLatch->SetSeenLatch(0);
pTestBench->pPrintRxB->pSeenLatch->SetSeenLatch(0);
pTestBench->pPrintRxC->pSeenLatch->SetSeenLatch(0);
pTestBench->pPrintRxD->pSeenLatch->SetSeenLatch(0);
pTestBench->pPrintRxE->pSeenLatch->SetSeenLatch(0);
pTestBench->pPrintRxF->pSeenLatch->SetSeenLatch(0);
pTestBench->pPrintRxG->pSeenLatch->SetSeenLatch(0);
pTestBench->pPrintRxH->pSeenLatch->SetSeenLatch(0);
// All heads
for (int head = 0; head < numHeads; head++) {
for (int idx = 0; idx <= (1 << (bpp - 1)) * stripeSize1BppWords; idx++)
{
uint32_t addr = MEM_BASE_ADDR + (head*(1<<(bpp-1))*stripeSize1BppWords+idx)*4;
directWriteMem (addr, STRIPE_1BPP0[(head*(1<<(bpp-1))*stripeSize1BppWords + idx) % 100], false);
}
}
// Get a pointer to data streamers
CDataStreamerAuto* pDs[4];
pDs[0] = pPrintCtrl->pPrintStreamer->pDataStreamer0;
pDs[1] = pPrintCtrl->pPrintStreamer->pDataStreamer1;
pDs[2] = pPrintCtrl->pPrintStreamer->pDataStreamer2;
pDs[3] = pPrintCtrl->pPrintStreamer->pDataStreamer3;
// All heads
for (int head = 0; head < numHeads; head++) {
// Check the queue space is 16
if (pDs[head]->pStatus->GetQueueSpace() != 16)
{
VPrint("**ERROR %3d : Initial queue status bad\n", 602 + (bpp == 3 ? 50 : 0));
error |= TEST_ERROR;
}
for (int idx = 0; idx < (1 << (bpp-1)); idx++)
{
// Send RD_DATA_PADDR command to data streamer 0 to read 192 words from base of memory
writeDsCmd(pDs[head], rdDataPaddr, headDest0, 0, stripeSize1BppWords, MEM_BASE_ADDR + (head*(1<<(bpp-1)) + idx) * stripeSize1BppWords * 4);
}
}
// All heads
for (int head = 0; head < numHeads; head++) {
// Wait for transfer to complete
while (pDs[head]->pStatus->GetQueueSpace() != 16)
{
usleepSim(10);
}
}
// Reset the state in the print data receiver prior to firing the sequence
pTestBench->pPrintRxA->pClear->SetClear(1);
pTestBench->pPrintRxB->pClear->SetClear(1);
pTestBench->pPrintRxC->pClear->SetClear(1);
pTestBench->pPrintRxD->pClear->SetClear(1);
pTestBench->pPrintRxE->pClear->SetClear(1);
pTestBench->pPrintRxF->pClear->SetClear(1);
pTestBench->pPrintRxG->pClear->SetClear(1);
pTestBench->pPrintRxH->pClear->SetClear(1);
// Send fire request from CPU
pPrintCtrl->pCpuFireReq->SetCpuFireReq(0);
// Wait until latch seen at head
while((pTestBench->pPrintRxA->pSeenLatch->GetSeenLatch() == 0) || (pTestBench->pPrintRxB->pSeenLatch->GetSeenLatch() == 0) ||
(pTestBench->pPrintRxC->pSeenLatch->GetSeenLatch() == 0) || (pTestBench->pPrintRxD->pSeenLatch->GetSeenLatch() == 0) ||
(pTestBench->pPrintRxE->pSeenLatch->GetSeenLatch() == 0) || (pTestBench->pPrintRxF->pSeenLatch->GetSeenLatch() == 0) ||
(pTestBench->pPrintRxG->pSeenLatch->GetSeenLatch() == 0) || (pTestBench->pPrintRxH->pSeenLatch->GetSeenLatch() == 0))
{
//VTick(10);
}
// Clear 'seen latch state'
pTestBench->pPrintRxA->pSeenLatch->SetSeenLatch(0);
pTestBench->pPrintRxB->pSeenLatch->SetSeenLatch(0);
pTestBench->pPrintRxC->pSeenLatch->SetSeenLatch(0);
pTestBench->pPrintRxD->pSeenLatch->SetSeenLatch(0);
pTestBench->pPrintRxE->pSeenLatch->SetSeenLatch(0);
pTestBench->pPrintRxF->pSeenLatch->SetSeenLatch(0);
pTestBench->pPrintRxG->pSeenLatch->SetSeenLatch(0);
pTestBench->pPrintRxH->pSeenLatch->SetSeenLatch(0);
// Get the base addresses of the latches
uint32_t* pRxLatchDataL[4];
uint32_t* pRxLatchDataR[4];
pRxLatchDataL[0] = (uint32_t*)pTestBench->pPrintRxA->GetCsrBaseAddr();
pRxLatchDataL[1] = (uint32_t*)pTestBench->pPrintRxC->GetCsrBaseAddr();
pRxLatchDataL[2] = (uint32_t*)pTestBench->pPrintRxE->GetCsrBaseAddr();
pRxLatchDataL[3] = (uint32_t*)pTestBench->pPrintRxG->GetCsrBaseAddr();
pRxLatchDataR[0] = (uint32_t*)pTestBench->pPrintRxB->GetCsrBaseAddr();
pRxLatchDataR[1] = (uint32_t*)pTestBench->pPrintRxD->GetCsrBaseAddr();
pRxLatchDataR[2] = (uint32_t*)pTestBench->pPrintRxF->GetCsrBaseAddr();
pRxLatchDataR[3] = (uint32_t*)pTestBench->pPrintRxH->GetCsrBaseAddr();
// All heads
for (int head = 0; head < numHeads; head++) {
bool foundError = false;
// Check latch values...
for (int idx = 0; idx < (1 << (bpp - 1)) * stripeSize1BppWords; idx++)
{
uint32_t data;
uint32_t expData = STRIPE_1BPP0[(head*(1<< (bpp - 1))*stripeSize1BppWords+idx) % 100];
// When in 3 bpp only 3/4 bits are actually used
if (bpp == 0 || bpp == 3)
expData &= 0x77777777;
// Read the next latch value.
if ((idx / ((1 << (bpp - 1))*stripeSize1BppWords / 2)) % 2 == 0)
csrReadMem((uint32_t)(pRxLatchDataL[head] + (idx % ((1 << (bpp - 1))*stripeSize1BppWords / 2))), &data);
else
csrReadMem((uint32_t)(pRxLatchDataR[head] + (idx % ((1 << (bpp - 1))*stripeSize1BppWords / 2))), &data);
// Compare with expected result
if (data != expData)
{
if (!foundError)
{
VPrint("**ERROR %03d : Data core latch value failure from idx = %d head %d (data = %08x exp = 0x%08x)\n",
603 + (bpp == 3 ? 50 : 0),
idx,
head,
data,
expData);
foundError = true;
}
error |= 1;
}
}
}
// Wait for sequence to finish
while (pPrintCtrl->pSeqStatusA->GetWaveSeqBusy())
{
usleepSim(10);
}
return error;
}
// --------------------------------------------------
// Shutdown monitor tests
// --------------------------------------------------
int runTest::shtdn_mon_test (CCoreAuto* pCore, int node)
{
int error = NOERROR;
// Calculate the size of a stripe in DWords
uint32_t stripeSize1BppWords = (maxOpWidth*shiftDepth/32);
CPrintCtrlAuto* pPrintCtrl = pCore->pPrintCtrl;
CTestAuto* pTestBench = new CTestAuto((uint32_t*)(0));
CShutdownMonitor0Auto* pShutDn = pCore->pShutdownMonitor0;
VPrint("Starting Shutdown monitor tests\n");
// Enable UART control of PIO input, and select which UART is to transmit
pTestBench->pUartTx->pControl->SetTxSel(0);
pTestBench->pUartTx->pControl->SetUartTxEn(1);
// Enable fire request masking on shutdown
pCore->pEnFireReqMask->SetEnFireReqMask(1);
// Set all PIOs as outputs
pCore->pGenericPio1->pPioOutEn->SetPioOutEn(0xffffffff);
pTestBench->pPioCpuCtrl->SetPioCpuCtrl(1);
// Set a good state on the bus
pTestBench->pPioCpuValue->SetPioCpuValue(0x0007000f);
for (int idx = 0; idx <= shutdnLastTest; idx++)
{
VPrint(" loop %d\n", idx);
// Enable watchdog for first test
if (idx == shutdnTestTrig)
{
pShutDn->pControl->SetWdPeriod(10);
pShutDn->pControl->SetEnableWd(1);
}
else
{
pShutDn->pControl->SetEnableWd(0);
}
// Set pwr bit delays
for (int jdx = 0; jdx < 19; jdx++)
{
switch(jdx)
{
case0: pShutDn->pShutdnDly0->SetShutdnDly0 (jdx*10); break;
case1: pShutDn->pShutdnDly1->SetShutdnDly1 (jdx*10); break;
case2: pShutDn->pShutdnDly2->SetShutdnDly2 (jdx*10); break;
case3: pShutDn->pShutdnDly3->SetShutdnDly3 (jdx*10); break;
case4: pShutDn->pShutdnDly4->SetShutdnDly4 (jdx*10); break;
case5: pShutDn->pShutdnDly5->SetShutdnDly5 (jdx*10); break;
case6: pShutDn->pShutdnDly6->SetShutdnDly6 (jdx*10); break;
case7: pShutDn->pShutdnDly7->SetShutdnDly7 (jdx*10); break;
case8: pShutDn->pShutdnDly8->SetShutdnDly8 (jdx*10); break;
case9: pShutDn->pShutdnDly9->SetShutdnDly9 (jdx*10); break;
case10: pShutDn->pShutdnDly10->SetShutdnDly10(jdx*10); break;
case11: pShutDn->pShutdnDly11->SetShutdnDly11(jdx*10); break;
case12: pShutDn->pShutdnDly12->SetShutdnDly12(jdx*10); break;
case13: pShutDn->pShutdnDly13->SetShutdnDly13(jdx*10); break;
case14: pShutDn->pShutdnDly14->SetShutdnDly14(jdx*10); break;
case15: pShutDn->pShutdnDly15->SetShutdnDly15(jdx*10); break;
case16: pShutDn->pShutdnDly16->SetShutdnDly16(jdx*10); break;
case17: pShutDn->pShutdnDly17->SetShutdnDly17(jdx*10); break;
case18: pShutDn->pShutdnDly18->SetShutdnDly18(jdx*10); break;
default: break;
}
}
// Set new pwr mask
pShutDn->pNewPwrMask->SetNewPwrMask(0xffffffff);
// Set new trip mask (unmask test bit at least)
pShutDn->pNewTripMask->SetNewTripMask(0x3ff);
// Set trip delay
pShutDn->pTripMaskDelay->SetTripMaskDelay(32);
// Set go
pShutDn->pControl->SetGo(1);
if (idx == shutdnTestTrig)
{
// Set test shutdown bit
pShutDn->pTestShutdnSignal->SetTestShutdnSignal(1);
// Wait a bit
usleepSim(1);
// Clear test shutdown bit
pShutDn->pTestShutdnSignal->SetTestShutdnSignal(0);
}
else if (idx == shutdnLimMainTrig)
{
// Instigate a shut down by setting the LIM_MAIN0 bit
pTestBench->pPioCpuValue->SetPioCpuValue(0x0017000f);
// Leave enough time for the bad status to get through the monitor's filter
nsleepSim(200);
// Reset PIO IN to good state
pTestBench->pPioCpuValue->SetPioCpuValue(0x0007000f);
// leave enough time for the cleared bad status to get through the monitor's filter
nsleepSim(200);
}
else if (idx == shutdnSomOvrTrig || idx == shutdnHmbOvrTrig || idx == shutdnHmb1OvrTrig)
{
uint32_t sel = idx == shutdnSomOvrTrig ? 0 :
idx == shutdnHmbOvrTrig ? 1 :
2;
// Enable UART control of PIO input, and select which UART is to transmit
pTestBench->pUartTx->pControl->SetTxSel(sel);
pTestBench->pUartTx->pControl->SetUartTxEn(1);
// Enable bitmap for ordinal 1
pCore->pUart1mbd3Som->pOvrgEn->SetOvrgEn(0x00000002);
// Send out an alert command over-range at ordinal 1
pTestBench->pUartTx->pUartReg0->SetUartReg0(OVR_RNG_ALERT | 0x1);
// Wait for the transfer to complete
while(pTestBench->pUartTxStatus->GetUartTxStatus())
{
usleepSim(10);
}
// Send out an alert command return from over-range at ordinal 1
pTestBench->pUartTx->pUartReg0->SetUartReg0(OVR_RNG_RTN_ALERT | 0x1);
// Wait for the transfer to complete
while(pTestBench->pUartTxStatus->GetUartTxStatus())
{
usleepSim(10);
}
// Allow the clearing of state to make its way through the filter
usleepSim(1);
}
else if (idx == shutdnThermTrig)
{
// Instigate a shut down by setting the THERM FAULT 0 bit
pTestBench->pPioCpuValue->SetPioCpuValue(0x0007000E);
// Leave enough time for the bad status to get through the monitor's filter
nsleepSim(200);
// Reset PIO IN to good state
pTestBench->pPioCpuValue->SetPioCpuValue(0x0007000F);
// Leave enough time for the cleared bad status to get through the monitor's filter
nsleepSim(200);
}
else if (idx == shutdnPGoodTrig)
{
// Instigate a shut down by setting the P_GOOD inout to bad
pTestBench->pPioCpuValue->SetPioCpuValue(0x0003000F);
// Leave enough time for the bad status to get through the monitor's filter
nsleepSim(200);
// Reset PIO IN to good state
pTestBench->pPioCpuValue->SetPioCpuValue(0x0007000F);
// Leave enough time for the cleared bad status to get through the monitor's filter
nsleepSim(200);
}
// Read status
if (pShutDn->pStatus->GetTripped() != 1)
{
VPrint("**ERROR 900 : Shutdown monitor trip status failure.\n");
error |= 1;
}
// Read bad status
if (pShutDn->pBadStatus->GetBadStatus())
{
VPrint("**ERROR 901 : Shutdown monitor bad status not 0 failure.\n");
error |= 1;
}
uint32_t exp;
uint32_t status;
switch(idx)
{
case shutdnTestTrig : exp = 0x200; break;
case shutdnLimMainTrig : exp = 0x1; break;
case shutdnSomOvrTrig : exp = 0x20; break;
case shutdnThermTrig : exp = 0x2; break;
case shutdnPGoodTrig : exp = 0x4; break;
case shutdnHmbOvrTrig : exp = 0x80; break;
case shutdnHmb1OvrTrig : exp = 0x80; break;
default: break;
}
if ((status = pShutDn->pBadStatusSnapshot->GetBadStatusSnapshot()) != exp)
{
VPrint("**ERROR 902 : Shutdown monitor bad status snapshot failure (exp 0x%08x got 0x%08x)\n", exp, status);
error |= 1;
}
// Write clear trip
pShutDn->pControl->SetClearTrip(1);
// Read status
if (pShutDn->pStatus->GetTripped())
{
VPrint("**ERROR 903 : Shutdown monitor trip status not cleared failure.\n");
error |= 1;
}
// Read bad status
if ((status = pShutDn->pBadStatus->GetBadStatus()) != 0)
{
VPrint("**ERROR 904 : Shutdown monitor bad status not 0 failure (0x%08x).\n", status);
error |= 1;
}
// Read bad status snapshot
if (pShutDn->pBadStatusSnapshot->GetBadStatusSnapshot())
{
VPrint("**ERROR 905 : Shutdown monitor bad snapshot status not 0 failure.\n");
error |= 1;
}
if (idx == shutdnTestTrig)
{
// Allow enough time for the watchdog to trip. In test mode the count units are in us, and the timeout was 10.
usleepSim(10);
// Read status
if (!pShutDn->pStatus->GetTripped())
{
VPrint("**ERROR 906 : Shutdown monitor trip status failure.\n");
error |= 1;
}
// Read bad status
if ((status = pShutDn->pBadStatusSnapshot->GetBadStatusSnapshot()) != 0x80000000)
{
VPrint("**ERROR 907 : Shutdown monitor bad snapshot status failure (got 0x%08x exp 0x80000000.\n", status);
error |= 1;
}
// Read bad status
if ((status = pShutDn->pBadStatus->GetBadStatus()) != 0)
{
VPrint("**ERROR 908 : Shutdown monitor bad status not 0 failure (0x%08x).\n", status);
error |= 1;
}
// Write clear trip
pShutDn->pControl->SetClearTrip(1);
}
}
return error;
}
// --------------------------------------------------
// Four heads tests
// --------------------------------------------------
int runTest::four_heads_test (CCoreAuto* pCore, int node)
{
int error = NOERROR;
uint32_t status;
// Calculate the size of a stripe in DWords for non-combined heads
uint32_t stripeSize1BppWords = (maxOpWidth/(numHeads) * shiftDepth/32);
CPrintCtrlAuto* pPrintCtrl = pCore->pPrintCtrl;
CTestAuto* pTestBench = new CTestAuto((uint32_t*)(0));
VPrint("Starting Four Heads tests\n");
// Do the data path common setup to get to a known starting point
error |= common_data_setup (pCore, node);
// reset the pixel buffers
pPrintCtrl->pControl->SetClearPxBuf(0xff);
// Fill the TB memory with a pattern.
for (int head = 0; head < 4; head++)
{
for (int idx = 0; idx < stripeSize1BppWords; idx++)
{
uint32_t addr = (head * 0x1000) + MEM_BASE_ADDR + idx*4;
directWriteMem (addr, STRIPE_1BPP0[(idx + head*17) % 100], false);
}
}
// Get a pointer to data streamers
CDataStreamerAuto* pDs[4];
pDs[0] = pPrintCtrl->pPrintStreamer->pDataStreamer0;
pDs[1] = pPrintCtrl->pPrintStreamer->pDataStreamer1;
pDs[2] = pPrintCtrl->pPrintStreamer->pDataStreamer2;
pDs[3] = pPrintCtrl->pPrintStreamer->pDataStreamer3;
// Create a linked list of data streamer commands at an offset in memory
uint32_t cmdListOffset[4];
// Set a pointer to the start of the linked list
uint32_t* memAddr[4];
for (int head = 0; head < 4; head++) {
// Check the queue space is 16
if (pDs[head]->pStatus->GetQueueSpace() != 16)
{
VPrint("**ERROR 1200 : Initial queue status bad\n");
error |= TEST_ERROR;
}
cmdListOffset[head] = 0x6000 + 0x100*head;
memAddr[head] = (uint32_t*)(MEM_BASE_ADDR + cmdListOffset[head]);
}
// Construct non-looping commands for this test
uint32_t loop = 0;
// Store RD_DATA_PADDR command for print streamer, Destination is head 0, size is 2 * 96 words
// Note: writeDsCmd to memory uses direct method and auto-increments memAddr.
writeDsCmd(memAddr[0], rdDataPaddr, headDest0, loop, stripeSize1BppWords, MEM_BASE_ADDR + 0x0000);
writeDsCmd(memAddr[1], rdDataPaddr, headDest0, loop, stripeSize1BppWords, MEM_BASE_ADDR + 0x1000);
writeDsCmd(memAddr[2], rdDataPaddr, headDest0, loop, stripeSize1BppWords, MEM_BASE_ADDR + 0x2000);
writeDsCmd(memAddr[3], rdDataPaddr, headDest0, loop, stripeSize1BppWords, MEM_BASE_ADDR + 0x3000);
// Send LD_CMD_Q_PADDR command to data streamers to start reading linked list commands
writeDsCmd(pDs[0], loadCmdQPaddr, cmdQueueDest, loop, 2, MEM_BASE_ADDR + cmdListOffset[0]);
writeDsCmd(pDs[1], loadCmdQPaddr, cmdQueueDest, loop, 2, MEM_BASE_ADDR + cmdListOffset[1]);
writeDsCmd(pDs[2], loadCmdQPaddr, cmdQueueDest, loop, 2, MEM_BASE_ADDR + cmdListOffset[2]);
writeDsCmd(pDs[3], loadCmdQPaddr, cmdQueueDest, loop, 2, MEM_BASE_ADDR + cmdListOffset[3]);
// Wait for transfer to complete
while(pDs[0]->pStatus->GetAutoCmdActive() || pDs[1]->pStatus->GetAutoCmdActive() ||
pDs[2]->pStatus->GetAutoCmdActive() || pDs[3]->pStatus->GetAutoCmdActive())
{
usleepSim(10);
}
// Clear all_on
uint32_t waveVector = constructWaveVector(
false, // STM8 trig
false, // Latch
false, // ALL ON
false); // Reset tick
pPrintCtrl->pPrintUnit0->pGenericSequencer15Wav0->pVector->SetVector(waveVector);
pPrintCtrl->pPrintUnit0->pGenericSequencer15Wav1->pVector->SetVector(waveVector);
pPrintCtrl->pPrintUnit1->pGenericSequencer15Wav0->pVector->SetVector(waveVector);
pPrintCtrl->pPrintUnit1->pGenericSequencer15Wav1->pVector->SetVector(waveVector);
pPrintCtrl->pPrintUnit2->pGenericSequencer15Wav0->pVector->SetVector(waveVector);
pPrintCtrl->pPrintUnit2->pGenericSequencer15Wav1->pVector->SetVector(waveVector);
pPrintCtrl->pPrintUnit3->pGenericSequencer15Wav0->pVector->SetVector(waveVector);
pPrintCtrl->pPrintUnit3->pGenericSequencer15Wav1->pVector->SetVector(waveVector);
// Reset the state in the print data receiver prior to firing the sequence
pTestBench->pPrintRxA->pLatchClear->SetLatchClear(1);
pTestBench->pPrintRxB->pLatchClear->SetLatchClear(1);
pTestBench->pPrintRxC->pLatchClear->SetLatchClear(1);
pTestBench->pPrintRxD->pLatchClear->SetLatchClear(1);
// Send fire request from CPU
pPrintCtrl->pCpuFireReq->SetCpuFireReq(0);
// Wait until latch seen at head
while(pTestBench->pPrintRxA->pSeenLatch->GetSeenLatch() == 0)
{
usleepSim(1);
}
// Clear 'seen latch state'
pTestBench->pPrintRxA->pSeenLatch->SetSeenLatch(1);
// Get the base addresses of the latches
uint32_t* pRxLatchData[4];
pRxLatchData[0] = (uint32_t*)pTestBench->pPrintRxA->GetCsrBaseAddr();
pRxLatchData[1] = (uint32_t*)pTestBench->pPrintRxB->GetCsrBaseAddr();
pRxLatchData[2] = (uint32_t*)pTestBench->pPrintRxC->GetCsrBaseAddr();
pRxLatchData[3] = (uint32_t*)pTestBench->pPrintRxD->GetCsrBaseAddr();
bool foundError = false;
// Read print control status
status = pPrintCtrl->pSeqStatusB->GetSeqStatusB();
// Check for errors in print control
if (status & 0xffffffff)
{
VPrint("**ERROR 1201 : Bad print control status (0x%08x)\n", status);
error |= 1;
}
// Check all heads' data
for (int head = 0; head < 4; head++)
{
// Check intermediate latch values after first wave data...
for (int idx = 0; idx < stripeSize1BppWords; idx++)
{
uint32_t data;
uint32_t exp_data;
// Read the next latch value.
csrReadMem((uint32_t)(pRxLatchData[head] + idx), &data);
exp_data = STRIPE_1BPP0[(idx + head*17) % 100];
if (data != exp_data)
{
if (!foundError)
{
VPrint("**ERROR 1202 : Data core wave 0 latch value failure from head = %d, idx = %d (data = %08x exp = 0x%08x)\n",
head,
idx,
data,
exp_data);
foundError = true;
}
error |= 1;
}
}
}
// Wait for sequence to finish
while (pPrintCtrl->pSeqStatusA->GetPrintSeqBusy() || pPrintCtrl->pSeqStatusA->GetWaveSeqBusy())
{
usleepSim(10);
}
return error;
}
// --------------------------------------------------
// Sub pixel firing test
// --------------------------------------------------
int runTest::sub_pixel_firing_test (CCoreAuto* pCore, int node)
{
int error = NOERROR;
CPrintCtrlAuto* pPrintCtrl = pCore->pPrintCtrl;
CTestAuto* pTestBench = new CTestAuto((uint32_t*)(0));
// Calculate the size of a stripe in DWords
uint32_t stripeSize1BppWords = (maxOpWidth*shiftDepth/32);
VPrint("Starting Sub Pixel Firing tests\n");
// Do the data path common setup to get to a known starting point
error |= common_data_setup (pCore, node);
// reset the pixel buffer
pPrintCtrl->pControl->SetClearPxBuf(0x3);
// For all heads
for (int head = 0; head < numHeads; head++) {
// Fill the TB memory with a pattern.
for (int idx = 0; idx <= 2*stripeSize1BppWords; idx++)
{
uint32_t addr = MEM_BASE_ADDR + head * 4 * stripeSize1BppWords * 4 + idx*4;
directWriteMem (addr, STRIPE_1BPP0[(idx + head * stripeSize1BppWords) % 100] ^ (idx + head * stripeSize1BppWords), false);
}
}
// Get a pointer to data streamers
CDataStreamerAuto* pDs[4] = { pPrintCtrl->pPrintStreamer->pDataStreamer0,
pPrintCtrl->pPrintStreamer->pDataStreamer1,
pPrintCtrl->pPrintStreamer->pDataStreamer2,
pPrintCtrl->pPrintStreamer->pDataStreamer3 };
for (int head = 0; head < numHeads; head++) {
// Check the queue space is 16
if (pDs[head]->pStatus->GetQueueSpace() != 16)
{
VPrint("**ERROR 502 : Initial queue status bad head : %d\n", head);
error |= TEST_ERROR;
}
}
// Create a linked list of data streamer commands at an offset in memory
uint32_t cmdListOffset = 0x6000;
for (int head = 0; head < numHeads; head++) {
// Set a pointer to the start of the linked list
uint32_t* memAddr = (uint32_t*)(MEM_BASE_ADDR + cmdListOffset + head * 0x100);
// This command is to loop once (i.e. execute twice)
uint32_t loop = 1;
// Store RD_DATA_PADDR command for print streamer, Destination is head 0, size is 2 * 96 words
// Note: writeDsCmd to memory uses direct method and auto-increments memAddr.
writeDsCmd(memAddr, rdDataPaddr, headDest0, loop, stripeSize1BppWords/2, MEM_BASE_ADDR + head * 4 * stripeSize1BppWords * 4);
// Store RD_DATA_PADDR command for print streamer, Destination is head 0, size is 1 * 192 words, fetching from end of last command
loop = 0;
writeDsCmd(memAddr, rdDataPaddr, headDest0, loop, stripeSize1BppWords, MEM_BASE_ADDR + head * 4 * stripeSize1BppWords * 4);
// Send LD_CMD_Q_PADDR command to data streamer 0 to start reading linked list commands
writeDsCmd(pDs[head], loadCmdQPaddr, cmdQueueDest, loop, 4, MEM_BASE_ADDR + cmdListOffset + head * 0x100);
// Wait for transfer to complete
while(pDs[head]->pStatus->GetAutoCmdActive())
{
usleepSim(10);
}
}
// Reset the state in the print data receiver prior to firing the sequence
CPrintRxAuto* pPrintRx[8] = { pTestBench->pPrintRxA, pTestBench->pPrintRxB, pTestBench->pPrintRxC, pTestBench->pPrintRxD,
pTestBench->pPrintRxE, pTestBench->pPrintRxF, pTestBench->pPrintRxG, pTestBench->pPrintRxH };
for (int shead = 0; shead < numHeads*subHeads; shead++) {
pPrintRx[shead]->pClear->SetClear(1);
}
// Get the base addresses of the latches
uint32_t* pRxLatchDataL[4];
uint32_t* pRxLatchDataR[4];
pRxLatchDataL[0] = (uint32_t*)pTestBench->pPrintRxA->GetCsrBaseAddr();
pRxLatchDataL[1] = (uint32_t*)pTestBench->pPrintRxC->GetCsrBaseAddr();
pRxLatchDataL[2] = (uint32_t*)pTestBench->pPrintRxE->GetCsrBaseAddr();
pRxLatchDataL[3] = (uint32_t*)pTestBench->pPrintRxG->GetCsrBaseAddr();
pRxLatchDataR[0] = (uint32_t*)pTestBench->pPrintRxB->GetCsrBaseAddr();
pRxLatchDataR[1] = (uint32_t*)pTestBench->pPrintRxD->GetCsrBaseAddr();
pRxLatchDataR[2] = (uint32_t*)pTestBench->pPrintRxF->GetCsrBaseAddr();
pRxLatchDataR[3] = (uint32_t*)pTestBench->pPrintRxH->GetCsrBaseAddr();
for (int shead = 0; shead < numHeads*subHeads; shead++) {
// Reset the state in the print data receiver prior to firing the sequence
pPrintRx[shead]->pLatchClear->SetLatchClear(1);
}
// Configure the FPM for numStripes stripes, at a *pixel* rate of 20KHz
// with a division ratio of 4, and four phases
configFpmForEmulPulses (pCore,
15.0, // Pixel frequency
32.0, // divider ratio
32, // Number of subpixel phases
clkFreqMHz, // FPM logic clock frequency
fpmSeq, // Sequence to load
fpmSeqLen); // Length of the sequence
// Generate a product detect to set off the two stripes (as configured in the sequence), and wait a bit
generatePDs (pCore,
1, // Number of product detects to generate
200000); // Time (in ns) to pause between PDs
VPrint("Configured and started FPM 6\n");
// Wait for the second stripe to arrive
for (int shead = 0; shead < numHeads*subHeads; shead++) {
while(pPrintRx[shead]->pClkCnt->GetClkCnt() != 1024);
}
bool foundError = false;
// Check all sub heads
for (int head = 0; head < numHeads; head++)
// Check intermediate latch values after first wave data...
for (int idx = 0; idx < stripeSize1BppWords; idx++)
{
uint32_t data;
uint32_t exp_data;
// Read the next latch value.
if ((idx / (stripeSize1BppWords / 2)) % 2 == 0)
csrReadMem((uint32_t)(pRxLatchDataL[head] + (idx % (stripeSize1BppWords / 2))), &data);
else
csrReadMem((uint32_t)(pRxLatchDataR[head] + (idx % (stripeSize1BppWords / 2))), &data);
// Compare with expected result
if (data != (exp_data = STRIPE_1BPP0[(head * stripeSize1BppWords + idx + stripeSize1BppWords * 2 * 0) % 100] ^ (idx + head * stripeSize1BppWords)))
{
if (!foundError)
{
VPrint("**ERROR 503 : Data core wave 0 latch value failure from sub head = %d idx = %d (data = 0x%08x exp = 0x%08x)\n",
head * 2 + (idx >= stripeSize1BppWords/2 ? 1:0),
idx,
data,
exp_data);
foundError = true;
}
error |= 1;
}
}
// Wait for sequence to finish
while (pPrintCtrl->pSeqStatusA->GetPrintSeqBusy())
{
usleepSim(10);
}
}
// --------------------------------------------------
// Common setup method for data path tests
// --------------------------------------------------
int runTest::common_data_setup (CCoreAuto* pCore, int node)
{
int error = NOERROR;
CGenericPio1Auto* pPio = pCore->pGenericPio1;
CPrintCtrlAuto* pPrintCtrl = pCore->pPrintCtrl;
CPrintUnitAuto* pPrintUnit[numHeads];
pPrintUnit[0] = pPrintCtrl->pPrintUnit0;
pPrintUnit[1] = pPrintCtrl->pPrintUnit1;
pPrintUnit[2] = pPrintCtrl->pPrintUnit2;
pPrintUnit[3] = pPrintCtrl->pPrintUnit3;
// Set HD_PWR_EN
pPio->pPioOutEn->SetPioOutEn(0xffffffff);
pPio->pCtrl->SetPioCpuCtrl(1);
pPio->pPioEgress->SetPioEgress(0x0F07000F);
// Set the vector output of the wave sequencer to set all_on
// Clear all_on
uint32_t waveVector = constructWaveVector(
false, // STM8 trig
false, // Latch
true, // ALL ON
false); // Reset tick
pPrintCtrl->pPrintUnit0->pGenericSequencer15Wav0->pVector->SetVector(waveVector);
pPrintCtrl->pPrintUnit0->pGenericSequencer15Wav1->pVector->SetVector(waveVector);
// Program the print data sequence RAM of head 0 with data starting from address 0
uint32_t printSeqAddr[numHeads];
for (int head = 0; head < numHeads; head++)
{
// Remember the print sequence buffer address for later
printSeqAddr[head] = (uint32_t)pPrintUnit[head]->pGenericSequencer15Print->GetSeqBaseAddr() + SEQ_ADDR_OFFSET;
// Load the sequence
for(int idx = 0; idx < 32; idx++)
{
csrWriteMem (printSeqAddr[head] + idx*4, runTest::PSEQ_PATTERN0[idx]);
}
}
// AVS read back the sequence data
for (int idx = 31; idx >= 0; idx--)
{
uint32_t data;
csrReadMem(printSeqAddr[0] + idx*4, &data);
if (data != runTest::PSEQ_PATTERN0[idx])
{
if (error == NOERROR)
{
VPrint("**ERROR 500 : Read print seq error from index %d (0x%08x v 0x%08x)\n", idx, data, runTest::PSEQ_PATTERN0[idx]);
}
error = TEST_ERROR;
}
}
// Program the wave data sequence RAM of head 0 with data starting from address 0
uint32_t waveSeq0Addr[numHeads];
uint32_t waveSeq1Addr[numHeads];
for (int head = 0; head < numHeads; head++)
{
// Remember the wave sequence buffer address for later
waveSeq0Addr[head] = (uint32_t)pPrintUnit[head]->pGenericSequencer15Wav0->GetSeqBaseAddr() + SEQ_ADDR_OFFSET;
waveSeq1Addr[head] = (uint32_t)pPrintUnit[head]->pGenericSequencer15Wav1->GetSeqBaseAddr() + SEQ_ADDR_OFFSET;
// Load the sequence
for(int idx = 0; idx < 41; idx++)
{
csrWriteMem (waveSeq0Addr[head] + idx*4, runTest::WSEQ_PATTERN0[idx]);
csrWriteMem (waveSeq1Addr[head] + idx*4, runTest::WSEQ_PATTERN0[idx]);
}
}
// AVS read back the sequence data
for (int idx = 40; idx >= 0; idx--)
{
uint32_t data;
csrReadMem(waveSeq0Addr[0] + idx*4, &data);
if (data != runTest::WSEQ_PATTERN0[idx])
{
if (error == NOERROR)
{
VPrint("**ERROR 501 : Read wave seq error from index %d (0x%08x v 0x%08x)\n", idx, data, runTest::WSEQ_PATTERN0[idx]);
}
error = TEST_ERROR;
}
}
// AVS read back the sequence data
for (int idx = 40; idx >= 0; idx--)
{
uint32_t data;
csrReadMem(waveSeq1Addr[0] + idx*4, &data);
if (data != runTest::WSEQ_PATTERN0[idx])
{
if (error == NOERROR)
{
VPrint("**ERROR 501 : Read wave seq error from index %d (0x%08x v 0x%08x)\n", idx, data, runTest::WSEQ_PATTERN0[idx]);
}
error = TEST_ERROR;
}
}
for (int head = 0; head < numHeads; head++)
{
// Enable the print data sequencer
pPrintUnit[head]->pGenericSequencer15Print->pCtrl->SetSeqEnable(1);
// Enable the wave data sequencer
pPrintUnit[head]->pGenericSequencer15Wav0->pCtrl->SetSeqEnable(1);
pPrintUnit[head]->pGenericSequencer15Wav1->pCtrl->SetSeqEnable(1);
}
// Set 1BPP mode for all eight heads
pPrintCtrl->pBppMode->SetBppMode(0x11111111);
// Enable channel, combine channels, set data width of maxOpWidth, pixel push select 0 (no cpu GL map)
pPrintCtrl->pControl->SetCpuPxSel(0);
pPrintCtrl->pControl->SetChanEn(1);
for (int head = 0; head < numHeads; head++)
{
// Put the wave delay queue into normal mode for head 0
pPrintUnit[head]->pGenericDelayQueue10->pCtrlMode->SetCtrlMode(3);
pPrintUnit[head]->pGenericDelayQueue11->pCtrlMode->SetCtrlMode(3);
}
return error;
}
int runTest::link_train_test(CCoreAuto* pCore, int node)
{
uint32_t error = 0;
uint32_t data;
CTestAuto* pTestBench = new CTestAuto((uint32_t*)(0));
VPrint("Starting link training tests\n");
// Write scratch register
i2cWrite(I2C_ADDR_SCRATCH0, 0x55, pTestBench);
// Read scratch register
i2cRead(I2C_ADDR_SCRATCH0, data, pTestBench);
if (data != 0x55)
{
VPrint("**ERROR 1300: Bad scratch register value. (got 0x%02x, exp 0x%02x)\n", data, 0x55);
error |= 1;
}
// Check link is aligned
uint32_t link_status = 0;
i2cRead(I2C_ADDR_LINK_STATUS, link_status, pTestBench);
if ((link_status & 0x01) == 0) {
VPrint(" Link is not aligned!\n");
error |= 1;
}
VPrint(" Enabling loopback...\n");
// Enable loopback
i2cWrite(I2C_ADDR_LINK_CTRL, 0x01, pTestBench);
// Enable training pattern transmission
pCore->pLinkCtrl->SetMode(0xf);
pCore->pLinkCtrl->SetRepeat(3);
pCore->pTrPattern0->SetTrPattern0(0x33221100);
pCore->pTrPattern1->SetTrPattern1(0x77665544);
pCore->pTrPattern2->SetTrPattern2(0xBBAA9988);
pCore->pTrPattern3->SetTrPattern3(0xFFEEDDCC);
pCore->pTrPattern4->SetTrPattern4(0xAA55AA55);
usleepSim(6);
for (uint32_t i = 0;i < numHeads; i++) {
uint32_t link_errors = 1;
while (link_errors != 0) {
pCore->pLinkCtrl->SetBitslip(1 << i);
pCore->pLinkCtrl->SetBitslip(0);
usleepSim(6);
link_errors = (i==0 ? pCore->pTrErrors0->GetTrErrors0() : (i==1 ? pCore->pTrErrors1->GetTrErrors1() : (i==2 ? pCore->pTrErrors2->GetTrErrors2() : pCore->pTrErrors3->GetTrErrors3())));
}
}
/* link_status = 0;
// Phase to 32 steps
i2cWrite(I2C_ADDR_LINK_PHLSB, 0x20, pTestBench);
i2cWrite(I2C_ADDR_LINK_PHMSB, 0x00, pTestBench);
i2cWrite(I2C_ADDR_LINK_CTRL, 0x03, pTestBench);
// Phase ready ?
while ((link_status & 0x02) == 0)
i2cRead(I2C_ADDR_LINK_STATUS, link_status, pTestBench);
link_status = 0;
// Phase to 16 steps
i2cWrite(I2C_ADDR_LINK_PHLSB, 0x10, pTestBench);
i2cWrite(I2C_ADDR_LINK_PHMSB, 0x00, pTestBench);
i2cWrite(I2C_ADDR_LINK_CTRL, 0x03, pTestBench);
// Phase ready ?
while ((link_status & 0x02) == 0)
i2cRead(I2C_ADDR_LINK_STATUS, link_status, pTestBench); */
return error;
}
int runTest::link_crc_test(CCoreAuto* pCore, int node)
{
uint32_t error = 0;
uint32_t dataA, dataB, dataC, dataD;
uint32_t errL, errR;
CTestAuto* pTestBench = new CTestAuto((uint32_t*)(0));
VPrint("Starting crc tests\n");
// Read link A/B errors registers
i2cRead(I2C_ADDR_CNT_ERR_L3, dataA, pTestBench);
i2cRead(I2C_ADDR_CNT_ERR_L2, dataB, pTestBench);
i2cRead(I2C_ADDR_CNT_ERR_L1, dataC, pTestBench);
i2cRead(I2C_ADDR_CNT_ERR_L0, dataD, pTestBench);
errL = (dataA << 24) | (dataB << 16) | (dataC << 8) | (dataD << 0);
i2cRead(I2C_ADDR_CNT_ERR_R3, dataA, pTestBench);
i2cRead(I2C_ADDR_CNT_ERR_R2, dataB, pTestBench);
i2cRead(I2C_ADDR_CNT_ERR_R1, dataC, pTestBench);
i2cRead(I2C_ADDR_CNT_ERR_R0, dataD, pTestBench);
errR = (dataA << 24) | (dataB << 16) | (dataC << 8) | (dataD << 0);
if (errL != 0x01)
{
VPrint("**ERROR 1400: Bad cnt error number for Channel L. (got 0x%02x, exp 0x%02x)\n", errL, 0x01);
error |= 1;
}
if (errR != 0x01)
{
VPrint("**ERROR 1401: Bad cnt error number for Channel R. (got 0x%02x, exp 0x%02x)\n", errR, 0x01);
error |= 1;
}
VPrint(" Clearing errors...\n");
// Clear CRC counters
i2cWrite(I2C_ADDR_CNT_ERR_L3, 0x00, pTestBench);
i2cWrite(I2C_ADDR_CNT_ERR_R3, 0x00, pTestBench);
// Read link A/B errors registers
i2cRead(I2C_ADDR_CNT_ERR_L3, dataA, pTestBench);
i2cRead(I2C_ADDR_CNT_ERR_L2, dataB, pTestBench);
i2cRead(I2C_ADDR_CNT_ERR_L1, dataC, pTestBench);
i2cRead(I2C_ADDR_CNT_ERR_L0, dataD, pTestBench);
errL = (dataA << 24) | (dataB << 16) | (dataC << 8) | (dataD << 0);
i2cRead(I2C_ADDR_CNT_ERR_R3, dataA, pTestBench);
i2cRead(I2C_ADDR_CNT_ERR_R2, dataB, pTestBench);
i2cRead(I2C_ADDR_CNT_ERR_R1, dataC, pTestBench);
i2cRead(I2C_ADDR_CNT_ERR_R0, dataD, pTestBench);
errR = (dataA << 24) | (dataB << 16) | (dataC << 8) | (dataD << 0);
if (errL != 0x00)
{
VPrint("**ERROR 1402: Bad cnt error number for Channel L. (got 0x%02x, exp 0x%02x)\n", errL, 0x00);
error |= 1;
}
if (errR != 0x00)
{
VPrint("**ERROR 1403: Bad cnt error number for Channel R. (got 0x%02x, exp 0x%02x)\n", errR, 0x00);
error |= 1;
}
return error;
}
// --------------------------------------------------
// I2C write method
// --------------------------------------------------
uint32_t runTest::i2cWrite (uint32_t hmb_addr, uint32_t data, CTestAuto* pTestBench)
{
csrWriteMem(CSR_TEST_I2C_MASTER | (SLAVE_I2C_ADDR << 2), ((hmb_addr & 0xff00) >> 8) | ((hmb_addr & 0xff) << 8) | ((data & 0xff) << 16));
// Wait until we've seen busy go high to indicate transaction excepted
while (pTestBench->pI2cStatus->GetBusy() == 0)
usleepSim(1);
// Wait until we've seen busy go low at the end of the transaction
while (pTestBench->pI2cStatus->GetBusy() == 1)
usleepSim(1);
return 0;
}
// --------------------------------------------------
// I2C read method
// --------------------------------------------------
uint32_t runTest::i2cRead(uint32_t hmb_addr, uint32_t &data, CTestAuto* pTestBench)
{
csrWriteMem(CSR_TEST_I2C_MASTER | ((CMD_READ_OFFSET | SLAVE_I2C_ADDR) << 2), ((hmb_addr & 0xff00) >> 8) | ((hmb_addr & 0xff) << 8));
// Wait until we've seen busy go high to indicate transaction excepted
while (pTestBench->pI2cStatus->GetBusy() == 0)
usleepSim(1);
// Wait until we've seen busy go low at the end of the transaction
while (pTestBench->pI2cStatus->GetBusy() == 1)
usleepSim(1);
uint32_t rd_data;
csrReadMem(CSR_TEST_I2C_MASTER | ((CMD_READ_OFFSET | SLAVE_I2C_ADDR) << 2), &rd_data);
// Wait until we've seen busy go high to indicate transaction excepted
while (pTestBench->pI2cStatus->GetBusy() == 0)
usleepSim(1);
// Wait until we've seen busy go low at the end of the transaction
while (pTestBench->pI2cStatus->GetBusy() == 1)
usleepSim(1);
csrReadMem(CSR_TEST_I2C_MASTER | ((CMD_READ_OFFSET | SLAVE_I2C_ADDR) << 2), &rd_data);
// Wait until we've seen busy go high to indicate transaction excepted
while (pTestBench->pI2cStatus->GetBusy() == 0)
usleepSim(1);
// Wait until we've seen busy go low at the end of the transaction
while (pTestBench->pI2cStatus->GetBusy() == 1)
usleepSim(1);
data = rd_data;
return 0;
}
// ------------------------------------
// Configure the FPM's pulse generator
//
int fpmConfig(CCoreAuto* pCore, double divRatio, uint32_t numSubPixPhases, uint32_t seq[], uint32_t seqLen)
{
CPulseGenerator3Auto* pPulseGen[4] = { pCore->pPulseGenerator30, pCore->pPulseGenerator31, pCore->pPulseGenerator32, pCore->pPulseGenerator33 };
for (int ch = 0; ch < 4; ch++)
{
// Program the sequence if a buffer pointer is provided and the length isn't zero.
if (seq != NULL && seqLen != 0)
{
// Load the sequencer with default program
uint32_t seqBaseAddr = (uint32_t)pPulseGen[ch]->GetCsrBaseAddr() + CSR_PULSE_GENERATOR_3_CHANNEL_CONTROLLER_SEQ;
for(int idx = 0; idx < seqLen; idx++)
{
csrWriteMem(seqBaseAddr + idx*4, seq[idx]);
}
}
// Disable/Re-enable first the whole pulse_generator
pPulseGen[ch]->pPulseGenControl->SetPulseGenControl(0);
pPulseGen[ch]->pPulseGenControl->SetEnable(1);
pPulseGen[ch]->pPulseGenControl->SetEnableOutput(1);
// Disable the Channel Controller sequencer
pPulseGen[ch]->pChannelControllerControl->SetChannelControllerControl(0);
// Set the number of sub-pixel phases
pPulseGen[ch]->pSubpixelPhaseNum->SetSubpixelPhaseNum(numSubPixPhases);
// Set the integer part of the div-ratio
uint64_t ratio_int = ((divRatio/(double)numSubPixPhases) * (double)(1UL << 24));
pPulseGen[ch]->pDividerRatioInt->SetDividerRatioInt((uint32_t)(ratio_int >> 24));
// Set the fractional part of the div-ratio
pPulseGen[ch]->pDividerRatioFraction->SetDividerRatioFraction((uint32_t)(ratio_int & ((1UL << 24)-1)));
// ----
// Disable/Enable the fractional divider
pPulseGen[ch]->pFractionalDividerControl->SetFractionalDividerControl(0);
pPulseGen[ch]->pFractionalDividerControl->SetFractionalDividerControl(CSR_PULSE_GENERATOR_3_FRACTIONAL_DIVIDER_CONTROL_ENABLE_MASK |
CSR_PULSE_GENERATOR_3_FRACTIONAL_DIVIDER_CONTROL_UDP_MAX_POS_MASK |
CSR_PULSE_GENERATOR_3_FRACTIONAL_DIVIDER_CONTROL_UDP_MIN_POS_MASK);
// enable the ch-ctrl sequencer
pPulseGen[ch]->pGenericSequencer15Channel->pCtrl->SetSeqEnable(1);
// Issue a start_req to the ch-ctrl sequencer
pPulseGen[ch]->pChannelControllerControl->SetChannelControllerControl(1);
}
};