# Patent

## Title
Recognition of a state machine in high-level integrated circuit description language code

## Abstract

A method and apparatus for recognizing a state machine in circuit design in a high-level IC description language. The present invention analyzes high-level IC description language code, such as VHDL and Verilog®, of an IC design and extracts description information corresponding to a state machine. The description information can be, for example, the high-level IC description language code corresponding to the state machine, a state diagram of the state machine, a state table for the state machine, or other representation of the state machine. In one embodiment, the present invention identifies a set of one or more processes as defined by VHDL “process” statements. By identifying one or more clocked processes, one or more transition processes, and one or more output processes, the present invention provides a state machine summary to describe the state machine identified in the high-level IC description language code.

## Background
CROSS-REFERENCE TO PRIOR APPLICATIONS
This application is a continuation of U.S. application Ser. No. 09/140,633, filed Aug. 26, 1998, now U.S. Pat. No. 6,675,359, and issued Jan. 6, 2004, which is hereby incorporated by reference.


FIELD OF THE INVENTION
The present invention relates to use of high-level integrated circuit description languages. More particularly, the present invention relates to analysis of high-level integrated circuit description language to identify code sequences defining integrated circuit implementations of state machines.
BACKGROUND OF THE INVENTION
High-level integrated circuit (IC) description languages such as VHDL and Verilog® are commonly used to design circuits. One embodiment of VHDL is described in greater detail in “IEEE Standard VHDL Language Reference Manual,” ANSI Std. 1076–1993, published Jun. 6, 1994. One embodiment of Verilog® is described in greater detail in “IEEE Standard Hardware Description Language Based on the Verilog® Hardware Description Language,” IEEE Standard 1364–1995, published Oct. 14, 1996. These high-level IC description languages allow a circuit designer to design and simulate circuits by using high-level code to describe the structure and/or behavior of the circuit being designed.
The high-level IC description language code is used to produce a netlist that describes an interconnection of circuit components to provide desired functionality. The netlist can then be used to develop the layout and ultimately fabricate an IC having the functionality of the designed circuit. The netlist can also be used for verification purposes.
Over time, many complex circuits have been designed using high-level IC description languages. The complexity of the code describing the circuits increases with the complexity of the circuit described, which in turn increases the cost of modifications to customize the circuit for new environments especially if the code is poorly documented and/or the original circuit designer is not available.
One component of a circuit design that is often modified to adapt the circuit design to a new environment is the state machine. A state machine is often used for control purposes, which is dependent on the environment in which the circuit design must operate. Therefore, in order to modify the circuit design to operate in a new environment, the state machine is often modified accordingly.
What is needed is a tool for recognizing and extracting state machines from high-level IC description language code.
SUMMARY OF THE INVENTION
A method and apparatus for identifying a integrated circuit (IC) implementation of a state machine in high-level IC description language code is described. One or more transition processes within the high-level IC description language code are identified. A state machine summary is built based at least in part on the one or more transition processes identified.
In one embodiment, one or more clocked processes and one or more output processes are also identified. A state machine summary is built based at least in part on the one or more transition processes, the one or more clocked processes and the one or more output processes. In one embodiment, the state machine summary is a textual description of the state machine. Alternatively, the state machine summary is a graphical representation of the state machine.



BRIEF DESCRIPTION OF THE DRAWINGS
The present invention is illustrated by way of example, and not by way of limitation, in the figures of the accompanying drawings in which like reference numerals refer to similar elements.
FIG. 1 is one embodiment of a computer system suitable for use to practice the present invention.
FIG. 2 is one embodiment of a block diagram of a recognition and extraction process for extracting a state machine from high-level IC description language code.
FIGS. 3a–3n are one embodiment of VHDL code describing a state machine implementation.
FIG. 4 is one embodiment of a flow diagram for recognizing a state machine according to the present invention.
FIG. 5 is one embodiment of a flow diagram for identifying a clocked process according to the present invention.
FIG. 6 is one embodiment of a flow diagram for identifying a reset clause according to the present invention.
FIG. 7 is one embodiment of a flow diagram for identifying a clock clause according to the present invention.
FIG. 8 is one embodiment of a flow diagram for identifying a process providing a next state assignment according to the present invention.
FIG. 9 is one embodiment of a flow diagram for identifying an output process according to the present invention.
FIG. 10 is one embodiment of a flow diagram for building a state machine summary according to the present invention.
FIG. 11 is one embodiment of a flow diagram for storing process information according to the present invention.
FIG. 12 is one embodiment of an output generated describing the state machine of FIGS. 3a–3n according to the present invention.



DETAILED DESCRIPTION
A method and apparatus for recognizing and extracting a state machine representation from high-level integrated (IC) description language code is described. In the following description, for purposes of explanation, numerous specific details are set forth in order to provide a thorough understanding of the present invention. It will be apparent, however, to one skilled in the art that the present invention can be practiced without these specific details. In other instances, well-known structures and devices are shown in block diagram form in order to avoid obscuring the present invention.
Briefly, the present invention analyzes high-level IC description language code, such as VHDL and Verilog®, of an IC design and extracts description information corresponding to a state machine. The description information can be, for example, the high-level IC description language code corresponding to the state machine, a state diagram of the state machine, a state table for the state machine, or other representation of the state machine. In one embodiment, the present invention identifies a set of one or more processes as defined by VHDL “process” statements. By identifying one or more clocked processes, one or more transition processes, and/or one or more output processes, the present invention provides a state machine summary to describe the state machine identified in the high-level IC description language code.
FIG. 1 is one embodiment of a computer system suitable for use to practice the present invention. Computer system 100 includes bus 101 or other communication device for communicating information, and processor 102 coupled with bus 101 for processing information. Computer system 100 further includes random access memory (RAM) or other dynamic storage device 104 (referred to as main memory), coupled to bus 101 for storing information and instructions to be executed by processor 102. Main memory 104 also can be used for storing temporary variables or other intermediate information during execution of instructions by processor 102. Computer system 100 also includes read only memory (ROM) and/or other static storage device 106 coupled to bus 101 for storing static information and instructions for processor 102. Data storage device 107 is coupled to bus 101 for storing information and instructions.
Data storage device 107 such as a magnetic disk or optical disc and its corresponding drive can be coupled to computer system 100. Computer system 100 can also be coupled via bus 101 to display device 121, such as a cathode ray tube (CRT) or liquid crystal display (LCD), for displaying information to a computer user. Alphanumeric input device 122, including alphanumeric and other keys, is typically coupled to bus 101 for communicating information and command selections to processor 102. Another type of user input device is cursor control 123, such as a mouse, a trackball, or cursor direction keys for communicating direction information and command selections to processor 102 and for controlling cursor movement on display 121.
The present invention is related to the use of computer system 100 to recognize and extract a state machine from high-level IC description language code. According to one embodiment, recognition and extraction of state machine code from high-level IC description language code is performed by computer system 100 in response to processor 102 executing sequences of instructions contained in memory 104. Execution of the sequences of instructions contained in memory 104 causes processor 102 to recognize and extract state machine code in high-level IC description language code, as will be described hereafter.
Instructions are provided to main memory 104 from a storage device, such as magnetic disk, CD-ROM, DVD, via a remote connection (e.g., over a network), etc. In alternative embodiments, hard-wired circuitry can be used in place of or in combination with software instructions to implement the present invention. Thus, the present invention is not limited to any specific combination of hardware circuitry and software structure.
FIG. 2 is one embodiment of a block diagram of a recognition and extraction process for extracting a state machine from high-level IC description language code. The components of FIG. 2 analyze high-level IC description language code for segments or sequences of instructions that define a state machine implementation in the IC circuit design.
The present invention is described below using block diagrams. The blocks of the block diagrams are not intended to specifically denote either hardware or software implementation for components or devices. For example, the recognition and extraction engine can be a software entity that performs the functions described below, or the recognition and extraction engine can be a hardware device designed to perform the functions described below. Alternatively, the recognition and extraction engine can be some combination of hardware and software. The high-level IC description language code defining the state machine is recognized and information is extracted from the high-level IC description language code and produced as output data. The extracted information describing a state machine can be used, for example, to generate a graphical representation of the state machine as described in U.S. Pat. No. 6,480,985, which issued Nov. 12, 2002 and was filed Aug. 26, 1998, entitled “METHOD AND APPARATUS FOR GRAPHICALLY PRESENTING AN INTEGRATED CIRCUIT DESIGN,” which is assigned to the corporate assignee of the present invention and hereby incorporated by reference. Alternatively, the output file can include a textual description of the state machine as is described in greater detail below.
High-level IC description language code 200 is any file or set of data including code written according to a high-level IC description language. The present invention is generally described in terms of VHDL code; however, any high-level IC description language, such as Verilog® can be used.
Analog/mixed-signal versions of high-level IC description languages (e.g., HDL-ATM, VHDL-AMS, Verilog®-AMS) can also be used for high-level IC description language code 200. One embodiment of VHDL-AMS is described in greater detail in 1076.1 Language Design Committee, several papers under the generic name “White Papers”, IEEE 1076.1 Internal work, 1996, and “1076.1 Working Document: Definition of Analog Extensions to IEEE Standard VHDL”, IEEE 1076.1 Committee Internal work, July, 1997.
High-level IC description language code 200 provides input to recognition and extraction engine 210. In one embodiment, recognition and extraction engine 210 is a computer system, such as computer system 100 of FIG. 1, executing a sequence of instructions to perform the process of recognition and extraction of state machine code; however, special purpose computer systems or other diagnostic or simulation tools can also be used.
Recognition and extraction engine 210 generates an output that is state machine description 220. In one embodiment, state machine description 220 is a graphical representation of a state diagram corresponding to the extracted state machine. Alternatively, state machine description 220 is a textual or tabular representation of the state machine and corresponding states.
In one embodiment, recognition and extraction engine 210 identifies the following attributes for each state machine recognized: state variables, states for each state variable, one or more transition processes for each state variable, a clock signal for the state machine, a reset signal for the state machine, a clocked process for each state variable, and one or more output processes for each state variable. Other combinations of attributes including some or all of the above attributes can also be used to describe a state machine.
In general, identifying one of the attributes listed above aids in the identification of the remaining attributes. In addition, identification of attributes can cause re-evaluation of previously identified attributes. Typically, identification of a clocked process is one of the easier attributes to identify, therefore recognition starts with identification of one or more clocked processes; however, recognition can start with identification of other attributes such as transition processes. Also, identification of a clocked process simplifies identification of clock signal(s), reset signal(s) and state variables.
In one embodiment, state variables are identified before a transition process is identified because a transition process is easier to find after the state variables on which it operates are identified than before. Output processes can then be identified, if necessary.
Identification of attributes is not required to proceed in the manner described; however, doing so can increase run-time performance. Because clocked processes are often the easiest attribute to identify, doing so first simplifies the overall state machine recognition process by reducing the number of processing iterations that are performed to recognize a state machine.
In one embodiment, attributes are recognized in the following order: a clocked process for each state variable, a reset signal, a clock signal, state variables, one or more transition processes for each state variable, one or more output processes for each state variable, and the states for each state variable. The last two attributes are easily interchanged because the two attributes are not interrelated. Alternatively, a transition process and state variables are identified to describe the state machine.
FIGS. 3a–3n are one embodiment of VHDL code describing a state machine implementation. The state machine of FIGS. 3a–3n is a concurrent state machine that can be recognized and extracted with the present invention. The state machine of FIGS. 3a–3n provides one embodiment of a universal asynchronous receiver/transmitter (UART).
FIG. 4 is one embodiment of a flow diagram for recognizing a state machine according to the present invention. In one embodiment, the recognition and extraction engine parses the high-level IC description language code to identify all processes, 410. The recognition and extraction engine identifies each “process” statement in VHDL code. In the example of FIGS. 3a–3n the following six processes are identified: machine0_clocked (FIG. 3c); machine0_nextstate (FIG. 3d); machine0_output (FIG. 3g); machine1_clocked (FIG. 3i); machine1_nextstate (FIG. 3j); and machine1_output (FIG. 3l). When parsing Verilog® code, the recognition and extraction engine identifies “always” or “initial” statements.
After the processes are identified, a subset of clocked processes are identified, 420. In one embodiment, to determine whether a process is a clocked process, the recognition and extraction engine parses the process (or always/initial structure in Verilog®) for a condition that changes the state of the process on a clock transition. In the example of FIGS. 3a–3n, the following two clocked processes are identified: machine0_clocked (FIG. 3c); and machine1_clocked (FIG. 3i).
Transition processes are identified, 430. Transition processes are processes in which state assignments are made. For example, in the state machine of FIGS. 3a–3n, the following two transition processes are identified: machine0_nextstate (FIG. 3d); and machine1_nextstate (FIG. 3j).
Output processes are identified, 440. Output processes are processes that assign a value to a non-state variable output signal. For example, in the state machine of FIGS. 3a–3n, the following two output processes are identified: machine0_output (FIG. 3g); and machine1_otuput (FIG. 3l).
A state machine summary is built, 450. One embodiment of a state machine summary is described in greater detail below with respect to FIG. 12. The state machine summary can be used, for example, to generate a graphical representation (470) of the state machine including a state diagram or a state table.
In one embodiment, an indicator of whether a state machine was recognized is generated, 460. The indicator can be used, for example, to determine whether the recognition and extraction process should continue.
FIG. 5 is one embodiment of a flow diagram for identifying a clocked process according to the present invention. Both VHDL and Verilog® embodiments find IF statements to identify a state machine implementation. An IF-THEN-ELSE statement in VHDL consists of:
IF <condition> THEN <then-part> [optional ELSIF part] [optional ELSE part] ENDIF;
where [optional ELSIF part] is zero or more:
ELSIF <condition> THEN <else-if-then part>;
and [optional ELSE part] is zero or one:
ELSE <else part>.
Verilog® syntax is slightly different. In Verilog® an IF-THEN-ELSE statement consists of:
if <condition> [optional else part];
where [optional else part] is:
else <else-statement>.
In Verilog® an <else-statement> may itself be an if statement, which results in:
else if <condition> <then-statement> else <else-statement>.
Each process is checked for a sensitivity list, 510. If the process does not have a sensitivity list and the process is not the final process at 565, the next process is evaluated, 570. If the process is the final process at 565, evaluation is complete.
If the process has a sensitivity list, the first IF statement in the process body is identified, 515. In one embodiment, the present invention assumes that the first IF statement includes “reset” and/or “clock” conditions. Alternatively, the first IF statement is not required to include the reset and/or clock conditions.
If an IF statement is not found at 520 and the process is not the final process at 565, the next process is evaluated, 570. If an IF statement is found at 520, an associated ELSE or ELSIF part is sought, 525. If an ELSE or ELSIF part (“else if” in Verilog®) is found at 530, the RESET clause is identified from the IF condition and corresponding THEN part, 540. Identification of the reset clause is discussed in greater detail below.
If a reset clause is identified from the IF and THEN parts, the clock clause is identified from the ELSE or ELSIF parts, 545. If the IF statement does not include ELSE or ELSIF parts, the clock clause is identified from the IF and THEN parts, 535.
If the clock clause is identified the current and next state variables are identified, 550. In one embodiment, the current process can be marked as a transition process (not shown in FIG. 5). For example, if the current process is a clocked process and a transition process that assigns state variables, the process is marked as a transition process at 550. Determining whether a process is a transition process is described in greater detail below. The clocked process is checked for proper form at 560, which is described in greater detail below. If the current process is not the last process at 565, the next process is evaluated, 570. If the current process is the final process, evaluation is complete.
FIG. 6 is one embodiment of a flow diagram for recognizing a reset clause of a state machine from corresponding high-level IC description language code. In one embodiment, the reset clause must be of the form “IF <reset_condition> THEN <action>”. In one embodiment, a condition is considered a reset condition when the condition tests for equality or inequality and a signal is checked against a constant or enumeration literal.
The recognition and extraction engine 610 checks the form of the reset condition, 610. The reset condition can include both constants and enumeration literal types. In one embodiment, the reset condition can be enclosed in parentheses and can include calls to the negation operator or negation function.
If the reset clause is in the proper form, the recognition and extraction engine checks for the reset signal in the condition, 620. For example, “rst=‘0’” or “rst/=‘0’” can be used to describe the reset condition. Other uses of the reset signal in the condition can also be supported.
If 610 and 620 are satisfied, the recognition and extraction engine checks for an assignment to a state variable in the THEN part of the reset clause, 630. If 610, 620 and 630 are satisfied, the reset clause is recognized. Otherwise, recognition ceases when a condition is not satisfied.
FIG. 7 is one embodiment of a flow diagram for identifying a clock clause of a state machine from corresponding high-level IC description language code. The form of the clock condition is checked, 710. In one embodiment, the form must be <IF or ELSIF> <clock_condition> THEN <action>. The condition is checked for the CLOCK signal, 720. In one embodiment, the clock condition can be a function call with one parameter (e.g., rising_edge(clk)) or an event test and level test (e.g., clk'event NAD clk=‘1’.
The action in the THEN part of the clock clause is checked for an assignment to a state variable, 730 or for a “case” statement test of the state variable, 740. If the clock clause is within a combined clocked and transition process, the THEN part of the clock clause typically contains a case statement testing the current state variable. if the clock clause is within a clocked process that is not a transition process, the THEN part of the clock clause typically contains an assignment to the current state variable. The present invention tests for both eventualities in order to identify the current state variable in either case. If 710, 720 and 730 or 740 are performed successfully, the CLOCK clause has been recognized. Otherwise, recognition ceases when a check is not satisfied.
FIG. 8 is one embodiment of a flow diagram for identifying a process that provides a next state assignment according to the present invention. The description with respect to FIG. 8 identifies a transition process that is a clocked process. A process that is both a transition process and a clocked process can also be marked as a transition process as described above with respect to FIG. 5.
The process is checked to determine whether the process is a clocked process, 810. If the process is not a clocked process at 810 and the process is not the final process at 860, the next process to be evaluated is found, 870. If the process is a clocked process at 810, the process is checked to determine whether the process is a transition process, 820. If the process has been previously marked as a transition process at 820 and the process is not the final process at 860, the next process to evaluate is found, 870.
If the process is not a transition process at 820, a process that assigns to the next state variable of the clocked process is found, 830. If a process that assigns to the next state variable is found at 840, the process is marked as a transition process 850.
If a process is that assigns to the next state variable is not found at 840 and the process is not the final process at 860, the next process is found, 870. If a process is marked as a transition process at 850 and the process is not the final process at 860, the next process is found. Otherwise, processing is complete.
FIG. 9 is one embodiment of a flow diagram for identifying an output process according to the present invention. The flow of FIG. 9 determines whether an output signal is assigned a value. Processes that determine output signals are marked as output processes.
The process is checked to determine whether the process is a clocked process at 910. If the process is not a clocked process at 910 and the process is not the final process at 950, the next process is identified at 960. If the process is the final process at 950, the evaluation described with respect to FIG. 9 is complete.
If the process is a clocked process at 910, a process that assigns to an output signal that is not a state variable is found at 920. The process identified at 920 is an output process. If an output process is not found at 930 and the process is not the final process at 950, the next process to be evaluated is identified at 960. If the process is the final process at 950, the evaluation described with respect to FIG. 9 is complete.
If an output process is found at 930, the process is marked as an output process at 940. If an output process is not found at 930 and the process is not the final process at 950, the next process to be evaluated is identified at 960. If the process is the final process at 950, the evaluation described with respect to FIG. 9 is complete.
FIG. 10 is one embodiment of a flow diagram for building a state machine summary according to the present invention. In one embodiment, the state machine summary is used to provide information describing the behavioral characteristics of the state machine.
The process is checked to determine whether the process has a current state variable at 1000. If the process does not have a current state variable at 1000 and the process is not the final process to be evaluated at 1080, the next process to be evaluated is identified at 1090. If the process is the final process at 1080, the evaluation described with respect to FIG. 10 is complete.
If the process has a current state variable at 1000, clock information is stored at 1010. In one embodiment, clock information includes a clock signal name and a clock signal type. Reset information is stored at 1020. In one embodiment, reset information includes a reset signal name and a reset signal type.
Current and next state information is stored at 1030. In one embodiment, current and next state information includes a current state variable name, a next state variable name and a state variable type. In one embodiment, the next state variable and the current state variable should be of the same type. Process information is stored at 1040. Storage of process information is described in greater detail below with respect to FIG. 11.
A list of states is built at 1050. The number of the states in the list of states is compared to the number of states corresponding to the minimum number of states (“N”) required for the high-level description language code to be considered a state machine. In one embodiment, N=1; however, such an embodiment may result in an unacceptable number of false positives, which can be the result of coding style. A false positive occurs when code that does not implement a state machine is recognized as a state machine. In an alternative embodiment, N=2, which provides more reliable recognition than when N=1.
FIG. 11 is one embodiment of a flow diagram for storing process information according to the present invention. The information stored as described with respect to FIG. 11 provides information for building a state machine model. Additional or different information can also be stored in order to provide a different or augmented state machine model. In one embodiment, the evaluation described with respect to FIG. 11 is performed for each process.
If the process is the first process that assigns the next state variable to the current state variable at 1100, the process is stored as the clocked process for the state variable at 1110. The clocked process for a state variable is the process that evaluates conditions that affect the state of the state machine on clock transitions.
If the process is the first transition process for a particular state variable or the first transition process that is not a clocked process at 1120, the process is stored as the transition process for the state variable at 1130. The transition process for a particular state variable is the transition process that assigns values to the state variable.
If the process is the first output process for a state variable or the first output process that is not a clocked or transition process at 1140, the process is stored as the output process for the state variable at 1150. The output process for the state variable is the process that assigns values to output signals associated with the state variable.
FIG. 12 is one embodiment of an output generated describing the state machine of FIGS. 3a–3n according to the present invention. The output of FIG. 12 describes clock name and type, reset name and type, state variable information for two state variables because the state machine of FIGS. 3a–3n is a concurrent state machine. Other output information can also be provided.
In the foregoing specification, the present invention has been described with reference to specific embodiments thereof. It will, however, be evident that various modifications and changes can be made thereto without departing from the broader spirit and scope of the invention. The specification and drawings are, accordingly, to be regarded in an illustrative rather than a restrictive sense.

## Claims

1. A system for extracting a representation of a state machine from high-level integrated circuit (IC) description language code, comprising:
a recognition and extraction engine, wherein the recognition and extraction engine is configured to identify one or more state variables from the high-level IC description language code and wherein the recognition and extraction engine also identifies one or more states for each of the state variables, one or more transition processes for each of the state variables, one or more clocked processes for each of the state variables, and one or more output processes for each of the state variables; and
an output file, wherein the output file comprises a state machine description based on the one or more state variables identified by the recognition and extraction engine.

2. The system of claim 1, wherein the recognition and extraction engine also identifies a clock signal for the state machine and a reset signal for the state machine.

3. The system of claim 1, wherein the recognition and extraction engine is implemented in software.

4. The system of claim 1, wherein the recognition and extraction engine is implemented as part of a hardware device.

5. The system of claim 1, wherein each of the transition processes is a process in which a state assignment is made.

6. The system of claim 1, wherein each of the clocked processes is a process that changes the state of the process on a clock transition.

7. The system of claim 1, wherein each of the output processes is a process that assigns a value to a non-state variable output signal.