嵌入式系统设计课程大作业.docx

上传人:b****1 文档编号:20784906 上传时间:2023-04-25 格式:DOCX 页数:14 大小:70.34KB
下载 相关 举报
嵌入式系统设计课程大作业.docx_第1页
第1页 / 共14页
嵌入式系统设计课程大作业.docx_第2页
第2页 / 共14页
嵌入式系统设计课程大作业.docx_第3页
第3页 / 共14页
嵌入式系统设计课程大作业.docx_第4页
第4页 / 共14页
嵌入式系统设计课程大作业.docx_第5页
第5页 / 共14页
点击查看更多>>
下载资源
资源描述

嵌入式系统设计课程大作业.docx

《嵌入式系统设计课程大作业.docx》由会员分享,可在线阅读,更多相关《嵌入式系统设计课程大作业.docx(14页珍藏版)》请在冰豆网上搜索。

嵌入式系统设计课程大作业.docx

嵌入式系统设计课程大作业

2012年上学期嵌入式系统设计课程大作业

1、叙述下列相关名词的含义

ARM、xscale、PXA255、RISC、体系结构

答:

1)ARM:

英国的一家公司;时下流行的一种体系结构。

2)XScale:

ARM架构v5TE指令集的CPU。

3)PXA255:

XScale的核版本。

4)RISC:

ReducedInstructionSetComputing,即精简指令集,一种CPU的设计概念;与之相对的是CISC,即复杂指令集

5)体系结构:

嵌入式系统硬件与软件的衔接;它确定嵌入式系统设计的部件、部件功能、部件间借口的设计,并集中于嵌入式系统的核心部分——处理器的运算与存的存取。

2、画出嵌入式硬件系统组成的模块结构图

3、叙述基于linux的嵌入式平台的搭建过程

答:

Linux嵌入式平台的搭建符合嵌入式平台搭建的一般过程,但是具体到Linux嵌入式平台,又有些许不同,其搭建过程如下:

1)处理器以及硬件开发平台的选择

以处理器为主,结合考虑硬件平台的情况。

处理器考虑的问题包括应用类型及I/O接口、主频和功耗、对不同类型存储器的支持、封装等;硬件平台的选择和设计包括存和外围存储器、输入输出接口以及设备等几项主要容。

2)操作系统的选择

由于已经选取了Linux操作系统,因此此处主要是核版本的选取以及对核功能的裁剪。

3)开发环境的选取

即开发工具的选取,主要是指开发软件的选取,比如常用的minicom。

4)开发实施

首先,Bootloader的烧制。

目的是对硬件系统基本功能的支持,比如串口通信。

其次,核文件的制作。

接下来,核文件的拷贝。

此时,可以通过串口或者网口实施传输,能够大幅度提高传输速度。

最后,在主机使用开发软件,完成对硬件系统的开发工作。

包括硬件驱动程序、上层的应用程序、系统的集成与调试等。

4、如下为xscale处理器的核框图:

 

简述核框图中每个模块的名称及指标。

答:

1)InstructionCache:

指令Cache;大小32KB,32路,支持线性锁定

2)Micro-Processor:

微处理器;七级流水

3)DataCache:

数据Cache;最大支持32KB,32路

4)DataRam:

数据Ram;最大支持28KB

5)Mini-DataCache:

迷你数据Cache;大小2KB,2路

6)BranchTargetBuffer:

分支目标缓存;128入口

7)IMMU/DMMU:

指令/数据存储管理单元;32路,全相关,支持锁定

8)FillBuffer:

填充缓存;4~8入口

9)PerformanceMonitoring:

功能显示器

10)Debug:

硬件中断断点记录

11)PowerManagementControl:

电源管理控制

12)MAC:

乘加单元;40位累加/累乘,16位单指令多数据流操作,16*32位操作单周期支持

13)WriteBuffer:

写缓存;8入口,支持合并操作

14)JTAG:

边界扫描技术;支持JTAG操作

5、下述英文为BTB模块功能的详细介绍,阅读后说明该模块的作用。

⏹TheBTBstoresthehistoryofbranchesthathaveexecutedalongwiththeirtargets.Figure5-1showsanentryintheBTB,wherethetagistheinstructionaddressofapreviouslyexecutedbranchandthedatacontainsthetargetaddressofthepreviouslyexecutedbranchalongwithtwobitsofhistoryinformation.

⏹TheBTBtakesthecurrentinstructionaddressandcheckstoseeifthisaddressisabranchthatwaspreviouslyseen.Itusesbits[8:

2]ofthecurrentaddresstoselectthetagfromtheBTBandthencomparesthistagtobits[31:

9,1]ofthecurrentinstructionaddress.IfthecurrentinstructionaddressmatchesthetagintheBTBandthehistorybitsindicatethatthisbranchisusuallytakeninthepast,theBTBusesthedata(targetaddress)asthenextinstructionaddresstosendtotheinstructioncache.

 

答:

分支目标缓存目标地址历史的分支,具体到每个入口(表项),由Tag和数据组成。

Tag是以前执行分支的指令地址,数据包括以前执行分支的目标地址,以及2比特的历史信息。

分支目标缓存取得当前的指令地址,检查这个地址是否是以前执行过的分支。

它用现行指令的位[8:

2]来选择分支目标缓存中的标志Tag,并与现行指令的位[31:

9,1]进行匹配。

若匹配且历史位指出该分支过去常产生,则分支目标缓存中的数据(目标地址[31:

1])作为下一条指令地址送至指令Cache。

6、下面是linux下的一个简单的设备驱动程序,写出linux设备驱动常用的数据结构,同时阅读下面代码,请给出测试程序中的每条语句加以注释。

 

设备驱动程序Keypad.c的源代码:

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#defineLEDnKEY_MAJOR251

#defineKEYPAD_NAME"X-Hyper250Keypad"

#defineKEYPAD_VERSION"Version0.1"

#defineEXT_KEY_CSEXT_PORT2

#defineEXT_LED_CSEXT_PORT3

#defineLED_SHOW10

/*EXT_KEY_CS为向外部LED进行数值设定,它定义在其它头文件里*/

voidled_off_on()/**/

{

inti;

EXT_LED_CS=0xff;

for(i=0;i<8;++i)

{

EXT_LED_CS=~((1<

udelay(30000);

}

EXT_LED_CS=0xff;

}

/*应用程序用open来打开设备文件,实际上调用驱动的lednkey_open()函数*/

intlednkey_open(structinode*inode,structfile*filp)/*打开设备文件*/

{

MOD_INC_USE_COUNT;/*核提供的一个宏,检查使用驱动程序的用户数*/

return(0);/*success*/

}

intlednkey_release(structinode*inode,structfile*filp)/*释放设备文件*/

{

led_off_on();

MOD_DEC_USE_COUNT;

return(0);

}

ssize_tlednkey_read(structfile*filp,char*Putbuf,size_tlength,loff_t*f_pos)/*按键读取函数*/

{

unsignedshortBottonStatus;

unsignedcharBottontmp=0;

inti;

BottonStatus=(EXT_KEY_CS&0xff);/*按键状态*/

for(i=0;i<8;++i)/*判断哪个按键按下*/

{

if(((BottonStatus>>i)&1)==0)

Bottontmp=(i+1);

}

copy_to_user(Putbuf,&Bottontmp,length);/*将数据从核态拷贝到用户态,这是由定义在里的特殊函数实现在不同的空间传输任意字节的数据*/

returnlength;

}

ssize_tlednkey_write(structfile*filp,constchar*Getbuf,size_tlength,loff_t*f_pos)

{

intnum;

unsignedcharUsrWantLed;

copy_from_user(&UsrWantLed,Getbuf,length);/*将数据从用户态拷贝到核心态*/

num=((UsrWantLed)&0xff);/*确定哪一位要进行设定*/

EXT_LED_CS=~(1<<(num-1));/*点亮相应LED灯*/

return(0);

}

intlednkey_ioctl(structinode*inode,structfile*filp,unsignedintcmd,unsignedlongarg)/*lednkey_ioctl接口函数,主要用于获取或者改变正在运行的设备参数*/

{

switch(cmd)

{

caseLED_SHOW:

/*如果要点亮LED灯*/

{

if(arg)

led_off_on();

break;

}

}

return0;

}

/*以下这些驱动函数是与用户的应用程序里对设备文件操作的函数相对应的*/

structfile_operationslednkey_fops={

open:

lednkey_open,

read:

lednkey_read,

write:

lednkey_write,

ioctl:

lednkey_ioctl,

release:

lednkey_release,

};

staticint_initxhyper250_keypad_init(void)/*初始化设备函数,在函数名之前加上这个属性之后,系统会在初始化完成之后丢弃初始化函数,收回它所占用的存,以减小核所占用的存空间,它只对建的驱动起作用*/

{

intresult;

result=register_chrdev(LEDnKEY_MAJOR,"lednkey",&lednkey_fops);/*向操作系统注册一个主号为251,设备名为"lednkey",并传递设备驱动程序的指针为lednkey_fops(全局变量),其中register_chrdev()是核提供的函数,作用是完成注册新的字符设备*/

printf("%s%sinitialized.\n",KEYPAD_NAME,KEYPAD_VERSION);

led_off_on();

return0;

}

staticvoid_exitxhyper250_keypad_exit(void)/*向操作系统卸载设备函数*/

{

unregister_chrdev(LEDnKEY_MAJOR,"lednkey");

led_off_on();

}

module_init(xhyper250_keypad_init);/*显式声明初始化设备函数*/

module_exit(xhyper250_keypad_exit);/*显式声明卸载设备函数*/

/*通过上述两个声明核知道驱动程序的进入点*/

测试文件的源代码如下:

#include

#include

#include

#include

#include

#include

#defineLED_SHOW10

intfd;

staticchar*dev_name="/dev/keypad";

intmain(intargc,char**argv)

{

intdata=0,pre_data;

fd=open(dev_name,O_RDWR);

if(!

(fd>=0))

{

printf("%sfileopenfailed\n",dev_name);

exit(-1);

}

printf("\nkeypadApp:

pressthepushbuttonseeshowled-ExitCtrl-C\n",dev_name);

ioctl(fd,LED_SHOW,1);

while

(1)

{

do

{

pre_data=data;

read(fd,(char*)&data,sizeof(data));

data=(data&0xff);

}while(data==0);

if(pre_data==0)

{

printf("Write%dLED\n",data);

write(fd,(constchar*)&data,sizeof((constchar)data));

}

}

close(fd);

return0;

}

1)数据结构

structfile_operations

{

structmodule*owner;

  loff_t(*llseek)(structfile*,loff_t,int);

  ssize_t(*read)(structfile*,char__user*,size_t,loff_t*);

  ssize_t(*aio_read)(structkiocb*,char__user*,size_t,loff_t);

  ssize_t(*write)(structfile*,constchar__user*,size_t,loff_t*);

  ssize_t(*aio_write)(structkiocb*,constchar__user*,size_t,loff_t);

  int(*readdir)(structfile*,void*,filldir_t);

  unsignedint(*poll)(structfile*,structpoll_table_struct*);

  int(*ioctl)(structinode*,structfile*,unsignedint,unsignedlong);

  long(*unlocked_ioctl)(structfile*,unsignedint,unsignedlong);

  long(*compat_ioctl)(structfile*,unsignedint,unsignedlong);

 int(*mmap)(structfile*,structvm_area_struct*);

  int(*open)(structinode*,structfile*);

  inode_operations。

  int(*flush)(structfile*);

  int(*release)(structinode*,structfile*);

  int(*fsync)(structfile*,structdentry*,intdatasync);

  int(*aio_fsync)(structkiocb*,intdatasync);

  int(*fasync)(int,structfile*,int);

  int(*lock)(structfile*,int,structfile_lock*);

  ssize_t(*readv)(structfile*,conststructiovec*,unsignedlong,loff_t*);

  ssize_t(*writev)(structfile*,conststructiovec*,unsignedlong,loff_t*);

  ssize_t(*sendfile)(structfile*,loff_t*,size_t,read_actor_t,void*);

  ssize_t(*sendpage)(structfile*,structpage*,int,size_t,loff_t*,int);

  unsignedlong(*get_unmapped_area)(structfile*,unsignedlong,unsignedlong,unsignedlong,unsignedlong);

int(*check_flags)(int);

  int(*dir_notify)(structfile*filp,unsignedlongarg);

  int(*flock)(structfile*,int,structfile_lock*);

}

2)程序注释

#include

#include

#include

#include

#include

#include

#defineLED_SHOW10

intfd;

staticchar*dev_name="/dev/keypad";

intmain(intargc,char**argv)

{

intdata=0,pre_data;

//使用函数open打开设备keypad

fd=open(dev_name,O_RDWR);

//打开失败,显示出错信息

if(!

(fd>=0))

{

printf("%sfileopenfailed\n",dev_name);

exit(-1);

}

 

//打开成功,提示用户输入

printf("\nkeypadApp:

pressthepushbuttonseeshowled-ExitCtrl-C\n",dev_name);

//循环显示LED,看LED是否正常

ioctl(fd,LED_SHOW,1);

while

(1)

{

//采用忙等待方式扫描用户输入,传递给write函数

do

{

pre_data=data;

//使用函数read从设备keypad读取数据

read(fd,(char*)&data,sizeof(data));

data=(data&0xff);

}while(data==0);

if(pre_data==0)

{

printf("Write%dLED\n",data);

//使用函数write写入数据,即向外部LED传输数据

write(fd,(constchar*)&data,sizeof((constchar)data));

}

}

//使用函数close关闭设备keypad

close(fd);

return0;

}

 

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > PPT模板 > 商务科技

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1