TWM607067U - Byte stuffing circuit - Google Patents

Byte stuffing circuit Download PDF

Info

Publication number
TWM607067U
TWM607067U TW109209875U TW109209875U TWM607067U TW M607067 U TWM607067 U TW M607067U TW 109209875 U TW109209875 U TW 109209875U TW 109209875 U TW109209875 U TW 109209875U TW M607067 U TWM607067 U TW M607067U
Authority
TW
Taiwan
Prior art keywords
byte
data stream
residual
gate
register
Prior art date
Application number
TW109209875U
Other languages
Chinese (zh)
Inventor
王育民
Original Assignee
優達科技股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 優達科技股份有限公司 filed Critical 優達科技股份有限公司
Priority to TW109209875U priority Critical patent/TWM607067U/en
Publication of TWM607067U publication Critical patent/TWM607067U/en

Links

Images

Abstract

A byte stuffing circuit is provided. An input gate receives a first data stream and generates a second data stream according to the first data stream, wherein a first size of the first data stream is N bytes, and a second size of the second data stream is 2N bytes. In response to a Xth byte of the second data stream matching a first flag byte, a Xth stage logic gate overwrites the Xth byte by a first stuffing byte, and inserts a second stuffing byte into a (X+1)th byte of the second data stream, wherein X is a positive integer between 1 and 2N-1. A remnant gate combines a remnant data stream and a first part of the second data stream to generate a third data stream, and configures a second part of the second data stream as the remnant data stream. An output gate outputs the third data stream.

Description

位元組填充電路Byte fill circuit

本新型是有關於一種位元組填充電路。The invention relates to a byte filling circuit.

高階資料鏈路控制(high-level data link control,HDLC)協定為一種廣域網路(wide area network,WAN)應用的乙太網資料格式。圖1是一種HDLC資料流的示意圖。HDLC資料流可包含數個HDLC框架(frame),且兩個HDLC框架之間可以旗標位元組隔開。一般來說,HDLC資料流是以十六進位數值「7E」來作為旗標位元組。為了使HDLC資料流的接收端能正確地辨識HDLC框架中的有效負載(payload)以及旗標之間的差異,HDLC框架中的十六進位數值「7E」需要被替換成其他的十六進位數值。The high-level data link control (HDLC) protocol is an Ethernet data format for wide area network (WAN) applications. Figure 1 is a schematic diagram of an HDLC data stream. The HDLC data stream can include several HDLC frames, and two HDLC frames can be separated by a flag byte. Generally speaking, the HDLC data stream uses the hexadecimal value "7E" as the flag byte. In order for the receiving end of the HDLC data stream to correctly recognize the difference between the payload and the flag in the HDLC frame, the hexadecimal value "7E" in the HDLC frame needs to be replaced with other hexadecimal values .

圖2是使用位元組填充以將資料流轉換成HDLC資料流的示意圖。包含十六進位數值「7E」的旗標位元組會被新增至資料流的兩端,而資料流中的十六進位數值「7E」會被替換成十六進位數值「7D5E」,並且資料流中的十六進位數值「7D」會被替換成十六進位數值「7D5D」。因此,經過位元組填充後,HDLC資料流的有效負載的尺寸會大於原本的資料流的尺寸。Figure 2 is a schematic diagram of using byte padding to convert a data stream into an HDLC data stream. The flag byte containing the hexadecimal value "7E" will be added to both ends of the data stream, and the hexadecimal value "7E" in the data stream will be replaced with the hexadecimal value "7D5E", and The hexadecimal value "7D" in the data stream will be replaced with the hexadecimal value "7D5D". Therefore, after byte filling, the size of the payload of the HDLC data stream will be larger than the size of the original data stream.

另一方面,隨著乙太網的載波頻率增加,許多常見的可程式邏輯陣列(field programmable gate array,FPGA)或超大型積體電路(very large scale integrated,VLSI)技術已經漸漸地無法支援乙太網的載波頻率。舉例來說,常見的FPGA或VLSI技術可能無法支援超過500百萬赫(MHz)的操作頻率,但現行的乙太網的載波頻率可能高達10吉赫(GHz)。為了減少操作頻率,乙太網的串列資料可被改為並列資料。舉例來說,將10GHz的64位元串列資料轉換成64位元並列資料,可將操作頻率從10GHz減少到156.25MHz。On the other hand, as the carrier frequency of Ethernet increases, many common field programmable gate array (FPGA) or very large scale integrated circuit (VLSI) technologies have gradually been unable to support B The carrier frequency of the Ethernet network. For example, common FPGA or VLSI technologies may not be able to support operating frequencies of more than 500 megahertz (MHz), but the current carrier frequency of Ethernet may be as high as 10 gigahertz (GHz). In order to reduce the operating frequency, the serial data of Ethernet can be changed to parallel data. For example, converting the 64-bit serial data of 10GHz into 64-bit parallel data can reduce the operating frequency from 10GHz to 156.25MHz.

然而,若對並列資料進行位元組填充以將並列資料轉換成HDLC資料,則所述HDLC資料的尺寸可能增大,從而超過並列資料的資料匯流排所支援的尺寸。However, if the parallel data is filled with bytes to convert the parallel data into HDLC data, the size of the HDLC data may increase, thereby exceeding the size supported by the data bus of the parallel data.

本新型提供一種位元組填充電路,適用於對並列資料進行位元組填充。The invention provides a byte filling circuit, which is suitable for byte filling parallel data.

本新型的一種位元組填充電路,包含輸入閘、邏輯電路、殘餘暫存器、殘餘閘以及輸出閘。輸入閘接收第一資料流並且根據第一資料流產生第二資料流,其中第一資料流的第一尺寸是N個位元組,並且第二資料流的第二尺寸是2N個位元組,其中N為正整數。邏輯電路耦接輸入閘,並且包含第X階邏輯閘。第X階邏輯閘響應於第二資料流的第X位元組與第一旗標位元組匹配而用第一填充位元組複寫第X位元組,並且將第二填充位元組插入至第二資料流的第(X+1)位元組,其中X為介於1至2N-1之間的正整數。殘餘暫存器儲存殘餘資料流。殘餘閘耦接邏輯電路以及殘餘暫存器,其中殘餘閘組合殘餘資料流以及第二資料流的第一部分以產生第三資料流,並且將第二資料流的第二部分配置為殘餘資料流。輸出閘耦接殘餘閘,並且輸出第三資料流。The new type of byte filling circuit includes an input gate, a logic circuit, a residual register, a residual gate and an output gate. The input gate receives the first data stream and generates a second data stream according to the first data stream, wherein the first size of the first data stream is N bytes, and the second size of the second data stream is 2N bytes , Where N is a positive integer. The logic circuit is coupled to the input gate and includes an X-th order logic gate. In response to the match between the Xth byte of the second data stream and the first flag byte, the Xth level logic gate overwrites the Xth byte with the first stuffing byte, and inserts the second stuffing byte To the (X+1)th byte of the second data stream, where X is a positive integer between 1 and 2N-1. The residual register stores residual data streams. The residual gate is coupled to the logic circuit and the residual register. The residual gate combines the residual data stream and the first part of the second data stream to generate a third data stream, and configures the second part of the second data stream as a residual data stream. The output gate is coupled to the residual gate and outputs the third data stream.

在本新型的一實施例中,上述的第X階邏輯閘響應於第X位元組與第二旗標位元組匹配而將第三填充位元組插入至第(X+1)位元組。In an embodiment of the present invention, the above-mentioned X-th level logic gate inserts the third stuffing byte into the (X+1)th bit in response to the match between the Xth byte and the second flag byte group.

在本新型的一實施例中,上述的第三資料流的第三尺寸是N個位元組,其中殘餘閘根據殘餘資料流的第四尺寸以及第三尺寸以決定第二資料流的第一部分。In an embodiment of the present invention, the third size of the third data stream is N bytes, and the residual gate determines the first part of the second data stream according to the fourth size and the third size of the residual data stream .

在本新型的一實施例中,上述的位元組填充電路更包含殘餘計數器以及控制器。殘餘計數器儲存對應於殘餘資料流的第四尺寸的殘餘計數值。控制器耦接至輸入閘、第X階邏輯閘以及殘餘閘,其中控制器響應於第殘餘計數值大於或等於N而停止輸入閘以及第X階邏輯閘的運作,直到經更新的殘餘計數值小於N。In an embodiment of the present invention, the above-mentioned byte filling circuit further includes a residual counter and a controller. The residual counter stores the residual count value corresponding to the fourth size of the residual data stream. The controller is coupled to the input gate, the X-level logic gate and the residual gate, wherein the controller stops the operation of the input gate and the X-level logic gate in response to the residual count value being greater than or equal to N until the updated residual count value Less than N.

在本新型的一實施例中,上述的第X階邏輯閘響應於第X位元組與第一旗標位元組以及第二旗標位元組的其中之一匹配而將計數值加一,其中殘餘閘根據計數值以及殘餘計數值產生經更新的殘餘計數值。In an embodiment of the present invention, the above-mentioned X-level logic gate increments the counter value by one in response to the X-th byte matching one of the first flag byte and the second flag byte , Wherein the residual gate generates an updated residual count value according to the count value and the residual count value.

在本新型的一實施例中,上述的第一旗標位元組是十六進位數值「7E」,第一填充位元組是十六進位數值「7D」,並且第二填充位元組是十六進位數值「5E」,其中第二旗標位元組是十六進位數值「7D」,並且第三填充位元組是十六進位數值「5D」。In an embodiment of the present invention, the above-mentioned first flag byte is the hexadecimal value "7E", the first stuffing byte is the hexadecimal value "7D", and the second stuffing byte is The hexadecimal value "5E", where the second flag byte is the hexadecimal value "7D", and the third padding byte is the hexadecimal value "5D".

在本新型的一實施例中,上述的第三資料流為並列資料。In an embodiment of the present invention, the aforementioned third data stream is parallel data.

在本新型的一實施例中,上述的輸入閘對第一資料流進行填零以產生第二資料流。In an embodiment of the present invention, the aforementioned input gate fills the first data stream with zeros to generate the second data stream.

在本新型的一實施例中,上述的第X階邏輯閘平移第二資料流中的第(X+1)位元組至第(2N)位元組以將第二填充位元組插入至第(X+1)位元組。In an embodiment of the present invention, the aforementioned X-level logic gate shifts the (X+1)th byte to the (2N)th byte in the second data stream to insert the second stuffing byte into The (X+1)th byte.

基於上述,本新型可對並列資料進行位元組填充,並且經過位元組填充後的並列資料的位元寬度(bit width)將不會變大。Based on the above, the present invention can perform byte filling on parallel data, and the bit width of the parallel data after byte filling will not increase.

圖3根據本新型的實施例繪示一種位元組填充電路100的示意圖。位元組填充電路100可包含控制器110、輸入暫存器120、輸入閘130、計數器141、暫存器142、邏輯電路300、殘餘閘(remnant gate)170、殘餘計數器181、殘餘暫存器182、輸出閘190以及輸出暫存器200。位元組填充電路100可接收資料流S1,對資料流S1進行位元組填充以產生資料流S3,並且輸出資料流S3,其中資料流S1可為串列資料(serial data)或並列資料(parallel data),並且資料流S3可為並列資料。位元組填充電路1005中的各個暫存器可以是先入先出(first in first out,FIFO)暫存器。FIG. 3 illustrates a schematic diagram of a byte filling circuit 100 according to an embodiment of the present invention. The byte filling circuit 100 may include a controller 110, an input register 120, an input gate 130, a counter 141, a register 142, a logic circuit 300, a remnant gate 170, a residual counter 181, and a residual register 182. The output gate 190 and the output register 200. The byte filling circuit 100 can receive the data stream S1, perform byte filling on the data stream S1 to generate the data stream S3, and output the data stream S3, where the data stream S1 can be serial data (serial data) or parallel data ( parallel data), and the data stream S3 can be parallel data. Each register in the byte filling circuit 1005 may be a first in first out (FIFO) register.

控制器110可耦接並且控制輸入暫存器120、輸入閘130、計數器141、暫存器142、邏輯電路300、殘餘閘170、殘餘計數器181、殘餘暫存器182、輸出閘190以及輸出暫存器200。詳細來說,控制器110例如是中央處理單元(central processing unit,CPU),或是其他可程式化之一般用途或特殊用途的微控制單元(micro control unit,MCU)、微處理器(microprocessor)、數位信號處理器(digital signal processor,DSP)、可程式化控制器、特殊應用積體電路(application specific integrated circuit,ASIC)、圖形處理器(graphics processing unit,GPU)、影像訊號處理器(image signal processor,ISP)、影像處理單元(image processing unit,IPU)、算數邏輯單元(arithmetic logic unit,ALU)、複雜可程式邏輯裝置(complex programmable logic device,CPLD)、FPGA或其他類似元件或上述元件的組合。The controller 110 can be coupled to and control the input register 120, input gate 130, counter 141, register 142, logic circuit 300, residual gate 170, residual counter 181, residual register 182, output gate 190, and output temporary存器200. In detail, the controller 110 is, for example, a central processing unit (CPU), or other programmable general-purpose or special-purpose micro control unit (MCU), microprocessor (microprocessor) , Digital signal processor (DSP), programmable controller, application specific integrated circuit (ASIC), graphics processing unit (GPU), image signal processor (image signal processor, ISP, image processing unit (IPU), arithmetic logic unit (ALU), complex programmable logic device (CPLD), FPGA or other similar components or the above components The combination.

輸入暫存器120可用以接收並儲存資料流S1,其中資料流S1可以是串列資料,並且資料流S1的尺寸可以是N個位元組。在本實施例中,N可為8,但本新型不限於此。舉例來說,N可以是任意的正整數。The input register 120 can be used to receive and store the data stream S1, where the data stream S1 can be serial data, and the size of the data stream S1 can be N bytes. In this embodiment, N may be 8, but the present invention is not limited to this. For example, N can be any positive integer.

輸入閘130可耦接輸入暫存器120,自輸入暫存器120接收資料流S1,並且根據資料流S1產生資料流S2,其中資料流S2的尺寸可以是2N個位元組。在本實施例中,2N可為16,但本新型不限於此。輸入閘130可對資料流S1進行填零(zero filling)以產生資料流S2。具體來說,資料流S1可包含第一位元組至第N位元組等N個位元組,其中所述第一位元組例如是資料流S1的最高有效位元組(most significant bit,MSB)或最低有效位元組(least significant bit,LSB)的其中之一,並且第N位元組例如是資料流S1的MSB或LSB的其中之另一。輸入閘130可在資料流S1的第N位元組後新增N個位元組以產生資料流S2,其中每一個新增的位元組的值可為零。換句話說,資料流S2的第一位元組至第N位元組可用以儲存資料流S1,並且資料流S2的第(N+1)位元組至第(2N)位元組可用以儲存數值「零」。The input gate 130 can be coupled to the input register 120, receives the data stream S1 from the input register 120, and generates the data stream S2 according to the data stream S1, wherein the size of the data stream S2 can be 2N bytes. In this embodiment, 2N may be 16, but the present invention is not limited to this. The input gate 130 can zero-fill the data stream S1 to generate the data stream S2. Specifically, the data stream S1 may include N bytes such as the first byte to the Nth byte, where the first byte is, for example, the most significant bit of the data stream S1. , MSB) or one of the least significant bit (LSB), and the Nth bit group is, for example, the other of the MSB or LSB of the data stream S1. The input gate 130 may add N bytes after the Nth byte of the data stream S1 to generate the data stream S2, and the value of each newly added byte may be zero. In other words, the first byte to the Nth byte of the data stream S2 can be used to store the data stream S1, and the (N+1)th byte to (2N)th byte of the data stream S2 can be used to store Store the value "zero".

輸入閘130可耦接暫存器142,並將資料流S2輸入至暫存器142以儲存,其中暫存器142的尺寸可以是2N個位元組。計數器141中的計數值C0可以是零。計數器141以及暫存器142可耦接至邏輯電路300。The input gate 130 can be coupled to the register 142 and input the data stream S2 to the register 142 for storage. The size of the register 142 can be 2N bytes. The count value C0 in the counter 141 may be zero. The counter 141 and the register 142 can be coupled to the logic circuit 300.

邏輯電路300可包含(2N-1)個階層,且每個階層可包含分別與控制器110耦接的邏輯閘、計數器以及暫存器,其中暫存器的尺寸可以是2N個位元組。舉例來說,邏輯電路300的第一階層可包含第一階邏輯閘150-1、第一階計數器161-1以及第一階暫存器162-1,其中第一階暫存器162-1的尺寸可以是2N個位元組。類似地,邏輯電路300的第X階層(X為介於1與(2N-1)之間的正整數)可包含第X階邏輯閘150-X、第X階計數器161-X以及第X階暫存器162-X,其中第X階暫存器162-X的尺寸可以是2N個位元組。邏輯電路300的第(2N-1)階層可包含第(2N-1)階邏輯閘150-(2N-1)、第(2N-1)階計數器161-(2N-1)以及第(2N-1)階暫存器162-(2N-1),其中第(2N-1)階暫存器162-(2N-1)的尺寸可以是2N個位元組。The logic circuit 300 may include (2N-1) levels, and each level may include a logic gate, a counter, and a register coupled to the controller 110, wherein the size of the register may be 2N bytes. For example, the first level of the logic circuit 300 may include a first level logic gate 150-1, a first level counter 161-1, and a first level register 162-1, where the first level register 162-1 The size can be 2N bytes. Similarly, the X-th level (X is a positive integer between 1 and (2N-1)) of the logic circuit 300 may include the X-level logic gate 150-X, the X-level counter 161-X, and the X-level The register 162-X, wherein the size of the X-level register 162-X can be 2N bytes. The (2N-1)th level of the logic circuit 300 may include the (2N-1)th level logic gate 150-(2N-1), the (2N-1)th level counter 161-(2N-1), and the (2N-th level). 1) Level register 162-(2N-1), where the size of the (2N-1)th level register 162-(2N-1) can be 2N bytes.

第一階邏輯閘150-1可耦接至計數器141以及暫存器142,並可耦接至第一階計數器161-1以及第一階暫存器162-1。第一階邏輯閘150-1可自計數器141接收計數值C0,並可自暫存器142接收資料流S2。第一階邏輯閘150-1可用以判斷資料流S2的第一位元組(例如:資料流S2的MSB或LSB的其中之一)是否與第一旗標位元組或第二旗標位元組匹配,從而決定是否對資料流S2的第一位元組進行位元組填充。若資料流S2的第一位元組與第一旗標位元組或第二旗標位元組的其中之一匹配,則第一階邏輯閘150-1可對資料流S2的第一位元組進行位元組填充,並可將計數值C0加一。若資料流S2的第一位元組與第一旗標位元組或第二旗標位元組不匹配,則第一階邏輯閘150-1可不對資料流S2的第一位元組進行位元組填充,並可不將計數值C0加一。The first-level logic gate 150-1 can be coupled to the counter 141 and the register 142, and can be coupled to the first-level counter 161-1 and the first-level register 162-1. The first-level logic gate 150-1 can receive the count value C0 from the counter 141, and can receive the data stream S2 from the register 142. The first-level logic gate 150-1 can be used to determine whether the first byte of the data stream S2 (for example, one of the MSB or the LSB of the data stream S2) is the same as the first flag byte or the second flag bit The tuples are matched to determine whether to perform byte filling on the first byte of the data stream S2. If the first byte of the data stream S2 matches one of the first flag byte or the second flag byte, then the first-level logic gate 150-1 can set the first bit of the data stream S2 The tuple is filled with bytes, and the count value C0 can be increased by one. If the first byte of the data stream S2 does not match the first or second flag byte, the first-level logic gate 150-1 may not perform the first byte of the data stream S2. The byte is filled and the count value C0 may not be increased by one.

圖4根據本新型的實施例繪示對資料流S2的第一位元組進行位元組填充的示意圖。第一階邏輯閘150-1可響應於資料流S2的第一位元組與第一旗標位元組匹配而用第一填充位元組複寫資料流S2的第一位元組,將第二填充位元組插入至資料流S2的第二位元組,並且將計數值C0加一。第一階邏輯閘150-1可平移第二位元組至第(2N)位元組以將第二填充位元組插入至資料流S2的第二位元組。FIG. 4 illustrates a schematic diagram of performing byte filling on the first byte of the data stream S2 according to an embodiment of the present invention. The first-level logic gate 150-1 can rewrite the first byte of the data stream S2 with the first padding byte in response to the matching of the first byte of the data stream S2 with the first flag byte, and the first byte of the data stream S2 Two stuffing bytes are inserted into the second byte of the data stream S2, and the counter value C0 is increased by one. The first-level logic gate 150-1 can translate the second byte to the (2N)th byte to insert the second stuffing byte into the second byte of the data stream S2.

在一實施例中,第一旗標位元組可為十六進位數值「7E」,第一填充位元組可為十六進位數值「7D」,並且第二填充位元組可為十六進位數值「5E」。據此,若第一階邏輯閘150-1判斷暫存器142中的資料流S2的第一位元組為十六進位數值「7E」,則第一階邏輯閘150-1可對所述第一位元組進行位元組填充。詳細來說,第一階邏輯閘150-1可用十六進位數值「7D」複寫資料流S2的第一位元組,並平移資料流S2的第二位元組至第(2N)位元組。在經過平移後,原先位於資料流S2的第i位元組的資料會被移動到資料流S2的第(i+1)位元組,其中i為介於2至(2N-1)的正整數。舉例來說,原先位於資料流S2的第二位元組的資料會被移動到資料流S2的第三位元組,原先位於資料流S2的第(2N-1)位元組的資料會被移動到資料流S2的第(2N)位元組,並且原先位於資料流S2的第(2N)位元組的資料會被刪除。在完成平移後,第一階邏輯閘150-1可將十六進位數值「5E」寫入至資料流S2的第二位元組,以完成對第二位元組的位元組填充。在完成對資料流S2的第一位元組的位元組填充後,第一階邏輯閘150-1可將資料流S2輸入至第一階暫存器162-1以儲存,其中第一階暫存器162-1的尺寸可為2N個位元組。另一方面,若第一階邏輯閘150-1判斷資料流S2的第一位元組為十六進位數值「7E」,則第一階邏輯閘150-1可將計數值C0加一以產生計數值C1,並將計數值C1輸入至第一階計數器161-1以儲存。In one embodiment, the first flag byte may be the hexadecimal value "7E", the first padding byte may be the hexadecimal value "7D", and the second padding byte may be sixteen. Carry the value "5E". Accordingly, if the first-level logic gate 150-1 determines that the first byte of the data stream S2 in the register 142 is a hexadecimal value "7E", the first-level logic gate 150-1 can The first byte is filled with bytes. In detail, the first-level logic gate 150-1 can use the hexadecimal value "7D" to rewrite the first byte of the data stream S2, and shift the second byte to the (2N)th byte of the data stream S2 . After translation, the data originally located in the i-th byte of data stream S2 will be moved to the (i+1)-th byte of data stream S2, where i is a positive value between 2 and (2N-1). Integer. For example, the data originally located in the second byte of the data stream S2 will be moved to the third byte of the data stream S2, and the data originally located in the (2N-1)th byte of the data stream S2 will be Move to the (2N)th byte of the data stream S2, and the data originally located in the (2N)th byte of the data stream S2 will be deleted. After the translation is completed, the first-level logic gate 150-1 can write the hexadecimal value "5E" into the second byte of the data stream S2 to complete the byte filling of the second byte. After completing the byte filling of the first byte of the data stream S2, the first-level logic gate 150-1 can input the data stream S2 to the first-level register 162-1 for storage. The size of the register 162-1 may be 2N bytes. On the other hand, if the first-level logic gate 150-1 determines that the first byte of the data stream S2 is a hexadecimal value "7E", the first-level logic gate 150-1 can increase the count value C0 by one to generate Count the value C1, and input the count value C1 to the first-stage counter 161-1 for storage.

另一方面,第一階邏輯閘150-1可響應於資料流S2的第一位元組與第二旗標位元組匹配而將第三填充位元組插入至資料流S2的第二位元組。第一階邏輯閘150-1可平移第二位元組至第(2N)位元組以將第三填充位元組插入至資料流S2的第二位元組。On the other hand, the first-level logic gate 150-1 can insert the third stuffing byte into the second bit of the data stream S2 in response to the match between the first byte of the data stream S2 and the second flag byte. Tuple. The first-level logic gate 150-1 can translate the second byte to the (2N)th byte to insert the third stuffing byte into the second byte of the data stream S2.

在一實施例中,第二旗標位元組可為十六進位數值「7D」,第三填充位元組可為十六進位數值「5D」。據此,若第一階邏輯閘150-1判斷資料流S2的第一位元組為十六進位數值「7D」,則第一階邏輯閘150-1可對所述第一位元組進行位元組填充。詳細來說,第一階邏輯閘150-1可平移資料流S2的第二位元組至第(2N)位元組。在經過平移後,原先位於資料流S2的第i位元組的資料會被移動到資料流S2的第(i+1)位元組,其中i為介於2至(2N-1)的正整數。在完成平移後,第一階邏輯閘150-1可將十六進位數值「5D」寫入至資料流S2的第二位元組,以完成對第二位元組的位元組填充。在完成對資料流S2的第一位元組的位元組填充後,第一階邏輯閘150-1可將資料流S2輸入至第一階暫存器162-1以儲存。另一方面,若第一階邏輯閘150-1判斷資料流S2的第一位元組為十六進位數值「7D」,則第一階邏輯閘150-1可將計數值C0加一以產生計數值C1,並將計數值C1輸入至第一階計數器161-1以儲存。In one embodiment, the second flag byte can be a hexadecimal value "7D", and the third padding byte can be a hexadecimal value "5D". Accordingly, if the first-level logic gate 150-1 determines that the first byte of the data stream S2 is a hexadecimal value "7D", then the first-level logic gate 150-1 can perform processing on the first byte Byte padding. In detail, the first-level logic gate 150-1 can shift the second byte to the (2N)th byte of the data stream S2. After translation, the data originally located in the i-th byte of data stream S2 will be moved to the (i+1)-th byte of data stream S2, where i is a positive value between 2 and (2N-1). Integer. After the translation is completed, the first-level logic gate 150-1 can write the hexadecimal value "5D" into the second byte of the data stream S2 to complete the byte filling of the second byte. After completing the byte filling of the first byte of the data stream S2, the first-level logic gate 150-1 can input the data stream S2 to the first-level register 162-1 for storage. On the other hand, if the first-level logic gate 150-1 determines that the first byte of the data stream S2 is a hexadecimal value "7D", the first-level logic gate 150-1 can increase the count value C0 by one to generate Count the value C1, and input the count value C1 to the first-stage counter 161-1 for storage.

回到圖3,控制器110可將第一階計數器161-1中的計數值C1以及第一階暫存器162-1中的資料流S2輸入至邏輯電路300的第二階層,以由第二階層決定是否對資料流S2的第二位元組進行位元組填充。以此類推,邏輯電路300的第X階層的第X階邏輯閘150-X可自邏輯電路300的第(X-1)階層接收計數值C(X-1)以及資料流S2,並可決定是否對資料流S2的第X位元組進行位元組填充。若資料流S2的第X位元組與第一旗標位元組或第二旗標位元組的其中之一匹配,則第X階邏輯閘150-X可對資料流S2的第X位元組進行位元組填充,並可將計數值C(X-1)加一。若資料流S2的第X位元組與第一旗標位元組或第二旗標位元組不匹配,則第X階邏輯閘150-X可不對資料流S2的第X位元組進行位元組填充,並可不將計數值C(X-1)加一。Returning to FIG. 3, the controller 110 can input the count value C1 in the first-level counter 161-1 and the data stream S2 in the first-level register 162-1 to the second level of the logic circuit 300, so that the The second level decides whether to perform byte filling on the second byte of the data stream S2. By analogy, the X-level logic gate 150-X of the X-level of the logic circuit 300 can receive the count value C(X-1) and the data stream S2 from the (X-1)-level of the logic circuit 300, and can determine Whether to perform byte filling on the Xth byte of the data stream S2. If the Xth byte of the data stream S2 matches one of the first flag byte or the second flag byte, then the X-level logic gate 150-X can set the Xth bit of the data stream S2 The tuple is filled with bytes, and the count value C(X-1) can be increased by one. If the Xth byte of the data stream S2 does not match the first flag byte or the second flag byte, the X-level logic gate 150-X may not perform the Xth byte of the data stream S2. The byte is filled, and the count value C(X-1) may not be increased by one.

圖5根據本新型的實施例繪示對資料流S2的第X位元組進行位元組填充的示意圖。邏輯電路300的第(X-1)階層可包含第(X-1)階邏輯閘150-(X-1)、第(X-1)階計數器161-(X-1)以及第(X-1)階暫存器162-(X-1)。第X階邏輯閘150-X可耦接至第(X-1)階計數器161-(X-1)以及第(X-1)階暫存器162-(X-1),並可耦接至第X階計數器161-X以及第X階暫存器162-X。第X階邏輯閘150-X可自第(X-1)階暫存器162-(X-1)取得資料流S2的第一位元組至第(X-1)位元組,並且將資料流S2的第一位元組至第(X-1)位元組輸入至第X階暫存器162-X以儲存。此外,第X階邏輯閘150-X可響應於資料流S2的第X位元組與第一旗標位元組匹配而用第一填充位元組複寫資料流S2的第X位元組,將第二填充位元組插入至資料流S2的第(X+1)位元組,並且將計數值C(X-1)加一。第X階邏輯閘150-X可平移第X位元組至第(2N)位元組以將第二填充位元組插入至資料流S2的第X位元組。FIG. 5 illustrates a schematic diagram of performing byte filling on the Xth byte of the data stream S2 according to an embodiment of the present invention. The (X-1)th level of the logic circuit 300 may include the (X-1)th level logic gate 150-(X-1), the (X-1)th level counter 161-(X-1), and the (X-1)th level. 1) Stage register 162-(X-1). The X level logic gate 150-X can be coupled to the (X-1) level counter 161-(X-1) and the (X-1) level register 162-(X-1), and can be coupled To the X-level counter 161-X and the X-level register 162-X. The X-level logic gate 150-X can obtain the first byte to the (X-1)-th byte of the data stream S2 from the (X-1)-th stage register 162-(X-1), and store The first byte to the (X-1)th byte of the data stream S2 are input to the X-th level register 162-X for storage. In addition, the X-level logic gate 150-X can overwrite the X-th byte of the data stream S2 with the first padding byte in response to the match between the X-th byte of the data stream S2 and the first flag byte. The second stuffing byte is inserted into the (X+1)th byte of the data stream S2, and the counter value C(X-1) is increased by one. The X-level logic gate 150-X can shift the Xth byte to the (2N)th byte to insert the second stuffing byte into the Xth byte of the data stream S2.

在一實施例中,第一旗標位元組可為十六進位數值「7E」,第一填充位元組可為十六進位數值「7D」,並且第二填充位元組可為十六進位數值「5E」。據此,若第X階邏輯閘150-X判斷第(X-1)階暫存器162-(X-1)中的資料流S2的第X位元組為十六進位數值「7E」,則第X階邏輯閘150-X可對第X位元組進行位元組填充。In one embodiment, the first flag byte may be the hexadecimal value "7E", the first padding byte may be the hexadecimal value "7D", and the second padding byte may be sixteen. Carry the value "5E". Accordingly, if the X-level logic gate 150-X determines that the X-th byte of the data stream S2 in the (X-1)-level register 162-(X-1) is the hexadecimal value "7E", Then, the X-th level logic gate 150-X can perform byte filling on the X-th byte.

詳細來說,第X階邏輯閘150-X可用十六進位數值「7D」複寫資料流S2的第X位元組,並平移資料流S2的第(X+1)位元組至第(2N)位元組。在經過平移後,原先位於資料流S2的第i位元組的資料會被移動到資料流S2的第(i+1)位元組,其中i為介於X+1至(2N-1)的正整數。舉例來說,原先位於資料流S2的第(X+1)位元組的資料會被移動到資料流S2的第(X+2)位元組,並且原先位於資料流S2的第(2N)位元組的資料會被刪除。在完成平移後,第X階邏輯閘150-X可將十六進位數值「5E」寫入至資料流S2的第(X+1)位元組,以完成對第X位元組的位元組填充。在完成對資料流S2的第X位元組的位元組填充後,第X階邏輯閘150-X可將資料流S2的第X位元組至第2N位元組輸入至第X階暫存器162-X以儲存,其中第X階暫存器162-X的尺寸可為2N個位元組。另一方面,若第X階邏輯閘150-X判斷資料流S2的第X位元組為十六進位數值「7E」,則第一階邏輯閘150-1可將計數值C(X-1)加一以產生計數值CX,並將計數值CX輸入至第X階計數器161-X以儲存。In detail, the X-level logic gate 150-X can use the hexadecimal value "7D" to rewrite the Xth byte of the data stream S2, and shift the (X+1)th byte of the data stream S2 to the (2N)th byte. ) Bytes. After translation, the data originally located in the i-th byte of the data stream S2 will be moved to the (i+1)-th byte of the data stream S2, where i is between X+1 and (2N-1) A positive integer. For example, the data originally located in the (X+1)th byte of data stream S2 will be moved to the (X+2)th byte of data stream S2, and originally located in the (2N)th byte of data stream S2 The byte data will be deleted. After the translation is completed, the X-level logic gate 150-X can write the hexadecimal value "5E" to the (X+1)th byte of the data stream S2 to complete the Xth byte Group fill. After filling the bytes of the Xth byte of the data stream S2, the X-level logic gate 150-X can input the Xth byte to the 2Nth byte of the data stream S2 to the Xth level temporary The memory 162-X is used for storage, and the size of the X-level register 162-X can be 2N bytes. On the other hand, if the X-level logic gate 150-X determines that the X-th byte of the data stream S2 is a hexadecimal value "7E", then the first-level logic gate 150-1 can change the count value C(X-1 ) Add one to generate a count value CX, and input the count value CX to the X-stage counter 161-X for storage.

另一方面,第X階邏輯閘150-X可響應於資料流S2的第X位元組與第二旗標位元組匹配而將第三填充位元組插入至資料流S2的第(X+1)位元組。第X階邏輯閘150-X可平移第(X+1)位元組至第(2N)位元組以將第三填充位元組插入至資料流S2的第(X+1)二位元組。On the other hand, the X-level logic gate 150-X can insert the third stuffing byte into the (Xth) bit of the data stream S2 in response to the match between the Xth byte of the data stream S2 and the second flag byte. +1) Bytes. The X-level logic gate 150-X can shift the (X+1)th byte to the (2N)th byte to insert the third stuffing byte into the (X+1)th bit of the data stream S2 group.

在一實施例中,第二旗標位元組可為十六進位數值「7D」,第三填充位元組可為十六進位數值「5D」。據此,若第X階邏輯閘150-X判斷資料流S2的第X位元組為十六進位數值「7D」,則第X階邏輯閘150-X可對所述第X位元組進行位元組填充。詳細來說,第X階邏輯閘150-X可平移資料流S2的第(X+1)位元組至第(2N)位元組。在經過平移後,原先位於資料流S2的第i位元組的資料會被移動到資料流S2的第(i+1)位元組,其中i為介於X+1至(2N-1)的正整數。舉例來說,原先位於資料流S2的第(X+1)位元組的資料會被移動到資料流S2的第(X+2)位元組,並且原先位於資料流S2的第(2N)位元組的資料會被刪除。在完成平移後,第X階邏輯閘150-X可將十六進位數值「5D」寫入至資料流S2的第(X+1)位元組,以完成對第X位元組的位元組填充。在完成對資料流S2的第X位元組的位元組填充後,第X階邏輯閘150-X可將資料流S2的第X位元組至第2N位元組輸入至第X階暫存器162-X以儲存。另一方面,若第X階邏輯閘150-X判斷資料流S2的第X位元組為十六進位數值「7D」,則第X階邏輯閘150-X可將計數值C(X-1)加一以產生計數值CX,並將計數值CX輸入至第X階計數器161-X以儲存。In one embodiment, the second flag byte can be a hexadecimal value "7D", and the third padding byte can be a hexadecimal value "5D". Accordingly, if the X-level logic gate 150-X determines that the X-th byte of the data stream S2 is a hexadecimal value "7D", then the X-level logic gate 150-X can perform processing on the X-th byte Byte padding. In detail, the X-level logic gate 150-X can shift the (X+1)th byte to the (2N)th byte of the data stream S2. After translation, the data originally located in the i-th byte of the data stream S2 will be moved to the (i+1)-th byte of the data stream S2, where i is between X+1 and (2N-1) A positive integer. For example, the data originally located in the (X+1)th byte of data stream S2 will be moved to the (X+2)th byte of data stream S2, and originally located in the (2N)th byte of data stream S2 The byte data will be deleted. After the translation is completed, the X-level logic gate 150-X can write the hexadecimal value "5D" to the (X+1)th byte of the data stream S2 to complete the Xth byte Group fill. After filling the bytes of the Xth byte of the data stream S2, the X-level logic gate 150-X can input the Xth byte to the 2Nth byte of the data stream S2 to the Xth level temporary Memory 162-X for storage. On the other hand, if the X-level logic gate 150-X determines that the X-th byte of the data stream S2 is a hexadecimal value "7D", then the X-level logic gate 150-X can change the count value C(X-1 ) Add one to generate a count value CX, and input the count value CX to the X-stage counter 161-X for storage.

回到圖3,與上述的邏輯電路300的第一階層或第X階層相似,邏輯電路300的最後階層,即第(2N-1)階層,可決定是否對資料流S2的第(2N-1)位元組進行位元組填充。第(2N-1)階邏輯閘151-(2N-1)可耦接至第(2N-1)階計數器161-(2N-1)以及第(2N-1)階暫存器162-(2N-1)。在執行完與第一階邏輯閘151-1或第X階邏輯閘151-X相似的步驟後,第(2N-1)階邏輯閘151-(2N-1)可將計數值C(2N-1)輸入至第(2N-1)階計數器161-(2N-1)以儲存,並可將資料流S2輸入至第(2N-1)階暫存器162-(2N-1)以儲存,其中第(2N-1)階暫存器162-(2N-1)的尺寸可為2N個位元組。Returning to FIG. 3, similar to the first level or the Xth level of the logic circuit 300 described above, the last level of the logic circuit 300, the (2N-1)th level, can determine whether to compare the data stream S2 to the (2N-1)th level. ) Bytes are filled with bytes. The (2N-1)th level logic gate 151-1(2N-1) can be coupled to the (2N-1)th level counter 161-(2N-1) and the (2N-1)th level register 162-(2N -1). After performing steps similar to the first-level logic gate 151-1 or the X-level logic gate 151-X, the (2N-1)-level logic gate 151-(2N-1) can change the count value C(2N- 1) Input to the (2N-1)th stage counter 161-(2N-1) for storage, and input the data stream S2 to the (2N-1)th stage register 162-(2N-1) for storage, The size of the (2N-1)th level register 162-(2N-1) can be 2N bytes.

殘餘閘170可耦接至第(2N-1)階計數器161-(2N-1)以及第(2N-1)階暫存器162-(2N-1),並可耦接至殘餘計數器181以及殘餘暫存器182。殘餘計數器181以及殘餘暫存器182可耦接至輸出閘190。輸出閘190可耦接至輸出暫存器200。殘餘暫存器182的尺寸可為2N個位元組,並可用以儲存殘餘資料流。殘餘計數器181可儲存殘餘計數值R,其中殘餘計數值R對應於殘餘資料流的尺寸。舉例來說,若殘餘資料流的尺寸為K個位元組,則殘餘計數值R可等於K,其中K為介於0至2N之間的正整數。The residual gate 170 can be coupled to the (2N-1)th stage counter 161-(2N-1) and the (2N-1)th stage register 162-(2N-1), and can be coupled to the residual counter 181 and Residual register 182. The residual counter 181 and the residual register 182 can be coupled to the output gate 190. The output gate 190 can be coupled to the output register 200. The size of the residual register 182 can be 2N bytes, and can be used to store residual data streams. The residual counter 181 can store a residual count value R, where the residual count value R corresponds to the size of the residual data stream. For example, if the size of the residual data stream is K bytes, the residual count value R can be equal to K, where K is a positive integer between 0 and 2N.

殘餘閘170可根據殘餘計數器181中的殘餘計數值R判斷殘餘暫存器182中的殘餘資料流的尺寸。若殘餘資料流的尺寸(或殘餘計數器181中的殘餘計數值R)小於資料流S3的尺寸(例如:N個位元組),則殘餘閘170可將殘餘暫存器182中的殘餘資料流與第(2N-1)階暫存器161-(2N-1)中的資料流S2的第一部分進行組合以產生資料流S3。殘餘閘170可根據資料流S3的尺寸和殘餘計數值R決定資料流S2的第一部份的尺寸。資料流S2的第一部分的尺寸可為資料流S3的尺寸減去殘餘計數值R。在產生資料流S3後,殘餘閘170可將資料流S3輸出至輸出閘190,並且輸出閘190可使用輸出暫存器200來儲存及輸出資料流S3。而後,殘餘閘170可將資料流S2的第二部分(即:除了第一部分外的剩餘部分)配置為新的殘餘資料流,並可根據第(2N-1)階計數器161-(2N-1)中的計數值C(2N-1)以及殘餘計數值R來更新殘餘計數值R,其中經更新的殘餘計數值R等於計數值C(2N-1)與原先的殘餘計數值R的總和(即:經更新的R=R+C(2N-1))。新的殘餘資料流可由殘餘暫存器182儲存。The residual gate 170 can determine the size of the residual data stream in the residual register 182 according to the residual count value R in the residual counter 181. If the size of the residual data stream (or the residual count value R in the residual counter 181) is smaller than the size of the data stream S3 (for example: N bytes), the residual gate 170 can remove the residual data stream in the residual register 182 Combine with the first part of the data stream S2 in the (2N-1)th stage register 161-(2N-1) to generate the data stream S3. The residual gate 170 can determine the size of the first part of the data stream S2 according to the size of the data stream S3 and the residual count value R. The size of the first part of the data stream S2 may be the size of the data stream S3 minus the residual count value R. After the data stream S3 is generated, the residual gate 170 can output the data stream S3 to the output gate 190, and the output gate 190 can use the output register 200 to store and output the data stream S3. Then, the residual gate 170 can configure the second part of the data stream S2 (that is, the remaining part except the first part) as a new residual data stream, and can configure it according to the (2N-1)th counter 161-(2N-1). ) In the count value C(2N-1) and the residual count value R to update the residual count value R, where the updated residual count value R is equal to the sum of the count value C(2N-1) and the original residual count value R ( That is: the updated R=R+C(2N-1)). The new residual data stream can be stored in the residual register 182.

圖6根據本新型的實施例繪示殘餘閘170與輸出閘190在時脈週期T1和T2時的運作的示意圖。在本實施例中,假設邏輯電路300共對資料流S2執行了三次的位元組填充,而使得資料流S2所包含的資料從資料流S1的N個位元組擴增為(N+3)個位元組,並使得計數值C(2N-1)等於3,其中N等於8。此外,假設殘餘暫存器182包含的殘餘資料流的尺寸為6個位元組,並且殘餘計數器181中的殘餘計數值R等於6。FIG. 6 illustrates a schematic diagram of the operation of the residual gate 170 and the output gate 190 in the clock cycles T1 and T2 according to an embodiment of the present invention. In this embodiment, it is assumed that the logic circuit 300 performs a total of three byte fillings on the data stream S2, so that the data contained in the data stream S2 is expanded from the N bytes of the data stream S1 to (N+3 ) Bytes, and make the count value C(2N-1) equal to 3, where N equals 8. In addition, it is assumed that the size of the residual data stream contained in the residual register 182 is 6 bytes, and the residual count value R in the residual counter 181 is equal to 6.

在時脈週期T1期間,殘餘閘170可響應於殘餘計數值R(R=6)小於N(N=8)而組合資料流S2的第一部分以及殘餘資料流,藉以產生資料流S3。殘餘閘170可基於資料流S3的尺寸(即:N=8)以及殘餘計數值R(即:R=6)的差值為2(即:8-6=2)而決定資料流S2的第一部份的尺寸等於2個位元組。殘餘閘170可將殘餘暫存器182中的殘餘資料流與第(2N-1)階暫存器162-(2N-1)中的資料流S2的2個位元組(例如:第一位元組以及第二位元組)進行組合以產生資料流S3。在資料流S3被輸出至輸出暫存器200後,殘餘暫存器182可被清空。殘餘閘170可將資料流S2的第二部分(即:剩餘的9個位元組)配置為新的殘餘資料流,並使用殘餘暫存器182來儲存新的殘餘資料流。殘餘閘170可根據原先的殘餘計數值R(即:R=6)與計數值C(2N-1)(即:C(2N-1)=3)的總和而將殘餘計數器181中的殘餘計數值R更新為9(即:6+3=9)。During the clock period T1, the residual gate 170 may combine the first part of the data stream S2 and the residual data stream in response to the residual count value R (R=6) being less than N (N=8) to generate the data stream S3. The residual gate 170 can determine the second data stream S2 based on the difference between the size of the data stream S3 (ie: N=8) and the residual count value R (ie: R=6) (ie: 8-6=2) The size of one part is equal to 2 bytes. The residual gate 170 can combine the residual data stream in the residual register 182 with the 2 bytes (e.g., the first bit) of the data stream S2 in the (2N-1)th stage register 162-(2N-1). The tuple and the second byte) are combined to generate the data stream S3. After the data stream S3 is output to the output register 200, the residual register 182 can be cleared. The residual gate 170 can configure the second part of the data stream S2 (ie, the remaining 9 bytes) as a new residual data stream, and use the residual register 182 to store the new residual data stream. The residual gate 170 can count the residual in the residual counter 181 according to the sum of the original residual count value R (ie: R=6) and the count value C(2N-1) (ie: C(2N-1)=3) The value R is updated to 9 (ie: 6+3=9).

另一方面,若殘餘資料流的尺寸(或殘餘計數器181中的殘餘計數值R)大於或等於資料流S3的尺寸(例如:N個位元組),則殘餘閘170可通知控制器110停止輸入閘130以及邏輯電路300的運作,直到經更新的殘餘計數值R小於N。殘餘閘170可將殘餘資料流S2中的N個位元組配置為資料流S3。在產生資料流S3後,殘餘閘170可將資料流S3輸出至輸出閘190,並且輸出閘190可使用輸出暫存器200來儲存及輸出資料流S3。而後,殘餘閘170可根據資料流S3的尺寸以及殘餘計數值R來更新殘餘計數值R,其中經更新的殘餘計數值R等於原先的殘餘計數值R與N的差值(即:經更新的R=R-N)。On the other hand, if the size of the residual data stream (or the residual count value R in the residual counter 181) is greater than or equal to the size of the data stream S3 (for example: N bytes), the residual gate 170 may notify the controller 110 to stop The input gate 130 and the logic circuit 300 operate until the updated residual count value R is less than N. The residual gate 170 can configure the N bytes in the residual data stream S2 as the data stream S3. After the data stream S3 is generated, the residual gate 170 can output the data stream S3 to the output gate 190, and the output gate 190 can use the output register 200 to store and output the data stream S3. Then, the residual gate 170 can update the residual count value R according to the size of the data stream S3 and the residual count value R, where the updated residual count value R is equal to the difference between the original residual count value R and N (ie: the updated R=RN).

圖7根據本新型的實施例繪示殘餘閘170與輸出閘190在時脈週期T2和T3時的運作的示意圖。在本實施例中,假設N等於8,並且假設殘餘暫存器182包含的殘餘資料流的尺寸為9個位元組,並且殘餘計數器181中的殘餘計數值R等於9。FIG. 7 illustrates a schematic diagram of the operation of the residual gate 170 and the output gate 190 during the clock cycles T2 and T3 according to an embodiment of the present invention. In this embodiment, it is assumed that N is equal to 8, and the size of the residual data stream contained in the residual register 182 is 9 bytes, and the residual count value R in the residual counter 181 is equal to 9.

在時脈週期T2期間,殘餘閘170可響應於殘餘計數值R(即:R=9)大於或等於N(即:N=8)而通知控制器110停止輸入閘130以及邏輯電路300的運作。在輸入閘130以及邏輯電路300停止運作的期間,將不會有新的資料流被輸入至殘餘暫存器182中。殘餘閘170可將殘餘資料流S2中的8個位元組的資料流配置為資料流S3。在產生資料流S3後,殘餘閘170可將資料流S3輸出至輸出閘190,並且輸出閘190可使用輸出暫存器200來儲存及輸出資料流S3。而後,殘餘閘170可根據原先的殘餘計數值R(即:R=9)與資料流S3的尺寸(即:N=8)的差值而將殘餘計數器181中的殘餘計數值R更新為1(即:9-8=1)。During the clock period T2, the residual gate 170 can notify the controller 110 to stop the operation of the input gate 130 and the logic circuit 300 in response to the residual count value R (ie: R=9) being greater than or equal to N (ie: N=8) . When the input gate 130 and the logic circuit 300 stop operating, no new data stream will be input to the residual register 182. The residual gate 170 can configure the data stream of 8 bytes in the residual data stream S2 as the data stream S3. After the data stream S3 is generated, the residual gate 170 can output the data stream S3 to the output gate 190, and the output gate 190 can use the output register 200 to store and output the data stream S3. Then, the residual gate 170 can update the residual count value R in the residual counter 181 to 1 according to the difference between the original residual count value R (ie: R=9) and the size of the data stream S3 (ie: N=8) (Ie: 9-8=1).

接著,在時脈週期T3期間,殘餘閘170可判斷經更新的殘餘計數值R(即:R=1)小於N(即:N=8)。據此,殘餘閘170可通知控制器110恢復輸入閘130以及邏輯電路300的運作。Then, during the clock period T3, the residual gate 170 can determine that the updated residual count value R (ie: R=1) is less than N (ie: N=8). Accordingly, the residual gate 170 can notify the controller 110 to resume the operation of the input gate 130 and the logic circuit 300.

圖8根據本新型的實施例繪示一種位元組填充方法的流程圖,其中所述位元組填充方法可由如圖3所示的位元組填充電路100實施。在步驟S801中,接收第一資料流,其中第一資料流的尺寸為N個位元組。N可為正整數。在步驟S802中,對第一資料流進行填零以產生第二資料流,其中第二資料流的尺寸為2N個位元組。在步驟S803中,檢查第二資料流的位元組[i](即:第二資料流的第i個位元組),其中i的初始值為1,並且i為介於1至(2N-1)之間的正整數。在步驟S804中,判斷第二資料流的位元組[i]是否與十六進位值「7E」匹配。若為是,則進入步驟S805。若為否,則進入步驟S808。在步驟S805中,用十六進位值「7D」複寫位元組[i]。在步驟S806中,將十六進位值「5E」插入至位元組[i+1]。在步驟S807中,使i等於(i+1)。在步驟S808中,判斷第二資料流的位元組[i]是否與十六進位值「7D」匹配。若為是,則進入步驟S809。若為否,則進入步驟S810。在步驟S809中,將十六進位值「5D」插入至位元組[i+1]。在步驟S810中,判斷i是否等於(2N-1)。若為是,則進入步驟S811。若為否,則進入步驟S807。在步驟S811中,組合殘餘資料流與第二資料流的第一部分以產生第三資料流,將第二資料流的第二部分配置為殘餘資料流,並且輸出第三資料流。FIG. 8 shows a flowchart of a byte filling method according to an embodiment of the present invention, wherein the byte filling method can be implemented by the byte filling circuit 100 shown in FIG. 3. In step S801, a first data stream is received, wherein the size of the first data stream is N bytes. N can be a positive integer. In step S802, zero-filling is performed on the first data stream to generate a second data stream, wherein the size of the second data stream is 2N bytes. In step S803, check the byte [i] of the second data stream (that is, the i-th byte of the second data stream), where the initial value of i is 1, and i is between 1 and (2N -1) A positive integer. In step S804, it is determined whether the byte [i] of the second data stream matches the hexadecimal value "7E". If yes, go to step S805. If not, go to step S808. In step S805, the byte [i] is overwritten with the hexadecimal value "7D". In step S806, the hexadecimal value "5E" is inserted into the byte group [i+1]. In step S807, i is made equal to (i+1). In step S808, it is determined whether the byte [i] of the second data stream matches the hexadecimal value "7D". If yes, go to step S809. If not, go to step S810. In step S809, the hexadecimal value "5D" is inserted into the byte group [i+1]. In step S810, it is determined whether i is equal to (2N-1). If yes, go to step S811. If not, go to step S807. In step S811, the residual data stream and the first part of the second data stream are combined to generate a third data stream, the second part of the second data stream is configured as a residual data stream, and the third data stream is output.

綜上所述,本新型的邏輯電路可對資料流進行位元組填充並以增大尺寸的暫存器來儲存經位元組填充的資料流。若殘餘暫存器中的殘餘資料流的尺寸小於預設值,則殘餘閘可將經位元組填充的資料流的一部分與殘餘暫存器中殘餘資料流組合以產生輸出資料流。若殘餘暫存器中的殘餘資料流的尺寸大於或等於預設值,則控制器可停止邏輯電路以及殘餘閘的運作,以便控制器清空殘餘暫存器中的部分資料。在殘餘暫存器中的部分資料被清空後,控制器可恢復邏輯電路以及殘餘閘的運作。邏輯電路可繼續地為資料流進行位元組填充,並且殘餘閘可繼續地將經過位元組填充的資料流的一部分與殘餘暫存器中殘餘資料流組合以產生輸出資料流。因此,本新型可對並列資料進行位元組填充,且經位元組填充的並列資料可正確地被輸出。In summary, the logic circuit of the present invention can perform byte-filling on the data stream and store the byte-filled data stream with an increased size register. If the size of the residual data stream in the residual register is smaller than the preset value, the residual gate may combine a part of the byte-filled data stream with the residual data stream in the residual register to generate an output data stream. If the size of the residual data stream in the residual register is greater than or equal to the preset value, the controller can stop the operation of the logic circuit and the residual gate, so that the controller clears part of the data in the residual register. After some data in the residual register is cleared, the controller can resume the operation of the logic circuit and the residual gate. The logic circuit can continue to perform byte filling for the data stream, and the residual gate can continue to combine a part of the byte filled data stream with the residual data stream in the residual register to generate an output data stream. Therefore, the present invention can perform byte filling on the parallel data, and the byte-filled parallel data can be output correctly.

100:位元組填充電路 110:控制器 120:輸入暫存器 130:輸入閘 141:計數器 142:暫存器 150-1:第一階邏輯閘 150-X:第X階邏輯閘 150-(2N-1):第(2N-1)階邏輯閘 161-1:第一階計數器 161-(X-1):第(X-1)階計數器 161-X:第X階計數器 161-(2N-1):第(2N-1)階計數器 162-1:第一階暫存器 162-(X-1):第(X-1)階暫存器 162-X:第X階暫存器 162-(2N-1):第(2N-1)階暫存器 170:殘餘閘 181:殘餘計數器 182:殘餘暫存器 190:輸出閘 200:輸出暫存器 300:邏輯電路 S1、S2、S3:資料流 S801、S802、S803、S804、S805、S806、S807、S808、S809、S810、S811:步驟 T1、T2、T3:時脈週期100: Byte fill circuit 110: Controller 120: Input register 130: input gate 141: Counter 142: Register 150-1: First-order logic gate 150-X: X-level logic gate 150-(2N-1): (2N-1) logic gate 161-1: First-order counter 161-(X-1): (X-1) order counter 161-X: X-order counter 161-(2N-1): (2N-1) level counter 162-1: First-level register 162-(X-1): (X-1) stage register 162-X: X-level register 162-(2N-1): (2N-1) stage register 170: Residual Gate 181: Residual counter 182: Residual register 190: output gate 200: output register 300: logic circuit S1, S2, S3: data flow S801, S802, S803, S804, S805, S806, S807, S808, S809, S810, S811: steps T1, T2, T3: clock cycle

圖1是一種HDLC資料流的示意圖。 圖2是使用位元組填充以將資料流轉換成HDLC資料流的示意圖。 圖3根據本新型的實施例繪示一種位元組填充電路的示意圖。 圖4根據本新型的實施例繪示對資料流的第一位元組進行位元組填充的示意圖。 圖5根據本新型的實施例繪示對資料流的第X位元組進行位元組填充的示意圖。 圖6根據本新型的實施例繪示殘餘閘與輸出閘在時脈週期T1和T2時的運作的示意圖。 圖7根據本新型的實施例繪示殘餘閘與輸出閘在時脈週期T2和T3時的運作的示意圖。 圖8根據本新型的實施例繪示一種位元組填充方法的流程圖。 Figure 1 is a schematic diagram of an HDLC data stream. Figure 2 is a schematic diagram of using byte padding to convert a data stream into an HDLC data stream. FIG. 3 illustrates a schematic diagram of a byte filling circuit according to an embodiment of the present invention. FIG. 4 illustrates a schematic diagram of performing byte filling on the first byte of a data stream according to an embodiment of the present invention. FIG. 5 illustrates a schematic diagram of performing byte filling on the Xth byte of a data stream according to an embodiment of the present invention. FIG. 6 illustrates a schematic diagram of the operation of the residual gate and the output gate in the clock cycles T1 and T2 according to an embodiment of the present invention. FIG. 7 illustrates a schematic diagram of the operation of the residual gate and the output gate in the clock cycles T2 and T3 according to an embodiment of the present invention. FIG. 8 shows a flowchart of a method for filling bytes according to an embodiment of the present invention.

100:位元組填充電路 100: Byte fill circuit

110:控制器 110: Controller

120:輸入暫存器 120: Input register

130:輸入閘 130: input gate

141:計數器 141: Counter

142:暫存器 142: Register

150-1:第一階邏輯閘 150-1: First-order logic gate

150-X:第X階邏輯閘 150-X: X-level logic gate

150-(2N-1):第(2N-1)階邏輯閘 150-(2N-1): (2N-1) logic gate

161-1:第一階計數器 161-1: First-order counter

161-X:第X階計數器 161-X: X-order counter

161-(2N-1):第(2N-1)階計數器 161-(2N-1): (2N-1) level counter

162-1:第一階暫存器 162-1: First-level register

162-X:第X階暫存器 162-X: X-level register

162-(2N-1):第(2N-1)階暫存器 162-(2N-1): (2N-1) stage register

170:殘餘閘 170: Residual Gate

181:殘餘計數器 181: Residual counter

182:殘餘暫存器 182: Residual register

190:輸出閘 190: output gate

200:輸出暫存器 200: output register

300:邏輯電路 300: logic circuit

S1、S2、S3:資料流 S1, S2, S3: data flow

Claims (9)

一種位元組填充電路,包括: 輸入閘,接收第一資料流並且根據所述第一資料流產生第二資料流,其中所述第一資料流的第一尺寸是N個位元組,並且所述第二資料流的第二尺寸是2N個位元組,其中N為正整數; 邏輯電路,耦接所述輸入閘,包括: 第X階邏輯閘,響應於所述第二資料流的第X位元組與第一旗標位元組匹配而用第一填充位元組複寫所述第X位元組,並且將第二填充位元組插入至所述第二資料流的第(X+1)位元組,其中X為介於1至2N-1之間的正整數; 殘餘暫存器,儲存殘餘資料流; 殘餘閘,耦接所述邏輯電路以及所述殘餘暫存器,其中所述殘餘閘組合所述殘餘資料流以及所述第二資料流的第一部分以產生第三資料流,並且將所述第二資料流的第二部分配置為所述殘餘資料流;以及 輸出閘,耦接所述殘餘閘,並且輸出所述第三資料流。 A byte filling circuit includes: The input gate receives a first data stream and generates a second data stream according to the first data stream, wherein the first size of the first data stream is N bytes, and the second data stream is The size is 2N bytes, where N is a positive integer; The logic circuit, coupled to the input gate, includes: The X-level logic gate, in response to the X-th byte of the second data stream being matched with the first flag byte, overwrites the X-th byte with the first padding byte, and replaces the second The padding byte is inserted into the (X+1)th byte of the second data stream, where X is a positive integer between 1 and 2N-1; Residual register to store residual data stream; The residual gate is coupled to the logic circuit and the residual register, wherein the residual gate combines the residual data stream and the first part of the second data stream to generate a third data stream, and the second data stream The second part of the two data streams is configured as the residual data stream; and The output gate is coupled to the residual gate and outputs the third data stream. 如請求項1所述的位元組填充電路,其中所述第X階邏輯閘響應於所述第X位元組與第二旗標位元組匹配而將第三填充位元組插入至所述第(X+1)位元組。The byte stuffing circuit according to claim 1, wherein the X-th level logic gate inserts a third stuffing byte in the Xth byte in response to a match between the Xth byte and the second flag byte The (X+1)th byte is described. 如請求項1所述的位元組填充電路,其中所述第三資料流的第三尺寸是N個位元組,其中所述殘餘閘根據所述殘餘資料流的第四尺寸以及所述第三尺寸以決定所述第二資料流的所述第一部分。The byte filling circuit according to claim 1, wherein the third size of the third data stream is N bytes, and the residual gate is based on the fourth size of the residual data stream and the first Three sizes are used to determine the first part of the second data stream. 如請求項1所述的位元組填充電路,更包括: 殘餘計數器,儲存對應於所述殘餘資料流的第四尺寸的殘餘計數值;以及 控制器,耦接至所述輸入閘、所述第X階邏輯閘以及所述殘餘閘,其中所述控制器響應於所述第殘餘計數值大於或等於N而停止所述輸入閘以及所述第X階邏輯閘的運作,直到經更新的所述殘餘計數值小於N。 The byte filling circuit described in claim 1, further including: A residual counter, storing a residual count value corresponding to the fourth size of the residual data stream; and A controller coupled to the input gate, the X-th order logic gate, and the residual gate, wherein the controller stops the input gate and the residual gate in response to the first residual count value being greater than or equal to N Operation of the X-level logic gate until the updated residual count value is less than N. 如請求項1所述的位元組填充電路,其中所述第X階邏輯閘響應於所述第X位元組與所述第一旗標位元組以及所述第二旗標位元組的其中之一匹配而將計數值加一,其中所述殘餘閘根據所述計數值以及所述殘餘計數值產生經更新的所述殘餘計數值。The byte filling circuit according to claim 1, wherein the X-th level logic gate is responsive to the X-th byte and the first flag byte and the second flag byte One of the matches increases the count value by one, wherein the residual gate generates the updated residual count value according to the count value and the residual count value. 如請求項2所述的位元組填充電路,其中所述第一旗標位元組是十六進位數值「7E」,所述第一填充位元組是十六進位數值「7D」,並且所述第二填充位元組是十六進位數值「5E」,其中所述第二旗標位元組是十六進位數值「7D」,並且所述第三填充位元組是十六進位數值「5D」。The byte stuffing circuit according to claim 2, wherein the first flag byte is a hexadecimal value "7E", the first stuffing byte is a hexadecimal value "7D", and The second padding byte is a hexadecimal value "5E", wherein the second flag byte is a hexadecimal value "7D", and the third padding byte is a hexadecimal value "5D". 如請求項1所述的位元組填充電路,其中所述第三資料流為並列資料。The byte filling circuit according to claim 1, wherein the third data stream is parallel data. 如請求項1所述的位元組填充電路,其中所述輸入閘對所述第一資料流進行填零以產生所述第二資料流。The byte filling circuit according to claim 1, wherein the input gate zero-fills the first data stream to generate the second data stream. 如請求項8所述的位元組填充電路,其中所述第X階邏輯閘平移所述第二資料流中的所述第(X+1)位元組至第(2N)位元組以將所述第二填充位元組插入至所述第(X+1)位元組。The byte filling circuit according to claim 8, wherein the X-th level logic gate shifts the (X+1)th byte to (2N)th byte in the second data stream by The second stuffing byte is inserted into the (X+1)th byte.
TW109209875U 2020-07-31 2020-07-31 Byte stuffing circuit TWM607067U (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
TW109209875U TWM607067U (en) 2020-07-31 2020-07-31 Byte stuffing circuit

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
TW109209875U TWM607067U (en) 2020-07-31 2020-07-31 Byte stuffing circuit

Publications (1)

Publication Number Publication Date
TWM607067U true TWM607067U (en) 2021-02-01

Family

ID=75782420

Family Applications (1)

Application Number Title Priority Date Filing Date
TW109209875U TWM607067U (en) 2020-07-31 2020-07-31 Byte stuffing circuit

Country Status (1)

Country Link
TW (1) TWM607067U (en)

Similar Documents

Publication Publication Date Title
US6760742B1 (en) Multi-dimensional galois field multiplier
Kebschull et al. Efficient graph-based computation and manipulation of functional decision diagrams
US10275219B2 (en) Bit-serial multiplier for FPGA applications
US7171604B2 (en) Method and apparatus for calculating cyclic redundancy check (CRC) on data using a programmable CRC engine
TW201104412A (en) Programmable CRC unit
JP2005102213A (en) Method for computing crc of message
JP5978382B2 (en) Parallel encoding of non-binary linear block codes
JP2016518750A (en) Modular and scalable cyclic redundancy check calculation circuit
US8042025B2 (en) Determining a message residue
JP2002524904A (en) Parallel CRC generation circuit for generating CRC code
US6603812B1 (en) Hardware implementation of a decimating finite impulse response filter
TWM607067U (en) Byte stuffing circuit
TWI756765B (en) Byte stuffing circuit and byte stuffing method
JPS6352494B2 (en)
JP2000004169A (en) Crc operating method and crc arithmetic circuit
JPH03219725A (en) Error inspection code generator and transmission error detector
US6442747B1 (en) Method of synthesizing a cycle redundancy code generator circuit using hardware description language
JP2002007112A (en) Remainder arithmetic calculating method and remainder arithmetic calculating device
JP6162429B2 (en) Hierarchical arithmetic circuit
US10879933B2 (en) Reed solomon decoder and semiconductor device including the same
Jeong et al. VLSI array synthesis for polynomial GCD computation
Thibeault et al. A scan-based configurable, programmable, and scalable architecture for sliding window-based operations
KR100427672B1 (en) Method for embodying a shift register in software
WO2007113964A1 (en) Multi-stage logic reconfiguration device and reconfiguration method, logic circuit correction device, and reconfigurable multi-stage logic circuit
KR100936374B1 (en) Parallel-structured word-based FSR and operating method thereof