本文主要是關(guān)于dsp和tms320c6000的相關(guān)介紹,并著重對dsp和tms320c6000進行了詳盡的闡述。
DSP
DSP是Digital Siginal Processor的簡稱。
(1)相對于PC等上的高端處理器,具有更低的功耗
(2)相對于PC等上的高端處理器,具有更低的價格
因此,在考慮價格、機械尺寸、低功耗以及“高頻”處理時使用DSP是較好的選擇。
相對于嵌入式ARM而言,DSP在信號處理上具有更大的優(yōu)勢,ARM偏向于控制。
在大部分的DSP算法中,乘積和(sum of product, SOP)是最基本的單元。
DSP TMS320C6000的基本特性
TMS320C6000產(chǎn)品是美國TI公司于1997年推出的dsp芯片,該DSP芯片定點、浮點兼容,其中,定點系列是TMS320C62xx系列,浮點系列是TMS320C67xx系列,2000年3月,TI發(fā)布新的C64xx內(nèi)核,主頻為1.1GHz,處理速度9000MIPS,在圖像處理和流媒體領域得到了廣泛的應用。
C6000片內(nèi)有8個并行的處理單元,分為相同的兩組。DSP的體系結(jié)構(gòu)采用超長指令字(vliw)結(jié)構(gòu),單指令字長為32位,指令包里有8條指令,總字長達到256位。執(zhí)行指令的功能單元已經(jīng)在編譯時分配好,程序運行時通過專門的指令分配模塊,可以將每個256為的指令包同時分配到8個處理單元,并有8個單元同時運行。芯片最高時鐘頻率為300MHz(67xx系列),且內(nèi)部8個處理單元并行運行時,其最大處理能力可達到1600MIPS。
dsp tms320c6000與gel文件
什么是gel文件?gel文件能干什么?
gel全稱General Extended Language,即通用擴展語言文件,gel文件中由類似C語言的代碼構(gòu)成,gel語言是一種解釋性語言,gel文件擴展名為.gel;
gel文件用于(1)擴展CCS功能,比如菜單選項等,(2)通過gel可以訪問目標板的存儲器。
1. gel基本語法——類C
gel函數(shù)和gel參數(shù)不需要在DSP程序中定義。gel具有C語言的很多相似的東西:函數(shù)、return語句、if-else語句、while語句、與C一樣的注釋方式、#define,這些函數(shù)或語句的用法也與C中的非常類似。
GEL函數(shù)
funcName(param1 “discription” [,param2 “discription”, param3 “discription”,。。.])
{
statements;
}
gel函數(shù)中不用聲明返回類型和參數(shù)類型,但函數(shù)中可以使用return語句返回;
參數(shù)使用“參數(shù)+字符串類型的描述”組成,參數(shù)不需要定義,可以是以下的任意一種:實際/仿真的DSP目標板的符號值;數(shù)字常量(表達式或常值);字符串常量。
GEL函數(shù)調(diào)用:通常可以在輸入C表達式的任意地方調(diào)用GEL函數(shù),也可以在另一個GEL函數(shù)中調(diào)用GEL函數(shù)。GEL函數(shù)無法遞歸調(diào)用。
GEL語句
返回語句:
return [expression];
條件語句:
if (exp)
statements 1;
else
statements 2;
循環(huán)語句:
while (exp) {
statements;
}
GEL預處理
#define identifier(arguments list) token-expression
GEL注釋
// 注釋
/* 注釋 */
2. gel特有關(guān)鍵字
menuitem/hotmenu
在CCS v4.2中測試,menuitem添加Scripts菜單下的子菜單項,hotmenu添加menuitem定義菜單項的子菜單項,參考本文后面的例子。
這兩個關(guān)鍵字聲明的函數(shù)都不需要參數(shù),比如
menuitem “Addressing Modes”;
hotmenu C27x_Mode()
{
AMODE = 0;
OBJMODE = 0;
}
hotmenu C28x_Mode()
{
AMODE = 0;
OBJMODE = 1;
}
hotmenu C2xLP_Mode()
{
AMODE = 1;
OBJMODE = 1;
}
上面代碼將產(chǎn)生如下的菜單結(jié)構(gòu),
Scripts
- Addressing Modes
- C27x_Mode
- C28x_Mode
- C2xLP_MODE
向menuitem定義的菜單中添加一個入口子菜單,并在點擊子菜單時彈出對話框。
menuitem “MyFunc”
dialog InitTarget(StartAddr “Starting Address”, EndAddr “Ending Address”)
{
statements;
}
dialog RefreshTarget()
{
statements;
}
slider
添加滑動條,每次移動滑動條都用滑動條上的新值重新調(diào)用GEL文件,定義格式如下,
slider param_def(minVal, maxVal, increment, pageIncrement, paramName)
{
statements;
}
3. gel文件的例子
/*
* 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 “l(fā)ess 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 */
}
上面的gel來自于CCS v4安裝目錄下ccsv4\emulation\gel\DSP621x_671x.gel文件,上面不僅使用了#define定義寄存器地址,還使用了類似C中的指針對EMIF(外部存儲器接口)進行配置。
/******************************************************************/
/* 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;
}
上面的代碼是DSP320F2812的一個GEL文件,上面添加了許多菜單項:
Scripts
- Initialize Memory Map
- F2812_Memory_Map
- Watchdog
- Disable_WD
- Code Security Module
- Unlock_CSM
- Addressing Modes
- C27x_Mode
- C28x_Mode
- C2xLP_Mode
結(jié)果的一個截圖如下,
4. 關(guān)于GEL文件中的一些函數(shù)
StartUp
啟動CCS時執(zhí)行該函數(shù),此時目標板可能還沒有連接,該調(diào)用如果有對目標板的操作則會出錯。
OnTargetConnect
連接目標板(點擊Connect Target時)時執(zhí)行。
OnReset
執(zhí)行Reset命令時執(zhí)行。
OnRestart
執(zhí)行Restart命令時執(zhí)行。
OnFileLoaded
執(zhí)行Load File.。.命令時執(zhí)行。
結(jié)語
關(guān)于dsp和tms320c6000的相關(guān)介紹就到這了,如有不足之處歡迎指正。
-
dsp
+關(guān)注
關(guān)注
553文章
7987瀏覽量
348729 -
TMS320C6000
+關(guān)注
關(guān)注
0文章
96瀏覽量
15749
發(fā)布評論請先 登錄
相關(guān)推薦
評論