A kind of multiplexer and its method of work with priority
Technical field
The present invention relates to technical field of electronic communication, and in particular to multiplexing technique.
Background technology
In computer network communication technology field, various multiplexing technologies are widely used, a multiplexing is used in transmitting terminal
Device(MUX, MULTIPLEXER, also referred to as data selector)So that multiple user terminals can be communicated with shared channel, correspondingly,
Demultiplexer is used in receiving terminal, the information distribution transmitted altogether is sent to corresponding terminal.Multiplexing technology solves traditional
The deficiency for needing single channel to be communicated between multiple user terminals, two or more signals independent of each other are merged into one
Individual composite signal, it is transmitted on a common channel, terminal device only needs to use by a physical communication channel connection
Family end equipment.
Multiplexer realizes data by fictionalizing multiple parallel logical communication channels on single physical communication port
Forwarding.But existing multiplexer does not consider the priority level of data in data transmit-receive, cause largely receiving data
During, it is impossible to the severity level according to data is transmitted, and causes very big inconvenience.
Application processor in the prior art(Application Processor, AP)And BBP(Modem)Between
Generally pass through UART (Universal Asynchronous Receiver/Transmitter, universal asynchronous receiving-transmitting transmitter)
Serial line interface is communicated, as shown in figure 1, passing through AT(Attention)Order, is directly fed to ATC(AT Command, AT lives
Order)Resume module, realize the purpose that data are exchanged by the serial line interface.
But generally except sending and receiving data message between application processor and BBP, also usually include language
Message ceases and video information, as shown in Fig. 2 such as using VT(Video telephone, videophone)During, VT is passed
Defeated data usually need the data than AT orders transmission to have higher priority, however, in existing communication port, and
It can not be transmitted according to the severity level of transmission information.
The content of the invention
It is an object of the present invention to provide a kind of multiplexer with priority, solves above technical problem;
The present invention also aims to, there is provided a kind of method of work of the multiplexer with priority, solve above skill
Art problem.
Technical problem solved by the invention can be realized using following technical scheme:
A kind of multiplexer with priority, wherein, including a multiplex interface, the multiplex interface be used for connecting communication
Terminal module, the data that there is the communication terminal module of different priorities to send pass through institute after being divided into multiple data elements
State multiplex interface and be sent into a buffering area;
The buffering area is divided into multiple buffer-stored blocks for being used to write the data element, and each buffering is deposited
Storage block has a setting address;
Also include multiple priority block lists, be each written into the buffer-stored block of data element according to corresponding excellent
First level is added in a priority block list, and the buffer-stored block in each priority block list has equal priority;
Be not written to data element the buffer-stored block link successively after be managed by a free list;
Also include a data transmission blocks, the data transmission blocks by receiving the instruction notification of the multiplex interface,
Data are obtained from the different priority block lists to be used to send.
Preferably, the buffer-stored block include prefix portion and behind the prefix portion be used for deposit data element
Follow-up portion.
Preferably, the prefix portion includes a memory unit, and the memory unit is used to store each follow-up portion
Deposit the length of data element.
Preferably, the prefix portion includes an indicate indicator, and the indicate indicator is used to indicate each follow-up portion
Address.
Preferably, the buffering area is divided into 40 buffer-stored blocks.
Preferably, each buffer-stored block is equal in magnitude.
Preferably, the size in the prefix portion is 64Kbytes.
Preferably, the amount of capacity in the follow-up portion is 4Kbytes.
A kind of method of work of the multiplexer with priority, wherein, applied to above-mentioned a kind of with priority
Multiplexer, write data the step of it is specific as follows:
Step s11:Obtain the buffer-stored block of a writable data element;
Step s12:Data element is write to the buffer-stored block;
Step s13:The buffer-stored block is added to corresponding preferential with the priority of the data element of write-in
Level block list is managed.
Preferably, before performing step s11, judge whether corresponding priority block list has writable data element
Buffer-stored block, the slow of writable data element is obtained from corresponding priority block list or free list according to judged result
Rush memory block.
Preferably, the priority block list includes at least three priority block lists.
Preferably, the step of reading data is specific as follows:
Step s21:The buffer-stored block of setting ratio is chosen from each priority block list successively;
Step s22:Sent after the data element of the buffer-stored block is taken out by the data transmission blocks.
Preferably, when the priority block list includes three priority block lists, according to priority from high to low suitable
Sequence chooses occupation proportion as 4 from three priority block lists:3:1 buffer-stored block.
Preferably, the situation according to the buffer-stored block included in each priority block list, it is determined that excellent from difference
The ratio of buffer-stored block is chosen in first level block list.
Due to using above technical scheme, beneficial effects of the present invention are:
1)The present invention can be handled the high priority data of high priority, the Data Post of low priority;
2)Choose the buffer-stored block of setting ratio from each priority block list successively simultaneously, avoid priority height
Whole handled, reprocess and block data caused by the data of low priority.
Brief description of the drawings
Fig. 1 is a kind of communication scheme of application processor and BBP in the prior art;
Fig. 2 is a kind of communication scheme of application processor and BBP in the prior art;
Fig. 3 is the system architecture schematic diagram of the present invention;
Fig. 4 is the step flow chart of the write-in data of the present invention;
Fig. 5 is the step flow chart of the reading data of the present invention.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present invention, the technical scheme in the embodiment of the present invention is carried out clear, complete
Site preparation describes, it is clear that described embodiment is only part of the embodiment of the present invention, rather than whole embodiments.It is based on
Embodiment in the present invention, those of ordinary skill in the art obtained on the premise of creative work is not made it is all its
His embodiment, belongs to the scope of protection of the invention.
It should be noted that in the case where not conflicting, the feature in embodiment and embodiment in the present invention can phase
Mutually combination.
The invention will be further described with specific embodiment below in conjunction with the accompanying drawings, but not as limiting to the invention.
Technical scheme includes a kind of multiplexer with priority, wherein, including a multiplex interface, it is multiple
It is used for connecting communication terminal module with interface, the data that there is the communication terminal module of different priorities to send are divided into more numbers
A buffering area is sent into by multiplex interface according to after element, buffering area is divided into multiple buffer-storeds for being used to write data element
Block, each buffer-stored block have a setting address;Also include multiple priority block lists, be each written into the slow of data element
Rush memory block to be added in a priority block list according to corresponding priority, the buffer-stored block in each priority block list
With equal priority;Be not written to data element buffer-stored block link successively after pipe carried out by a free list
Reason;Also include a data transmission blocks, data transmission blocks are by receiving the instruction of multiplex interface(TX Event)Notice is different
Priority block list obtain data be used for send.
When carrying out data segmentation, can be connected according to the length of the largest frames in communication channel, i.e. data link(DLC)
In largest frames length, by data be divided into it is multiple matching buffer-stored block sizes data elements.
The structure of one buffer-stored block includes prefix portion and is used for behind prefix portion after depositing data element
Continuous portion.A memory unit is consisted predominantly of in prefix portion, memory unit is used for the length for storing each follow-up portion's storage data element
Degree.Prefix portion also includes an indicate indicator, and indicate indicator is used for the address for indicating each follow-up portion.In a preferably embodiment party
In formula, the memory unit in prefix portion can be realized by a memory unit variable data_len, and memory unit variable data_len is represented
The length of each follow-up portion's storage data, the indicate indicator in prefix portion can be by a pointer variable * data and another pointer variable *
Next realizes that pointer variable * data point to the initial address of the data element of buffer-stored block, and another pointer variable * next refer to
To the address of next buffer-stored block.It is pointed out that above-mentioned realize reservoir part and indicate indicator with program variable
Embodiment is only that preferably embodiment, the present invention in the embodiment that the present invention is included is not excluded for real in hardware
Existing reservoir part and indicate indicator.
As shown in figure 3, in a kind of specific embodiment, communication terminal module 1 may include ATC modules, PPPx modules, VT moulds
Block, PPPx modules are the module based on PPP (Point to Point Protocol, point-to-point protocol) agreement, wherein in order to just
In explanation, the priority of setting VT module transfer information is higher than ATC modules, and the priority of ATC module transfer information is higher than PPPx
Module, multiplex interface 2(MUX APP)Priority according to communication terminal module 1 is sent into a buffering area 4 after receiving data, buffers
Area 4 is the memory space distributed in initialization procedure, and in one preferably embodiment, buffering area 4 can be divided into 40
Buffer-stored block, each buffer-stored block it is equal in magnitude, 40 buffer-stored block logical connections form a single-track link tables, pass through
Free list(Block Free List)41 are managed.The size in prefix portion is 64Kbytes, and the amount of capacity in follow-up portion is
4Kbytes.Priority block list includes multiple priority block lists, can such as include three priority block lists, and respectively
One priority block list(L1), the second priority block list(L2)And third priority block list(L3).
Also include a kind of method of work of the multiplexer with priority in technical scheme, applied to above-mentioned
A kind of multiplexer with priority, write data the step of referring to Fig. 4, it is specific as follows:
Step s11:Obtain the buffer-stored block of a writable data element;
Step s12:Data element is write to buffer-stored block;
Step s13:Buffer-stored block is added to priority block list corresponding with the priority of the data element of write-in
It is managed.
When needing to write data to buffering area, as shown in figure 3, for convenience of description, the setting before continuing to continue to use, when
When needing to write the data from VT modules, a buffer-stored block is obtained from free list, data are write to buffer-stored block
Element, and be managed added to the first priority block list;
Correspondingly, when needing to write the data from ATC modules, then a buffer-stored block is obtained from free list,
Data element is write to buffer-stored block, and is managed added to the second priority block list.
As a further improvement on the present invention, full buffer-stored block is not write in order to avoid existing in priority block list,
Cause the waste of resource, when obtaining the buffer-stored block of writable data element, first check for priority block list whether be
Buffer-stored block in empty or priority block list whether insufficient space, obtain writable data element from priority block list
Buffer-stored block.
Such as when needing to write the data from VT modules, the first priority block list is first checked for(L1List)Whether be
Buffer-stored block in empty or the first priority block list whether insufficient space, when the first priority block list has writable number
According to element buffer-stored block when, to buffer-stored block write data element;When the first priority block list is that sky or first are excellent
During buffer-stored block space deficiency in first level block list, then a buffer-stored block is obtained from free list, to buffer-stored
Block writes data element, and is managed added to the first priority block list.
Similarly, such as the second priority block list is first checked for when needing to write the data from ATC modules
(L2List)Whether be empty or the second priority block list in buffer-stored block whether insufficient space, when the second priority block arranges
When table has the buffer-stored block of writable data element, data element is write to buffer-stored block;When the second priority block arranges
When table is the buffer-stored block space deficiency in empty or the second priority block list, then a buffer-stored is obtained from free list
Block, data element is write to buffer-stored block, and be managed added to the second priority block list.
The step of reading data is specific as follows referring to Fig. 5:
Step s21:The buffer-stored block of setting ratio is chosen from each priority block list successively;
Step s22:Sent after the data element of buffer-stored block is taken out by data transmission blocks.
When needing to take out data from buffering area, the instruction that data transmission blocks 3 receive multiplex interface transmission enters transmission
State, by choosing the buffer-stored block of setting ratio from each priority block list successively, by the data of buffer-stored block
Element is sent to the drive module of upper level applications after taking out by data transmission blocks(MUX DRV).Choose setting ratio
Buffer-stored block carry out processing and can avoid reprocessing low priority after the high buffer-stored block of priority all handle
Data caused by block data.
A kind of specific embodiment, when priority block list includes three priority block lists, for purposes of illustration only, setting first
The data element priority stored in buffer-stored block corresponding to priority block list is higher than corresponding to the second priority block list
The data stored in buffer-stored block, the data element priority stored in buffer-stored block corresponding to the second priority block list
Higher than the data element stored in buffer-stored block corresponding to third priority block list.According to the order of priority from high to low
It is 4 that occupation proportion is chosen from three priority block lists:3:1 buffer-stored block.Chosen from the first priority block list
1/2 buffer-stored block, 3/8 buffer-stored block is chosen from the second priority block list, from third priority block list
Choose 1/8 buffer-stored block.The high priority data processing to high priority, the Data Post of low priority can be caused;Together
When can also avoid all having handled the high data of priority, reprocess and block data caused by the data of low priority.
In another specific embodiment, can according to the situation of the buffer-stored block included in each priority block list,
It is determined that the ratio of buffer-stored block is chosen from different priorities block list.As when the priority block list with higher priority
In the buffer-stored block that includes included far fewer than in lower priority block list buffer-stored block when, can set relatively low
The ratio of buffer-stored block is chosen in priority block list higher than the ratio that buffer-stored block is chosen from higher priority block list
Example, avoid all handle the high data of priority, reprocess and block data caused by the data of low priority so that locate
Reason process is more orderly efficient.
Or when not including buffer-stored block in a certain priority block list, then only selected from remaining priority block list
Buffer-stored block is taken, the quantity of the buffer-stored block included according to remaining priority block list selects suitable ratio, realizes
Processing procedure is efficient in order.
Preferred embodiments of the present invention are these are only, not thereby limit embodiments of the present invention and protection domain, it is right
For those skilled in the art, it should can appreciate that and all be replaced with being equal made by description of the invention and diagramatic content
Change and obviously change resulting scheme, should be included in protection scope of the present invention.