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, particularly a kind of communication controler and the transfer of data and communication control method that carries out information communication with form of data frames that 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, at present the communication controler that exists is all only supported wherein a kind of of following communication mode, can not change in these communication modes dynamically.Duplex communication pattern one to one, i.e. communication only takes place between two terminals, is the communication pattern of most of communication controlers.One-to-many simplex pattern is a terminal sends identical data, an 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, an 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 single frames data, also has the difference of packet size, and these different application demands require the nature difference 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, the data-handling capacity deficiency when data processing side to receiving, when occurring handling 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 objective 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 solve the communication controler and the control method communication corresponded manner that exist at present to the adaptation of using environment, the problem that can not dynamically be configured.The present invention can support the dynamic translation of duplex communication pattern one to one, 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 different application background, can finish conversion, do not need to change the communication controler that hardware just can provide support by configuration control unit register to different, the packet size of multiframe data and single frames data.
The present invention also has a purpose to be to send and receives the formation mode that adopts, with the bottleneck problem between solving processing and communicating by letter.Make the queue length dynamic adjustable by the control unit register, then can adopt the different buffer memory degree of depth, thereby avoid loss of data and improve response speed according to the difference of concrete application.
Purpose of the present invention can be by realizing by the following technical solutions: a kind of asynchronous communication controller, adopt configurable data storage cell, support the quick asynchronous communication of the multiframe packet of single frames packet, the multiple communication mode of adaptation, its main feature is the packet memory cell (2) that includes with CPU (1) UNICOM, control unit (3) respectively with packet memory cell (2), transmitting element (4), receiving element (5) UNICOM, transmitting element (4) by communication the physical channel (6) with receiving element (5) UNICOM:
Described memory cell (2) is deployment queue length, configuration data bag memory cell size, supports the quick asynchronous communication of single frames packet, 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 be by start bit and position of rest realize 16 bit data synchronously;
Described receiving element (5) receives data by data receiver circuit, and data storing is being received memory cell;
The different control models that described control unit (3) is provided with according to register are controlled and are started memory cell (2), receiving element (5) and transmitting element (4).
Described asynchronous communication controller, described packet memory cell (2) comprise transmission memory cell (2-0) and receive memory cell (2-1); Wherein receiving memory cell is to receive data and storage data by data reception module according to communication control processor; Transmitting element is by the data of data transmission blocks according to communication control processor transmission memory cell.Described packet memory cell (2) memory space is divided into six sections, is made up of the reception memory space of 4K byte and the transmission memory space of 4K byte for every section, 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 promptly is 2 multiple according to 16 alignment requirements.
Described asynchronous communication controller, described communication controler memory cell (2) also includes 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.Queuing register group (2-2), control register group (2-3), status register group (2-4) take memory cell (2) internal storage location, are consistent with the memory access interface of receiving and dispatching buffer area (2-0,2-1).The working method of the value decision control unit (3) of these registers group configurations.Ppu can obtain the cell stores spatiality by the status register of access control unit, and transmitting element and receiving element operating state receive packet data verification state.Ppu changes the 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.
Described asynchronous communication controller, 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 (reception) storage unit space separately.
Described asynchronous communication controller, a plurality of sending module correspondences of a plurality of receiver modules of described receiving element (5) and described transmitting element (4), control by described control unit (3), realize that a circuit-switched data sends by a plurality of transmitting elements are parallel, or multichannel data sends in proper order by a transmitting element, or multichannel data sends by sending module separately.
Described asynchronous communication controller, 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 asynchronous communication controller, 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), transmit status module (3-2-3), padding data frame module (3-2-4) respectively.
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 sign indicating number, by the high-speed serial bus of supporting multiple level standard (LVDS, LVTTL, LVCEL), by the optical transceiver transceive 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, reduce data copy replication task amount the response time by formation; If Tong Xin single frames data length is very big on the other hand, can transfers big data block and reduce queue length to adapt to the transmission of big 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 sign indicating number and postamble sign.
Send application layer the data pack buffer that will send is gone into 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, embeds in the communication frame then to send; From receive formation, fetch data piece and carry out verification of recipient; Receive verification by removing the communication frame additional information and notifying application layer to handle, 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, 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 promptly is judged to be invalid frame.); If do not detect frame head or frame check mistake, then enter step 102 and detect frame head again and carry out the frame format verification; If correct, enter step 103 and judge single frames or multiframe;
(2), carry out entering step 107 and judging interrupt mode after single frames receive to handle if single frames then enters step 105;
(3) if multiframe then enters step 104, carry out entering step 106 and judging the tail frame after multiframe receive to handle, 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 by the status register of access control unit on the one hand, and transmitting element and receiving element operating state receive packet data verification state; Ppu changes the 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 be provided with 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 then enter step 203 and fill communication frame;
(2) after step 203 filling communication frame is finished, enter step 204 and send, after transmission finishes, enter next round; Application layer is according to frame format configuration register (for example 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 gone into transmit queue; Transmit leg fetches data from transmit queue that piece is carried out checking algorithm and at data block afterbody affix check information, embeds in the communication frame then to send; From receive formation, 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 handle, 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, reduce data copy replication task amount the response time by formation; If Tong Xin single frames data length is very big on the other hand, can transfers big data block and reduce queue length to adapt to the transmission of big 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 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 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 big Frame.
Description of drawings:
Fig. 1 is a communication controler general structure schematic diagram.
Fig. 2 is a communication controler internal structure schematic diagram.
Fig. 3 is the communications data frame schematic diagram.
Fig. 4 receives control flow chart for communication controler.
Fig. 5 sends control flow chart for communication controler.
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 single frames packet, the multiple communication mode of adaptation, 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 single frames packet, 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 be by start bit and position of rest realize 16 bit data synchronously;
Described receiving element 5 receives data by data receiver circuit, and data storing is being received memory cell;
The different control models that described control unit 3 is provided with according to register are controlled and are started memory cell 2, receiving element 5 and transmitting element 4.
Outer CPU 1 refers to use 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 is provided with and controls.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 is provided with.What in the present embodiment, adopted communication physical channel 6 is that 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 promptly 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 to receive data and storage data by data reception module according to communication control processor; 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, are made up of the reception memory space of 4K byte and the transmission memory space of 4K byte for every section, 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 promptly 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 working method of the value decision control unit 3 of these registers group configurations.Ppu can obtain the cell stores spatiality by the status register of access control unit, and transmitting element and receiving element operating state receive packet data verification state.Ppu changes the 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,2-1 corresponding memory space are divided into multistage, form by the reception memory space of 4K byte and the transmission memory space of 4K byte for every section, 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 is gone into 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, embeds then 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 receive formation, fetch data piece and carry out verification of recipient; Reception verification unanimity, to remove the communication frame additional information and also notify application layer to handle, verification is inconsistent then to be abandoned this packet and reports check errors.If the multiframe mode data packet just notifies application side to handle after then the tail frame receives in packet; Receive the frame in the new data packets when not receiving the tail frame as yet, control unit can report that data take place to be covered.
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 module correspondences of a plurality of receiver modules of described receiving element 5 and described transmitting element 4, control by described control unit 3, realize that a circuit-switched data sends by a plurality of transmitting elements are parallel, or multichannel data sends in proper order 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, transmit status module 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 sign indicating number, by the high-speed serial bus of supporting multiple level standard LVDS or LVTTL or LVCEL, by the optical transceiver transceive 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, reduce data copy replication task amount the response time by formation; If Tong Xin single frames data length is very big on the other hand, can transfers big data block and reduce queue length to adapt to the transmission of big 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 sign indicating number and postamble sign.
Send application layer the data pack buffer that will send is gone into 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, embeds in the communication frame then to send; From receive formation, fetch data piece and carry out verification of recipient; Receive verification by removing the communication frame additional information and notifying application layer to handle, 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 promptly is judged to be invalid frame.); If do not detect frame head or frame check mistake, then enter step 102 and detect frame head again and carry out the frame format verification; If correct, enter step 103 and judge single frames or multiframe;
(2), carry out entering step 107 and judging interrupt mode after single frames receive to handle if single frames then enters step 105;
(3) if multiframe then enters step 104, carry out entering step 106 and judging the tail frame after multiframe receive to handle, 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 by the status register of access control unit on the one hand, and transmitting element and receiving element operating state receive packet data verification state; Ppu changes the 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 be provided with 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 then enter step 203 and fill communication frame;
(2) after step 203 filling communication frame is finished, enter step 204 and send, after transmission finishes, enter next round; The transmit leg application layer is according to frame format configuration register (for example 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 gone into transmit queue; Transmit leg fetches data from transmit queue that piece is carried out checking algorithm and at data block afterbody affix check information, embeds in the communication frame then to send; From receive formation, 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 handle, 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, reduce data copy replication task amount the response time by formation; If Tong Xin single frames data length is very big on the other hand, can transfers big data block and reduce queue length to adapt to the transmission of big 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 plurality of communication schemes such as " one to one ", " one-to-many ", " many-one " by the setting of communication pattern register.