MIPSIOandInterrupt

上传人:sx****84 文档编号:243045416 上传时间:2024-09-14 格式:PPT 页数:15 大小:122.50KB
返回 下载 相关 举报
MIPSIOandInterrupt_第1页
第1页 / 共15页
MIPSIOandInterrupt_第2页
第2页 / 共15页
MIPSIOandInterrupt_第3页
第3页 / 共15页
点击查看更多>>
资源描述
Click to edit Master title style,Click to edit Master text styles,Second level,Third level,Fourth level,Fifth level,*,*,MIPS I/O and Interrupt,1,SPIM I/O and MIPS Interrupts,The materials of this lecture can be found in A7-A8 (3,rd,Edition) and B7-B8 (4,th,Edition).,2,The MIPS memory,Actually, everything above 0x7fffffff is used by the system.,3,What is in there?,Special operating system functions,I/O registers mapped to memory addresses,Kernel data,4,SPIM Input,SPIM allows you to read from key board (which is similar to reading something from the true I/O register),5,.,text,.globl main,main:,addi $s0, $0, 113 # q key,lui $t0, 0xFFFF # $t0 = 0xFFFF0000;,waitloop:,lw $t1, 0($t0),andi $t1, $t1, 0x0001,beq $t1, $zero, waitloop,lw $a0, 4($t0),beq $a0, $s0, done,li $v0,1,syscall,li $v0,4,la $a0, new_line,syscall,j waitloop,done:,li $v0, 10 # exit,syscall,.data,new_line: .asciiz n”,Remember to select mapped I/O in PCSpim settings.,To set it, select Simulator then Settings,6,SPIM output,Similar to the input, SPIM has two memory locations for output,0xffff0008: Transmitter control.,Bit 1: interrupt enable,Bit 0: ready,0xffff000c: Transmitter data.,Bit 0-7: data byte,7,SPIM output,If you need to show something on the console, do the following:,Check if ready bit is 1. If yes, proceed. Otherwise, wait.,Write to the data. The ready bit will be reset to 0, and will be set to 1 after the byte is transmitted.,8,question,Is this the most efficient way to do it?,Remember that the processor usually has a lot of things to do simultaneously,9,Interrupt,The key problem is that the time when the input occurs cannot be predicted by your program,Wouldnt it be nice if you could “focus on what you are doing” while be “interrupted” if some inputs come?,10,MIPS interrupt,For external interrupt, your code is executing, and if an event happens that must be processed,The address of the instruction that is about to be executed is saved into a special register called EPC,PC is set to be 0x80000180, the starting address of the interrupt handler,Then, after processing this interrupt, call “eret” to set the value of the PC to the value stored in EPC,11,MIPS Interrupt,Is it okay to use $t0 in the interrupt? Note the difference between an interrupt and a function call.,For a function call, the caller is aware of the function call, so, it is not expecting the value of $t0 to be the same after the call.,For an interrupt, the user program is running and got interrupted. The user may not know about the interruption at all, so if you changed $t0 inside an interrupt, the user program may take the wrong value of $t0 and keep on calculating, which will result in errors.,Interrupt handlers should be short, because the processor often have multiple types of interrupts. It could happen that while you are processing interrupt A and interrupt B is triggered. Usually, in an interrupt handler, you disable other interrupts. To make sure that interrupt B can be processed in time, the handler for A should not take too long.,12,MIPS interrupt,Coprocessor 0 is a part of the CPU to handle interrupts. In SPIM, Coprocessor 0 contains the,BadVAddr (8), storing the memory address causing the exception,Count (9), increment by 1 every 10ms by default,Compare (11), if equals to Count, trigger an interrupt of level 5,Status (12),Bit 8-15: interrupt mask. A bit being 1 means that this interrupt is enabled.,Bit 4: user mode. With SPIM, always 1.,Bit 1: exception level (EXL). Normally 0, set to 1 if an exception occurred. When 1, no further interrupt is enabled and EPC is not updated.,Bit 0: interrupt enable. Enable (1) or disable (0) all interrupts.,Cause (13),Bit 8-15: pending interrupts . A bit being 1 means that this interrupt situation occurred, even if it is not enabled.,Bit 2-6: Exception code. 0 is hardware interrupt.,EPC (14),Config (16), config the machine,These registers can be read and modified using the instructions,mfc0 (move from coprocessor 0) and mtc0 (move to coprocessor 0).,13,MIPS Interrupt,$k0,and,$k1,are both used as temporary variables in interrupt servicing routines.,14,The code we used in the class (copy and paste the address into the address bar),15,
展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 图纸专区 > 课件教案


copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!