Thisstyle has one process, and uses explicit (manually-coded) state encodings. This is the only style that uses manual codings; the remaining styles all allow the synthesiser to select the state codings.
The intent of the code below is that the BUSY and SCK outputs should both be registered, and that this 2-bit register should also be the state register itself; this should give the most compact implementation.
In principle, an explicit state coding allows the designer to manually optimise an FSM, and to guarantee that important bits of the state register are registered at the module outputs, and not delayed by additional combinatorial decoding.
In practice, the synthesiser will probably modify the FSM unless it is instructed not to. XST, for example, will by default ignore the manual state codings in these examples, and will generate a one-hot FSM with a new set of 4-bit state codings. This may, in general, produce an FSM which is either smaller or faster than the designer's original, but it does introduce two potential problems:
Style #1 is only used in VHDL when the designer specifically needs the requested state coding, and is sure that the synthesiser will not change the codings. In Verilog, however, the general form of this style is also used when the designer does expect the synthesiser to carry out state recoding. In these cases, the original designer-specified state coding is not required. However, the state codings cannot simply be ignored; the parameters must be set in a way that will allow the RTL code to simulate. The synthesiser will also analyse the FSM before recoding it, and will complain if two states have the same encoding, for example.
FSMs are almost always described in Verilog by using parameter constants to represent state encodings. Historically, a synthesiser directive (/* synopsys enum */) was added to the code to allow the synthesiser to treat the state register as being of an enumerated type. The synthesiser (but not the simulator) could then report an error if, for example, a constant value, rather than a declared parameter, was assigned to the state register. This is similar to the VHDL coding of enumerated FSMs (Style #2), but it does require the parameters to be given specific values. In other words, each state must be manually encoded.
The precise form of the parameter and state vector declarations in the Verilog code may depend on the synthesiser. Historically, Synopsys required a state vector and parameter declaration in this form:
The VHDL implementation uses a block to form a new declarative region. This isn't required, but provides greater encapsulation, by allowing the state register and the state encodings to be declared locally to the FSM itself.
With the default automatic FSM encoding, XST recoded the 2-bit state register into a 4-bit one-hot state register. The technology schematic showed 4 flip-flops, two of which were driven by 4-input LUTs. The SCK and BUSY outputs were driven by 2-input LUTs, giving a total utilisation of 4 flip-flops and 4 LUTs. Since XST had recoded the state register, the SCK and BUSY outputs were no longer registered outputs, and each was derived from a combination of 2 state bits.
With user-defined FSM encoding, the technology output was exactly as expected. There were 2 state register bits, one driven by a LUT2, and the other by a LUT4. The SCK and BUSY outputs were directly driven from the state register bits. The total utilisation was 2 flip-flops and 2 LUTs:
3a8082e126