Asynchronous communication controller and control method thereof
Technical field:
The present invention relates generally to a kind of asynchronous communication controller and control method thereof, a kind of communication controler and transfer of data and communication control method that carries out information communication with form of data frames that particularly can be configured in response to multiple applied environment.
Background technology:
Existing communication controler and communication mode, the main problem that has following three aspects::
The one, the communication controler that exists is at present all only supported wherein a kind of of following communication mode, can not change in these communication modes dynamically.One to one duplex communication pattern, i.e. communication only occurs between two terminals, is the communication pattern of most of communication controlers.One-to-many simplex pattern is a terminal sends identical data, one-way communication pattern from the reception of a plurality of terminal to a plurality of terminals.Many-one simplex pattern is a plurality of terminals send data, one-way communication pattern from this terminal reception to same terminal.One-to-many duplex communication pattern is that a terminal sends identical data and receives the different data that a plurality of terminals are sent to a plurality of terminals.
The 2nd, communications applications has the different of multiframe data and frame data, also has the difference of data package size, and these different application demands require nature different to communication controler.Present communication controler can only be fixed in a certain application, must substitute with another communication controler when applied environment changes.
The 3rd, not enough to the data-handling capacity that receives when data processing side, when occurring processing untimely situation, the existing communication controller has two kinds of processing policies.The one, follow-up data covers the data of before having received, this can cause receiving side data to lose; The 2nd, the recipient does not do to comprehend to follow-up data before the data of receiving deal with, and this recipient can occur to transmit leg does not respond or the response time is long problem.
Summary of the invention:
The object of the invention is to avoid the deficiencies in the prior art part, a kind of asynchronous communication controller and communication control method thereof are provided, single, single to the adaptation of using environment to solve the communication controler and the control method communication corresponded manner that exist at present, the problem that can not dynamically be configured.The present invention can support the dynamic translation of one to one duplex communication pattern, one-to-many simplex pattern and many-one simplex pattern, one-to-many duplex communication pattern by configuration control unit register.
Another object of the present invention is to the different application background to different, the data package size of multiframe data and frame data, can finish conversion by configuration control unit register, do not need to change the communication controler that hardware just can provide support.
The present invention also has a purpose to be that sending and receiving adopts the formation mode, to solve the bottleneck problem of transceiver communication velocity mismatch.Make queue length dynamically adjustable by the control unit register, then can adopt according to the difference of concrete application the different buffer memory degree of depth, thereby avoid loss of data and improve response speed.
Purpose of the present invention can be by realizing a kind of asynchronous communication controller by the following technical solutions, adopt configurable data storage cell (2), support single frames, the multiframe packet, adapt to the quick asynchronous communication of communication, include the configurable data storage cell (2) with CPU (1) UNICOM, control unit (3) respectively with configurable data storage cell (2), transmitting element (4), receiving element (5) UNICOM, transmitting element (4) and receiving element (5) all with the physical channel of communicating by letter (6) UNICOM; Described configurable data storage cell (2) contains queuing register group (2-2), control register group (2-3), status register group (2-4) and transmitting-receiving buffer area, by can support the transmitting-receiving of multifrequency packet to the configuration of offset register in the control register group; Can support the dynamic translation of one to one duplex communication pattern, one-to-many simplex pattern and many-one simplex pattern, one-to-many duplex communication pattern by configuration control unit register; Described transmitting element (4) is by data transmit circuit, is that high level, start bit are that the figure place of low level, 16 bit data positions and position of rest is the data that 1 self-defined High-speed Asynchronous Secial Communication control protocol sends memory cell according to idle condition; Described receiving element (5) passes through the data receiver circuit receive data, and data storing is being received memory cell (2-1); The different control models that described control unit (3) arranges according to register are controlled and are started configurable data storage cell (2), receiving element (5) and transmitting element (4).
Described configurable data storage cell (2) comprises transmission memory cell (2-0) and receives memory cell (2-1); Described configurable data storage cell (2) memory space is divided into six sections, every section is comprised of the reception memory space of 4K byte and the transmission memory space of 4K byte, memory space address is not overlapping, every section memory space correspondence sending module and receiver module separately; Described configurable data storage cell (2) is connected with ppu bus interface (1-1) by parallel bus, and two-way read-write realizes the not conversion of isotopic number of data; The address halfword-aligned namely is 2 multiple according to 16 alignment requirements.
Described configurable data storage cell (2) has queuing register group (2-2), control register group (2-3), status register group (2-4), transmitting-receiving buffer area (2-0,2-1), described transmitting-receiving buffer area (2-0,2-1) and queuing register group (2-2), control register group (2-3), status register group (2-4) memory space address are not overlapping, every section transmitting-receiving memory space correspondence sending module and receiver module separately.
Described receiving element (5) includes a plurality of receiver modules, each receiver module correspondence reception storage unit space separately; Described transmitting element (4) includes a plurality of sending modules, each sending module correspondence transmission storage unit space separately.
A plurality of sending modules of a plurality of receiver modules of described receiving element (5) and described transmitting element (4) are corresponding, control by described control unit (3), realize that a circuit-switched data sends by a plurality of transmitting elements are parallel, or multichannel data sequentially sends by a transmitting element, or multichannel data sends by sending module separately.
Described control unit (3) includes the reception control module (3-1-2) that is connected with described receiving element (5), and described reception control module (3-1-2) links to each other with reception length identification module (3-1-1), accepting state module (3-1-3), resolution data frame module (3-1-4) respectively.
Described control unit (3) also includes the transmission control module (3-2-2) that is connected with described transmitting element (4), and described transmission control module (3-2-2) links to each other with transmission length identification module (3-2-1), transmission block of state (3-2-3), padding data frame module (3-2-4) respectively.
A kind of data transmission method of aforesaid asynchronous communication controller, when sending the data of memory cell with self-defined High-speed Asynchronous Secial Communication control protocol, sending module is nested in packet in the communications data frame, by the high-speed serial bus of supporting the plurality of level standard, by the optical transceiver transceiving data.
The data transmission method of described asynchronous communication controller, its main feature is when sending the data of memory cell with self-defined High-speed Asynchronous Secial Communication control protocol, sending module is nested in packet in the communications data frame, comprise communication controler ID and data check code, by the high-speed serial bus of supporting plurality of level standard (LVDS, LVTTL, LVCEL), by the optical transceiver transceiving data.
When sending by formation, queue length and data block size are defaulted as default value, can also to corresponding registers the realization dynamic-configuration be set according to concrete the application.On the one hand can reduce strict demand to the response time by formation, reduce data copy replication task amount; If the frame data length of communication is very large on the other hand, can tunes up data block and reduce queue length to adapt to the transmission of large Frame.In addition, this communication control method is by supporting the transmitting-receiving of multiframe packet to the configuration of offset register in the control register group; Setting by communication pattern can be supported one to one, the conversion between one-to-many, many-one plurality of communication schemes.
The data transmission method of described asynchronous communication controller, described communications data frame comprise frame head sign, frame pattern, data packet length, data, data check code and postamble sign.
Send application layer the data pack buffer that will send is entered transmit queue; The transmit leg piece that fetches data from transmit queue is carried out checking algorithm and at data block afterbody affix check information, then embeds in the communication frame to send; From receiving queue, fetch data piece and carry out verification of recipient; Receive verification by removing the communication frame additional information and notifying application layer to process, verification is unsanctioned then to be abandoned this packet and reports check errors.
The data transmission method of described asynchronous communication controller, described frame pattern include frame type sign, packet frame number, frame number.
The communications reception control method of described asynchronous communication controller, its main feature is, includes following steps:
(1) preparation: after step 101 system starts working, whether step 102 at first detects frame head is 0x3C3C, if meet then carry out frame check, if do not detect frame head or frame check mistake, then enter step 102 and again detect frame head and carry out the frame format verification; If correct, enter step 103 and judge single frames or multiframe;
(2) if single frames then enters step 105, carry out the single frames reception ﹠ disposal after, enter step 107 and judge interrupt mode;
(3) if multiframe then enters step 104, carry out the multiframe reception ﹠ disposal after, enter step 106 and judge the tail frame, if not the tail frame, then enter step 102 and rejudge frame head; If the tail frame then enters step 107 and judges interrupt mode;
(4) if interrupt mode enters step 108 and triggers interruption, after finishing, then enter step 102 and rejudge frame head; If not interrupt mode, then enter step 102 and rejudge frame head.
Ppu and this communication controler are mutual, and ppu can obtain the cell stores spatiality, transmitting element and receiving element operating state, receive data bag data check state by the status register of access control unit on the one hand; Ppu changes different sending modes and the passage of controller by the control register of control unit is set, and starts and stop transmitting element and receiving element work; Ppu can arrange the transmission packet by memory cell, also can read the packet that receives.If trigger register is set to interrupt mode in the control unit of communication controler, then when sending or receiving packet, communication controler can notify ppu to be for further processing by interrupt mode; Otherwise be polling mode, i.e. the related register of the continuous query communication controller of ppu control unit and then determine next step processing.
The communication sending control method of described asynchronous communication controller, its main feature is, includes following steps:
(1) preparation: after step 201 system started working, step 202 judged whether to start and sends; If not, then enter step 202 and rejudge whether start transmission; If so, then enter step 203 and fill communication frame;
(2) after step 203 filling communication frame is finished, enter step 204 and send, after being sent, enter next round; Application layer is according to frame format configuration register (such as length register, frame type register etc.) padding data frame; Start when sending, sending module is finished the filling of communication frame according to the setting of register; If transmit control register is set to the formation sending mode, then when being sent completely, go Frame whether to also have in the query request Frame to need to send.
Send application layer the data-block cache that will send is entered transmit queue; Transmit leg fetches data from transmit queue that piece is carried out checking algorithm and at data block afterbody affix check information, then embeds in the communication frame to send; From receiving queue, fetch data piece and carry out verification of recipient; The removal communication frame additional information that the reception verification is passed through also notifies application layer to process, and verification is unsanctioned then to be abandoned this packet and report check errors.Described queue length and data block size not only have default value, can also to corresponding registers the realization dynamic-configuration be set according to concrete the application.On the one hand can reduce strict demand to the response time by formation, reduce data copy replication task amount; If the frame data length of communication is very large on the other hand, can tunes up data block and reduce queue length to adapt to the transmission of large Frame.In addition, this communication control method can be supported the transmitting-receiving of multiframe packet by the setting of offset register; Can support the conversion between the plurality of communication schemes such as " one to one ", " one-to-many ", " many-one " by the setting of communication pattern register.
The invention has the beneficial effects as follows: compared with the prior art, the communication controler and the control method communication corresponded manner that the invention solves present existence are single, single to the adaptation of using environment, the problem that can not dynamically change.Can support the transmitting-receiving of multiframe packet by the setting of offset register; Can support the conversion between the plurality of communication schemes such as " one to one ", " one-to-many ", " many-one " by the setting of communication pattern register; Can adjust the ppu response time requirement by adjusting queue depth and data block size, also can adapt to the transmission of large Frame.
Description of drawings:
Fig. 1 is communication controler general structure schematic diagram;
Fig. 2 is communication controler internal structure schematic diagram;
Fig. 3 is the communications data frame schematic diagram;
Fig. 4 is that communication controler receives control flow chart;
Fig. 5 is that communication controler sends control flow chart;
Embodiment:
Below in conjunction with accompanying drawing, one of most preferred embodiment shown in the present is elaborated.Below illustrated be embodiments of the invention, but the invention is not restricted to the following description.
See Fig. 1, a kind of asynchronous communication controller, adopt configurable data storage cell, support the quick asynchronous communication of the multiframe packet of frame data bag, adaptation communication, its main feature is the packet memory cell 2 that includes with CPU1 UNICOM, control unit 3 respectively with packet memory cell 2, transmitting element 4, receiving element 5 UNICOMs, transmitting element 4 is by communication physical channel 6 and receiving element 5 UNICOMs:
Described memory cell 2 configurable queue lengths, configuration data bag memory cell size are supported the quick asynchronous communication of frame data bag, multiframe packet;
Described transmitting element 4 sends the data of memory cell by data transmit circuit according to self-defined High-speed Asynchronous Secial Communication control protocol; Self-defined high-speed asynchronous serial comprises line idle state (idle, high level), start bit (startbit, low level), 16 bit data positions (data bits) and position of rest (stop bit, figure place is 1), this form is to realize the synchronous of 16 bit data by start bit and position of rest;
Described receiving element 5 passes through the data receiver circuit receive data, and data storing is being received memory cell;
The different control models that described control unit 3 arranges according to register are controlled and are started memory cell 2, receiving element 5 and transmitting element 4.
Outer CPU 1 finger uses communication controler to carry out the communication controler ppu of data transmit-receive, between it and the communication controler memory cell 2 bus interface is arranged, and comprises data/address bus, address bus and control bus.Comprise the data transmit-receive buffer area in the memory cell 2, also comprise the set of registers of control unit 3 and the formation groups of configuration registers of self simultaneously.Outer CPU 1 and control unit 3 all can be read and write these registers, to reach the purpose that arranges and control.Control unit 3 is controlled the transmission of transmitting element 4 and the reception of receiving element 5 according to the register value that outer CPU 1 arranges.In the present embodiment, what adopted communication physical channel 6 is optical transceiving device, and transmitting element 4,5 of receiving elements adopt high-speed serial communication.Cooperate " many-one ", " one-to-many " communication mode, transmitting element 4 and receiving element 5 can corresponding a plurality of optical transceiving devices, have a plurality of optical transceiving devices to be connected with communication controler in the physical channel 6 of namely communicating by letter.
See Fig. 2, a kind of asynchronous communication controller, described packet memory cell 2 comprises transmission memory cell 2-0 and receives memory cell 2-1; Wherein receiving memory cell is according to communication control processor receive data and storage data by data reception module; Transmitting element is by the data of data transmission blocks according to communication control processor transmission memory cell.Described packet memory cell 2 memory spaces are divided into six sections, and every section is comprised of the reception memory space of 4K byte and the transmission memory space of 4K byte, and memory space address is not overlapping, every section memory space correspondence sending module and receiver module separately; Described packet memory cell 2 is connected with ppu bus interface 1-1 by parallel bus, and two-way read-write realizes the not conversion of isotopic number of data; The address halfword-aligned namely is 2 multiple according to 16 alignment requirements.
Described asynchronous communication controller, described communication controler memory cell 2 have queuing register group 2-2, control register group 2-3, status register group 2-4, transmitting-receiving buffer area 2-0,2-1, are set up in parallel.Described transmitting-receiving buffer area 2-0,2-1 and queuing register group 2-2, control register group 2-3, status register group 2-4 memory space address are not overlapping, every section transmitting-receiving memory space correspondence sending module and receiver module separately.Queuing register group 2-2, control register group 2-3, status register group 2-4 take memory cell 2 internal storage locations, are consistent with the memory access interface of receiving and dispatching buffer area 2-0,2-1.The value that these register assembly are put determines the working method of control unit 3.Ppu can obtain the cell stores spatiality by the status register of access control unit, transmitting element and receiving element operating state, receive data bag data check state.Ppu changes different sending modes and the passage of controller by the control register of access control unit, starts and stop transmitting element and receiving element work.
The transmitting-receiving buffer area 2-0 of memory cell 2, the memory space that 2-1 is corresponding are divided into multistage, every section is comprised of the reception memory space of 4K byte and the transmission memory space of 4K byte, memory space address is not overlapping, every section memory space correspondence sending module and receiver module separately.Memory cell is connected with ppu by parallel bus, and two-way read-write realizes the not conversion of isotopic number of data.The space layout of every intersegmental part depends on the setting of queuing register group.
The transmit leg application layer enters transmit queue to the data-block cache that will send; Transmit leg fetches data from transmit queue that piece is carried out checking algorithm and at data block afterbody affix check information, then embeds in the communication frame and be sent to communication physical channel 6 by high speed serialization.
Receiving element receives serial data stream and decode stored to the corresponding formation of memory cell from communication physical channel 6; From receiving queue, fetch data piece and carry out verification of recipient; It is consistent to receive verification, removes the communication frame additional information and notifies application layer to process, and verification is inconsistent then to be abandoned this packet and report check errors.If the multiframe mode data packet just notifies application side to process after then the tail frame receives in packet; Receive the frame in the new data packets when not yet receiving the tail frame, control unit can be reported the generation data cover.
Described receiving element 5 includes a plurality of receiver modules, each receiver module correspondence reception storage unit space separately; Described transmitting element 4 includes a plurality of sending modules, each sending module correspondence transmission storage unit space separately.
A plurality of sending modules of a plurality of receiver modules of described receiving element 5 and described transmitting element 4 are corresponding, control by described control unit 3, realize that a circuit-switched data sends by a plurality of transmitting elements are parallel, or multichannel data sequentially sends by a transmitting element, or multichannel data sends by sending module separately.
Described control unit 3 includes the reception control module 3-1-2 that is connected with described receiving element 5, and described reception control module 3-1-2 links to each other with reception length identification module 3-1-1, accepting state module 3-1-3, resolution data frame module 3-1-4 respectively.
Described control unit 3 also includes the transmission control module 3-2-2 that is connected with described transmitting element 4, and described transmission control module 3-2-2 links to each other with transmission length identification module 3-2-1, transmission block of state 3-2-3, padding data frame module 3-2-4 respectively.
See Fig. 3, a kind of data transmission method of asynchronous communication controller, when sending the data of memory cell with self-defined High-speed Asynchronous Secial Communication control protocol, sending module is nested in packet in the communications data frame, comprise communication controler ID and data check code, by the high-speed serial bus of supporting plurality of level standard LVDS or LVTTL or LVCEL, by the optical transceiver transceiving data.
When sending by formation, queue length and data block size are defaulted as default value, can also to corresponding registers the realization dynamic-configuration be set according to concrete the application.On the one hand can reduce strict demand to the response time by formation, reduce data copy replication task amount; If the frame data length of communication is very large on the other hand, can tunes up data block and reduce queue length to adapt to the transmission of large Frame.In specific design, memory cell capacity R fixes certainly, and the pass between data block size D and the queue length L is: R=D*L.In addition, this communication control method is by supporting the transmitting-receiving of multiframe packet to the configuration of offset register in the control register group; Setting by communication pattern can be supported one to one, the conversion between one-to-many, many-one plurality of communication schemes.
The data transmission method of described asynchronous communication controller, described communications data frame comprise frame head sign, frame pattern, data packet length, data, data check code and postamble sign.
Send application layer the data pack buffer that will send is entered transmit queue; The transmit leg piece that fetches data from transmit queue is carried out checking algorithm and at data block afterbody affix check information, then embeds in the communication frame to send; From receiving queue, fetch data piece and carry out verification of recipient; Receive verification by removing the communication frame additional information and notifying application layer to process, verification is unsanctioned then to be abandoned this packet and reports check errors.
The data transmission method of described asynchronous communication controller, described frame pattern include frame type sign, packet frame number, frame number.
See Fig. 4, a kind of communications reception control method of asynchronous communication controller includes following steps:
(1) preparation: after step 101 system starts working, step 102 at first detects frame head 0x3C3C, if meet then carry out frame check (when frame is carried out verification, at first judge whether 0x3C3C, postamble 0xC3C3 whether of frame head, whether middle the data CRC16 verification is consistent with the check code in the Frame, violates wherein any one and namely is judged to be invalid frame.); If do not detect frame head or frame check mistake, then enter step 102 and again detect frame head and carry out the frame format verification; If correct, enter step 103 and judge single frames or multiframe;
(2) if single frames then enters step 105, carry out the single frames reception ﹠ disposal after, enter step 107 and judge interrupt mode;
(3) if multiframe then enters step 104, carry out the multiframe reception ﹠ disposal after, enter step 106 and judge the tail frame, if not the tail frame, then enter step 102 and rejudge frame head; If the tail frame then enters step 107 and judges interrupt mode;
(4) if interrupt mode enters step 108 and triggers interruption, after finishing, then enter step 102 and rejudge frame head; If not interrupt mode, then enter step 102 and rejudge frame head.
Ppu and this communication controler are mutual, and ppu can obtain the cell stores spatiality, transmitting element and receiving element operating state, receive data bag data check state by the status register of access control unit on the one hand; Ppu changes different sending modes and the passage of controller by the control register of control unit is set, and starts and stop transmitting element and receiving element work; Ppu can arrange the transmission packet by memory cell, also can read the packet that receives.If trigger register is set to interrupt mode in the control unit of communication controler, then when sending or receiving packet, communication controler can notify ppu to be for further processing by interrupt mode; Otherwise be polling mode, i.e. the related register of the continuous query communication controller of ppu control unit and then determine next step processing.
See Fig. 5, a kind of communication sending control method of asynchronous communication controller includes following steps:
(1) preparation: after step 201 system started working, step 202 judged whether to start and sends; If not, then enter step 202 and rejudge whether start transmission; If so, then enter step 203 and fill communication frame;
(2) after step 203 filling communication frame is finished, enter step 204 and send, after being sent, enter next round; The transmit leg application layer is according to frame format configuration register (such as length register, frame type register etc.) padding data frame; Start when sending, sending module is finished the filling of communication frame according to the setting of register; If transmit control register is set to the formation sending mode, then when being sent completely, go Frame whether to also have in the query request Frame to need to send.
Send application layer the data-block cache that will send is entered transmit queue; Transmit leg fetches data from transmit queue that piece is carried out checking algorithm and at data block afterbody affix check information, then embeds in the communication frame to send; From receiving queue, fetch data piece and carry out verification of recipient; The removal communication frame additional information that the reception verification is passed through also notifies application layer to process, and verification is unsanctioned then to be abandoned this packet and report check errors.Described queue length and data block size not only have default value, can also to corresponding registers the realization dynamic-configuration be set according to concrete the application.On the one hand can reduce strict demand to the response time by formation, reduce data copy replication task amount; If the frame data length of communication is very large on the other hand, can tunes up data block and reduce queue length to adapt to the transmission of large Frame.In addition, this communication control method can be supported the transmitting-receiving of multiframe packet by the setting of offset register; Can support the conversion between the plurality of communication schemes such as " one to one ", " one-to-many ", " many-one " by the setting of communication pattern register.