Interrupt Handling Upon detecting an interrupt signal, provided the particular interrupt or interrupt class is not masked, the CPU acknowledges the interrupt (so that the device can deassert its request signal) and begins executing an interrupt service routine. 1. Save the CPU state and call the interrupt service routine. 2. Disable all interrupts. 3. Save minimal information about the interrupt on the stack. 4. Enable interrupts (or at least higher priority ones). 5. Identify cause of interrupt and attend to the underlying request. 6. Restore CPU state to what existed before the last interrupt. 7. Return from interrupt service routine. The capability to handle nested interrupts is important in dealing with multiple high-speed I/O devices. Computer Architecture, Input/Output and Interfacing Slide 38
read write architecture behav_detailed of cpu-mem is Microprocessor-Memory Communication signal address: integer; signal data_in, data_out : word; (contd): A more detailed behavioral description signal data_read, data_write, mem_ready: std_logic := `0’; Shantanu Dutt, UIC CPU-Mem begin 6 6’ CMI: process is -- CPU-Memory Interface module data_read variable AR, PC : integer; variable data_reg, instr_reg: word; 3 3’ begin CPU-Mem data_write wait until read = ‘1’ or write = ‘1’; Interface 1 if read = ‘1’ then data_in dr 2 AR := PC; wait for 1 ns; -- 1 ns reg. acc. time 3 2 3’ 3 address <= AR after 2 ns; -- 2 ns prop. delay Memory PC address AR 3 data_read <= `1’ after 2 ns; -- 2ns prop. delay; note simult. w/ addr 4’ 4 4’ wait until mem_ready = ‘1’; 5 +2 data_out 5 instr_reg := data_out; wait for 1 ns; 6 IR <= instr_reg after 1 ns; ir 7’ 7 8 6 data_read <= `0’ after 2 ns; 4’ mem_ready 4 7’ wait until mem_ready = `0’; 8 PC := PC+2; wait for 1 ns; 6 1 DR ARin IR elsif write = ‘1’ then data_reg := DR; AR := ARin; Legend: dr: data_reg wait for 1 ns; -- 1 ns reg acc (both happening in parallel) ir: instr_reg address <= AR after 2 ns; data_in <= data_reg after 2 ns; The red arrows w/ #s show the seq. of operations (or of data_write <= ‘1’ after 2 ns; …………………… end if; corresp. signals). For a # j, j’ end process CMI; denotes the delayed version of CPU the corresp. signal Relate this Memory: process is seq. to the seq. of opers type data_type is array (0 to 63) of word; described in the VHDL code on variable store: data_type; variable temp_reg: word; the left. 2ns reg + 1ns reg (PC) variable addr: integer; RAM access 2ns prop. access delay begin 2ns prop. delay delay delay wait until data_read = `1’ or data_write = `1’; data_read 2ns prop. 3’ if data_read = ‘1’ then – next:1ns reg. & ram access delay for 2ns prop. addr :=address; temp_reg := store(addr/2); wait for 2 ns; read sig. delay mem_ready 4 data_out <= temp_reg after 2 ns; • Multi-process description describing fully responsive handshaking -- RAM r/w time is 1ns; prop. time = 2ns 4 mem_ready <= ‘1’ after 2 ns; between the CPU-Mem interface (CMI) and Memory modules • Most Data/address/control-signal propagation delays and storage 6’ wait until data_read = ‘0’; 7 mem_ready <= ‘0’ after 2 ns; access times are accounted for: delay parameters used: 1-way commun. elsif data_write = ‘1’ then addr := address; store(addr/2) := data_in; wait for 2 ns; ……………… end if; end process Memory; end architecture behav_detailed; time w/ memory = 2 ns, RAM/register r/w time = 1 ns. • Note: A safer form of wait until X = ‘1’ is if X /= ‘1’ then wait until X = ‘1’ when it is not known for sure that X will not be ‘1’ at the point we want to wait for X being ‘1’. Similarly for waiting for X to be ‘0’.
The 8085 Interrupts • • • • When a device interrupts, it actually wants the MP to give a service which is equivalent to asking the MP to call a subroutine. This subroutine is called ISR (Interrupt Service Routine) The ‘EI’ instruction is a one byte instruction and is used to Enable the non-maskable interrupts. The ‘DI’ instruction is a one byte instruction and is used to Disable the non-maskable interrupts. The 8085 has a single Non-Maskable interrupt. – The non-maskable interrupt is not affected by the value of the Interrupt Enable flip flop. CSE 307 - Microprocessors Mohd. Moinul Hoque, Lecturer, CSE, AUST 5
Interrupts • Interrupt is a process where an external device can get the attention of the microprocessor. – The process starts from the I/O device – The process is asynchronous. • Classification of Interrupts – Interrupts can be classified into two types: • Maskable Interrupts (Can be delayed or Rejected) • Non-Maskable Interrupts (Can not be delayed or Rejected) • Interrupts can also be classified into: • Vectored (the address of the service routine is hard-wired) • Non-vectored (the address of the service routine needs to be supplied externally by the device) CSE 307 - Microprocessors Mohd. Moinul Hoque, Lecturer, CSE, AUST 2
Hardware interrupts • Maskable and non-maskable interrupts – Maskable: used for events that occur during regular operation conditions – Nonmaskable: reserved for extremely critical events – They are hardware mechanism for providing prompt services to external events. – Reduce real-time punctuality and make response times nondeterministic. • Processors provide two atomic instructions – EPI: enable priority interrupt (EPI) and – DPI: disable priority interrupt (DPI) 16