Summary of the invention
Technical matters to be solved by this invention is, overcome in the prior art deficiency of the means of communication between two processors, a kind of method that adopts DPRAM and specific communications protocol to realize the real-time communication between two processors is proposed, reduction improves dirigibility and universal to the degree of dependence of hardware circuit.
In order to address the above problem, the present invention proposes the means of communication between a kind of dual processor, is applied to comprise in the system of first processor, second processor and DPRAM, and wherein, described first processor, second processor link to each other with the different port of DPRAM respectively; Second processor triggers the interruption of first processor; It is characterized in that, in DPRAM, mark off 4 nonoverlapping storage areas: first memory block, second memory block, the 3rd memory block and the 4th memory block; Second processor periodically alternately triggers the interruption of first processor: first interrupts and second interruption;
Trigger first interrupt after, trigger second interrupt before, second processor reads the communication data of preserving in first memory block, and writes communication data in the 3rd memory block;
As the response to first interruption, first processor writes communication data in second memory block, and reads the communication data of preserving in the 4th memory block;
Trigger second interrupt after, trigger first interrupt before, second processor reads the communication data of preserving in second memory block, and writes communication data in the 4th memory block;
As the response to second interruption, first processor writes communication data in first memory block, and reads the communication data of preserving in the 3rd memory block.
In addition, the interrupt control position is set in described DPRAM, described second processor triggers the interruption of described first processor in the mode that writes the numerical value that identifies interrupt type in this interrupt control position; Have no progeny in receiving, described first processor is judged the type of the interruption that receives according to the numerical value in this interrupt control position, and interrupts clearly; Described interrupt control bit length is greater than 1 bit.
In addition, the subsystem of described first processor operation comprises first clock counter, and the subsystem of second processor operation comprises the second clock counter, second processor trigger first interrupt after, trigger second and first clock counter added 1 before interrupting; First processor is as first response of interrupting is added 1 with the second clock counter.
In addition, described communication data comprises: data length is used for identifying the length of the data that respective storage areas preserves; Data type is used for the type of identification data; And data content.
In addition, described second processor writes the communication data of expression system time in the 4th memory block, and described first processor is according to this communication data Adjustment System time.
In addition, triggering first interrupts the time interval between triggering second interruption and triggers second interrupting triggering carrying out Interrupt Process and DPRAM is carried out the required time of read-write operation interval greater than second processor and first processor of first interruption.
In addition, the time interval between the triggering constantly interrupted of twice first of being adjacent constantly of described second triggering of interrupting equates.
The present invention is by being initiated the read-write operation to the specific region of DPRAM by the mode of 2 interruptions of one in two processors triggering, not only realized the real-time communication of two processors, and isolated the otherness that operates in two operating systems on the processor fully, greatly shortened the cycle of the integration and the transplanting of different system.
Embodiment
Basic ideas of the present invention are, in the system that comprises processor A and processor B, processor B triggers the interruption of 2 second processor A at interval with regular time, after down trigger, processor A and processor B are carried out read or write to the specific region of DPRAM simultaneously, to be implemented in the bi-directional data between the processor A and processor B and the communication of message in this time interval.
Below in conjunction with drawings and Examples the present invention is described in detail.
Fig. 1 is the structural representation by the two-processor system of DPRAM communication, and as shown in Figure 1, this system comprises processor A, processor B and DPRAM.Wherein, all link to each other with data bus between processor A and processor B and the DPRAM with the address.In addition, also comprise the interrupt control line between processor A and the DPRAM.
Wherein, processor A normally has the flush bonding processor of better control function, as ARM or PPC, is responsible for the task scheduling and the management of total system; The A of operation system on the processor A.
Processor B normally has the DSP (Digital Signal Processing, digital signal processor) of strong calculation function, is responsible for complicated data operation and processing; The B of operation system on the processor B.
DPRAM has 2 independently RAM of access port (random access memory), allows processor A by different ports it to be carried out the data write operation respectively with processor B, is used to store interactive messages or data between two processors.
The interrupt control line is used to trigger the interruption of processor A.The realization principle of interrupting is relevant with the design of hardware, can adopt the particular register write data among the DPRAM is produced interruption the clear mode of interrupting of read data.The interrupt control position that present embodiment adopts processor B to write among the DPRAM produces interruption, and processor A is read the clear working method of interrupting in interrupt control position among the DPRAM.
As a system that comprises the multiprocessor collaborative work, particularly comprise ASIC (Application SpecialIntegrated Circuit, the special IC) chip of multiprocessor, need to guarantee in a system unique clock is arranged.In the present embodiment, with processor B as the unique clock source in the system, by with regular time interval T constantly trigger the interruption of processor A, can be so that two processors keep synchronously.
In order to realize processor A and the processor B exclusive reference to DPRAM, processor B need trigger the interruption of 2 second processor A to initiate communication at time interval T.That is to say that system time is divided into the unit that length is T, and we are referred to as frame; One frame can comprise the clock period of a plurality of processors, the moment that each frame begins, be called full frame constantly, and constantly, be called field constantly in the middle of each frame.The interruption that processor B is initiated constantly at full frame is called full frame and interrupts; The interruption that processor B is initiated constantly at field is called field and interrupts.
Fig. 2 is the synoptic diagram of the means of communication between dual processor of the present invention.As shown in Figure 2, DPRAM is divided into upstream message, upstream data, downstream message, 5 zones of downlink data and interrupt control position.Wherein, message and the data that processor A sends to processor B are preserved in upstream message and upstream data zone; Message and the data that processor B sends to processor A are preserved in downstream message and downlink data zone; The interrupt control position is used for processor B and writes interrupting information to distinguish the type of interrupting, and triggers simultaneously and interrupts.
Communication between processor A and the processor B comprises full frame communication and field communication two parts:
Full frame communication: when the interim constantly processor B of full frame and processor A carry out following operation:
201: processor B writes the full frame interrupting information to the interrupt control position, triggers hardware interrupts;
Wherein the full frame interrupting information can be the integer greater than 0, is that full frame interrupts in order to the type that identifies this interruption.
202: processor B reads upstream data from DPRAM;
203: processor B writes downstream message to DPRAM;
204: simultaneously, processor A response hardware interrupts reads the interrupt control position, and identifying is that full frame interrupts; And writing 0 to the interrupt control position, the clear interruption is so that can respond interrupt request next time;
In addition, according to the requirement of system design, clear mode of interrupting also can be to remove automatically after processor A reads the interrupt control position.
205: processor A writes upstream message to DPRAM;
206: processor A reads downlink data from DPRAM.
Field communication: when the interim constantly processor B of field and processor A carry out following operation:
207: processor B writes the field interrupting information to the interrupt control position, triggers hardware interrupts;
Wherein the field interrupting information is to be not equal to 0 and the integer of full frame interrupting information, is that field interrupts in order to the type that identifies this interruption.
208: processor B reads upstream message from DPRAM;
209: processor B writes downlink data to DPRAM;
210: simultaneously, processor A response hardware interrupts reads the interrupt control position, and identifying is that field interrupts; And writing 0 to the interrupt control position, the clear interruption is so that can respond interrupt request next time;
211: processor A writes upstream data to DPRAM;
212: processor A reads downstream message from DPRAM.
Processor B can know that the full frame moment and field arriving constantly are to trigger corresponding interruption by periodic interruptions (clock interruption).In the full frame moment and the field moment, processor A and processor B repeat above-mentioned steps respectively, can realize two real-time communications between the processor.
To be that the invention will be further described for example with the WCDMA physical layer software test platform that comprises ARM and two processors of DSP below.
This test platform is made up of background module subsystem and foreground module subsystem, runs on respectively on two processors of ARM and DSP, and the operating system of the last operation of ARM is VxWorks, the last operation of DSP be Nucleus.Because two mechanism differences that operating system realizes, system function is also different, can not directly be undertaken alternately by message, therefore adopts DPRAM to realize the mutual of message and data as intermediary in this system.
In this test platform, adopted the DPRAM of a 4K byte-sized, comprise ULMSG, DLMSG, ULDATA, DLDATA, five zones of INTReg, the corresponding upstream message of difference, downstream message, upstream data, downlink data and interrupt control position, wherein ULMSG, DLMSG, ULDATA, DLDATA are divided into length and data/information two parts, data/message part also can comprise data/information type and data/information content, length is 1 byte partly, is used to identify this regional data/message length, and information such as concrete space and data flow see the following form:
In this system, a frame comprises 16 time slots, and in order to realize two real-time communications between processor, DSP needs to interrupt starting communication in 0 time slot triggering full frame interruption and 7 time slots triggering field respectively.Concrete communications protocol as above step 201 as described in 212.
Wherein, the length of interrupt control position is 1 byte, and it is set to 1 and triggered that full frame interrupts and the field interruption at 2 o'clock respectively DSP; ARM reads behind the interrupt control position its zero clearing.
In this system, for two system times on the processor are consistent, on two subsystems, be respectively arranged with clock counter usually, when full frame interim constantly, clock counter on the DSP adds 1, simultaneously ARM receive full frame when interrupting the clock counter on also with it add 1.
In addition, DSP also can submit to ARM with the form of message with clock information at field constantly, and ARM carries out the adjustment of clock counter according to this information.
The sequential relationship that DSP and ARM carry out communication in this system as shown in Figure 3.
As seen from the above description, eight read-write operations of processor A and processor B need be finished between two full frames interrupt, and this needs the dominant frequency (processing speed) of processor A and processor B to satisfy this requirement.In the example of above-mentioned WCDMA physical layer software test platform, according to the 3GPP agreement, 1 frame is 10ms, and this frame is divided into 16 time slots, so DSP and ARM need to finish at most in 8 time slots and once read and a write operation.
On the basis of the foregoing description, the present invention also has other mapping mode, and for example, the interruption that triggers processor A can realize by alternate manner.
General processor all provides GPIO (general input and output), is used for the User Defined purposes.The GPIO#0 that we can utilize processor B is as the purposes of the interruption that triggers processor A, and connects an interrupt line from the GPIO#0 of processor B to processor A.We just can send pulse (level) by the corresponding value of the control register of writing GPIO#0 like this, and then trigger the processor A interruption.Processor A just can interrupt clearly by the mode of reading (or writing 0) after detecting interrupt request.Can realize the interrupt control between processor in this way equally.