VHDL counters — two ways to remember the current state In synthesizable VHDL for a counter or state machine, which pair of VHDL objects are used to hold (remember) the current state across clock cycles?

Difficulty: Easy

Correct Answer: With SIGNAL and VARIABLE

Explanation:


Introduction / Context:
VHDL provides multiple object classes—signals, variables, constants—that behave differently with respect to time and simulation. For sequential logic like counters, designers must understand which objects store values across cycles and how synthesis tools map them to flip-flops and registers.


Given Data / Assumptions:

  • Signals are the primary means of modeling wires and registered state in RTL.
  • Variables exist inside processes and procedures and update immediately within that scope.
  • Both can represent state that persists, depending on coding style and clocked processes.


Concept / Approach:
A common pattern uses a variable within a clocked process to compute the next state, then assigns that value to a signal for registered output at the rising edge. Alternatively, a signal alone can hold the current state if assigned in a synchronous process. Thus, both SIGNAL and VARIABLE are valid constructs for remembering state; the difference lies in update semantics and scope.


Step-by-Step Solution:

Create a clocked process sensitive to CLK.Use a VARIABLE (e.g., tmp_state) to compute intermediate results in the same delta cycle.Assign the VARIABLE back to a SIGNAL (e.g., state) which synthesizes to flip-flops.On the next clock, the SIGNAL presents the remembered current state.


Verification / Alternative check:
Post-synthesis netlists show that clocked signal assignments generate registers. Variables used only for intermediate computation do not create extra storage unless written to signal/registers or mapped into memories by the tool.


Why Other Options Are Wrong:

  • Functions/processes are structural elements, not storage objects.
  • “Counters and timers” are design concepts, not VHDL objects.
  • “bit types” are data types, not storage mechanisms by themselves.
  • FILE/TEXTIO are for simulation I/O, not hardware state.


Common Pitfalls:

  • Assuming variables update like signals; variables update immediately within a process and can simplify sequential arithmetic.


Final Answer:
With SIGNAL and VARIABLE

More Questions from Digital System Projects Using HDL

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion