Manchester code receiving and storing method and system
By converting Manchester code serial data into parallel signals and decoding them independently of the clock signal, and using shift registers and loop counters to identify data packet headers, the problem of Manchester code decoding depending on clock synchronization is solved. This enables efficient decoding and classified storage in the absence of accurate clock synchronization and is applicable to various bus data transmission protocols.
Patent Information
- Application Number
- CN202511210832.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-27
- Publication Date
- 2025-12-12
AI Technical Summary
Existing Manchester code decoding relies on the synchronization of serial signals and clocks, which limits its application scenarios and makes it impossible to classify and store different types of data. In particular, it cannot effectively decode and store data in scenarios with complex data types, frequencies, and formats during serial bus communication.
By converting the serial data signal of Manchester code into a parallel signal and making it independent of the clock signal during the decoding process, a state machine is designed to control the decoding process using a shift register and a loop counter to identify the preamble and data packet header, adapting to different data formats, and classifying and storing data based on the packet header information.
It achieves effective decoding even without accurate clock synchronization, and the parallel signal decoding is independent of the clock signal. It can adapt to various data packet headers, realize classified storage, and is suitable for various bus transmission data protocols, thus having good versatility.
Smart Images

Figure CN121124819A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of FPGA encoding design and relates to a Manchester code receiving and storage method and system. Background Technology
[0002] Traditional Manchester code decoding uses either XORing the serial signal with a clock signal to obtain the encoded signal, or decoding by combining a shift register with a counter to extract the most significant bit. The former relies on the synchronization of the serial signal and the clock signal, making it unsuitable for scenarios where the received serial signal lacks a precisely synchronized clock input; the latter, which extracts the most significant bit, ignores the characteristics of Manchester code and fails to make good use of this digital baseband signal transmission code. Summary of the Invention
[0003] The purpose of this invention is to solve the problems in the existing technology where Manchester code decoding relies on the synchronization of serial signals and clocks, which limits the application scenarios. Furthermore, the types, frequencies, and formats of data received during serial bus communication are complex, making it impossible to classify and store different types of data. This invention provides a Manchester code receiving and storage method and system, which is particularly suitable for application scenarios involving the receiving of serial data with multiple data protocol formats and the decoding of Manchester codes. It has the advantages that part of the decoding process is independent of the clock signal and that it can classify and store the received data according to the packet header information.
[0004] To achieve the above objectives, the present invention employs the following technical solution:
[0005] A Manchester code receiving and storage method includes the following steps:
[0006] Obtain the serial data signal in Manchester code;
[0007] The serial data signal of Manchester code is converted into a parallel signal, the parallel signal is decoded, and the decoded data is obtained.
[0008] The header and length of the decoded data are matched to obtain the high-order and low-order addresses of the data. The matched data is stored based on the high-order and low-order addresses. The stored data is verified, and the verified data is stored again.
[0009] A further improvement of the present invention is that:
[0010] The acquisition of the Manchester code serial data signal includes:
[0011] Using a shift register, the preamble of the serial signal is identified, and after identifying the preamble, the serial data signal is obtained. The serial data signal includes a packet header, length, valid data, and CRC checksum.
[0012] The process of converting Manchester code serial data signals into parallel signals, decoding the parallel signals, and obtaining the decoded data includes:
[0013] The serial signal is converted into a parallel signal using a shift register.
[0014] A loop counter is designed based on the width of the shift register. The loop counter counts the received data. When the loop counter is full, the value in the loop counter is decoded to obtain the decoded data.
[0015] The process of matching the header and length of the decoded data to obtain the high-order and low-order addresses of the data, and storing the matched data based on the high-order and low-order addresses, includes:
[0016] The header of the decoded data is compared with a predefined set of headers;
[0017] If the data packet header matches the predefined packet header, the high-order address corresponding to the predefined packet header will be allocated to the current data; if the data packet header does not match the predefined packet header, the data will not be received.
[0018] Design a counter that increments by one each time a word of data is received. When the counter value equals the defined packet length, the counter value is used as the low-order address.
[0019] The high-order and low-order addresses are combined and used as the storage address for the received data. Then, the received data is written into the random access memory one in sequence.
[0020] The process of verifying the stored data and then storing the verified data again includes:
[0021] The received data is subjected to cyclic redundancy check by the check code in the received data. If the check passes, the data is stored in random access memory 2. If the check fails, the system waits to receive the next valid data packet.
[0022] The random access memory is a pseudo dual-port random access memory.
[0023] The second random access memory is a dual-port random access memory.
[0024] A Manchester code receiving and storage system, comprising:
[0025] The data acquisition module is used to acquire the serial data signal of Manchester code;
[0026] The data decoding module is used to convert the serial data signal of Manchester code into a parallel signal, decode the parallel signal, and obtain the decoded data.
[0027] The data matching and storage module is used to match the packet header and packet length of the decoded data, obtain the high-order address and low-order address of the data, store the matched data based on the high-order address and low-order address, verify the stored data, and store the data that passes the verification a second time.
[0028] A terminal device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of any of the methods described in this invention.
[0029] A computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of any of the methods described in this invention.
[0030] Compared with the prior art, the present invention has the following beneficial effects:
[0031] This invention discloses a Manchester code receiving and storage method. First, the serial data signal of Manchester code is converted into a parallel signal. During the decoding of the serial signal, the decoding action is isolated from the clock signal, reducing the dependence of the decoding process on clock synchronization. This method is suitable for scenarios where the serial signal does not have an accurate synchronous clock input. The high-order address of the storage address is determined by judging the packet header data definition, and the low-order address is determined by the packet length. Different packet header data are stored in their corresponding addresses, realizing the classification and address-based storage of received data frames based on packet header information. This method can be applied to various bus transmission data protocols and is suitable for various FPGA developments, demonstrating good versatility and application prospects. Attached Figure Description
[0032] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0033] Figure 1 This is the logic diagram of the serial bus data receiving control state machine of the present invention;
[0034] Figure 2 This is a functional diagram of the serial bus receiving control module of the present invention;
[0035] Figure 3 This is a flowchart of the method of the present invention. Detailed Implementation
[0036] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. The components of the embodiments of the present invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.
[0037] Therefore, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.
[0038] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.
[0039] In the description of the embodiments of the present invention, it should be noted that if terms such as "upper," "lower," "horizontal," or "inner" indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings, or the orientation or positional relationship commonly used when the product of the invention is in use, they are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of the present invention. Furthermore, terms such as "first" and "second" are only used to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0040] Furthermore, the use of the term "horizontal" does not imply that the component must be absolutely horizontal, but rather that it can be slightly tilted. For example, "horizontal" simply means that its direction is more horizontal than "vertical," and does not mean that the structure must be completely horizontal, but can be slightly tilted.
[0041] In the description of the embodiments of the present invention, it should also be noted that, unless otherwise explicitly specified and limited, the terms "set," "install," "connect," and "link" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art can understand the specific meaning of the above terms in the present invention according to the specific circumstances.
[0042] The present invention will now be described in further detail with reference to the accompanying drawings:
[0043] See Figures 1 to 3 This invention discloses a Manchester code receiving and storage method. Specifically, addressing the issue that Manchester code decoding relies on the synchronization of serial signals and clocks, this invention provides a decoding method that uses a state machine to control the decoding process. The decoding process for parallel signals is independent of the clock signal, reducing the dependence of the decoding process on clock synchronization. This method is suitable for scenarios where the serial signal does not have an accurately synchronized clock input. Furthermore, considering the complex data types, different data formats, and receiving frequencies in serial bus communication, this invention provides an adaptive receive-storage mode that can adapt to the received data with various data packet headers and perform classified storage.
[0044] Specifically, it includes:
[0045] This invention discloses a Manchester code receiving and storage method, comprising the following steps:
[0046] Step 1: Obtain the Manchester code serial data signal;
[0047] Step 2: Convert the Manchester code serial data signal into a parallel signal, decode the parallel signal, and obtain the decoded data;
[0048] Step 3: Match the header and length of the decoded data to obtain the high-order and low-order addresses of the data. Store the matched data based on the high-order and low-order addresses. Verify the stored data. Store the verified data a second time.
[0049] Furthermore, in this embodiment, since Manchester code decoding relies on the synchronization of the serial signal and the clock, the decoding process is specifically controlled by a state machine:
[0050] First, a shift register is used to identify the preamble of the serial signal. In this embodiment, the preamble is a special code specified in the communication protocol to inform the receiver that it is ready to receive data.
[0051] Furthermore, the serial data signal is immediately followed by the preamble, and the serial data signal includes, in sequence, the packet header, length, valid data, and CRC checksum.
[0052] Furthermore, step 2 includes:
[0053] Step 2.1: Use a shift register to convert the serial signal into a parallel signal;
[0054] Step 2.2: Design a loop counter according to the width of the shift register. For example, for a 32-bit wide shift register, design the loop counter to count up to 32. When the loop counter reaches 32, decode the value in the shift register through combinational logic and store the decoded data.
[0055] In this embodiment, combinational logic decoding includes, for example, translating 10 to 1 and 01 to 0;
[0056] In this embodiment, the parallel signal before decoding is 32-bit Manchester encoding, and the signal after decoding is 16-bit data. Specifically, when the loop counter reaches 32, the value of the shift register is the 32-bit Manchester encoding before decoding: 101010101010101010101010101010, and the signal after decoding is 1111111111111111.
[0057] In this embodiment, during data decoding, the serial data is converted into parallel data in the first stage, which relies on a clock signal. The second stage, decoding the parallel signal, is independent of the clock signal and is completed using combinational logic. This design, which isolates the decoding action from the clock signal, reduces the dependence of the decoding process on clock synchronization, making it suitable for scenarios where the serial signal does not have an accurately synchronized clock input.
[0058] Furthermore, in this embodiment, the packet header and packet length of the decoded data are matched to obtain the high-order and low-order addresses of the data. The matched data is stored based on the high-order and low-order addresses. The stored data is verified, and the verified data is stored a second time. Specifically, this includes:
[0059] Faced with complex data types, different data formats, and receiving frequencies, this invention provides an adaptive receive-storage mode that can adapt to received data with various packet headers and classify and store it. To ensure that each data format has a latest value stored, this invention uses BRAM to store the received data. The high-order address is determined by judging the packet header data definition, and the low-order address is defined according to the longest data packet with valid data in the protocol. Specifically, it includes the following steps:
[0060] Step 3.1, Capture the packet header:
[0061] The header of the received data packet is compared with a predefined set of headers. If the header matches the definition, the corresponding high-order address is assigned according to the predefined header. That is, different headers are matched with different high-order addresses. If the header does not match the definition, no more data is received until the header of the received data packet is in the header set.
[0062] Step 3.2, Capture Packet Length:
[0063] Design a counter that increments by one for each received data word, and resets to zero when the counter value equals the packet length.
[0064] Step 3.3: Use the counter value as the low-order address, merge it with the high-order address in Step 3.1, and use it as the final address to write to the random access memory (RAM). Write the received data into the first random access memory (RAM1) in sequence.
[0065] By storing different header data in corresponding addresses, the received data frames can be classified and stored at different addresses based on the header information.
[0066] Specifically, in practical applications, see Figure 1 The state machine transition conditions include:
[0067] "IDLE" is the initial state, and it transitions to the receive data state (RECEIVE_DATA state) after the protocol preamble is detected.
[0068] The RECEIVE_DATA state receives serial data. Once the received payload length is determined to be equal to the length defined in the packet header (i.e., the data packet is valid), the system transitions to the CHECK_CRC state. The serial data-parallel data-decoding-storage process is completed within the RECEIVE_DATA state.
[0069] CHECK_CRC state: Performs cyclic redundancy check (CRC check). If the check passes, it transitions to the process end state (FRAME_END state); if the check fails, it returns to the initial state (IDLE state).
[0070] After a certain time, the process will automatically jump to the initial state (IDLE state) after the process ends (FRAME_END state).
[0071] Furthermore, in this embodiment, see... Figure 2 The data processing of the serial bus receiving control module includes the following steps:
[0072] rx is the serial bus input signal.
[0073] The state machine controls the decoded data output. Figure 2 (data) and Random Access Memory (RAM) storage address ( Figure 2 The address is written to the RAM1 module. The high-order address (fixed width) of the random access memory (RAM) is allocated according to the "packet header", and the low-order address (fixed width) is incremented by one for each word written. The complete data packet is stored according to the "packet length".
[0074] The RAM1 module is a pseudo dual-port random access memory (RAM) with different read and write clocks, and its function is as a cache space.
[0075] The state machine control outputs a verification success flag signal after the cyclic redundancy check (CRC check) passes. Figure 2 (CRC_CORRECT).
[0076] Received the verification correct signal ( Figure 2 After CRC_CORRECT, the top-level control module (RECV_CTRL module) generates a read RAM1 signal.
[0077] RAM1 stores successfully verified data in RAM2. RAM2 is a dual-port random access memory (RAM) that can be read simultaneously by both buses.
[0078] In scenarios where there is no accurate synchronous clock input for serial signals, this invention, while fully considering the characteristics of Manchester code, makes the parallel signal decoding process independent of the clock signal, thus completing Manchester decoding.
[0079] When communicating via a serial bus, this invention can classify and store the received data in cases where there are different types of data, different data formats, and different receiving frequencies. Different data formats are stored in different addresses, and it is ensured that each data format has a latest value stored.
[0080] This invention realizes a data transmission process based on a serial bus and designs a Manchester decoding state machine with multiple functions such as packet header recognition, frame length, and CRC check.
[0081] This embodiment also discloses a Manchester code receiving and storage system, including:
[0082] The data acquisition module is used to acquire the serial data signal of Manchester code;
[0083] The data decoding module is used to convert the serial data signal of Manchester code into a parallel signal, decode the parallel signal, and obtain the decoded data.
[0084] The data matching and storage module is used to match the packet header and packet length of the decoded data, obtain the high-order address and low-order address of the data, store the matched data based on the high-order address and low-order address, verify the stored data, and store the data that passes the verification a second time.
[0085] This invention enables the decoding of parallel signals independently of the clock signal while fully considering the characteristics of Manchester code. It can adapt to receiving data with various packet headers. After capturing the packet header, it determines the storage address by judging the header data and stores different header data in the corresponding address, thus realizing the classification and address-based storage of received data frames according to header information. It can be widely applied to various bus data transmission protocols, is suitable for various FPGA developments, and has good versatility and application prospects.
[0086] A schematic diagram of a terminal device according to an embodiment of the present invention. The terminal device of this embodiment includes: a processor, a memory, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the steps in the various method embodiments described above. Alternatively, when the processor executes the computer program, it implements the functions of each module / unit in the various device embodiments described above.
[0087] The computer program can be divided into one or more modules / units, which are stored in the memory and executed by the processor to complete the present invention.
[0088] The terminal device can be a desktop computer, laptop computer, cloud server, or other device with strong computing power. The terminal device may include, but is not limited to, a processor and memory.
[0089] The optimal choice for the processor is a multi-core high-speed central processing unit (CPU).
[0090] The memory can be used to store the computer program and / or module. The processor implements various functions of the terminal device by running or executing the computer program and / or module stored in the memory and calling the data stored in the memory.
[0091] If the modules / units integrated into the terminal device are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the computer-readable medium can be appropriately added or removed according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electrical carrier signals and telecommunication signals.
[0092] The above are merely preferred embodiments of the present invention and are not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A Manchester code receiving and storage method, characterized in that, Includes the following steps: Obtain the serial data signal in Manchester code; The serial data signal of Manchester code is converted into a parallel signal, the parallel signal is decoded, and the decoded data is obtained. The header and length of the decoded data are matched to obtain the high-order and low-order addresses of the data. The matched data is stored based on the high-order and low-order addresses. The stored data is verified, and the verified data is stored again.
2. The Manchester code receiving and storage method according to claim 1, characterized in that, The acquisition of the Manchester code serial data signal includes: Using a shift register, the preamble of the serial signal is identified, and after identifying the preamble, the serial data signal is obtained. The serial data signal includes a packet header, length, valid data, and CRC checksum.
3. The Manchester code receiving and storage method according to claim 1, characterized in that, The process of converting Manchester code serial data signals into parallel signals, decoding the parallel signals, and obtaining the decoded data includes: The serial signal is converted into a parallel signal using a shift register. A loop counter is designed based on the width of the shift register. The loop counter counts the received data. When the loop counter is full, the value in the loop counter is decoded to obtain the decoded data.
4. The Manchester code receiving and storage method according to claim 1, characterized in that, The process of matching the header and length of the decoded data to obtain the high-order and low-order addresses of the data, and storing the matched data based on the high-order and low-order addresses, includes: The header of the decoded data is compared with a predefined set of headers; If the data packet header matches the predefined packet header, the high-order address corresponding to the predefined packet header will be allocated to the current data; otherwise, the data will not be received. Design a counter that increments by one each time a word of data is received. When the counter value equals the defined packet length, the counter value is used as the low-order address. The high-order and low-order addresses are combined and used as the storage address for the received data. Then, the received data is written into the random access memory one in sequence.
5. A Manchester code receiving and storage method according to claim 4, characterized in that, The process of verifying the stored data and then storing the verified data again includes: The received data is subjected to cyclic redundancy check by the check code in the received data. If the check passes, the data is stored in random access memory 2. If the check fails, the system waits to receive the next valid data packet.
6. The Manchester code receiving and storage method according to claim 5, characterized in that, The random access memory is a pseudo dual-port random access memory.
7. A Manchester code receiving and storage method according to claim 6, characterized in that, The second random access memory is a dual-port random access memory.
8. A Manchester code receiving and storage system, characterized in that, include: The data acquisition module is used to acquire the serial data signal of Manchester code; The data decoding module is used to convert the serial data signal of Manchester code into a parallel signal, decode the parallel signal, and obtain the decoded data. The data matching and storage module is used to match the packet header and packet length of the decoded data, obtain the high-order address and low-order address of the data, store the matched data based on the high-order address and low-order address, verify the stored data, and store the data that passes the verification a second time.
9. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method as described in any one of claims 1-7.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method as described in any one of claims 1-7.
