提交 5b361e37 创建 作者: 李川's avatar 李川

Merge branch 'irq' into 'master'

修改硬中断实验项目 See merge request !1
*.cir
*.xml
*.bak
/.vs
\ No newline at end of file
......@@ -339,5 +339,5 @@ aU4 [ ASK_FOR_INT NETU4_2 NETU4_3] NETINTR_ADDRESS_GATE_^EN OR3
.model OR3 d_or(rise_delay = 1e-9 fall_delay = 1e-9 input_load = 1e-3)
xuPC_NEXT UPC15 UPC14 UPC13 UPC12 UPC11 UPC10 UPC9 UPC8 UPC7 UPC6 UPC5 UPC4 UPC3 UPC2 UPC1 UPC0 UPC_NEXT15 UPC_NEXT14 UPC_NEXT13 UPC_NEXT12 UPC_NEXT11 UPC_NEXT10 UPC_NEXT9 UPC_NEXT8 UPC_NEXT7 UPC_NEXT6 UPC_NEXT5 UPC_NEXT4 UPC_NEXT3 UPC_NEXT2 UPC_NEXT1 UPC_NEXT0 modulecir6
.include "D:\codecode\Answer\computer_system\lab8\interrupt\uPC_NEXT.dlsche.cir"
.include "D:\codecode\Hardware-IRQ\uPC_NEXT.dlsche.cir"
.ends
......@@ -175,16 +175,24 @@ a1 1 out var_clock
.model var_clock d_osc(cntl_array = [-1.0 0.0 1.0 2.0] freq_array = [10 100 1e3 {frequency}] duty_cycle ={dutycycle} init_phase = 0 rise_delay = {risedelay} fall_delay = {falldelay})
.ends
x2 NET2_1 P
.subckt P 1
a1 1 2 InputBuffer
a2 2 Digload
.MODEL Digload d_pulldown(load = 1e-12)
.MODEL InputBuffer d_buffer (rise_delay = 1n fall_delay = 1n)
.ends
xALU CN FLAG_REG_EN S0 S1 S2 W_REG_EN A_REG_EN CLK DBUS7 DBUS6 DBUS5 DBUS4 DBUS3 DBUS2 DBUS1 DBUS0 CF ZF L_GATE_EN R_GATE_EN D_GATE_EN S3 C M DBUS7 DBUS6 DBUS5 DBUS4 DBUS3 DBUS2 DBUS1 DBUS0 CLK modulecir1
xREG IR0 IR1 REG_WR REG_READ CLK IA_GATE_EN SP_GATE_EN ASR_GATE_EN IA_REG_EN SP_REG_EN ASR_REG_EN CST_U\D CST_LOAD CST_GATE_EN DBUS7 DBUS6 DBUS5 DBUS4 DBUS3 DBUS2 DBUS1 DBUS0 DBUS7 DBUS6 DBUS5 DBUS4 DBUS3 DBUS2 DBUS1 DBUS0 modulecir2
xPC CF ZF IR2 IR3 PC_LOAD_EN CLK DBUS7 DBUS6 DBUS5 DBUS4 DBUS3 DBUS2 DBUS1 DBUS0 PC_A_GATE_EN PC_D_GATE_EN PC_ADD INTR_LOAD DBUS7 DBUS6 DBUS5 DBUS4 DBUS3 DBUS2 DBUS1 DBUS0 ABUS7 ABUS6 ABUS5 ABUS4 ABUS3 ABUS2 ABUS1 ABUS0 RESET modulecir3
xMEM ABUS7 ABUS6 ABUS5 ABUS4 ABUS3 ABUS2 ABUS1 ABUS0 DBUS7 DBUS6 DBUS5 DBUS4 DBUS3 DBUS2 DBUS1 DBUS0 MEM_WR CLK MEM_GATE_EN DBUS7 DBUS6 DBUS5 DBUS4 DBUS3 DBUS2 DBUS1 DBUS0 modulecir4
xCU CLK DBUS7 DBUS6 DBUS5 DBUS4 DBUS3 DBUS2 DBUS1 DBUS0 IR0 IR1 IR2 IR3 S0 S1 S2 A_REG_EN W_REG_EN FLAG_REG_EN CN REG_WR SP_REG_EN ROUT_REG_EN MAR_GATE_EN MAR_REG_EN PC_LOAD_EN PC_A_GATE_EN ASR_REG_EN MEM_WR IA_REG_EN SP_GATE_EN PC_D_GATE_EN D_GATE_EN R_GATE_EN L_GATE_EN ASR_GATE_EN IA_GATE_EN RIN_GATE_EN MEM_GATE_EN CST_GATE_EN CST_LOAD REG_READ S3 C M CST_U\D PC_ADD INTR INTR_LOAD IF RESET INTA2 EOI INTA1 modulecir5
xHDINT NETC3_1 NETC4_1 NETC5_1 NETC6_1 NETC7_1 NETC8_1 NETC9_1 NETC10_1 INTA2 EOI RESET INTR DBUS7 DBUS6 DBUS5 DBUS4 DBUS3 DBUS2 DBUS1 DBUS0 INTA1 RESET CLK INTA2 modulecir7
.include "D:\codecode\Answer\computer_system\lab8\interrupt\ALU.dlsche.cir"
.include "D:\codecode\Answer\computer_system\lab8\interrupt\REG.dlsche.cir"
.include "D:\codecode\Answer\computer_system\lab8\interrupt\PC.dlsche.cir"
.include "D:\codecode\Answer\computer_system\lab8\interrupt\MEM.dlsche.cir"
.include "D:\codecode\Answer\computer_system\lab8\interrupt\CU.dlsche.cir"
.include "D:\codecode\Answer\computer_system\lab8\interrupt\HDINT.dlsche.cir"
xIRQ NETC3_1 NETC4_1 NETC5_1 NETC6_1 NETC7_1 NETC8_1 NETC9_1 NETC10_1 INTA2 EOI RESET NET2_1 DBUS7 DBUS6 DBUS5 DBUS4 DBUS3 DBUS2 DBUS1 DBUS0 INTA1 RESET CLK INTA2 modulecir7
.include "D:\codecode\Hardware-IRQ\ALU.dlsche.cir"
.include "D:\codecode\Hardware-IRQ\REG.dlsche.cir"
.include "D:\codecode\Hardware-IRQ\PC.dlsche.cir"
.include "D:\codecode\Hardware-IRQ\MEM.dlsche.cir"
.include "D:\codecode\Hardware-IRQ\CU.dlsche.cir"
.include "D:\codecode\Hardware-IRQ\IRQ.dlsche.cir"
.end
这个 源代码变更 因为 太大 而不能显示。 你可以 浏览blob
这个 源代码变更 因为 太大 而不能显示。 你可以 浏览blob
.subckt modulecir7 IR0 IR1 IR2 IR3 IR4 IR5 IR6 IR7 NET1_^EN EOI RESET INTR DBUS7 DBUS6 DBUS5 DBUS4 DBUS3 DBUS2 DBUS1 DBUS0 INTA1 RESET CLK NET1_^EN
x1 NET1_A0 NET1_A1 NET1_A2 NET1_A3 NET1_A4 NET1_A5 NET1_A6 NET1_A7 DBUS0 DBUS1 DBUS2 DBUS3 DBUS4 DBUS5 DBUS6 DBUS7 NET1_^EN BUS_TRANS8
.subckt BUS_TRANS8 A0 A1 A2 A3 A4 A5 A6 A7 B0 B1 B2 B3 B4 B5 B6 B7 EN
xU3 EN IEN NNOT
xU5 A0 IA0 NNOT
xU6 A1 IA1 NNOT
xU7 A2 IA2 NNOT
xU8 A3 IA3 NNOT
xU9 A4 IA4 NNOT
xU10 A5 IA5 NNOT
xU11 A6 IA6 NNOT
xU12 A7 IA7 NNOT
.subckt NNOT IN OUT
aU1 IN NetU1_2 NOT
aU2 NetU1_2 OUT NOT
.model NOT d_inverter(rise_delay = 1e-9 fall_delay = 1e-9 input_load = 1e-3)
.ends
a1 [ IA0 IA1 IA2 IA3 IA4 IA5 IA6 IA7] IEN [ B0 B1 B2 B3 B4 B5 B6 B7] MULTI_TRISTATE
.model MULTI_TRISTATE d_multristate(delay = 0.5e-9 input_load = 0.5e-12 enable_load = 0.5e-12)
.ends
xIRR NET1_A0 NET1_A1 NET1_A2 NET1_^EN IR0 IR1 IR2 IR3 IR4 IR5 IR6 IR7 IRR0 IRR1 IRR2 IRR3 IRR4 IRR5 IRR6 IRR7 RESET CLK modulecir8
xISR INTA1 EOI NET1_A0 NET1_A1 NET1_A2 INTR RESET ISR7 ISR6 ISR5 ISR4 ISR3 ISR2 ISR1 ISR0 IRNM0 IRNM1 IRNM2 CLK CLK modulecir9
xPR ISR7 ISR6 ISR5 ISR4 ISR3 ISR2 ISR1 ISR0 IRR7 IRR6 IRR5 IRR4 IRR3 IRR2 IRR1 IRR0 INTR IRNM0 IRNM1 IRNM2 modulecir10
.include "D:\codecode\Answer\computer_system\lab8\interrupt\IRR.dlsche.cir"
.include "D:\codecode\Answer\computer_system\lab8\interrupt\ISR.dlsche.cir"
.include "D:\codecode\Answer\computer_system\lab8\interrupt\PR.dlsche.cir"
.ends
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<project id="1066ea9b-8510-4194-ab6e-5b2e2c42f996" name="interrupt" version="1">
<project id="1066ea9b-8510-4194-ab6e-5b2e2c42f996" name="Hardware-IRQ" version="1">
<files>
<filefolder id="a9f57fc8-c239-4574-a5da-f8fa2760024b" name="子模块">
......@@ -8,10 +8,9 @@
<file relativepath="REG.dlsche"/>
<file relativepath="CU.dlsche"/>
<file relativepath="MEM.dlsche"/>
<file relativepath="IRR1.dlsche"/>
<file relativepath="uPC_NEXT.dlsche"/>
<file relativepath="IRR.dlsche"/>
<file relativepath="HDINT.dlsche"/>
<file relativepath="IRQ.dlsche"/>
<file relativepath="PR.dlsche"/>
<file relativepath="ISR.dlsche"/>
</filefolder>
......@@ -27,7 +26,7 @@
<file relativepath="ram.rxm"/>
<file relativepath="rom.rxm"/>
</filefolder>
<file relativepath="DM1000.dlsche"/>
<file relativepath="Hardware-IRQ.dlsche"/>
</files>
</project>
这个 源代码变更 因为 太大 而不能显示。 你可以 浏览blob
差异被折叠。
差异被折叠。
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<svg height="303" version="1.1" width="1635" xmlns="http://www.w3.org/2000/svg">
<text alignment-baseline="after-edge" fill="#000000" font-family="微软雅黑" font-size="250" font-weight="700" text-anchor="start" x="19" y="315">硬中断控制器</text>
</svg>
......@@ -28,6 +28,26 @@ lea a, int_3
mov r0, 0xfb
mov [r0], a
;4号中断向量0xfc,0xfc中保存4号中断服务程序的入口地址
lea a, int_4
mov r0, 0xfc
mov [r0], a
;5号中断向量0xfd,0xfd中保存5号中断服务程序的入口地址
lea a, int_5
mov r0, 0xfd
mov [r0], a
;6号中断向量0xfe,0xfe中保存6号中断服务程序的入口地址
lea a, int_6
mov r0, 0xfe
mov [r0], a
;7号中断向量0xff,0xff中保存7号中断服务程序的入口地址
lea a, int_7
mov r0, 0xff
mov [r0], a
;=======================================================
;主程序代码
......@@ -66,3 +86,28 @@ mov a, 0x13
or a, [r0]
ret
;4号中断的服务程序
int_4:
mov r1, 2
mov a, 0
adc a, r1
ret
;5号中断的服务程序
int_5:
mov r2, 3
mov a, 1
and a, r2
ret
;6号中断的服务程序
int_6:
mov a, 2
sbb a, 3
ret
;7号中断的服务程序
int_7:
mov a, 2
shl a
ret
\ No newline at end of file
没有这种文件类型的预览
......@@ -9,60 +9,105 @@
0009 ;中断向量本身是一个地址,它指向一个存储单元,该存储单元保存的就是某个中断服务程序的入口地址(起始地址)
0010 ;设中断向量列表的首地址为0xf8,即第一个中断向量是存储单元0xf8
0011 ;0号中断向量0xf8,0xf8中保存0号中断服务程序的入口地址
0012 02 98 1D lea a, int_0
0012 02 98 31 lea a, int_0
0013 04 8C F8 mov r0, 0xf8
0014 06 84 mov [r0], a
0015
0016 ;1号中断向量0xf9,0xf9中保存1号中断服务程序的入口地址
0017 07 98 22 lea a, int_1
0017 07 98 36 lea a, int_1
0018 09 8C F9 mov r0, 0xf9
0019 0B 84 mov [r0], a
0020
0021 ;2号中断向量0xfa,0xfa中保存2号中断服务程序的入口地址
0022 0C 98 27 lea a, int_2
0022 0C 98 3B lea a, int_2
0023 0E 8C FA mov r0, 0xfa
0024 10 84 mov [r0], a
0025
0026 ;3号中断向量0xfb,0xfb中保存3号中断服务程序的入口地址
0027 11 98 2B lea a, int_3
0027 11 98 3F lea a, int_3
0028 13 8C FB mov r0, 0xfb
0029 15 84 mov [r0], a
0030
0031 ;=======================================================
0032 ;主程序代码
0033
0034 16 7C FF mov a, -1
0031 ;4号中断向量0xfc,0xfc中保存4号中断服务程序的入口地址
0032 16 98 43 lea a, int_4
0033 18 8C FC mov r0, 0xfc
0034 1A 84 mov [r0], a
0035
0036 LOOPC:
0037 18 8C 01 mov r0, 1
0038 1A 10 add a, r0
0039
0040 1B AC 18 jmp LOOPC
0041
0042
0043 ;=======================================================
0044 ;中断服务程序
0045 ;0号中断的服务程序
0046 int_0:
0047 1D 7C 10 mov a, 0x10
0048 1F 2C FF adc a, -1
0049 21 C8 ret
0036 ;5号中断向量0xfd,0xfd中保存5号中断服务程序的入口地址
0037 1B 98 49 lea a, int_5
0038 1D 8C FD mov r0, 0xfd
0039 1F 84 mov [r0], a
0040
0041 ;6号中断向量0xfe,0xfe中保存6号中断服务程序的入口地址
0042 20 98 4F lea a, int_6
0043 22 8C FE mov r0, 0xfe
0044 24 84 mov [r0], a
0045
0046 ;7号中断向量0xff,0xff中保存7号中断服务程序的入口地址
0047 25 98 54 lea a, int_7
0048 27 8C FF mov r0, 0xff
0049 29 84 mov [r0], a
0050
0051 ;1号中断的服务程序
0052 int_1:
0053 22 7C 11 mov a, 0x11
0054 24 3C FF sub a, -1
0055 26 C8 ret
0056
0057 ;2号中断的服务程序
0058 int_2:
0059 27 7C 12 mov a, 0x12
0060 29 50 and a, r0
0061 2A C8 ret
0051 ;=======================================================
0052 ;主程序代码
0053
0054 2A 7C FF mov a, -1
0055
0056 LOOPC:
0057 2C 8C 01 mov r0, 1
0058 2E 10 add a, r0
0059
0060 2F AC 2C jmp LOOPC
0061
0062
0063 ;3号中断的服务程序
0064 int_3:
0065 2B 7C 13 mov a, 0x13
0066 2D 64 or a, [r0]
0067 2E C8 ret
0068
0063 ;=======================================================
0064 ;中断服务程序
0065 ;0号中断的服务程序
0066 int_0:
0067 31 7C 10 mov a, 0x10
0068 33 2C FF adc a, -1
0069 35 C8 ret
0070
0071 ;1号中断的服务程序
0072 int_1:
0073 36 7C 11 mov a, 0x11
0074 38 3C FF sub a, -1
0075 3A C8 ret
0076
0077 ;2号中断的服务程序
0078 int_2:
0079 3B 7C 12 mov a, 0x12
0080 3D 50 and a, r0
0081 3E C8 ret
0082
0083 ;3号中断的服务程序
0084 int_3:
0085 3F 7C 13 mov a, 0x13
0086 41 64 or a, [r0]
0087 42 C8 ret
0088
0089 ;4号中断的服务程序
0090 int_4:
0091 43 8D 02 mov r1, 2
0092 45 7C 00 mov a, 0
0093 47 21 adc a, r1
0094 48 C8 ret
0095
0096 ;5号中断的服务程序
0097 int_5:
0098 49 8E 03 mov r2, 3
0099 4B 7C 01 mov a, 1
0100 4D 52 and a, r2
0101 4E C8 ret
0102
0103 ;6号中断的服务程序
0104 int_6:
0105 4F 7C 02 mov a, 2
0106 51 4C 03 sbb a, 3
0107 53 C8 ret
0108
0109 ;7号中断的服务程序
0110 int_7:
0111 54 7C 02 mov a, 2
0112 56 D4 shl a
0113 57 C8 ret
\ No newline at end of file
没有这种文件类型的预览
没有这种文件类型的预览
差异被折叠。
......@@ -422,17 +422,21 @@ dup 5, null
;
dup 16, null
;硬中断调用返回指令
;=====================================================================
;硬中断调用返回指令。
;硬中断返回就是出栈过程,将栈顶指针sp指向的存储单元内的返回地址加载到PC,实现中断返回
;与此同时,sp加1,指向新的栈顶
; ret
path sp, mar
path sp, cst
path sp_inc, cst
path cst, sp
path [mar], pc
eoi ;清除已经服务完的硬中断标志
path sp, mar ;将栈顶指针SP传入地址寄存器MAR,也就是将中断返回地址传入mar
path sp, cst ;sp传入cst计数器
path sp_inc, cst ;cst计数器加1
path cst, sp ;将cst减1后的结果写入sp,也就是出栈后,sp减1,指向新的栈顶
path [mar], pc ;将mar寄存器指向存储单元的内容作为地址传入PC,实现中断返回
eoi ;清除已经服务完的硬中断标志
reset upc
dup 1, null
;=====================================================================
; 填充空白指令
dup 8, null
......@@ -499,16 +503,18 @@ reset upc
dup 5, null
;======================================================================
; 硬中断处理微指令程序,完成中断现场保护并跳转到中断服务程序的入口地址处执行中断服务程序
; 硬中断处理微指令程序。
;硬中断处理就是入栈过程,将下一条指令的地址(中断返回地址)入栈,入栈过程就是将返回地址写入sp加1后指向的存储单元中
;然后将硬中断服务程序入口地址加载到PC,转去执行服务程序。
path sp, cst ;将堆栈指针寄存器sp的值传送到cst计数器
path sp_dec, cst ;计数器cst减1
path cst, sp ;将减计数结果写回sp,完成堆栈指针sp-1操作,为返回地址入栈做准备
path sp, mar ;sp堆栈指针寄存器内容传送到地址寄存器mar
path pc, [mar] ;将返回地址PC入栈
; 获取中断号中断服务程序入口地址
inta1
inta2 ;发出第二个中断应答信号,主要用于清除已经响应的中断请求,避免重复响应
; 根据中断号获取中断服务程序入口地址
inta1 ;发出第一个中断应答信号,中断控制器保存最高优先级中断请求对应的编号(0~7)
inta2 ;发出第二个中断应答信号,将响应中断的终端号读入IA寄存器中,并清除响应的中断请求,避免重复响应
path int_ia, pc ;将中断向量(ia寄存器的内容)传入PC
path [int_pc], pc ;读出中断向量中的内容(中断服务程序首地址),将其加载到PC,执行中断服务程序
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论