Interrupt Process device and method in the chip
Technical field
Treating apparatus that the present invention relates to interrupt and method relate in particular to the Interrupt Process device and method in a kind of chip.
Background technology
In a chip, may have many interrupt sources, and chip to distribute to the pin of interruption be limited, chip piece has only an interrupt pin usually.
As shown in Figure 1, the Interrupt Process device that is used in the prior art in the chip comprises that one interrupts importation 1, is used to import a plurality of interruptions; An interruptable controller 2 is used for from interrupting importation 1 interruption of selecting a limit priority of output being arranged; And an interrupt handler 3, be used to handle the interruption of on interruptable controller 2, selecting.
In the Interrupt Process device of Fig. 1, when a new interruption is input in the interruption importation 1, the priority of interrupt handled on the priority of interrupt of input newly and the interrupt handler 3 is compared, if the priority of interrupt of new input is not higher than the priority of interrupt of handling on the interrupt handler 3, then continue the current interruption of handling; If the priority of interrupt of new input is higher than the priority of interrupt of handling on the interrupt handler 3, then stop current ongoing interruption, interruption priority is higher by interruptable controller 2 outputs to interrupt handler 3, is handled by interrupt handler 3.
When the priority of interrupt of handling on the priority of interrupt of new generation and the interrupt handler 3 is identical, interruptable controller 2 outputs to interrupt handler 3 according to the sequencing that interrupts producing with interruption, the interruption that produces earlier will at first obtain handling, when handling this interruption, the interruption of other equal priority will be left in the basket, if when the interruption of several equal priority produces simultaneously, can only have an interruption processed, other interruption also will be left in the basket.
The shortcoming of above-mentioned interruption processing method is: when interrupting processor in handling interrupt, the interruption of the equal priority of other new generations will be left in the basket; When the interruption of several equal priority produces simultaneously, can only there be an interruption processed, other interruption will be left in the basket.Some interrupts just can not get handling like this, must handle if the interruption that neglects is a chip, will the function of chip be impacted.
Summary of the invention
The object of the present invention is to provide the Interrupt Process device and method in a kind of chip, when solving the underway disconnected processing of prior art, the problem that some interruption will be left in the basket.
For addressing the above problem, the invention provides following technical scheme:
Interrupt Process device in a kind of chip comprises:
Interrupt generating unit is used to produce look-at-me;
The interrupt vector storage unit is used to store the interrupt vector that interrupt generating unit produces;
The control output unit is used for interrupt generating unit and produces when interrupting, and sends interrupt request singal;
Have a plurality of functional modules in the interrupt generating unit, wherein the look-at-me of each functional module is imported control output unit and interrupt vector storage unit respectively.
Described interrupt vector storage unit is for reading zero clearing formula register, and the look-at-me of each functional module is input in the interior corresponding position of register.
Described control output unit is or door, or the output terminal of door is connected with the host computer of chip.
Described interrupt vector storage unit is connected with the host computer of chip.
A kind of interruption processing method comprises step:
Produce the functional module of interrupting in A, the interrupt generating unit look-at-me is input to interrupt vector storage unit and control output unit respectively;
The host computer of B, chip reads the interrupt vector storage unit by interrupt service routine, carries out the interruption that reads;
C, when interrupt service routine carry out to interrupt, if there is new interruption to produce, then repeated execution of steps A, B if there is not new interruption to produce, after interrupt service routine is finished, withdraw from.
In described step C, interrupt service routine is carried out the interruption that reads in proper order or is carried out the interruption that reads according to predefined interrupt priority level.
Because the present invention has adopted above technical scheme, so have following beneficial effect:
Interrupt Process device of the present invention can all be noted all interrupt vectors, interrupt service routine by host computer decides which interrupt vector of execution, priority of interrupt judged by interrupt service routine, also can all interrupt vectors are handled by the host computer order.When adopting the present invention to carry out Interrupt Process, the interruption of all generations can both be processed, the problem that some interruption is left in the basket can not occur.
Description of drawings
Fig. 1 is for being used for the structural representation of the Interrupt Process device in the chip in the prior art;
Fig. 2 is for being divided into chip the synoptic diagram of different stage module;
Fig. 3 is the schematic diagram of Interrupt Process device of the present invention;
Fig. 4 is the structural representation of Interrupt Process device of the present invention;
Fig. 5 is the process flow diagram of interruption processing method of the present invention.
Embodiment
As shown in Figure 2, in the chip design process, chip can be divided into a lot of one-level modules, each one-level module is made up of some secondary modules again, comprises littler module in the secondary module again.Like this entire chip is divided into a lot of levels.In the present invention, chip can be counted as a module, has a total Interrupt Process device corresponding with it, all corresponding Interrupt Process device of each module in the chip, and each Interrupt Process device all has an interrupt signal output.The look-at-me of each one-level module output is that one-level is interrupted, and with all one-level look-at-me lines or constitute the interruption output pin of total Interrupt Process device together, interrupt request singal is sent to the host computer of chip by interrupting output pin.Each one-level module is made up of many secondary modules, each one-level module all has an one-level Interrupt Process device corresponding with it, interrupt the same with one-level, secondary look-at-me line in each one-level module also all or together constitutes the interruption output pin of one-level Interrupt Process device, this interrupts output pin and is connected with the host computer of chip, its working method is identical with total Interrupt Process device, by that analogy, produces multistage Interrupt Process mode.
The structure of the Interrupt Process device of different stage is identical in the chip, and as shown in Figure 3, Interrupt Process device of the present invention comprises: an interrupt generating unit is used to produce the look-at-me of a plurality of functional modules of same rank; An interrupt vector storage unit is used to store the interrupt vector that interrupt generating unit produces; A control output unit is used for interrupt generating unit and produces when interrupting, and sends interrupt request singal; Have a plurality of functional modules in the interrupt generating unit, wherein the look-at-me of each functional module is imported control output unit and interrupt vector storage unit respectively.
As shown in Figure 4, above-mentioned interrupt vector storage unit is connected with the host computer of chip, for reading the register of zero clearing formula, in this interrupt vector register each is all corresponding with a functional module in the interrupt generating unit, and the look-at-me of each functional module is input in the interior corresponding position of interrupt vector register.Above-mentioned control output unit be one or, or the output terminal of door is connected with the host computer of chip, the look-at-me line of all functions module or together constituted the interruption output pin of this Interrupt Process device.
As shown in Figure 5, when a plurality of functional modules in the interrupt generating unit produce interruption, come the interruption of process chip according to the methods below.
In above-mentioned Interrupt Process device, when the functional module in the interrupt generating unit produce to be interrupted, the interrupt signal output line of functional module respectively high level signal is input to or door and interrupt vector register in corresponding with it that.Interrupt high level signal of output pin output and give the host computer of chip, the host computer of chip reads interrupt vector register by interrupt service routine after receiving this high level signal, all interrupt vectors are noted, when some position of finding interrupt vector register changes, can conclude that is which module produces interruption, because interrupt vector register is the design of reading zero clearing, therefore after running through all interrupt vector registers, all interrupt vector registers are zero.
Interrupt service routine can be carried out the interrupt vector that is read in proper order, also can at first define each priority of interrupt by the external software program, after the interruption service routine reads interrupt vector register, determine the interrupt service routine of current limit priority to be performed earlier by the external software program, carry out the interruption of next priority then.When carrying out the interrupt vector read, if produce new interrupt vector, then this interrupt vector can import or door and interrupt vector register corresponding position with it in, the host computer of chip can read interrupt vector register once more, carries out accordingly to interrupt; If do not produce new interrupt vector, after executing the interrupt vector that reads, just withdraw from interrupt service routine.
The above; only for the preferable embodiment of the present invention, but protection scope of the present invention is not limited thereto, and anyly is familiar with those skilled in the art in the technical scope that the present invention discloses; the variation that can expect easily or replacement all should be encompassed within protection scope of the present invention.Therefore, protection scope of the present invention should be as the criterion with the protection domain of claims.