What is a gel file? What can a gel file do?
GEL stands for General Extended Language, which is a general extended language file. The GEL file is composed of codes similar to C language. GEL language is an interpreted language. The extension of GEL file is .gel.
GEL files are used to (1) extend CCS functionality, such as menu options, and (2) provide access to the target board's memory.
1. Basic syntax of gel - Class C
Gel functions and gel parameters do not need to be defined in the DSP program. Gel has many similarities to C language: functions, return statements, if-else statements, while statements, the same comment method as C, #define, and the usage of these functions or statements is also very similar to that in C.
GEL Function
funcName(param1 "discription" [,param2 "discription", param3 "discription",...])
{
statements;
}
There is no need to declare the return type and parameter type in the gel function, but the return statement can be used in the function;
Parameters are composed of "parameter + string type description". Parameters do not need to be defined and can be any of the following: symbolic value of the actual/simulated DSP target board; digital constant (expression or constant); string constant.
GEL function call: You can usually call a GEL function anywhere you enter a C expression, or you can call a GEL function from within another GEL function. GEL functions cannot be called recursively.
GEL Statements
Return statement:
return [expression];
Conditional Statements:
-
if (exp)
-
statements 1;
-
else
-
statements 2;
Loop statement:
-
while (exp) {
-
statements;
-
}
GEL Pretreatment
#define identifier(arguments list) token-expression
GEL Notes
// Comments
/* Comments */
2. Gel-specific keywords
menuitem/hotmenu
Tested in CCS v4.2, menuitem adds submenu items under the Scripts menu, and hotmenu adds submenu items of the menu item defined by menuitem. Refer to the examples later in this article.
Functions declared with these two keywords do not require parameters, such as
-
menuitem "Addressing Modes";
-
hotmenu C27x_Mode()
-
{
-
AMODE = 0;
-
OBJMODE = 0;
-
}
-
hotmenu C28x_Mode()
-
{
-
AMODE = 0;
-
OBJMODE = 1;
-
}
-
hotmenu C2xLP_Mode()
-
{
-
AMODE = 1;
-
OBJMODE = 1;
-
}
The above code will generate the following menu structure,
Scripts
-Addressing Modes
-C27x_Mode
- C28x_Mode
- C2xLP_MODE
dialog
Add an entry submenu to the menu defined by menuitem and pop up a dialog box when the submenu is clicked.
menuitem "MyFunc"
dialog InitTarget(StartAddr "Starting Address", EndAddr "Ending Address")
{
statements;
}
dialog RefreshTarget()
{
statements;
}
slider
Add a slider. Each time you move the slider, call the GEL file again with the new value on the slider. The definition format is as follows:
slider param_def(minVal, maxVal, increment, pageIncrement, paramName)
{
statements;
}
3. GEL file example
-
/*
-
* This GEL file (DSP621x_671x.gel) provides example code on how to
-
* reset the C6x DSP and initialize the External Memory Interface.
-
*
-
* You will have to edit settings in emif_init() to your own
-
* specifications as the example is applicable to the C6711 DSK.
-
*
-
* This file is has minimal functionality and is designed to be used
-
* as a starting point for custom GEL files.
-
*
-
* Refer to CCS Help for detailed information on GEL commands.
-
*
-
*/
-
/*
-
* The StartUp() function is called every time you start Code Composer.
-
* It should only include functions that do not "touch the hardware" -
-
* Hardware initialization should be invoked from the OnTargetConnect()
-
* function or the GEL menu.
-
*/
-
StartUp()
-
{
-
/* setMemoryMap;
-
this should be a function to initialize the mem map based
-
on the particular hardware that is used
-
*/
-
}
-
/*--------------------------------------------------------------*/
-
/* OnTargetConnect() -- this function is called after a target */
-
/* connect. */
-
/*--------------------------------------------------------------*/
-
OnTargetConnect()
-
{
-
/* GEL_Reset is used to deal with the worst case senario of
-
unknown target state. If for some reason a reset is not
-
desired upon target connection, GEL_Reset may be removed
-
and replaced with something "less brutal" like a cache
-
initialization function
-
GEL_Reset();
-
*/
-
}
-
OnReset(int nErrorCode){
-
/* emif_init(); */
-
}
-
/*
-
* OnPreFileLoaded()
-
* This function is called automatically when the 'Load Program'
-
* Menu item is selected .....
-
*/
-
OnPreFileLoaded()
-
{
-
CleanCache();
-
}
-
/*
-
* CleanCache()
-
* Actually Invalidate L1D, L1P, and L2
-
*/
-
CleanCache() {
-
*(int *)0x01845004 = 1;
-
}
-
emif_init()
-
{
-
/*---------------------------------------------------------------------------*/
-
/* EMIF REGISTERS */
-
/*---------------------------------------------------------------------------*/
-
#define EMIF_GCTL 0x01800000
-
#define EMIF_CE1 0x01800004
-
#define EMIF_CE0 0x01800008
-
#define EMIF_CE2 0x01800010
-
#define EMIF_CE3 0x01800014
-
#define EMIF_SDRAMCTL 0x01800018
-
#define EMIF_SDRAMTIMING 0x0180001C
-
#define EMIF_SDRAMEXT 0x01800020
-
/*---------------------------------------------------------------------------*/
-
/* EMIF REGISTER VALUES - these should be modified to match TARGET hardware */
-
/*---------------------------------------------------------------------------*/
-
*(int *)EMIF_GCTL = 0x00003040;/* EMIF global control register */
-
*(int *)EMIF_CE1 = 0xFFFFFF23; /* CE1 - 32-bit asynch access after boot*/
-
*(int *)EMIF_CE0 = 0xFFFFFF30; /* CE0 - SDRAM */
-
*(int *)EMIF_CE2 = 0xFFFFFF23; /* CE2 - 32-bit asynch on daughterboard */
-
*(int *)EMIF_CE3 = 0xFFFFFF23; /* CE3 - 32-bit asynch on daughterboard */
-
*(int *)EMIF_SDRAMCTL = 0x07117000; /* SDRAM control register (100 MHz)*/
-
*(int *)EMIF_SDRAMTIMING = 0x0000061A; /* SDRAM Timing register */
-
}
The gel above comes from the ccsv4\emulation\gel\DSP621x_671x.gel file in the CCS v4 installation directory. It not only uses #define to define the register address, but also uses pointers similar to C to configure the EMIF (external memory interface).
-
/******************************************************************/
-
/* Code Composer Studio supports five reserved GEL functions that */
-
/* automatically get executed if they are defined. They are: */
-
/* */
-
/* StartUp() - Executed whenever CCS is invoked */
-
/* OnReset() - Executed after Debug->Reset CPU */
-
/* OnRestart() - Executed after Debug->Restart */
-
/* OnPreFileLoaded() - Executed before File->Load Program */
-
/* OnFileLoaded() - Executed after File->Load Program */
-
/* */
-
/******************************************************************/
-
StartUp()
-
{
-
/* Initialize F2812 memory map */
-
GEL_Reset();
-
F2812_Memory_Map();
-
/* Enable_DFT(); */
-
GEL_TextOut("Gel StartUp Complete.\n");
-
}
-
OnReset(int nErrorCode)
-
{
-
Enable_DFT();
-
}
-
/* commented out to avoid execution
-
OnRestart(int nErrorCode)
-
{
-
}
-
OnPreFileLoaded()
-
{
-
}
-
OnFileLoaded(int nErrorCode, int bSymbolsOnly)
-
{
-
}
-
*/
-
menuitem "Initialize Memory Map";
-
/*------------------- F2812 Memory Map, MPNMC=0 --------------------*/
-
/* */
-
/* Note: M0M1MAP and VMAP signals tied high on F2812 core */
-
/* */
-
/* 0x000000 - 0x0007ff M0/M1 SARAM (Prog and Data) */
-
/* 0x000800 - 0x000fff Peripheral Frame0 (PF0) (Data only) */
-
/* 0x002000 - 0x003fff XINTF ZONE 0 (Prog and Data) */
-
/* 0x004000 - 0x005fff XINTF ZONE 1 (Prog and Data) */
-
/* 0x006000 - 0x006fff Peripheral Frame1 (PF1) (Data only) */
-
/* 0x007000 - 0x007fff Peripheral Frame2 (PF2) (Data only) */
-
/* 0x008000 - 0x009fff L0/L1 SARAM (Prog and Data) */
-
/* 0x080000 - 0x0fffff XINTF ZONE 2 (Prog and Data) */
-
/* 0x100000 - 0x17ffff XINTF ZONE 6 (Prog and Data) */
-
/* 0x3d7800 - 0x3d7fff OTP (Prog and Data) */
-
/* 0x3d8000 - 0x3f7fff FLASH (Prog and Data) */
-
/* 0x3f8000 - 0x3f9fff H0 SARAM (Prog and Data) */
-
/* 0x3fc000 - 0x3fffff XINTF ZONE 7 (MPNMC=1) (Prog and Data) */
-
/* 0x3ff000 - 0x3fffff BOOT ROM (MPNMC=0) (Prog and Data) */
-
/*------------------------------------------------------------------*/
-
hotmenu F2812_Memory_Map()
-
{
-
GEL_MapReset();
-
GEL_MapOn();
-
/* Program memory maps */
-
GEL_MapAdd(0x0,0,0x800,1,1); /* M0/M1 SARAM */
-
GEL_MapAdd(0x2000,0,0x2000,1,1); /* XINTF ZONE 0 */
-
GEL_MapAdd(0x4000,0,0x2000,1,1); /* XINTF ZONE 1 */
-
GEL_MapAdd(0x8000,0,0x2000,1,1); /* L0/L1 SARAM */
-
GEL_MapAdd(0x80000,0,0x80000,1,1); /* XINTF ZONE 2 */
-
GEL_MapAdd(0x100000,0,0x80000,1,1); /* XINTF ZONE 6 */
-
GEL_MapAdd(0x3d7800,0,0x800,1,0); /* OTP */
-
GEL_MapAdd(0x3d8000,0,0x20000,1,0); /* FLASH */
-
GEL_MapAdd(0x3f8000,0,0x2000,1,1); /* H0 SARAM */
-
/* Data memory maps */
-
GEL_MapAdd(0x0,1,0x800,1,1); /* M0/M1 SARAM */
-
GEL_MapAdd(0x800,1,0x800,1,1); /* PF0 */
-
GEL_MapAdd(0x2000,1,0x2000,1,1); /* XINTF ZONE 0 */
-
GEL_MapAdd(0x4000,1,0x2000,1,1); /* XINTF ZONE 1 */
-
GEL_MapAdd(0x6000,1,0x1000,1,1); /* PF1 */
-
GEL_MapAddStr(0x7000,1,0x1000,"R|W|AS2",0); /* PF2 */
-
GEL_MapAdd(0x8000,1,0x2000,1,1); /* L0/L1 SARAM */
-
GEL_MapAdd(0x80000,1,0x80000,1,1); /* XINTF ZONE 2 */
-
GEL_MapAdd(0x100000,1,0x80000,1,1); /* XINTF ZONE 6 */
-
GEL_MapAdd(0x3d7800,1,0x800,1,0); /* OTP */
-
GEL_MapAdd(0x3d8000,1,0x20000,1,0); /* FLASH */
-
GEL_MapAdd(0x3f8000,1,0x2000,1,1); /* H0 SARAM */
-
/* Uncomment the map that corresponds to the MPNMC value. */
-
F2812_Boot_ROM_Map();
-
/* F2812_XINTF_Zone7_Map(); */
-
}
-
/* Map Boot ROM if MPNMC = 0 */
-
F2812_Boot_ROM_Map()
-
{
-
GEL_MapAdd(0x3ff000,0,0x1000,1,0); /* BOOT ROM */
-
GEL_MapAdd(0x3ff000,1,0x1000,1,0); /* BOOT ROM */
-
}
-
/* Map External Interface Zone 7 if MPNMC = 1 */
-
F2812_XINTF_Zone7_Map()
-
{
-
GEL_MapAdd(0x3fc000,0,0x4000,1,1); /* XINTF ZONE 7 */
-
GEL_MapAdd(0x3fc000,1,0x4000,1,1); /* XINTF ZONE 7 */
-
}
-
/* Enable DFT read/write for SARAM blocks */
-
Enable_DFT()
-
{
-
*0x950 = 0x0300; /* M0 */
-
*0x951 = 0x0300; /* M1 */
-
*0x952 = 0x0300; /* L0 */
-
*0x953 = 0x0300; /* L1 */
-
*0x954 = 0x0300; /* H0 */
-
}
-
menuitem "Watchdog";
-
hotmenu Disable_WD()
-
{
-
/* Enable WD override */
-
*0x7029 = *0x7029 | 0x0068;
-
*0x7025 = 0x0055;
-
*0x7025 = 0x00AA;
-
}
-
menuitem "Code Security Module"
-
hotmenu Unlock_CSM()
-
{
-
/* Assumes flash is erased */
-
*0xAE0 = 0xFFFF;
-
*0xAE1 = 0xFFFF;
-
*0xAE2 = 0xFFFF;
-
*0xAE3 = 0xFFFF;
-
*0xAE4 = 0xFFFF;
-
*0xAE5 = 0xFFFF;
-
*0xAE6 = 0xFFFF;
-
*0xAE7 = 0xFFFF;
-
/* Read the password locations */
-
XAR0 = *0x3F7FF8;
-
XAR0 = *0x3F7FF9;
-
XAR0 = *0x3F7FFA;
-
XAR0 = *0x3F7FFB;
-
XAR0 = *0x3F7FFC;
-
XAR0 = *0x3F7FFD;
-
XAR0 = *0x3F7FFE;
-
XAR0 = *0x3F7FFF;
-
}
-
menuitem "Addressing Modes";
-
hotmenu C27x_Mode()
-
{
-
AMODE = 0;
-
OBJMODE = 0;
-
}
-
hotmenu C28x_Mode()
-
{
-
AMODE = 0;
-
OBJMODE = 1;
-
}
-
hotmenu C2xLP_Mode()
-
{
-
AMODE = 1;
-
OBJMODE = 1;
-
}
The above code is a GEL file for DSP320F2812
A screenshot of the results is as follows,
|