TWM607067U - Byte stuffing circuit - Google Patents
Byte stuffing circuit Download PDFInfo
- 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
Links
Images
Abstract
Description
本新型是有關於一種位元組填充電路。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
控制器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
輸入暫存器120可用以接收並儲存資料流S1,其中資料流S1可以是串列資料,並且資料流S1的尺寸可以是N個位元組。在本實施例中,N可為8,但本新型不限於此。舉例來說,N可以是任意的正整數。The
輸入閘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
輸入閘130可耦接暫存器142,並將資料流S2輸入至暫存器142以儲存,其中暫存器142的尺寸可以是2N個位元組。計數器141中的計數值C0可以是零。計數器141以及暫存器142可耦接至邏輯電路300。The
邏輯電路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
第一階邏輯閘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
圖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
另一方面,第一階邏輯閘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
圖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
在一實施例中,第一旗標位元組可為十六進位數值「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
殘餘閘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
殘餘閘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
圖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
在時脈週期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
另一方面,若殘餘資料流的尺寸(或殘餘計數器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
圖7根據本新型的實施例繪示殘餘閘170與輸出閘190在時脈週期T2和T3時的運作的示意圖。在本實施例中,假設N等於8,並且假設殘餘暫存器182包含的殘餘資料流的尺寸為9個位元組,並且殘餘計數器181中的殘餘計數值R等於9。FIG. 7 illustrates a schematic diagram of the operation of the
在時脈週期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
接著,在時脈週期T3期間,殘餘閘170可判斷經更新的殘餘計數值R(即:R=1)小於N(即:N=8)。據此,殘餘閘170可通知控制器110恢復輸入閘130以及邏輯電路300的運作。Then, during the clock period T3, the
圖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
綜上所述,本新型的邏輯電路可對資料流進行位元組填充並以增大尺寸的暫存器來儲存經位元組填充的資料流。若殘餘暫存器中的殘餘資料流的尺寸小於預設值,則殘餘閘可將經位元組填充的資料流的一部分與殘餘暫存器中殘餘資料流組合以產生輸出資料流。若殘餘暫存器中的殘餘資料流的尺寸大於或等於預設值,則控制器可停止邏輯電路以及殘餘閘的運作,以便控制器清空殘餘暫存器中的部分資料。在殘餘暫存器中的部分資料被清空後,控制器可恢復邏輯電路以及殘餘閘的運作。邏輯電路可繼續地為資料流進行位元組填充,並且殘餘閘可繼續地將經過位元組填充的資料流的一部分與殘餘暫存器中殘餘資料流組合以產生輸出資料流。因此,本新型可對並列資料進行位元組填充,且經位元組填充的並列資料可正確地被輸出。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)
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) |
-
2020
- 2020-07-31 TW TW109209875U patent/TWM607067U/en unknown
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 |