state_type
is not a resolved subtype. Multiple drivers are detected during loading prior to model execution after being identified during elaboration.
IEEE Std 1076-2008
14.5 Elaboration of a statement part
14.5.5 Other concurrent statements
All other concurrent statements are either process statements or are statements for which there is an equivalent process statement.
Elaboration of a process statement proceeds as follows:
a) The process declarative part is elaborated.
b) The drivers required by the process statement are identified.
6.4.2.3 Signal declarations
... It is an error if, after the elaboration of a description, a signal has multiple sources and it is not a resolved signal. ...
There are drivers for next_state
in processes SYNC_PROC and NEXT_STATE_DECODE
14.7 Execution of a model
14.7.2 Drivers
Every signal assignment statement in a process statement defines a set of drivers for certain scalar signals. There is a single driver for a given scalar signal S in a process statement, provided that there is at least one signal assignment statement in that process statement and that the longest static prefix of the target signal of that signal assignment statement denotes S or denotes a composite signal of which S is a subelement. Each such signal assignment statement is said to be associated with that driver. Execution of a signal assignment statement affects only the associated driver(s).
state_type
an enumerated type and is a scalar type:
5.2 Scalar types
5.2.1 General
Scalar types consist of enumeration types, integer types, physical types, and floating-point types. ...
The solution would appear to be to reset state
in SYNC_PROC instead of next_state
.
If you remove the two extraneous grave accents ('`', 15.2 Character set) your code would be a Minimal, Complete, and Verifiable example despite Tricky's expression of suspicion. I removed them from your code example, after which your code analyzes and elaborates following the change to process SYNC_PROC:
if(r='1') then
state <= SA; -- WAS next_state
(Note the parentheses around a condition (here r='1') are redundant. In VHDL a condition is known to be an expression with a BOOLEAN value.)
If your simulator allows execution with top level ports it would report the multiple drivers. For those simulators that don't you'd require a testbench instantiating simpfsm
:
14.2 Elaboration of a design hierarchy
An implementation may allow, but is not required to allow, a design entity at the root of a design hierarchy to have generics and ports. If an implementation allows these top-level interface objects, it may restrict their allowed forms (that is, whether they are allowed to be interface types, subprograms, packages, or objects), and, in the case of interface objects, their allowed types and modes in an implementation-defined manner.
As you might gather this represents a portability issue for detecting the error without a testbench or depending on an interactive of script driven simulator. The error can demonstrated with ghdl prior to the signal assignment target change:
ghdl -r simpfsm
for signal: .simpfsm(behavioral).next_state
./simpfsm:error: several sources for unresolved signal
./simpfsm:error: error during elaboration
Loading an elaborated design specification into memory is deferred to 'program' execution in compiler based VHDL simulators:
14.2 Elaboration of a design hierarchy
Elaboration of a design hierarchy is completed as follows:
— The drivers identified during elaboration of process statements (see 14.5.5) are created.
— The initial transaction defined by the default value associated with each scalar signal driven by a process statement is inserted into the corresponding driver.
next_state
and state
both have default values of state_type'LEFT (SA
).
6.4.2.3 Signal declarations
In the absence of an explicit default expression, an implicit default value is assumed for a signal of a scalar subtype or for each scalar subelement of a composite signal, each of which is itself a signal of a scalar subtype. The implicit default value for a signal of a scalar subtype T is defined to be that given by T'LEFT.
And this implies detecting multiple drivers occurs during the loading portion of elaboration when each net is identified:
14.7.3.4 Signal update
A net is a collection of drivers, signals (including ports and implicit signals), conversion functions, and resolution functions that, taken together, determine the effective and driving values of every signal on the net.
We see in that part of elaboration (loading here) occurs during execution (ghdl's -r command):
14.2 Elaboration of a design hierarchy
The elaboration of a design hierarchy creates a collection of processes interconnected by nets; this collection of processes and nets can then be executed to simulate the behavior of the design.
Tricky's suspicion is somewhat valid, the grave accents would cause errors during analysis, while the error you provide occurs during elaboration. They can be assumed to be transcription errors here by investigating your reported error first.