WO2016101726A1 - Equivalent transformation method and device for state machine - Google Patents

Equivalent transformation method and device for state machine Download PDF

Info

Publication number
WO2016101726A1
WO2016101726A1 PCT/CN2015/094489 CN2015094489W WO2016101726A1 WO 2016101726 A1 WO2016101726 A1 WO 2016101726A1 CN 2015094489 W CN2015094489 W CN 2015094489W WO 2016101726 A1 WO2016101726 A1 WO 2016101726A1
Authority
WO
WIPO (PCT)
Prior art keywords
block
state
state machine
extracted
extraction
Prior art date
Application number
PCT/CN2015/094489
Other languages
French (fr)
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 中国科学院自动化研究所
Publication of WO2016101726A1 publication Critical patent/WO2016101726A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/38Concurrent instruction execution, e.g. pipeline or look ahead

Definitions

  • the present invention relates to the field of digital integrated circuits, and more particularly to a method and apparatus for equivalent conversion of a state machine to reduce the circuit complexity of the dynamically configurable pipeline and the difficulty of developing the configuration program.
  • the pipeline and the connection between the various pipeline stages and the pipeline stages on the state machine control line are a common form of digital integrated circuits.
  • the pipeline of instructions the pipeline that processes packets in the network processor, the pipeline of baseband signal processing, and so on.
  • Instruction pipeline technology refers to a processing technique in which multiple instructions overlap when a program is executed. It breaks down instructions into different stages, allowing the circuit to more fully utilize hardware resources according to specified operations.
  • Dynamic reconfigurable pipeline technology makes the hardware circuit structure more flexible and controllable. The essence is to describe the behavior of each state machine on the pipeline.
  • the state machine corresponds to each functional unit in the circuit, and the hardware resources can be conveniently manipulated by programming and configuring the state machine. Then, when the circuit is more complicated, the design and configuration of the state machine becomes extremely complicated.
  • the present invention proposes a method for equivalence transformation of a state machine to design an equivalent transformation rule for various state machines that conform to an equivalent transformation rule, thereby improving the splicing range and correctness of the state machine.
  • the present invention provides a method for equivalent transformation of a state machine, comprising the steps of:
  • Step 1 initialize the state block of the state machine into a tree-shaped two-dimensional structure
  • Step 2 Read a state extraction mode of the state machine and the state machine, select output or reverse for the state machine according to the state extraction mode; if the extraction mode is forward extraction, put the input state machine into the input of step 3, and jump Go to step 3; if the extraction mode is reverse extraction, put the status block into the input of step 2.1, call step 2.1, replace the status block returned in step 2.1 with the original status block in the state machine, and add the new state machine Put in the input of step 3, jump to step 3;
  • step 2.1 the tail region of the input state machine is marked as a header region, and the original header region is identified as a tail region;
  • the current main area is a nested loop block
  • the status block in the loop block is nested
  • the sequence is reversed, and step 2.1 is called for each status block, and the original state in the nested loop block is replaced with the returned status block.
  • Block if the current main area is not a nested loop block, reverse all the states in the status block in the main area;
  • Step 3 reading the first status block of an input state machine, determining the type of the status block, and jumping to the step of extracting the status of the corresponding status block;
  • step 4 If the current status block is a sequential block, then jump to step 4;
  • step 5 If the current status block is a loop block, then jump to step 5;
  • step 6 If the current status block is a nested loop block, then jump to step 6;
  • Step 4 receiving a sequence status block and a length to be extracted as an input, extracting a specified number of states from the input sequence block header into the header area, and modifying the length to be extracted; outputting the extracted state machine to jump to Step 8;
  • Step 5 Receive a loop block and a length to be extracted as an input, determine a length to be extracted, a number of internal states of the loop block, and a number of state of the tail region, and extract a specified number of states;
  • Sub-step 5.0 calculating the length of the loop block tail region, and determining whether it is necessary to extract a loop block at present;
  • Sub-step 5.1 all the states inside the loop body are sequentially formed into a new sequential block, the order block is placed in the head of the tail region, the number of cycles of the loop block is incremented by 1, and the jump to sub-step 5.2;
  • Sub-step 5.2 if the length to be extracted is greater than or equal to the number of internal states of the loop block, the first sequential block in the tail region is placed at the end of the extraction region, and the number to be extracted is subtracted from the interior of the loop block.
  • the number of states jumps to step 8; if the length to be extracted is less than the number of states inside the loop block, the sequential blocks in the tail region are merged into one sequential block in order, and then the header to be extracted is extracted from the merged sequential block
  • the length of each state a new sequence block is placed in the tail of the extraction area, and the tail area is cleared. If the number of states in the extracted sequence block is not 0, the extracted sequence block is placed in the tail area. Go to substep 5.3;
  • Sub-step 5.3 the state of the head to be extracted in the loop block is taken out to the end of the state in the loop block, forming a cyclic scroll, and the length to be extracted is set to 0, and jumps to sub-step 8;
  • Step 6 receiving the nested loop block and the length to be extracted as an input, extracting a specified number of states from the input nested loop block header, and outputting a combination of the state blocks usable for the state machine splicing;
  • Sub-step 6.0 if the tail region is empty, skip to sub-step 6.1; if the tail region is not empty, skip to sub-step 6.2;
  • Sub-step 6.1 extract all the state blocks in the nested loop block, put them in the tail region in order, add the number of cycles of the nested loop block to 1, and jump to sub-step 6.2;
  • Sub-step 6.2 taking the tail region of the nested loop block to form a new state machine, taking the length to be extracted and the new state machine as input, recursively calling the method, and returning the header of the first state block of the state machine All state blocks in the area are taken out, placed in the tail of the extraction area, and jump to sub-step 6.3;
  • Sub-step 6.3 taking out all the state blocks in the nested loop block, forming a new state machine in order, and extracting the length and the new state machine as input, recursively calling the method, and returning the first state block of the state machine All state blocks in the header area are fetched after the last state block of the returned state machine, and all state blocks in the nested loop block are replaced with state blocks in the state machine, and the length to be fetched is set to 0, hopping Go to step 8;
  • Step 8 if the current to-be-extracted length is not 0, the current state machine and the length to be extracted are taken as the input of step 3, and the process proceeds to step 3, otherwise the process proceeds to step 9.
  • Step 9 the extraction area is placed at the end of the first status block header area; if the original extraction mode is reverse extraction, the first status block is placed in the input of step 2.1, and step 2.1 is invoked, and the status block returned in step 2.1 is returned.
  • the method replaces the original status block in the state machine; otherwise the method ends.
  • step 1 includes:
  • each state block of the input state machine it is judged whether it is already a two-dimensional structure, that is, composed of a header region, a main region, and a tail region, and if so, the state machine is a state machine that has participated in the equivalent transformation, and jumps Go to step 2; if not, construct a two-dimensional structure of the head region, the main region, and the tail region for the state block, put the original state block into the body portion, and empty the header region and the tail region, if the state block is a nested loop The block constructs a two-dimensional structure for each state block within the state block;
  • step 4 The step of receiving a sequence status block and the length to be extracted as an input in step 4, extracting a specified number of states from the input sequence block header into the header area, and modifying the length to be extracted is:
  • the extraction is started from the beginning of the state block, and the specified number of states are sequentially extracted from the first state of the current state block, and the states are merged into a new sequential state block. , put this state block at the end of the extraction area; extract the remaining part as a new sequential status block, replacing the original status block. Set the length to be extracted to zero.
  • the length to be extracted is greater than or equal to the number of states in the sequence block, all the sequence blocks are placed at the end of the extraction region, the state block in the state machine is deleted, and the number of states in the sequence block is subtracted from the length to be extracted.
  • the present invention also provides an equivalent conversion device for a state machine, comprising:
  • First and second state machine registers 1, 9 for receiving and storing a header area, a main area, and a tail area in the transform process
  • the state block type judging module 3 implements a transform type judging step in the state machine equivalent conversion method; the module reads the to-be-transformed state block output by the first state machine inversion module 2, and outputs the status block to the execution result according to the execution result.
  • the first and second state machine reversal modules 2, 10 implement a state machine reversal step, wherein the first state machine reversal module 2 reads the initial input state machine and the length to be extracted for processing the reverse extraction
  • the second state machine inversion module 10 is coupled to the second state machine register 9 and the state block stack 4 for implementing a state of the state machine for reverse extraction at the output
  • the machine reverses the sequence and outputs a splicable state machine after the step is executed;
  • the status block stack 4 is connected to the first and second state machine inversion modules 2, 10 and the extraction module 5, and provides a stack storage function of the status block for the main state machine equivalent conversion step, assisting in completing these several The transformation step performed in the module;
  • the extraction module 5 includes a sequential block extraction module 6, a cyclic block extraction module 7, and a nested cyclic block extraction module 8; wherein the sequential block extraction module 6 implements a sequential block state extraction step, and the cyclic block extraction module 7 implements a loop block extraction step, the nested loop block extraction module 8 implements a nested loop block extraction step; the extraction module 5 aggregates three different types of state block extraction modules into a whole to connect the state block stack 4. The storage and invocation of the status block is performed by the status block stack 4; the output of the extraction module 5 is stored in the second state machine register 9.
  • the first and second state machine registers 1, 9 are designed as a storage mode of a tree-shaped two-dimensional structure.
  • the status block stack 4 is a stack register for storing a status block, and the status block is a basic storage unit internally, and a storage structure such as a stack and a queue for storing the status block is implemented.
  • the equivalent conversion device is implemented by a C++ programming language and is applicable to an x86 or MIPS processor system.
  • the equivalent conversion device is implemented by hardware in verilog as an independent portable pipeline configuration module.
  • the method of the present invention can greatly improve the range and correctness of the state machine splicing as an important sub-method in the state machine splicing method. At the same time, it can also be applied to the formal transformation and analysis of other similar programs and code segments.
  • FIG. 1 is a schematic structural view of a state machine equivalent conversion device of the present invention
  • FIG. 2 is a schematic diagram of an input status block according to Embodiment 1 of the present invention.
  • FIG. 3 is a schematic diagram of a state block of step 1 of Embodiment 1 of the present invention.
  • FIG. 4 is a schematic diagram of a state block in step 5.1 of Embodiment 1 of the present invention.
  • Figure 5 is a schematic diagram of a state block of step 5.2 of Embodiment 1 of the present invention.
  • FIG. 6 is a schematic diagram of a state block of step 5.3 of Embodiment 1 of the present invention.
  • FIG. 7 is a schematic diagram of an output state machine in step 9 of Embodiment 1 of the present invention.
  • Figure 8 is a schematic diagram of an input status block according to Embodiment 2 of the present invention.
  • FIG. 9 is a schematic diagram of a first state block of Embodiment 2 of the present invention.
  • FIG. 10 is a schematic diagram of a sub-step 6.1 status block according to Embodiment 2 of the present invention.
  • FIG. 11 is a schematic diagram of a recursive fourth step state block according to Embodiment 2 of the present invention.
  • Figure 12 is a schematic diagram of a state block of sub-step 5.1 of Embodiment 2 of the present invention.
  • Figure 13 is a schematic diagram of a sub-step 5.2 status block of Embodiment 2 of the present invention.
  • FIG. 14 is a schematic diagram of a sub-step 5.3 status block according to Embodiment 2 of the present invention.
  • FIG. 15 is a schematic diagram of a recursive ninth step state block according to Embodiment 2 of the present invention.
  • FIG. 16 is a schematic diagram of a sub-step 6.3 state block according to Embodiment 2 of the present invention.
  • FIG. 17 is a schematic diagram of an output state machine in step 9 of Embodiment 2 of the present invention.
  • Figure 18 is a flow chart showing a state machine equivalent conversion method of the present invention.
  • the invention discloses a method and device for equivalent transformation of a state machine.
  • the basic way of the state machine equivalent transformation of the present invention is to extract the length of the state to be extracted from the front of a state block (forward extraction) or the latter (reverse extraction) to form a combination of the new state block and the extracted state block.
  • forward extraction or the latter
  • reverse extraction reverse extraction
  • the state machine equivalent conversion method of the present invention comprises the following steps: a state machine preprocessing step, a state block inversion step, a transform type judging step, a sequential block state extracting step, a loop block state extracting step, a nested loop block state extracting step, Iterative decision step and output step. This will be described in detail below with reference to FIG.
  • Step 1 state machine preprocessing steps
  • This step initializes the state block of the state machine into a tree-shaped two-dimensional structure.
  • This step is characterized by determining, for each state block of the input state machine, whether it is already a two-dimensional structure, that is, consisting of a header region, a main region, and a tail region, and if so, the state machine has participated in the method equivalent. Change the state machine, jump to step 2; if not, build a header area, main area for the status block The two-dimensional structure of the domain and the tail region places the original state block into the body portion, and the head region and the tail region are blanked. If the state block is a nested loop block, a two-dimensional structure is constructed for each state block in the state block.
  • Step 2 state block reverse step
  • This step is to arrange the first state block of the state machine in reverse order, and the output state block can be equivalently transformed according to the forward extraction mode, and then arranged in reverse order to achieve the purpose of reverse extraction.
  • This step reads the state extraction mode (forward extraction or reverse extraction) of a state machine and state machine, and selects the output or reverses the state machine according to the state extraction mode.
  • step 3 If the extraction method is forward extraction, the input state machine is placed in the input of step 3, and the process proceeds to step 3.
  • step 2.1 If the extraction mode is reverse extraction, the status block is placed in the input of step 2.1, step 2.1 is invoked, the status block returned in step 2.1 is replaced with the original status block in the state machine, and the new state machine is placed in step 3. Enter and go to step 3.
  • Step 2.1 state machine reverse sequence steps
  • step 2.1 is called for each status block, replacing the original status block in the header area with the returned status block.
  • the current main area is a nested loop block
  • the status block in the loop block is nested
  • the sequence is reversed, and step 2.1 is called for each status block, and the original status block in the nested loop block is replaced with the returned status block; If the current main area is not a nested loop block, all the states in the status block in the main area are reversed.
  • step 2.1 is called for each state block, replacing the original state block in the tail region with the returned status block.
  • the adjusted status block output is returned to the previous step that called the current step.
  • Step 3 Transformation type judgment step
  • This step reads the first status block of an input state machine, determines the type of the status block, and jumps to the corresponding state block state extraction step.
  • step 4 If the current status block is a sequential block, skip to step 4.
  • step 5 If the current status block is a cyclic block, skip to step 5.
  • Step 4 Sequence block state extraction step
  • the step receives an order status block and a length to be extracted as an input, extracts a specified number of states from the input sequence block header into the header area, and modifies the length to be extracted.
  • the characteristics of this step are:
  • the extraction is started from the beginning of the state block, and the specified number of states are sequentially extracted from the first state of the current state block, and the states are merged into a new sequential state block. , put this state block at the end of the extraction area; extract the remaining part as a new sequential status block, replacing the original status block. Set the length to be extracted to zero.
  • the length to be extracted is greater than or equal to the number of states in the sequence block, all the sequence blocks are placed at the end of the extraction region, the state block in the state machine is deleted, and the number of states in the sequence block is subtracted from the length to be extracted.
  • This step receives a loop block and the length to be extracted as an input, determines the length to be extracted and the number of internal states of the loop block and the number of state of the tail region, and extracts a specified number of states.
  • This substep calculates the length of the loop block tail region, (the tail region of the loop block should contain only the sequence block), and determines whether it is necessary to extract the loop block at present.
  • the feature is: accumulating the number of states in all the sequential blocks in the tail region as the length of the tail region, and if the length of the tail region is greater than or equal to the length to be extracted, jumping to sub-step 5.2, otherwise jumping to sub-step 5.1
  • All the states inside the loop body are sequentially formed into a new sequence block.
  • the sequence block is placed in the head of the tail region, and the number of cycles of the loop block is incremented by one, and the jump to sub-step 5.2.
  • the first sequential block in the tail region (the length must be the number of internal states of the loop block) is placed at the end of the extraction region, and the number of states to be extracted is subtracted from the number of states in the loop block. , go to step 8.
  • the sequential blocks in the tail region are sequentially merged into one sequential block, and then the lengths of the headers to be extracted are extracted from the merged sequential blocks to form a new sequence.
  • the block is placed in the tail of the extraction area, and the tail area is cleared. If the number of states in the sequence block is not 0, the extracted sequence block is placed in the tail region. Go to substep 5.3.
  • the state of the head to be extracted in the loop block is taken out to the end of the state in the loop block to form a cyclic scroll, and the length to be extracted is set to zero. Go to substep 8.
  • Step 6 Nested loop block state extraction step
  • This step receives the nested loop block and the length to be extracted as input, extracts a specified number of states from the input nested loop block header, and outputs a combination of state blocks that can be used for state machine stitching.
  • Sub-step 6.1 single-round nested loop block extraction sub-step
  • Extract all the state blocks in the nested loop block place them in the tail region in order, add 1 to the number of loops of the nested loop block, and jump to substep 6.2.
  • Step 8 Iterative judgment step
  • step 3 If the current to-be-extracted length is not 0, the current state machine and the to-be-extracted length are taken as the input of step 3, and the process proceeds to step 3, otherwise, the process proceeds to step 9.
  • Step 9 the output step
  • step 2.1 If the original extraction mode is reverse extraction, the first status block is placed in the input of step 2.1, step 2.1 is invoked, the status block returned in step 2.1 is replaced with the original status block in the state machine, and the method ends; otherwise the method ends.
  • the state machine equivalent conversion device of the present invention is as shown in FIG.
  • the first and second state machine registers 1 and 9, the state block type judging module 3, the first and second state machine reversing modules 2 and 10, the state block stack 4, the extracting module 5, the sequential block extracting module 6, and the loop are included.
  • the device inputs the state machine to be transformed and the extracted length, performs all state machine equivalent conversion methods, and outputs a splicable state machine.
  • the first and second state machine registers 1 and 9 are used to receive and store the state machine. These registers are designed as a tree-shaped two-dimensional storage mode for storing the header area, the main area, and the tail area in the state machine transformation process. Each zone can store one or more complete status blocks separately.
  • the first and second state machine registers 1 and 9 are connected to the first and second state machine inversion modules 2 and 10, the sequence block extraction module 6, the cyclic block extraction module 7, and the nested loop block extraction module 8, for these The module performs the storage and invocation of each regional state machine in the step.
  • the status block stack 4 is a stack register for storing a status block
  • the internal state block is a basic storage unit, and a storage structure such as a stack and a queue for storing the status block is realized.
  • the status block stack 4 is connected to the first and second state machine inversion modules 2 and 10 and the extraction module 5, and provides a stack storage function of the status block for the main state machine equivalent conversion step, assisting in the execution of these modules. Transformation steps.
  • the first and second state machine reverse modules 2 and 10 implement the state machine reverse step in the method, wherein the first state machine reverse module 2 reads the initial input state machine and the length to be extracted for processing the reverse The first state machine is reversed when it is extracted.
  • the second state machine inversion module 10 is connected to the second state machine register 9 and the state block stack 4, and is configured to implement a state machine reverse sequence transformation performed by the state machine that is inversely extracted at the output, and outputs a splicable state after the step is executed. machine.
  • the state block type judging module 3 implements the transform type judging step in the state machine equivalent conversion method.
  • the module reads the status block to be transformed output by the first state machine reverse module 2, and according to the implementation
  • the row result outputs the status block to one of the sequence block extraction module 6, the loop block extraction module 7, or the nested loop block extraction module 8.
  • the extraction module 5 includes a sequential block extraction module 6, a cyclic block extraction module 7, and a nested cyclic block extraction module 8.
  • the sequential block extraction module 6 implements the sequential block state extraction step in the state machine equivalent conversion method of the present invention
  • the cyclic block extraction module 7 implements the cyclic block extraction step in the method
  • the nested loop block extraction module 8 implements A nested loop block extraction step in the method.
  • the extraction module 5 aggregates three different types of state block extraction modules into a whole to connect the state block stack 4, and stores and calls the state blocks through the state block stack 4.
  • the output of the extraction module 5 is stored in the second state machine register 9.
  • the splicable state machine output by the device generally includes three state blocks, which conform to the splicable rules, and can be used for subsequent state machine splicing methods or re-determining the state machine equivalence judgment method.
  • the above device is implemented by C++ programming language, and can be applied to x86, MIPS and other processor systems for realizing the configuration and downloading of dynamic reconfigurable pipelines.
  • the device can also be implemented in hardware via verilog as a stand-alone, portable pipeline configuration module.
  • a complete loop includes three states, the number of loops is N, and the state block of length 2 is forwardly extracted.
  • Step 1 Step 1, state machine preprocessing steps
  • the input is a cyclic state block, not a two-dimensional structure. Construct a header area, a main area, and a tail area for the status block, and place the original loop status block into the main area, and the header area and the tail area are blanked, as shown in FIG.
  • Step 2 Step 2, Status Block Reverse Step
  • the extraction method is forward extraction, and the input state machine is placed in the input of step 3, and the process proceeds to step 3.
  • step 3 transformation type judgment step
  • the current status block is a cyclic block and go to step 5.
  • Step 4 Step 5: Loop block state extraction step
  • This step receives the input loop block and the length to be extracted is 2.
  • the current tail area is empty, the length is 0, which is smaller than the length to be extracted, and jump to sub-step 5.1.
  • All the states inside the loop body are sequentially formed into a new sequence block, and the sequence block is placed in the head of the tail region, and the number of cycles of the loop block is increased by 1 (the total number of cycles of the loop body is reduced by 1), as shown in FIG. . Go to substep 5.2.
  • the length to be extracted is 2, the number of internal states of the cyclic block is 3, and the length to be extracted is smaller than the number of internal states of the cyclic block.
  • the two states of the header are extracted from the sequential block of the tail region, and a new sequential block is placed in the tail of the extraction region, and the tail region is cleared.
  • the number of states in the extracted sequential block is 1, and the extracted sequential block is (Only one state A3) is placed in the tail region as shown in Figure 5. Go to substep 5.3.
  • the two states of the head in the loop block are taken out to the end of the state in the loop block to form a cyclic scroll, and the length to be extracted is set to 0, as shown in FIG. Go to substep 8.
  • Step 5 Step 8, iterative judgment step
  • the current length to be extracted is 0, and the process jumps to step 9.
  • Step 6 Step 9 output steps
  • the extraction area now contains a sequential status block with 2 states A1 and A2.
  • the extracted area status block is placed at the end of the first status block header area;
  • the second status block is a cyclic status block, the internal status is A3, A1, A2, and the number of loops is 9;
  • the third status block is the tail status status
  • the block contains a state A3.
  • the nested loop state block As shown in Figure 8, the nested loop state block, a complete loop includes a sequence state block and a loop state block, the loop state block loop number is M, the nested loop block loop number is N, and the forward extraction length is A status block of 2.
  • Step 1 Step 1, state machine preprocessing steps
  • the input is a nested loop state block, not a two-dimensional structure.
  • a header area, a main area, and a tail area are constructed for the status block, and the original nested loop status block is placed in the main area, and the header area and the tail area are set to be empty.
  • a two-dimensional structure is constructed for each state block within the state block.
  • a two-dimensional structure is constructed for the internal sequence block A1: a header area, a main area, and a tail area are constructed for the sequence block, and the order block is placed in the main area, and its header area and the tail area are set to be empty.
  • construct a two-dimensional structure for the inner loop state block construct a head region, a main region, and a tail region for the loop block, and put the loop block into the main region, and its head region and tail region are set to be empty.
  • Step 2 Step 2, Status Block Reverse Step
  • the extraction method is forward extraction, and the input state machine is placed in the input of step 3, and the process proceeds to step 3.
  • step 3 transformation type judgment step
  • the current status block is a nested loop block. Go to step 6.
  • Step 4 Step 6. Nested loop block state extraction step
  • This step receives the nested loop block input and the length to be extracted is 2.
  • the tail region of the current nested loop block is empty, skip to substep 6.1;
  • Sub-step 6.1 single-round nested loop block extraction sub-step
  • All state blocks in the nested loop block are extracted, placed in the tail region in order, and the number of loops of the nested loop block is incremented by 1, as shown in FIG. Go to substep 6.2.
  • the tail region of the nested loop block is taken out to form a new state machine, which replaces a sequence block A1 and a loop block A2A3.
  • the method is recursively called with the length 2 to be extracted and the new state machine as input.
  • Step 1 state machine preprocessing steps
  • the input is a sequential status block and a cyclic status block, both of which are two-dimensional structures. Go to step 2.
  • step 2 state block reverse step
  • the extraction method is forward extraction, and the input state machine is placed in the input of step 3, and the process proceeds to step 3.
  • Step 4 sequential block state extraction step
  • This step receives the sequence status block A1, which has a length of 1 and a length to be extracted of 2. If the number of states to be extracted is greater than or equal to the number of states in the sequence block, all the sequence blocks A1 are placed at the end of the extraction region, the state block in the state machine is deleted, and the length to be extracted is subtracted from the state number 1 in the sequence block, and the current to-be-extracted length Is 1.
  • the extracted state machine is output as shown in FIG. Go to step 8.
  • the current to-be-extracted length is not 0, and the current state machine and the length 1 to be extracted are taken as the input of step 3, and the process proceeds to step 3.
  • Step 5 loop block state extraction step
  • the loop block received in this step is A2A3, the number of loops is 5, and the length to be extracted is 1.
  • the current tail region is empty, the length is 0, which is smaller than the length 1 to be extracted, and jumps to sub-step 5.1.
  • All the states inside the loop body are grouped into a new sequence block in order, and the sequence block is placed in the head of the tail region, and the number of cycles of the loop block is incremented by 1, as shown in FIG. Go to substep 5.2.
  • the length to be extracted is 1, which is smaller than the number of internal states of the loop block. 2
  • the state of the head is extracted from the sequence block in the tail region, placed in the tail of the extraction region, the tail region is cleared, and the number of states in the sequence block after the extraction is obtained. If it is not 0, the extracted sequential block A3 is placed in the tail region as shown in FIG. Go to substep 5.3.
  • the state of the head in the loop block is taken out to the end of the state inside the loop block, forming a cyclic scroll, and the length to be extracted is set to zero.
  • the current loop block is A3A2, and the number of loops is M-1, as shown in FIG. Go to substep 8.
  • the current length to be extracted is not 0, and the process jumps to step 9.
  • the extracted area status block A1A2 is placed at the end of the first status block header area.
  • the original extraction method is forward extraction, and the recursive method ends.
  • the first status block is output as the sequence block A1A2
  • the second status block is the loop block A3A2
  • the number of loops is M-1
  • the third status block is A3, as shown in FIG. Returns the recursive call location.
  • Step 4 Step 6. Nested loop block state extraction step
  • the recursive call returns, the first status block returned is the sequence block A1A2, which is taken out to the end of the extraction area. Go to substep 6.3.
  • All state blocks in the nested loop block are fetched, and a new state machine is formed in order, which includes a sequential block A1 and a loop block A2A3, and the number of loops is 5.
  • This method is called recursively, and the input is the state machine, and the length to be extracted is 2.
  • This recursive call process is exactly the same as the previous one.
  • the first state block returned by the state machine is the sequence block A1A2, which is taken out after the last state block of the return state machine, and all state blocks within the nested loop block are replaced with state blocks within the state machine.
  • All the status blocks in the current nested loop block are: loop block A3A2, loop number 4; sequence block A3; sequence block A1A2. Set the length to be extracted to 0, as shown in Figure 16. Go to step 8.
  • Step 5 Step 8, iterative judgment step
  • the current length to be extracted is 0, and the process jumps to step 9.
  • Step 6 Step 9 output steps
  • the extracted area status block A1A2 is placed at the end of the first status block header area.
  • the extraction method is forward extraction, and the method ends.
  • the final output state machine is shown in Figure 17.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

Disclosed in the present invention are an equivalent transformation method and device for a state machine, the method comprising a determination step of transformation type, a sequence block state extraction step, a circulating block state extraction step and a nested loop block state extraction step. The equivalent transformation device of the state machine is capable of receiving an input of one or more state block conforming to an equivalent transformation rule, executing all steps in the equivalent transformation method of the state machine and outputting a device of the state block conforming to a spliceable rule. The method of the present invention is an important sub-method in a splicing method of the state machine, greatly improving splicing range and accuracy of the state machine; besides, the present invention can also be applied to type transformation and analysis of other similar program sections and code sections.

Description

一种状态机等价变换的方法和装置Method and device for equivalent transformation of state machine 技术领域Technical field
本发明涉及数字集成电路领域,更具体地涉及一种状态机等价变换的方法和装置,以降低动态可配置流水线的电路复杂度和配置程序的开发难度。The present invention relates to the field of digital integrated circuits, and more particularly to a method and apparatus for equivalent conversion of a state machine to reduce the circuit complexity of the dynamically configurable pipeline and the difficulty of developing the configuration program.
背景技术Background technique
流水线以及用状态机控制流水线上的各个流水级和流水级之间的连接关系是一种普遍应用的数字集成电路形式。例如指令的流水线、网络处理器里处理数据包的流水线、基带信号处理的流水线等等。指令流水线技术是指在程序执行时多条指令重叠进行操作的一种处理技术,它将指令分解成不同的阶段,让电路能够按照指定的操作更加充分的利用硬件资源。The pipeline and the connection between the various pipeline stages and the pipeline stages on the state machine control line are a common form of digital integrated circuits. For example, the pipeline of instructions, the pipeline that processes packets in the network processor, the pipeline of baseband signal processing, and so on. Instruction pipeline technology refers to a processing technique in which multiple instructions overlap when a program is executed. It breaks down instructions into different stages, allowing the circuit to more fully utilize hardware resources according to specified operations.
动态可重配流水线技术使得硬件电路结构更加灵活可控,其本质是用程序描述流水线上各个状态机的行为。状态机对应于电路中各个功能单元,通过编程设计和配置状态机可以方便的操控硬件资源。然后,电路较为复杂时,状态机的设计和配置就变得极其复杂。Dynamic reconfigurable pipeline technology makes the hardware circuit structure more flexible and controllable. The essence is to describe the behavior of each state machine on the pipeline. The state machine corresponds to each functional unit in the circuit, and the hardware resources can be conveniently manipulated by programming and configuring the state machine. Then, when the circuit is more complicated, the design and configuration of the state machine becomes extremely complicated.
当状态机实现的功能较为复杂、状态机的形式和类型较多的时候,在状态机拼接过程中会遇到很多复杂的情况导致无法直接拼接。例如循环状态块和顺序状态块的拼接情况,以及循环状态块和嵌套循环状态块的拼接情况等。这时需要对状态机进行特定的定价变换,使得变换后的状态机可以进行拼接,且状态机实现的功能不变。When the functions implemented by the state machine are complex and the form and type of the state machine are many, many complicated situations are encountered in the state machine splicing process, which makes it impossible to directly splicing. For example, the splicing of the cyclic state block and the sequential state block, and the splicing of the loop state block and the nested loop state block. At this time, a specific pricing transformation is required for the state machine, so that the transformed state machine can be spliced, and the functions implemented by the state machine are unchanged.
发明内容Summary of the invention
有鉴于此,本发明提出一种状态机等价变换的方法,以对各种符合等价变换规则的状态机设计等价变换规则,提高状态机拼接范围和正确性。In view of this, the present invention proposes a method for equivalence transformation of a state machine to design an equivalent transformation rule for various state machines that conform to an equivalent transformation rule, thereby improving the splicing range and correctness of the state machine.
为了实现上述目的,作为本发明的一个方面,本发明提出了一种状态机等价变换的方法,包括以下步骤: In order to achieve the above object, as an aspect of the present invention, the present invention provides a method for equivalent transformation of a state machine, comprising the steps of:
步骤1,将状态机的状态块初始化成树形二维结构;Step 1: initialize the state block of the state machine into a tree-shaped two-dimensional structure;
步骤2,读取一个状态机和状态机的状态提取方式,根据状态提取方式对状态机选择输出或反向;如果提取方式是正向提取,则将输入状态机放入步骤3的输入中,跳转至步骤3;如果提取方式是反向提取,则将状态块放入步骤2.1的输入中,调用步骤2.1,将步骤2.1返回的状态块替换状态机中的原状态块,并将新状态机放入步骤3的输入,跳转至步骤3;Step 2: Read a state extraction mode of the state machine and the state machine, select output or reverse for the state machine according to the state extraction mode; if the extraction mode is forward extraction, put the input state machine into the input of step 3, and jump Go to step 3; if the extraction mode is reverse extraction, put the status block into the input of step 2.1, call step 2.1, replace the status block returned in step 2.1 with the original status block in the state machine, and add the new state machine Put in the input of step 3, jump to step 3;
步骤2.1,将输入状态机的尾区域标示为头区域,同时将原头区域标识为尾区域;In step 2.1, the tail region of the input state machine is marked as a header region, and the original header region is identified as a tail region;
其中,如果当前主区域为嵌套循环块,则将嵌套循环块中的状态块,颠倒序列,并对每个状态块调用步骤2.1,用返回的状态块替换嵌套循环块中的原状态块;如果当前主区域不是嵌套循环块,则将主区域中状态块里所有状态颠倒顺序;Wherein, if the current main area is a nested loop block, the status block in the loop block is nested, the sequence is reversed, and step 2.1 is called for each status block, and the original state in the nested loop block is replaced with the returned status block. Block; if the current main area is not a nested loop block, reverse all the states in the status block in the main area;
将调整后的状态块输出,返回到调用当前此步骤的前一个步骤中;Output the adjusted status block and return to the previous step of calling the current step;
步骤3,读取一个输入状态机的首个状态块,判断该状态块的类型,并跳转到相应状态块状态提取的步骤中;其中Step 3, reading the first status block of an input state machine, determining the type of the status block, and jumping to the step of extracting the status of the corresponding status block;
如果当前状态块为顺序块,则跳转至步骤4;If the current status block is a sequential block, then jump to step 4;
如果当前状态块为循环块,则跳转至步骤5;If the current status block is a loop block, then jump to step 5;
如果当前状态块为嵌套循环块,则跳转至步骤6;If the current status block is a nested loop block, then jump to step 6;
步骤4,接收一个顺序状态块和待提取长度作为输入,从输入顺序块头部提取出指定数量个状态置于头区域中,并修改待提取长度;将提取后的状态机输出,跳转至步骤8;Step 4: receiving a sequence status block and a length to be extracted as an input, extracting a specified number of states from the input sequence block header into the header area, and modifying the length to be extracted; outputting the extracted state machine to jump to Step 8;
步骤5,接收一个循环块和待提取长度作为输入,判断待提取长度与循环块内部状态数量和尾区域状态数量,提取指定数量的状态;Step 5: Receive a loop block and a length to be extracted as an input, determine a length to be extracted, a number of internal states of the loop block, and a number of state of the tail region, and extract a specified number of states;
子步骤5.0,计算循环块尾区域的长度,并判断当前是否需要提取一次循环块;Sub-step 5.0, calculating the length of the loop block tail region, and determining whether it is necessary to extract a loop block at present;
子步骤5.1,将循环体内部所有状态按顺序组成一个新的顺序块,将该顺序块放入尾区域的头部,将循环块的已循环次数加1,跳转至子步骤5.2;Sub-step 5.1, all the states inside the loop body are sequentially formed into a new sequential block, the order block is placed in the head of the tail region, the number of cycles of the loop block is incremented by 1, and the jump to sub-step 5.2;
子步骤5.2,如果待提取长度大于等于循环块内部状态数量,则将尾区域中首个顺序块放到提取区域的尾部,并将待提取数量减去循环块内部 状态数量,跳转到步骤8;如果待提取长度小于循环块内部状态数量,则将尾区域中的顺序块按顺序合并成一个顺序块,然后从合并的顺序块中提取出头部的待提取长度个状态,组成一个新的顺序块放入提取区域的尾部,清空尾区域,若提取后的顺序块内状态数不为0,则将提取后的顺序块放入尾区域中。跳转至子步骤5.3;Sub-step 5.2, if the length to be extracted is greater than or equal to the number of internal states of the loop block, the first sequential block in the tail region is placed at the end of the extraction region, and the number to be extracted is subtracted from the interior of the loop block. The number of states, jumps to step 8; if the length to be extracted is less than the number of states inside the loop block, the sequential blocks in the tail region are merged into one sequential block in order, and then the header to be extracted is extracted from the merged sequential block The length of each state, a new sequence block is placed in the tail of the extraction area, and the tail area is cleared. If the number of states in the extracted sequence block is not 0, the extracted sequence block is placed in the tail area. Go to substep 5.3;
子步骤5.3,将循环块内头部待提取长度个状态取出放到循环块内状态的尾部,形成一次循环滚动,并将待提取长度置为0,跳转至子步骤8;Sub-step 5.3, the state of the head to be extracted in the loop block is taken out to the end of the state in the loop block, forming a cyclic scroll, and the length to be extracted is set to 0, and jumps to sub-step 8;
步骤6,接收嵌套循环块和待提取长度作为输入,从输入嵌套循环块头部提取出指定数量个状态,输出可用于状态机拼接的状态块的组合;Step 6, receiving the nested loop block and the length to be extracted as an input, extracting a specified number of states from the input nested loop block header, and outputting a combination of the state blocks usable for the state machine splicing;
子步骤6.0,如果尾区域为空,则跳至子步骤6.1;如果尾区域非空,则跳至子步骤6.2;Sub-step 6.0, if the tail region is empty, skip to sub-step 6.1; if the tail region is not empty, skip to sub-step 6.2;
子步骤6.1,提取嵌套循环块内的所有状态块,按顺序置于尾区域中,将嵌套循环块的已循环次数加1,跳转至子步骤6.2;Sub-step 6.1, extract all the state blocks in the nested loop block, put them in the tail region in order, add the number of cycles of the nested loop block to 1, and jump to sub-step 6.2;
子步骤6.2,将嵌套循环块的尾区域取出,组成一个新的状态机,将待提取长度和新的状态机作为输入,递归调用本方法,将返回的状态机的首个状态块的头区域内所有状态块取出,放入提取区域的尾部,跳转至子步骤6.3;Sub-step 6.2, taking the tail region of the nested loop block to form a new state machine, taking the length to be extracted and the new state machine as input, recursively calling the method, and returning the header of the first state block of the state machine All state blocks in the area are taken out, placed in the tail of the extraction area, and jump to sub-step 6.3;
子步骤6.3,将嵌套循环块内所有状态块取出,按顺序组成一个新的状态机,待提取长度和新的状态机作为输入,递归调用本方法,将返回的状态机的首个状态块的头区域内所有状态块取出放到返回的状态机的最后一个状态块后面,并用该状态机内的状态块替换嵌套循环块内的所有状态块,并将待提取长度置为0,跳转至步骤8;Sub-step 6.3, taking out all the state blocks in the nested loop block, forming a new state machine in order, and extracting the length and the new state machine as input, recursively calling the method, and returning the first state block of the state machine All state blocks in the header area are fetched after the last state block of the returned state machine, and all state blocks in the nested loop block are replaced with state blocks in the state machine, and the length to be fetched is set to 0, hopping Go to step 8;
步骤8,如果当前待提取长度不为0,则将当前状态机和待提取长度作为步骤3的输入,跳转至步骤3,否则跳转至步骤9;Step 8, if the current to-be-extracted length is not 0, the current state machine and the length to be extracted are taken as the input of step 3, and the process proceeds to step 3, otherwise the process proceeds to step 9.
步骤9,将提取区域,放置到首个状态块头区域的尾部;如果原提取方式是反向提取,将首个状态块放入步骤2.1的输入中,调用步骤2.1,将步骤2.1返回的状态块替换状态机中的原状态块,该方法结束;否则该方法结束。 Step 9, the extraction area is placed at the end of the first status block header area; if the original extraction mode is reverse extraction, the first status block is placed in the input of step 2.1, and step 2.1 is invoked, and the status block returned in step 2.1 is returned. The method replaces the original status block in the state machine; otherwise the method ends.
其中,所述步骤1包括: Wherein, the step 1 includes:
对于输入状态机的每个状态块,判断其是否已经是二维结构,即由头区域、主区域和尾区域组成,如果是,则该状态机是已经参与过等价变换的状态机,跳转到步骤2;如果不是,则为状态块构建一个头区域、主区域和尾区域的二维结构,将原状态块放入主体部分,头区域和尾区域置空,若状态块是嵌套循环块则对状态块内的每个状态块构建二维结构;For each state block of the input state machine, it is judged whether it is already a two-dimensional structure, that is, composed of a header region, a main region, and a tail region, and if so, the state machine is a state machine that has participated in the equivalent transformation, and jumps Go to step 2; if not, construct a two-dimensional structure of the head region, the main region, and the tail region for the state block, put the original state block into the body portion, and empty the header region and the tail region, if the state block is a nested loop The block constructs a two-dimensional structure for each state block within the state block;
跳转到步骤2。Go to step 2.
其中,步骤4中所述接收一个顺序状态块和待提取长度作为输入,从输入顺序块头部提取出指定数量个状态置于头区域中,并修改待提取长度的步骤的特征是:The step of receiving a sequence status block and the length to be extracted as an input in step 4, extracting a specified number of states from the input sequence block header into the header area, and modifying the length to be extracted is:
若待提取长度小于等于顺序块中的状态数,从状态块开始处进行提取,从当前状态块第一个状态开始按顺序提取出指定数量个状态,把这些状态合并为一个新的顺序状态块,把这个状态块置于提取区域尾部;提取剩余的部分作为新的顺序状态块,替换原状态块。将待提取长度置为零。If the length to be extracted is less than or equal to the number of states in the sequence block, the extraction is started from the beginning of the state block, and the specified number of states are sequentially extracted from the first state of the current state block, and the states are merged into a new sequential state block. , put this state block at the end of the extraction area; extract the remaining part as a new sequential status block, replacing the original status block. Set the length to be extracted to zero.
若待提取长度大于等于顺序块中的状态数,将全部顺序块置于提取区域尾部,删除状态机中的该状态块,并将待提取长度减去顺序块中的状态数。If the length to be extracted is greater than or equal to the number of states in the sequence block, all the sequence blocks are placed at the end of the extraction region, the state block in the state machine is deleted, and the number of states in the sequence block is subtracted from the length to be extracted.
作为本发明的另一个方面,本发明还提出了一种状态机的等价变换装置,包括:As another aspect of the present invention, the present invention also provides an equivalent conversion device for a state machine, comprising:
第一和第二状态机寄存器1、9,用于接收和存储变换过程中的头区域、主区域和尾区域;First and second state machine registers 1, 9 for receiving and storing a header area, a main area, and a tail area in the transform process;
状态块类型判断模块3,实现了状态机等价变换方法中的变换类型判断步骤;该模块读取第一状态机反向模块2输出的待变换状态块,并根据执行结果将状态块输出给顺序块提取模块6、循环块提取模块7或嵌套循环块提取模块8之一;The state block type judging module 3 implements a transform type judging step in the state machine equivalent conversion method; the module reads the to-be-transformed state block output by the first state machine inversion module 2, and outputs the status block to the execution result according to the execution result. One of the sequential block extraction module 6, the cyclic block extraction module 7, or the nested cyclic block extraction module 8;
第一和第二状态机反向模块2、10,实现了状态机反向步骤,其中所述第一状态机反向模块2读取初始输入状态机和待提取长度,用于处理反向提取时的第一次状态机逆序变换;所述第二状态机反向模块10与所述第二状态机寄存器9和状态块堆栈4连接,用于实现输出时反向提取的状态机进行的状态机逆序变换,并在步骤执行完毕后输出可拼接状态机; The first and second state machine reversal modules 2, 10 implement a state machine reversal step, wherein the first state machine reversal module 2 reads the initial input state machine and the length to be extracted for processing the reverse extraction The first state machine reverse sequence conversion; the second state machine inversion module 10 is coupled to the second state machine register 9 and the state block stack 4 for implementing a state of the state machine for reverse extraction at the output The machine reverses the sequence and outputs a splicable state machine after the step is executed;
状态块堆栈4,与所述第一和第二状态机反向模块2、10、提取模块5连接,为主要的状态机等价变换步骤提供了状态块的堆栈存储功能,辅助完成这几个模块中执行的变换步骤;The status block stack 4 is connected to the first and second state machine inversion modules 2, 10 and the extraction module 5, and provides a stack storage function of the status block for the main state machine equivalent conversion step, assisting in completing these several The transformation step performed in the module;
提取模块5,包含了顺序块提取模块6、循环块提取模块7、嵌套循环块提取模块8;其中所述顺序块提取模块6实现了顺序块状态提取步骤,所述循环块提取模块7实现了循环块提取步骤,所述嵌套循环块提取模块8实现了嵌套循环块提取步骤;所述提取模块5将三个不同类型的状态块提取模块集合为一个整体以连接所述状态块堆栈4,并通过所述状态块堆栈4进行状态块的存储和调用;所述提取模块5的输出结果存储至所述第二状态机寄存器9中。The extraction module 5 includes a sequential block extraction module 6, a cyclic block extraction module 7, and a nested cyclic block extraction module 8; wherein the sequential block extraction module 6 implements a sequential block state extraction step, and the cyclic block extraction module 7 implements a loop block extraction step, the nested loop block extraction module 8 implements a nested loop block extraction step; the extraction module 5 aggregates three different types of state block extraction modules into a whole to connect the state block stack 4. The storage and invocation of the status block is performed by the status block stack 4; the output of the extraction module 5 is stored in the second state machine register 9.
其中,所述第一和第二状态机寄存器1、9设计为树形二维结构的存储模式。The first and second state machine registers 1, 9 are designed as a storage mode of a tree-shaped two-dimensional structure.
其中,所述状态块堆栈4为存储状态块的堆栈寄存器,内部以状态块为基本存储单元,实现了状态块存储的堆栈、队列等存储结构。The status block stack 4 is a stack register for storing a status block, and the status block is a basic storage unit internally, and a storage structure such as a stack and a queue for storing the status block is implemented.
其中,所述等价变换装置通过C++编程语言来实现,适用于x86或MIPS处理器体系。Wherein, the equivalent conversion device is implemented by a C++ programming language and is applicable to an x86 or MIPS processor system.
其中,所述等价变换装置通过verilog进行硬件实现,作为独立的可移植的流水线配置模块。Wherein, the equivalent conversion device is implemented by hardware in verilog as an independent portable pipeline configuration module.
基于上述技术方案可知,本发明的方法作为状态机拼接方法中的重要子方法,能够极大提高状态机拼接的范围和正确性。同时,还可以应用于其他类似程序段和代码段的形式变换和分析。Based on the above technical solutions, the method of the present invention can greatly improve the range and correctness of the state machine splicing as an important sub-method in the state machine splicing method. At the same time, it can also be applied to the formal transformation and analysis of other similar programs and code segments.
附图说明DRAWINGS
图1是本发明的状态机等价变换装置的结构示意图;1 is a schematic structural view of a state machine equivalent conversion device of the present invention;
图2是本发明实施例1输入状态块的示意图;2 is a schematic diagram of an input status block according to Embodiment 1 of the present invention;
图3是本发明实施例1步骤1状态块的示意图;3 is a schematic diagram of a state block of step 1 of Embodiment 1 of the present invention;
图4是本发明实施例1步骤5.1状态块的示意图;4 is a schematic diagram of a state block in step 5.1 of Embodiment 1 of the present invention;
图5是本发明实施例1步骤5.2状态块的示意图;Figure 5 is a schematic diagram of a state block of step 5.2 of Embodiment 1 of the present invention;
图6是本发明实施例1步骤5.3状态块的示意图;6 is a schematic diagram of a state block of step 5.3 of Embodiment 1 of the present invention;
图7是本发明实施例1步骤9输出状态机的示意图; 7 is a schematic diagram of an output state machine in step 9 of Embodiment 1 of the present invention;
图8是本发明实施例2输入状态块的示意图;Figure 8 is a schematic diagram of an input status block according to Embodiment 2 of the present invention;
图9是本发明实施例2第一步状态块的示意图;9 is a schematic diagram of a first state block of Embodiment 2 of the present invention;
图10是本发明实施例2子步骤6.1状态块的示意图;10 is a schematic diagram of a sub-step 6.1 status block according to Embodiment 2 of the present invention;
图11是本发明实施例2递归第四步状态块的示意图;11 is a schematic diagram of a recursive fourth step state block according to Embodiment 2 of the present invention;
图12是本发明实施例2子步骤5.1状态块的示意图;Figure 12 is a schematic diagram of a state block of sub-step 5.1 of Embodiment 2 of the present invention;
图13是本发明实施例2子步骤5.2状态块的示意图;Figure 13 is a schematic diagram of a sub-step 5.2 status block of Embodiment 2 of the present invention;
图14是本发明实施例2子步骤5.3状态块的示意图;14 is a schematic diagram of a sub-step 5.3 status block according to Embodiment 2 of the present invention;
图15是本发明实施例2递归第九步状态块的示意图;15 is a schematic diagram of a recursive ninth step state block according to Embodiment 2 of the present invention;
图16是本发明实施例2子步骤6.3状态块的示意图;16 is a schematic diagram of a sub-step 6.3 state block according to Embodiment 2 of the present invention;
图17是本发明实施例2步骤9输出状态机的示意图;17 is a schematic diagram of an output state machine in step 9 of Embodiment 2 of the present invention;
图18是本发明的状态机等价变换方法的流程图。Figure 18 is a flow chart showing a state machine equivalent conversion method of the present invention.
具体实施方式detailed description
为使本发明的目的、技术方案和优点更加清楚明白,以下结合具体实施例,并参照附图,对本发明作进一步的详细说明。The present invention will be further described in detail below with reference to the specific embodiments of the invention,
本发明公开了一种状态机等价变换的方法和装置。本发明的状态机等价变换的基本方式是从一个状态块前面(正向提取)或后面(反向提取)提取待提取长度个状态形成新的状态块和被提取状态块的组合。该方法正向提取时,从前面提取出来的状态连接在被提取的状态块的头部后仍和原始状态块一致;进行反向提取时,从后面提取出来的状态连接在被提取的状态块的尾部后仍和原始状态块一致。The invention discloses a method and device for equivalent transformation of a state machine. The basic way of the state machine equivalent transformation of the present invention is to extract the length of the state to be extracted from the front of a state block (forward extraction) or the latter (reverse extraction) to form a combination of the new state block and the extracted state block. When the method is forward-fetched, the state extracted from the front is connected to the original state block after being connected to the header of the extracted state block; when the reverse extraction is performed, the state extracted from the back is connected to the extracted state block. The tail is still consistent with the original state block.
本发明的状态机等价变换方法包括以下步骤:状态机预处理步骤、状态块反向步骤、变换类型判断步骤、顺序块状态提取步骤、循环块状态提取步骤、嵌套循环块状态提取步骤、迭代判断步骤和输出步骤。下面结合附图18分别对其进行详细阐述。The state machine equivalent conversion method of the present invention comprises the following steps: a state machine preprocessing step, a state block inversion step, a transform type judging step, a sequential block state extracting step, a loop block state extracting step, a nested loop block state extracting step, Iterative decision step and output step. This will be described in detail below with reference to FIG.
步骤1、状态机预处理步骤 Step 1, state machine preprocessing steps
该步骤将状态机的状态块初始化成树形二维结构。该步骤的特征为对于输入状态机的每个状态块,判断其是否已经是二维结构,即由头区域、主区域和尾区域组成,如果是,则该状态机是已经参与过本方法等价变换的状态机,跳转到步骤2;如果不是,则为状态块构建一个头区域、主区 域和尾区域的二维结构,将原状态块放入主体部分,头区域和尾区域置空,若状态块是嵌套循环块则对状态块内的每个状态块构建二维结构。This step initializes the state block of the state machine into a tree-shaped two-dimensional structure. This step is characterized by determining, for each state block of the input state machine, whether it is already a two-dimensional structure, that is, consisting of a header region, a main region, and a tail region, and if so, the state machine has participated in the method equivalent. Change the state machine, jump to step 2; if not, build a header area, main area for the status block The two-dimensional structure of the domain and the tail region places the original state block into the body portion, and the head region and the tail region are blanked. If the state block is a nested loop block, a two-dimensional structure is constructed for each state block in the state block.
预处理完成后,跳转到步骤2。After the preprocessing is complete, skip to step 2.
步骤2、状态块反向步骤 Step 2, state block reverse step
该步骤的作用是将状态机的首个状态块做逆序排列,输出的状态块可以按照正向提取的方式进行等价变换,再逆序排列,达到反向提取的目的。该步骤读取一个状态机和状态机的状态提取方式(正向提取或反向提取),根据状态提取方式对状态机选择输出或反向。The function of this step is to arrange the first state block of the state machine in reverse order, and the output state block can be equivalently transformed according to the forward extraction mode, and then arranged in reverse order to achieve the purpose of reverse extraction. This step reads the state extraction mode (forward extraction or reverse extraction) of a state machine and state machine, and selects the output or reverses the state machine according to the state extraction mode.
若提取方式是正向提取,则将输入状态机放入步骤3的输入中,跳转至步骤3。If the extraction method is forward extraction, the input state machine is placed in the input of step 3, and the process proceeds to step 3.
若提取方式是反向提取,则将状态块放入步骤2.1的输入中,调用步骤2.1,将步骤2.1返回的状态块替换状态机中的原状态块,并将新状态机放入步骤3的输入,跳转至步骤3。If the extraction mode is reverse extraction, the status block is placed in the input of step 2.1, step 2.1 is invoked, the status block returned in step 2.1 is replaced with the original status block in the state machine, and the new state machine is placed in step 3. Enter and go to step 3.
步骤2.1、状态机逆序步骤Step 2.1, state machine reverse sequence steps
将输入状态机的尾区域标示为头区域,同时将原头区域标识为尾区域。Mark the tail area of the input state machine as the head area and the original head area as the tail area.
将当前头区域中的状态块,颠倒序列,并对每个状态块调用步骤2.1,用返回的状态块替换头区域中的原状态块。The status block in the current header area is reversed, and step 2.1 is called for each status block, replacing the original status block in the header area with the returned status block.
若当前主区域为嵌套循环块,则将嵌套循环块中的状态块,颠倒序列,并对每个状态块调用步骤2.1,用返回的状态块替换嵌套循环块中的原状态块;若当前主区域不是嵌套循环块,则将主区域中状态块里所有状态颠倒顺序。If the current main area is a nested loop block, the status block in the loop block is nested, the sequence is reversed, and step 2.1 is called for each status block, and the original status block in the nested loop block is replaced with the returned status block; If the current main area is not a nested loop block, all the states in the status block in the main area are reversed.
将当前尾区域中的状态块,颠倒序列,并对每个状态块调用步骤2.1,用返回的状态块替换尾区域中的原状态块。The status block in the current tail region is reversed, and step 2.1 is called for each state block, replacing the original state block in the tail region with the returned status block.
将调整后的状态块输出,返回到调用当前此步骤的前一个步骤中。The adjusted status block output is returned to the previous step that called the current step.
步骤3、变换类型判断步骤Step 3: Transformation type judgment step
该步骤读取一个输入状态机的首个状态块,判断该状态块的类型,并跳转到相应状态块状态提取的步骤中。This step reads the first status block of an input state machine, determines the type of the status block, and jumps to the corresponding state block state extraction step.
若当前状态块为顺序块,则跳转至步骤4。If the current status block is a sequential block, skip to step 4.
若当前状态块为循环块,则跳转至步骤5。If the current status block is a cyclic block, skip to step 5.
若当前状态块为嵌套循环块,则跳转至步骤6。 If the current status block is a nested loop block, skip to step 6.
步骤4、顺序块状态提取步骤 Step 4. Sequence block state extraction step
该步骤接收一个顺序状态块和待提取长度作为输入,从输入顺序块头部提取出指定数量个状态置于头区域中,并修改待提取长度。该步骤的特征是:The step receives an order status block and a length to be extracted as an input, extracts a specified number of states from the input sequence block header into the header area, and modifies the length to be extracted. The characteristics of this step are:
若待提取长度小于等于顺序块中的状态数,从状态块开始处进行提取,从当前状态块第一个状态开始按顺序提取出指定数量个状态,把这些状态合并为一个新的顺序状态块,把这个状态块置于提取区域尾部;提取剩余的部分作为新的顺序状态块,替换原状态块。将待提取长度置为零。If the length to be extracted is less than or equal to the number of states in the sequence block, the extraction is started from the beginning of the state block, and the specified number of states are sequentially extracted from the first state of the current state block, and the states are merged into a new sequential state block. , put this state block at the end of the extraction area; extract the remaining part as a new sequential status block, replacing the original status block. Set the length to be extracted to zero.
若待提取长度大于等于顺序块中的状态数,将全部顺序块置于提取区域尾部,删除状态机中的该状态块,并将待提取长度减去顺序块中的状态数。If the length to be extracted is greater than or equal to the number of states in the sequence block, all the sequence blocks are placed at the end of the extraction region, the state block in the state machine is deleted, and the number of states in the sequence block is subtracted from the length to be extracted.
将提取后的状态机输出,跳转至步骤8。Output the extracted state machine and go to step 8.
步骤5、循环块状态提取步骤Step 5, loop block state extraction step
该步骤接收一个循环块和待提取长度作为输入,判断待提取长度与循环块内部状态数量和尾区域状态数量,提取指定数量的状态。This step receives a loop block and the length to be extracted as an input, determines the length to be extracted and the number of internal states of the loop block and the number of state of the tail region, and extracts a specified number of states.
子步骤5.0、尾区域长度判断子步骤Sub-step 5.0, tail region length judgment sub-step
该子步骤计算循环块尾区域的长度,(循环块的尾区域中应该只包含顺序块),并判断当前是否需要提取一次循环块。其特征为:将尾区域内所有顺序块内的状态数累加作为尾区域的长度,若尾区域长度大于等于待提取长度,则跳转至子步骤5.2,否则跳转至子步骤5.1This substep calculates the length of the loop block tail region, (the tail region of the loop block should contain only the sequence block), and determines whether it is necessary to extract the loop block at present. The feature is: accumulating the number of states in all the sequential blocks in the tail region as the length of the tail region, and if the length of the tail region is greater than or equal to the length to be extracted, jumping to sub-step 5.2, otherwise jumping to sub-step 5.1
子步骤5.1、单轮循环提取子步骤Sub-step 5.1, single-round loop extraction sub-step
将循环体内部所有状态按顺序组成一个新的顺序块,将该顺序块放入尾区域的头部,将循环块的已循环次数加1,跳转至子步骤5.2。All the states inside the loop body are sequentially formed into a new sequence block. The sequence block is placed in the head of the tail region, and the number of cycles of the loop block is incremented by one, and the jump to sub-step 5.2.
子步骤5.2、尾区域提取子步骤Sub-step 5.2, tail region extraction sub-step
若待提取长度大于等于循环块内部状态数量,则将尾区域中首个顺序块(长度必然是循环块内部状态数量)放到提取区域的尾部,并将待提取数量减去循环块内部状态数量,跳转到步骤8。If the length to be extracted is greater than or equal to the number of internal states of the loop block, the first sequential block in the tail region (the length must be the number of internal states of the loop block) is placed at the end of the extraction region, and the number of states to be extracted is subtracted from the number of states in the loop block. , go to step 8.
若待提取长度小于循环块内部状态数量,则将尾区域中的顺序块按顺序合并成一个顺序块,然后从合并的顺序块中提取出头部的待提取长度个状态,组成一个新的顺序块放入提取区域的尾部,清空尾区域,若提取后 的顺序块内状态数不为0,则将提取后的顺序块放入尾区域中。跳转至子步骤5.3。If the length to be extracted is less than the number of internal states of the cyclic block, the sequential blocks in the tail region are sequentially merged into one sequential block, and then the lengths of the headers to be extracted are extracted from the merged sequential blocks to form a new sequence. The block is placed in the tail of the extraction area, and the tail area is cleared. If the number of states in the sequence block is not 0, the extracted sequence block is placed in the tail region. Go to substep 5.3.
子步骤5.3、循环块滚动子步骤Sub-step 5.3, loop block rolling sub-step
将循环块内头部待提取长度个状态取出放到循环块内状态的尾部,形成一次循环滚动,并将待提取长度置为0。跳转至子步骤8。The state of the head to be extracted in the loop block is taken out to the end of the state in the loop block to form a cyclic scroll, and the length to be extracted is set to zero. Go to substep 8.
步骤6、嵌套循环块状态提取步骤Step 6. Nested loop block state extraction step
该步骤接收嵌套循环块和待提取长度作为输入,从输入嵌套循环块头部提取出指定数量个状态,输出可用于状态机拼接的状态块的组合。This step receives the nested loop block and the length to be extracted as input, extracts a specified number of states from the input nested loop block header, and outputs a combination of state blocks that can be used for state machine stitching.
子步骤6.0、尾区域判断子步骤Sub-step 6.0, tail region judgment sub-step
若尾区域为空,则跳至子步骤6.1;If the tail area is empty, skip to sub-step 6.1;
若尾区域非空,则跳至子步骤6.2。If the tail region is not empty, skip to substep 6.2.
子步骤6.1、单轮嵌套循环块提取子步骤Sub-step 6.1, single-round nested loop block extraction sub-step
提取嵌套循环块内的所有状态块,按顺序置于尾区域中,将嵌套循环块的已循环次数加1,跳转至子步骤6.2。Extract all the state blocks in the nested loop block, place them in the tail region in order, add 1 to the number of loops of the nested loop block, and jump to substep 6.2.
子步骤6.2、嵌套提取子步骤Sub-step 6.2, nested extraction sub-steps
将嵌套循环块的尾区域取出,组成一个新的状态机,将待提取长度和新的状态机作为输入,递归调用本方法,将返回的状态机的首个状态块的头区域内所有状态块取出,放入提取区域的尾部。跳转至子步骤6.3。Take the tail region of the nested loop block to form a new state machine, take the length to be extracted and the new state machine as input, recursively call this method, and return all states in the header region of the first state block of the state machine. The block is taken out and placed in the tail of the extraction area. Go to substep 6.3.
子步骤6.3、嵌套滚动子步骤Sub-step 6.3, nested scrolling substeps
将嵌套循环块内所有状态块取出,按顺序组成一个新的状态机,待提取长度和新的状态机作为输入,递归调用本方法,将返回的状态机的首个状态块的头区域内所有状态块取出放到返回的状态机的最后一个状态块后面,并用该状态机内的状态块替换嵌套循环块内的所有状态块,并将待提取长度置为0。跳转至步骤8。Take out all the state blocks in the nested loop block, form a new state machine in order, and extract the length and the new state machine as input, recursively call this method, and return the header of the first state block of the state machine All state blocks are fetched after the last state block of the returned state machine, and all state blocks within the nested loop block are replaced with state blocks within the state machine, and the length to be fetched is set to zero. Go to step 8.
步骤8、迭代判断步骤Step 8. Iterative judgment step
若当前待提取长度不为0,则将当前状态机和待提取长度作为步骤3的输入,跳转至步骤3,否则跳转至步骤9。If the current to-be-extracted length is not 0, the current state machine and the to-be-extracted length are taken as the input of step 3, and the process proceeds to step 3, otherwise, the process proceeds to step 9.
步骤9、输出步骤 Step 9, the output step
将提取区域,放置到首个状态块头区域的尾部。 Place the extracted area at the end of the first status block header area.
若原提取方式是反向提取,将首个状态块放入步骤2.1的输入中,调用步骤2.1,将步骤2.1返回的状态块替换状态机中的原状态块,该方法结束;否则该方法结束。If the original extraction mode is reverse extraction, the first status block is placed in the input of step 2.1, step 2.1 is invoked, the status block returned in step 2.1 is replaced with the original status block in the state machine, and the method ends; otherwise the method ends.
状态机等价变换装置State machine equivalent conversion device
本发明的状态机等价变换装置如图1所示。包括第一和第二状态机寄存器1和9、状态块类型判断模块3、第一和第二状态机反向模块2和10、状态块堆栈4、提取模块5、顺序块提取模块6、循环块提取模块7、嵌套循环块提取模块8。The state machine equivalent conversion device of the present invention is as shown in FIG. The first and second state machine registers 1 and 9, the state block type judging module 3, the first and second state machine reversing modules 2 and 10, the state block stack 4, the extracting module 5, the sequential block extracting module 6, and the loop are included. The block extraction module 7 and the nested loop block extraction module 8.
该装置输入待变换状态机和提取长度,执行全部的状态机等价变换方法,并输出可拼接状态机。The device inputs the state machine to be transformed and the extracted length, performs all state machine equivalent conversion methods, and outputs a splicable state machine.
第一和第二状态机寄存器1和9用于接收和存储状态机。这些寄存器被设计为树形二维结构的存储模式,用于存储状态机变换过程中的头区域、主区域和尾区域。每个区域都能够分别存储一个或多个完整的状态块。第一和第二状态机寄存器1和9与第一和第二状态机反向模块2和10、顺序块提取模块6、循环块提取模块7、嵌套循环块提取模块8连接,用于这些模块执行步骤中各个区域状态机的存储和调用。The first and second state machine registers 1 and 9 are used to receive and store the state machine. These registers are designed as a tree-shaped two-dimensional storage mode for storing the header area, the main area, and the tail area in the state machine transformation process. Each zone can store one or more complete status blocks separately. The first and second state machine registers 1 and 9 are connected to the first and second state machine inversion modules 2 and 10, the sequence block extraction module 6, the cyclic block extraction module 7, and the nested loop block extraction module 8, for these The module performs the storage and invocation of each regional state machine in the step.
状态块堆栈4为存储状态块的堆栈寄存器,内部以状态块为基本存储单元,实现了状态块存储的堆栈、队列等存储结构。状态块堆栈4与第一和第二状态机反向模块2和10、提取模块5连接,为主要的状态机等价变换步骤提供了状态块的堆栈存储功能,辅助完成这几个模块中执行的变换步骤。The status block stack 4 is a stack register for storing a status block, and the internal state block is a basic storage unit, and a storage structure such as a stack and a queue for storing the status block is realized. The status block stack 4 is connected to the first and second state machine inversion modules 2 and 10 and the extraction module 5, and provides a stack storage function of the status block for the main state machine equivalent conversion step, assisting in the execution of these modules. Transformation steps.
第一和第二状态机反向模块2和10实现了该方法中的状态机反向步骤,其中第一状态机反向模块2读取初始输入状态机和待提取长度,用于处理反向提取时的第一次状态机逆序变换。第二状态机反向模块10与第二状态机寄存器9和状态块堆栈4连接,用于实现输出时反向提取的状态机进行的状态机逆序变换,并在步骤执行完毕后输出可拼接状态机。The first and second state machine reverse modules 2 and 10 implement the state machine reverse step in the method, wherein the first state machine reverse module 2 reads the initial input state machine and the length to be extracted for processing the reverse The first state machine is reversed when it is extracted. The second state machine inversion module 10 is connected to the second state machine register 9 and the state block stack 4, and is configured to implement a state machine reverse sequence transformation performed by the state machine that is inversely extracted at the output, and outputs a splicable state after the step is executed. machine.
状态块类型判断模块3实现了状态机等价变换方法中的变换类型判断步骤。该模块读取第一状态机反向模块2输出的待变换状态块,并根据执 行结果将状态块输出给顺序块提取模块6、循环块提取模块7或嵌套循环块提取模块8之一。The state block type judging module 3 implements the transform type judging step in the state machine equivalent conversion method. The module reads the status block to be transformed output by the first state machine reverse module 2, and according to the implementation The row result outputs the status block to one of the sequence block extraction module 6, the loop block extraction module 7, or the nested loop block extraction module 8.
提取模块5包含了顺序块提取模块6、循环块提取模块7、嵌套循环块提取模块8。其中顺序块提取模块6实现了本发明的状态机等价变换方法中的顺序块状态提取步骤,循环块提取模块7实现了该方法中的循环块提取步骤,嵌套循环块提取模块8实现了该方法中的嵌套循环块提取步骤。提取模块5将三个不同类型的状态块提取模块集合为一个整体以连接状态块堆栈4,并通过状态块堆栈4进行状态块的存储和调用。提取模块5的输出结果存储至第二状态机寄存器9中。The extraction module 5 includes a sequential block extraction module 6, a cyclic block extraction module 7, and a nested cyclic block extraction module 8. The sequential block extraction module 6 implements the sequential block state extraction step in the state machine equivalent conversion method of the present invention, and the cyclic block extraction module 7 implements the cyclic block extraction step in the method, and the nested loop block extraction module 8 implements A nested loop block extraction step in the method. The extraction module 5 aggregates three different types of state block extraction modules into a whole to connect the state block stack 4, and stores and calls the state blocks through the state block stack 4. The output of the extraction module 5 is stored in the second state machine register 9.
该装置输出的可拼接状态机一般包含三个状态块,这些状态块符合可拼接规则,可用于后续的状态机拼接方法或重新进行状态机等价性判断方法。The splicable state machine output by the device generally includes three state blocks, which conform to the splicable rules, and can be used for subsequent state machine splicing methods or re-determining the state machine equivalence judgment method.
上述装置通过C++编程语言来实现,可以适用于x86、MIPS等处理器体系,用于实现动态可重配流水线的配置与下载工作。该装置也可以通过verilog进行硬件实现,作为独立的可移植的流水线配置模块。The above device is implemented by C++ programming language, and can be applied to x86, MIPS and other processor systems for realizing the configuration and downloading of dynamic reconfigurable pipelines. The device can also be implemented in hardware via verilog as a stand-alone, portable pipeline configuration module.
下面结合具体实施例对本发明作进一步的阐述。The invention is further illustrated below in conjunction with specific embodiments.
实施例1:Example 1:
如图2所示的循环状态块,一次完整的循环包括3个状态,循环次数为N,正向提取长度为2的状态块。As shown in the loop state block of FIG. 2, a complete loop includes three states, the number of loops is N, and the state block of length 2 is forwardly extracted.
第一步:步骤1、状态机预处理步骤Step 1: Step 1, state machine preprocessing steps
输入为1个循环状态块,不是二维结构。为状态块构建一个头区域、一个主区域、一个尾区域,将原循环状态块放入主区域,头区域和尾区域置空,如图3所示。The input is a cyclic state block, not a two-dimensional structure. Construct a header area, a main area, and a tail area for the status block, and place the original loop status block into the main area, and the header area and the tail area are blanked, as shown in FIG.
第二步:步骤2、状态块反向步骤Step 2: Step 2, Status Block Reverse Step
提取方式是正向提取,将输入状态机放入步骤3的输入中,跳转至步骤3。The extraction method is forward extraction, and the input state machine is placed in the input of step 3, and the process proceeds to step 3.
第三步:步骤3、变换类型判断步骤The third step: step 3, transformation type judgment step
读取输入状态机的首个状态块,当前状态块为循环块,跳转至步骤5。 Read the first status block of the input state machine. The current status block is a cyclic block and go to step 5.
第四步:步骤5、循环块状态提取步骤Step 4: Step 5: Loop block state extraction step
该步骤接收输入的循环块,待提取长度为2。This step receives the input loop block and the length to be extracted is 2.
子步骤5.0尾区域长度判断子步骤Substep 5.0 tail region length judgment substep
当前尾区域为空,长度为0,小于待提取长度,跳至子步骤5.1。The current tail area is empty, the length is 0, which is smaller than the length to be extracted, and jump to sub-step 5.1.
子步骤5.1单轮循环提取子步骤Sub-step 5.1 single-round loop extraction sub-step
将循环体内部所有状态按顺序组成一个新的顺序块,将该顺序块放入尾区域的头部,循环块的已循环次数加1(循环体总循环次数减1),如图4所示。跳转至子步骤5.2。All the states inside the loop body are sequentially formed into a new sequence block, and the sequence block is placed in the head of the tail region, and the number of cycles of the loop block is increased by 1 (the total number of cycles of the loop body is reduced by 1), as shown in FIG. . Go to substep 5.2.
子步骤5.2、尾区域提取子步骤Sub-step 5.2, tail region extraction sub-step
待提取长度为2,循环块内部状态数量为3,待提取长度小于循环块内部状态数量。从尾区域的顺序块中提取出头部的2个状态,组成一个新的顺序块放入提取区域的尾部,清空尾区域,提取后的顺序块内状态数为1,将提取后的顺序块(只有一个状态A3)放入尾区域中,如图5所示。跳转至子步骤5.3。The length to be extracted is 2, the number of internal states of the cyclic block is 3, and the length to be extracted is smaller than the number of internal states of the cyclic block. The two states of the header are extracted from the sequential block of the tail region, and a new sequential block is placed in the tail of the extraction region, and the tail region is cleared. The number of states in the extracted sequential block is 1, and the extracted sequential block is (Only one state A3) is placed in the tail region as shown in Figure 5. Go to substep 5.3.
子步骤5.3循环块滚动子步骤Sub-step 5.3 cyclic block rolling substep
将循环块内头部2个状态取出放到循环块内状态的尾部,形成一次循环滚动,并将待提取长度置为0,如图6所示。跳转至子步骤8。The two states of the head in the loop block are taken out to the end of the state in the loop block to form a cyclic scroll, and the length to be extracted is set to 0, as shown in FIG. Go to substep 8.
第五步:步骤8、迭代判断步骤Step 5: Step 8, iterative judgment step
当前待提取长度为0,跳转至步骤9。The current length to be extracted is 0, and the process jumps to step 9.
第六步:步骤9、输出步骤Step 6: Step 9, output steps
此时提取区域包含一个顺序状态块,它有2个状态A1和A2。将提取区域状态块放置到首个状态块头区域的尾部;第二个状态块为一个循环状态块,内部状态依次为A3、A1、A2,循环次数为9;第三个状态块为尾区域状态块,包含一个状态A3。输出这3个状态块,如图7所示。该方法结束。The extraction area now contains a sequential status block with 2 states A1 and A2. The extracted area status block is placed at the end of the first status block header area; the second status block is a cyclic status block, the internal status is A3, A1, A2, and the number of loops is 9; the third status block is the tail status status The block contains a state A3. These three status blocks are output, as shown in Figure 7. The method ends.
实施例2:Example 2:
如图8所示的嵌套循环状态块,一次完整的循环包括1个顺序状态块和一个循环状态块,该循环状态块循环次数为M,嵌套循环块循环次数为N,正向提取长度为2的状态块。 As shown in Figure 8, the nested loop state block, a complete loop includes a sequence state block and a loop state block, the loop state block loop number is M, the nested loop block loop number is N, and the forward extraction length is A status block of 2.
第一步:步骤1、状态机预处理步骤Step 1: Step 1, state machine preprocessing steps
输入为1个嵌套循环状态块,不是二维结构。为状态块构建一个头区域、一个主区域、一个尾区域,将原嵌套循环状态块放入主区域,头区域和尾区域置空。The input is a nested loop state block, not a two-dimensional structure. A header area, a main area, and a tail area are constructed for the status block, and the original nested loop status block is placed in the main area, and the header area and the tail area are set to be empty.
由于该状态块为嵌套循环块,对状态块内的每个状态块构建二维结构。首先对内部顺序块A1构建二维结构:为顺序块构建一个头区域、一个主区域、一个尾区域,将顺序块放入主区域,它的头区域和尾区域置空。再对内部的循环状态块构建二维结构:为循环块构建一个头区域、一个主区域、一个尾区域,将该循环块放入主区域,它的头区域和尾区域置空。Since the state block is a nested loop block, a two-dimensional structure is constructed for each state block within the state block. First, a two-dimensional structure is constructed for the internal sequence block A1: a header area, a main area, and a tail area are constructed for the sequence block, and the order block is placed in the main area, and its header area and the tail area are set to be empty. Then construct a two-dimensional structure for the inner loop state block: construct a head region, a main region, and a tail region for the loop block, and put the loop block into the main region, and its head region and tail region are set to be empty.
预处理完成,如图9所示。跳转到步骤2。The pre-processing is completed as shown in Figure 9. Go to step 2.
第二步:步骤2、状态块反向步骤Step 2: Step 2, Status Block Reverse Step
提取方式是正向提取,将输入状态机放入步骤3的输入中,跳转至步骤3。The extraction method is forward extraction, and the input state machine is placed in the input of step 3, and the process proceeds to step 3.
第三步:步骤3、变换类型判断步骤The third step: step 3, transformation type judgment step
读取输入状态机的首个状态块,当前状态块为嵌套循环块,跳转至步骤6。Read the first status block of the input state machine. The current status block is a nested loop block. Go to step 6.
第四步:步骤6、嵌套循环块状态提取步骤Step 4: Step 6. Nested loop block state extraction step
该步骤接收嵌套循环块输入,待提取长度为2。This step receives the nested loop block input and the length to be extracted is 2.
子步骤6.0、尾区域判断子步骤Sub-step 6.0, tail region judgment sub-step
当前嵌套循环块的尾区域为空,跳至子步骤6.1;The tail region of the current nested loop block is empty, skip to substep 6.1;
子步骤6.1、单轮嵌套循环块提取子步骤Sub-step 6.1, single-round nested loop block extraction sub-step
提取嵌套循环块内的所有状态块,按顺序置于尾区域中,将嵌套循环块的已循环次数加1,如图10所示。跳转至子步骤6.2。All state blocks in the nested loop block are extracted, placed in the tail region in order, and the number of loops of the nested loop block is incremented by 1, as shown in FIG. Go to substep 6.2.
子步骤6.2、嵌套提取子步骤Sub-step 6.2, nested extraction sub-steps
将嵌套循环块的尾区域取出,组成一个新的状态机,该状态机包换一个顺序块A1和一个循环块A2A3。将待提取长度2和新的状态机作为输入,递归调用本方法。The tail region of the nested loop block is taken out to form a new state machine, which replaces a sequence block A1 and a loop block A2A3. The method is recursively called with the length 2 to be extracted and the new state machine as input.
递归第一步:步骤1、状态机预处理步骤Recursive first step: Step 1, state machine preprocessing steps
输入为1个顺序状态块和一个循环状态块,这两个状态块都是二维结构。跳转到步骤2。 The input is a sequential status block and a cyclic status block, both of which are two-dimensional structures. Go to step 2.
递归第二步:步骤2、状态块反向步骤Recursive second step: step 2, state block reverse step
提取方式是正向提取,将输入状态机放入步骤3的输入中,跳转至步骤3。The extraction method is forward extraction, and the input state machine is placed in the input of step 3, and the process proceeds to step 3.
递归第三步:步骤3、变换类型判断步骤Recursive third step: step 3, transformation type judgment step
读取输入状态机的首个状态块为顺序块,跳转至步骤4。Read the first status block of the input state machine as a sequence block and jump to step 4.
递归第四步:步骤4、顺序块状态提取步骤Recursive fourth step: Step 4, sequential block state extraction step
该步骤接收顺序状态块A1,它的长度为1,待提取长度为2。待提取长度大于等于顺序块中的状态数,全部顺序块A1置于提取区域尾部,删除状态机中的该状态块,并将待提取长度减去顺序块中的状态数1,当前待提取长度为1。将提取后的状态机输出,如图11所示。跳转至步骤8。This step receives the sequence status block A1, which has a length of 1 and a length to be extracted of 2. If the number of states to be extracted is greater than or equal to the number of states in the sequence block, all the sequence blocks A1 are placed at the end of the extraction region, the state block in the state machine is deleted, and the length to be extracted is subtracted from the state number 1 in the sequence block, and the current to-be-extracted length Is 1. The extracted state machine is output as shown in FIG. Go to step 8.
递归第五步:步骤8、迭代判断步骤Recursive fifth step: step 8, iterative judgment step
当前待提取长度不为0,将当前状态机和待提取长度1作为步骤3的输入,跳转至步骤3。The current to-be-extracted length is not 0, and the current state machine and the length 1 to be extracted are taken as the input of step 3, and the process proceeds to step 3.
递归第六步:步骤3、变换类型判断步骤Recursive sixth step: step 3, transformation type judgment step
读取输入状态机的首个状态块为循环块,跳转至步骤5。Read the first status block of the input state machine as a loop block and skip to step 5.
递归第七步:步骤5、循环块状态提取步骤Recursive seventh step: Step 5, loop block state extraction step
该步骤接收的循环块为A2A3,循环次数为5,待提取长度为1。The loop block received in this step is A2A3, the number of loops is 5, and the length to be extracted is 1.
子步骤5.0、尾区域长度判断子步骤Sub-step 5.0, tail region length judgment sub-step
当前尾区域为空,长度为0,小于待提取长度1,跳转至子步骤5.1。The current tail region is empty, the length is 0, which is smaller than the length 1 to be extracted, and jumps to sub-step 5.1.
子步骤5.1、单轮循环提取子步骤Sub-step 5.1, single-round loop extraction sub-step
将循环体内部所有状态按顺序组成一个新的顺序块,将该顺序块放入尾区域的头部,将循环块的已循环次数加1,如图12所示。跳转至子步骤5.2。All the states inside the loop body are grouped into a new sequence block in order, and the sequence block is placed in the head of the tail region, and the number of cycles of the loop block is incremented by 1, as shown in FIG. Go to substep 5.2.
子步骤5.2、尾区域提取子步骤Sub-step 5.2, tail region extraction sub-step
待提取长度为1,小于循环块内部状态数量2,将尾区域中的顺序块中提取出头部的1个状态,放入提取区域的尾部,清空尾区域,提取后的顺序块内状态数不为0,则将提取后的顺序块A3放入尾区域中,如图13所示。跳转至子步骤5.3。The length to be extracted is 1, which is smaller than the number of internal states of the loop block. 2, the state of the head is extracted from the sequence block in the tail region, placed in the tail of the extraction region, the tail region is cleared, and the number of states in the sequence block after the extraction is obtained. If it is not 0, the extracted sequential block A3 is placed in the tail region as shown in FIG. Go to substep 5.3.
子步骤5.3、循环块滚动子步骤 Sub-step 5.3, loop block rolling sub-step
将循环块内头部1个状态取出放到循环块内状态的尾部,形成一次循环滚动,并将待提取长度置为0。当前循环块为A3A2,循环次数为M-1,如图14所示。跳转至子步骤8。The state of the head in the loop block is taken out to the end of the state inside the loop block, forming a cyclic scroll, and the length to be extracted is set to zero. The current loop block is A3A2, and the number of loops is M-1, as shown in FIG. Go to substep 8.
递归第八步:步骤8、迭代判断步骤Recursive eighth step: step 8, iterative judgment step
当前待提取长度不为0,跳转至步骤9。The current length to be extracted is not 0, and the process jumps to step 9.
递归第九步:步骤9、输出步骤Recursive ninth step: step 9, output step
将提取区域状态块A1A2放置到首个状态块头区域的尾部。原提取方式是正向提取,递归方法结束。输出第一个状态块为顺序块A1A2,第二个状态块为循环块A3A2,循环次数为M-1,第三个状态块为A3,如图15所示。返回递归调用位置。The extracted area status block A1A2 is placed at the end of the first status block header area. The original extraction method is forward extraction, and the recursive method ends. The first status block is output as the sequence block A1A2, the second status block is the loop block A3A2, the number of loops is M-1, and the third status block is A3, as shown in FIG. Returns the recursive call location.
第四步:步骤6、嵌套循环块状态提取步骤Step 4: Step 6. Nested loop block state extraction step
子步骤6.2嵌套提取子步骤Sub-step 6.2 nested extraction sub-steps
递归调用返回,返回的首个状态块为顺序块A1A2,将它取出放入提取区域的尾部。跳转至子步骤6.3。The recursive call returns, the first status block returned is the sequence block A1A2, which is taken out to the end of the extraction area. Go to substep 6.3.
子步骤6.3嵌套滚动子步骤Sub-step 6.3 nested scroll substeps
将嵌套循环块内所有状态块取出,按顺序组成一个新的状态机,它包含一个循序块A1和一个循环块A2A3,循环次数为5。递归调用本方法,输入为该状态机,待提取长度为2。本次递归调用过程与之前一次完全相同。返回的状态机首个状态块为顺序块A1A2,将它取出放在返回状态机的最后一个状态块后面,并用该状态机内的状态块替换嵌套循环块内的所有状态块。当期嵌套循环块内的所有状态块依次是:循环块A3A2,循环次数为4;顺序块A3;顺序块A1A2。将待提取长度置为0,如图16所示。跳转至步骤8。All state blocks in the nested loop block are fetched, and a new state machine is formed in order, which includes a sequential block A1 and a loop block A2A3, and the number of loops is 5. This method is called recursively, and the input is the state machine, and the length to be extracted is 2. This recursive call process is exactly the same as the previous one. The first state block returned by the state machine is the sequence block A1A2, which is taken out after the last state block of the return state machine, and all state blocks within the nested loop block are replaced with state blocks within the state machine. All the status blocks in the current nested loop block are: loop block A3A2, loop number 4; sequence block A3; sequence block A1A2. Set the length to be extracted to 0, as shown in Figure 16. Go to step 8.
第五步:步骤8、迭代判断步骤Step 5: Step 8, iterative judgment step
当前待提取长度为0,跳转至步骤9。The current length to be extracted is 0, and the process jumps to step 9.
第六步:步骤9、输出步骤Step 6: Step 9, output steps
将提取区域状态块A1A2,放置到首个状态块头区域的尾部。提取方式为正向提取,该方法结束。最终输出的状态机如图17所示。The extracted area status block A1A2 is placed at the end of the first status block header area. The extraction method is forward extraction, and the method ends. The final output state machine is shown in Figure 17.
以上所述的具体实施例,对本发明的目的、技术方案和有益效果进行了进一步详细说明,应理解的是,以上所述仅为本发明的具体实施例而已, 并不用于限制本发明,凡在本发明的精神和原则之内,所做的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。 The specific embodiments described above further explain the objects, technical solutions and advantageous effects of the present invention. It should be understood that the above description is only specific embodiments of the present invention. It is not intended to limit the invention, and any modifications, equivalents, improvements, etc., made within the spirit and scope of the invention are intended to be included within the scope of the invention.

Claims (8)

  1. 一种状态机等价变换的方法,包括以下步骤:A method for equivalent transformation of a state machine includes the following steps:
    步骤1,将状态机的状态块初始化成树形二维结构;Step 1: initialize the state block of the state machine into a tree-shaped two-dimensional structure;
    步骤2,读取一个状态机和状态机的状态提取方式,根据状态提取方式对状态机选择输出或反向;如果提取方式是正向提取,则将输入状态机放入步骤3的输入中,跳转至步骤3;如果提取方式是反向提取,则将状态块放入步骤2.1的输入中,调用步骤2.1,将步骤2.1返回的状态块替换状态机中的原状态块,并将新状态机放入步骤3的输入,跳转至步骤3;Step 2: Read a state extraction mode of the state machine and the state machine, select output or reverse for the state machine according to the state extraction mode; if the extraction mode is forward extraction, put the input state machine into the input of step 3, and jump Go to step 3; if the extraction mode is reverse extraction, put the status block into the input of step 2.1, call step 2.1, replace the status block returned in step 2.1 with the original status block in the state machine, and add the new state machine Put in the input of step 3, jump to step 3;
    步骤2.1,将输入状态机的尾区域标示为头区域,同时将原头区域标识为尾区域;In step 2.1, the tail region of the input state machine is marked as a header region, and the original header region is identified as a tail region;
    其中,如果当前主区域为嵌套循环块,则将嵌套循环块中的状态块,颠倒序列,并对每个状态块调用步骤2.1,用返回的状态块替换嵌套循环块中的原状态块;如果当前主区域不是嵌套循环块,则将主区域中状态块里所有状态颠倒顺序;Wherein, if the current main area is a nested loop block, the status block in the loop block is nested, the sequence is reversed, and step 2.1 is called for each status block, and the original state in the nested loop block is replaced with the returned status block. Block; if the current main area is not a nested loop block, reverse all the states in the status block in the main area;
    将调整后的状态块输出,返回到调用当前此步骤的前一个步骤中;Output the adjusted status block and return to the previous step of calling the current step;
    步骤3,读取一个输入状态机的首个状态块,判断该状态块的类型,并跳转到相应状态块状态提取的步骤中;其中Step 3, reading the first status block of an input state machine, determining the type of the status block, and jumping to the step of extracting the status of the corresponding status block;
    如果当前状态块为顺序块,则跳转至步骤4;If the current status block is a sequential block, then jump to step 4;
    如果当前状态块为循环块,则跳转至步骤5;If the current status block is a loop block, then jump to step 5;
    如果当前状态块为嵌套循环块,则跳转至步骤6;If the current status block is a nested loop block, then jump to step 6;
    步骤4,接收一个顺序状态块和待提取长度作为输入,从输入顺序块头部提取出指定数量个状态置于头区域中,并修改待提取长度;将提取后的状态机输出,跳转至步骤8;Step 4: receiving a sequence status block and a length to be extracted as an input, extracting a specified number of states from the input sequence block header into the header area, and modifying the length to be extracted; outputting the extracted state machine to jump to Step 8;
    步骤5,接收一个循环块和待提取长度作为输入,判断待提取长度与循环块内部状态数量和尾区域状态数量,提取指定数量的状态;Step 5: Receive a loop block and a length to be extracted as an input, determine a length to be extracted, a number of internal states of the loop block, and a number of state of the tail region, and extract a specified number of states;
    子步骤5.0,计算循环块尾区域的长度,并判断当前是否需要提取一次循环块; Sub-step 5.0, calculating the length of the loop block tail region, and determining whether it is necessary to extract a loop block at present;
    子步骤5.1,将循环体内部所有状态按顺序组成一个新的顺序块,将该顺序块放入尾区域的头部,将循环块的已循环次数加1,跳转至子步骤5.2;Sub-step 5.1, all the states inside the loop body are sequentially formed into a new sequential block, the order block is placed in the head of the tail region, the number of cycles of the loop block is incremented by 1, and the jump to sub-step 5.2;
    子步骤5.2,如果待提取长度大于等于循环块内部状态数量,则将尾区域中首个顺序块放到提取区域的尾部,并将待提取数量减去循环块内部状态数量,跳转到步骤8;如果待提取长度小于循环块内部状态数量,则将尾区域中的顺序块按顺序合并成一个顺序块,然后从合并的顺序块中提取出头部的待提取长度个状态,组成一个新的顺序块放入提取区域的尾部,清空尾区域,若提取后的顺序块内状态数不为0,则将提取后的顺序块放入尾区域中。跳转至子步骤5.3;Sub-step 5.2, if the length to be extracted is greater than or equal to the number of internal states of the loop block, the first sequential block in the tail region is placed at the end of the extraction region, and the number of states to be extracted is subtracted from the number of states in the loop block, and the process proceeds to step 8. If the length to be extracted is less than the number of internal states of the loop block, the sequential blocks in the tail region are merged into one sequential block in order, and then the lengths of the head to be extracted are extracted from the merged sequential blocks to form a new one. The sequence block is placed at the end of the extraction area, and the tail area is cleared. If the number of states in the extracted sequence block is not 0, the extracted sequence block is placed in the tail area. Go to substep 5.3;
    子步骤5.3,将循环块内头部待提取长度个状态取出放到循环块内状态的尾部,形成一次循环滚动,并将待提取长度置为0,跳转至子步骤8;Sub-step 5.3, the state of the head to be extracted in the loop block is taken out to the end of the state in the loop block, forming a cyclic scroll, and the length to be extracted is set to 0, and jumps to sub-step 8;
    步骤6,接收嵌套循环块和待提取长度作为输入,从输入嵌套循环块头部提取出指定数量个状态,输出可用于状态机拼接的状态块的组合;Step 6, receiving the nested loop block and the length to be extracted as an input, extracting a specified number of states from the input nested loop block header, and outputting a combination of the state blocks usable for the state machine splicing;
    子步骤6.0,如果尾区域为空,则跳至子步骤6.1;如果尾区域非空,则跳至子步骤6.2;Sub-step 6.0, if the tail region is empty, skip to sub-step 6.1; if the tail region is not empty, skip to sub-step 6.2;
    子步骤6.1,提取嵌套循环块内的所有状态块,按顺序置于尾区域中,将嵌套循环块的已循环次数加1,跳转至子步骤6.2;Sub-step 6.1, extract all the state blocks in the nested loop block, put them in the tail region in order, add the number of cycles of the nested loop block to 1, and jump to sub-step 6.2;
    子步骤6.2,将嵌套循环块的尾区域取出,组成一个新的状态机,将待提取长度和新的状态机作为输入,递归调用本方法,将返回的状态机的首个状态块的头区域内所有状态块取出,放入提取区域的尾部,跳转至子步骤6.3;Sub-step 6.2, taking the tail region of the nested loop block to form a new state machine, taking the length to be extracted and the new state machine as input, recursively calling the method, and returning the header of the first state block of the state machine All state blocks in the area are taken out, placed in the tail of the extraction area, and jump to sub-step 6.3;
    子步骤6.3,将嵌套循环块内所有状态块取出,按顺序组成一个新的状态机,待提取长度和新的状态机作为输入,递归调用本方法,将返回的状态机的首个状态块的头区域内所有状态块取出放到返回的状态机的最后一个状态块后面,并用该状态机内的状态块替换嵌套循环块内的所有状态块,并将待提取长度置为0,跳转至步骤8;Sub-step 6.3, taking out all the state blocks in the nested loop block, forming a new state machine in order, and extracting the length and the new state machine as input, recursively calling the method, and returning the first state block of the state machine All state blocks in the header area are fetched after the last state block of the returned state machine, and all state blocks in the nested loop block are replaced with state blocks in the state machine, and the length to be fetched is set to 0, hopping Go to step 8;
    步骤8,如果当前待提取长度不为0,则将当前状态机和待提取长度作为步骤3的输入,跳转至步骤3,否则跳转至步骤9; Step 8, if the current to-be-extracted length is not 0, the current state machine and the length to be extracted are taken as the input of step 3, and the process proceeds to step 3, otherwise the process proceeds to step 9.
    步骤9,将提取区域,放置到首个状态块头区域的尾部;如果原提取方式是反向提取,将首个状态块放入步骤2.1的输入中,调用步骤2.1,将步骤2.1返回的状态块替换状态机中的原状态块,该方法结束;否则该方法结束。Step 9, the extraction area is placed at the end of the first status block header area; if the original extraction mode is reverse extraction, the first status block is placed in the input of step 2.1, and step 2.1 is invoked, and the status block returned in step 2.1 is returned. The method replaces the original status block in the state machine; otherwise the method ends.
  2. 根据权利要求1所述的状态机等价变换的方法,其中所述步骤1包括:The method of equivalence transformation of a state machine according to claim 1, wherein said step 1 comprises:
    对于输入状态机的每个状态块,判断其是否已经是二维结构,即由头区域、主区域和尾区域组成,如果是,则该状态机是已经参与过等价变换的状态机,跳转到步骤2;如果不是,则为状态块构建一个头区域、主区域和尾区域的二维结构,将原状态块放入主体部分,头区域和尾区域置空,若状态块是嵌套循环块则对状态块内的每个状态块构建二维结构;For each state block of the input state machine, it is judged whether it is already a two-dimensional structure, that is, composed of a header region, a main region, and a tail region, and if so, the state machine is a state machine that has participated in the equivalent transformation, and jumps Go to step 2; if not, construct a two-dimensional structure of the head region, the main region, and the tail region for the state block, put the original state block into the body portion, and empty the header region and the tail region, if the state block is a nested loop The block constructs a two-dimensional structure for each state block within the state block;
    跳转到步骤2。Go to step 2.
  3. 根据权利要求1所述的状态机等价变换的方法,其中步骤4中所述接收一个顺序状态块和待提取长度作为输入,从输入顺序块头部提取出指定数量个状态置于头区域中,并修改待提取长度的步骤的特征是:A method for equivalence transformation of a state machine according to claim 1, wherein in step 4, said receiving a sequence state block and a length to be extracted as an input, extracting a specified number of states from the input sequence block header into the header region And the features of the step of modifying the length to be extracted are:
    若待提取长度小于等于顺序块中的状态数,从状态块开始处进行提取,从当前状态块第一个状态开始按顺序提取出指定数量个状态,把这些状态合并为一个新的顺序状态块,把这个状态块置于提取区域尾部;提取剩余的部分作为新的顺序状态块,替换原状态块。将待提取长度置为零。If the length to be extracted is less than or equal to the number of states in the sequence block, the extraction is started from the beginning of the state block, and the specified number of states are sequentially extracted from the first state of the current state block, and the states are merged into a new sequential state block. , put this state block at the end of the extraction area; extract the remaining part as a new sequential status block, replacing the original status block. Set the length to be extracted to zero.
    若待提取长度大于等于顺序块中的状态数,将全部顺序块置于提取区域尾部,删除状态机中的该状态块,并将待提取长度减去顺序块中的状态数。If the length to be extracted is greater than or equal to the number of states in the sequence block, all the sequence blocks are placed at the end of the extraction region, the state block in the state machine is deleted, and the number of states in the sequence block is subtracted from the length to be extracted.
  4. 一种状态机的等价变换装置,包括:An equivalent conversion device for a state machine, comprising:
    第一和第二状态机寄存器(1、9),用于接收和存储变换过程中的头区域、主区域和尾区域;First and second state machine registers (1, 9) for receiving and storing a header area, a main area, and a tail area in the transform process;
    状态块类型判断模块(3),实现了状态机等价变换方法中的变换类型判断步骤;该模块读取第一状态机反向模块(2)输出的待变换状态块,并根据执行结果将状态块输出给顺序块提取模块(6)、循环块提取模块(7)或嵌套循环块提取模块(8)之一; The state block type judging module (3) implements a transform type judging step in the state machine equivalence transform method; the module reads the to-be-transformed state block output by the first state machine inversion module (2), and according to the execution result The status block is output to one of the sequential block extraction module (6), the cyclic block extraction module (7) or the nested cyclic block extraction module (8);
    第一和第二状态机反向模块(2、10),实现了状态机反向步骤,其中所述第一状态机反向模块(2)读取初始输入状态机和待提取长度,用于处理反向提取时的第一次状态机逆序变换;所述第二状态机反向模块(10)与所述第二状态机寄存器(9)和状态块堆栈(4)连接,用于实现输出时反向提取的状态机进行的状态机逆序变换,并在步骤执行完毕后输出可拼接状态机;The first and second state machine reversal modules (2, 10) implement a state machine reversal step, wherein the first state machine reversal module (2) reads the initial input state machine and the length to be extracted for Processing a first state machine reverse-order transformation during reverse extraction; the second state machine inversion module (10) is coupled to the second state machine register (9) and the state block stack (4) for implementing an output The state machine performed by the backward extraction state machine reverses the sequence, and outputs a splicable state machine after the step is executed;
    状态块堆栈(4),与所述第一和第二状态机反向模块(2、10)、提取模块(5)连接,为主要的状态机等价变换步骤提供了状态块的堆栈存储功能,辅助完成这几个模块中执行的变换步骤;a status block stack (4) coupled to the first and second state machine inversion modules (2, 10) and the extraction module (5) to provide a stack storage function for the status block for the primary state machine equivalent transformation step , assisting in the transformation steps performed in these modules;
    提取模块(5),包含了顺序块提取模块(6)、循环块提取模块(7)、嵌套循环块提取模块(8);其中所述顺序块提取模块(6)实现了顺序块状态提取步骤,所述循环块提取模块(7)实现了循环块提取步骤,所述嵌套循环块提取模块(8)实现了嵌套循环块提取步骤;所述提取模块(5)将三个不同类型的状态块提取模块集合为一个整体以连接所述状态块堆栈(4),并通过所述状态块堆栈(4)进行状态块的存储和调用;所述提取模块(5)的输出结果存储至所述第二状态机寄存器(9)中。The extraction module (5) comprises a sequential block extraction module (6), a cyclic block extraction module (7), and a nested cyclic block extraction module (8); wherein the sequential block extraction module (6) implements sequential block state extraction Step, the loop block extraction module (7) implements a loop block extraction step, the nested loop block extraction module (8) implements a nested loop block extraction step; the extraction module (5) will have three different types The state block extraction module is assembled as a whole to connect the state block stack (4), and the state block is stored and called through the state block stack (4); the output result of the extraction module (5) is stored to The second state machine register (9).
  5. 根据权利要求4所述的状态机的等价变换装置,其中所述第一和第二状态机寄存器(1、9)设计为树形二维结构的存储模式。The equivalent conversion apparatus of the state machine according to claim 4, wherein said first and second state machine registers (1, 9) are designed as a storage mode of a tree-shaped two-dimensional structure.
  6. 根据权利要求4所述的状态机的等价变换装置,其中所述状态块堆栈(4)为存储状态块的堆栈寄存器,内部以状态块为基本存储单元,实现了状态块存储的堆栈、队列等存储结构。The equivalent conversion apparatus of the state machine according to claim 4, wherein said status block stack (4) is a stack register for storing a status block, and a status block is used as a basic storage unit, and a stack and a queue for storing the status block are implemented. And other storage structures.
  7. 根据权利要求4所述的状态机的等价变换装置,其中所述等价变换装置通过C++编程语言来实现,适用于x86或MIPS处理器体系。The equivalent conversion apparatus of a state machine according to claim 4, wherein said equivalent conversion means is implemented by a C++ programming language and is suitable for an x86 or MIPS processor system.
  8. 根据权利要求4所述的状态机的等价变换装置,其中所述等价变换装置通过verilog进行硬件实现,作为独立的可移植的流水线配置模块。 The equivalent conversion apparatus of a state machine according to claim 4, wherein said equivalent conversion means is implemented by hardware in verilog as an independent portable pipeline configuration module.
PCT/CN2015/094489 2014-12-26 2015-11-12 Equivalent transformation method and device for state machine WO2016101726A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201410836231.6A CN104572028B (en) 2014-12-26 2014-12-26 A kind of method and apparatus of state machine equivalence transformation
CN201410836231.6 2014-12-26

Publications (1)

Publication Number Publication Date
WO2016101726A1 true WO2016101726A1 (en) 2016-06-30

Family

ID=53088205

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2015/094489 WO2016101726A1 (en) 2014-12-26 2015-11-12 Equivalent transformation method and device for state machine

Country Status (2)

Country Link
CN (1) CN104572028B (en)
WO (1) WO2016101726A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104572028B (en) * 2014-12-26 2017-06-20 中国科学院自动化研究所 A kind of method and apparatus of state machine equivalence transformation

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101013447A (en) * 2006-01-31 2007-08-08 株式会社东芝 Automatic design apparatus, automatic design method, and automatic design program of digital circuit
CN101517533A (en) * 2006-09-15 2009-08-26 微软公司 Transformation of modular finite state transducers
CN101517531A (en) * 2006-09-15 2009-08-26 微软公司 Transformation of modular finite state transducers
CN104572028A (en) * 2014-12-26 2015-04-29 中国科学院自动化研究所 Equivalent transformation method and device of finite state machine

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6233544B1 (en) * 1996-06-14 2001-05-15 At&T Corp Method and apparatus for language translation
CN101196810B (en) * 2006-12-08 2012-01-11 中颖电子股份有限公司 Built-in equipment operation method
US8484154B2 (en) * 2009-12-14 2013-07-09 Intel Corporation Methods and systems to traverse graph-based networks
US8201119B2 (en) * 2010-05-06 2012-06-12 Synopsys, Inc. Formal equivalence checking between two models of a circuit design using checkpoints

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101013447A (en) * 2006-01-31 2007-08-08 株式会社东芝 Automatic design apparatus, automatic design method, and automatic design program of digital circuit
CN101517533A (en) * 2006-09-15 2009-08-26 微软公司 Transformation of modular finite state transducers
CN101517531A (en) * 2006-09-15 2009-08-26 微软公司 Transformation of modular finite state transducers
CN104572028A (en) * 2014-12-26 2015-04-29 中国科学院自动化研究所 Equivalent transformation method and device of finite state machine

Also Published As

Publication number Publication date
CN104572028A (en) 2015-04-29
CN104572028B (en) 2017-06-20

Similar Documents

Publication Publication Date Title
CN110825440B (en) Instruction execution method and device
EP3912074B1 (en) Generating a synchronous digital circuit from a source code construct defining a function call
AU2014203218A1 (en) Memory configuration for inter-processor communication in an MPSoC
CN110032363B (en) Data structure construction method and system for robot programming
KR102013657B1 (en) Apparatus for statically analyzing assembly code including assoxiated multi files
JP6257745B2 (en) Method for improving the speed of executing a return branch instruction in a processor
WO2016101726A1 (en) Equivalent transformation method and device for state machine
WO2016101725A1 (en) Method and device for determining finite state machine spliceability and splicing rules
CN104503733A (en) Merging method and device for state machine
US11960866B2 (en) Method and system for constructing compiler intermediate representations from TensorFlow graph
CN114449063B (en) Message processing method, device and equipment
US9703920B2 (en) Intra-run design decision process for circuit synthesis
US8385340B1 (en) Pipeline of a packet processor programmed to concurrently perform operations
JP4383496B1 (en) Microcomputer and instruction execution method thereof
CN111179175B (en) Image processing method and device based on convolutional neural network and storage medium
US11531869B1 (en) Neural-network pooling
CN113705795A (en) Convolution processing method and device, convolution neural network accelerator and storage medium
CN113779311A (en) Data processing method, device and storage medium
JP2010238057A (en) Apparatus, method and program for extracting test restriction
WO2024125340A1 (en) Clock tree gate delay optimization method and system, and device and computer storage medium
JP2006285721A (en) Arithmetic processing device and arithmetic processing method
CN112862109B (en) Deep learning model execution method and device, electronic equipment and storage medium
US9250898B2 (en) VLIW processor, instruction structure, and instruction execution method
US9621130B2 (en) Configurable generic filter hardware block and methods
CN117251298B (en) Pipeline task cyclic execution method, system, equipment and medium

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 15871796

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 15871796

Country of ref document: EP

Kind code of ref document: A1