User guide

CIF Module - SimpleVSP
CoMET Version 5.9 – Tutorial 67
Creating and Compiling Target Code
This tutorial does not cover compiling target code for a particular VPM. The following code
writes a string to the memory, reads it back and displays it. The code works for the
ARM926EJS processor. Some adjustments may be necessary for the VPM you use.
/*
**-----------------------------------------------------------------------------
**
** Copyright (c) 2004, VaST Systems Technology Corporation.
**
** SimpleVSP Hello World
**
**-----------------------------------------------------------------------------
*/
#include <stdio.h>
#include <string.h>
#include "vastdef.h"
#include "tspi.h"
#include "printf_to_tspi.h"
#define EXT_MEM_BASE 0x00180000 /* define this for your specific VPM */
int main(void)
{
tWord8 i;
tWord8 cnt;
tWord32 *ptr;
char *hello = "Hello World from the VPM.";
tWord32 data[100];
tWord32 check_data[100];
cnt = (strlen(hello) / 4) + 1;
memcpy((char *)data, hello, cnt * 4);
printf("SimpleVSP: Writing data \"%s\" to memory on the bus.\n", hello);
ptr = (tWord32 *) EXT_MEM_BASE;
for ( i = 0; i < cnt; i++ )
{
*ptr++ = data[i];
}
printf("SimpleVSP: Reading data from memory on the bus.\n");
ptr = (tWord32 *) EXT_MEM_BASE;
for ( i = 0; i < cnt; i++ )
{
check_data[i] = *ptr++;
}
printf("SimpleVSP: Data is \"%s\".\n", (char *)check_data);
if (strcmp((char *)check_data, hello) != 0)
printf("*** Demo failed: Unexpected data read from memory.\n");
else
printf("*** Demo worked. ***\n");
TspiVpmStop();
}