Skip to content
Tutorials Center
My learning

Topics

Lesson 6 of 37 ยท Entities and Architectures

The Architecture Body

Understand the VHDL architecture: declarative part, statement part, dataflow, behavioral and structural styles, multiple architectures and configurations.

An architecture implements an entity. Where the entity is the pin list, the architecture is the circuit board behind it. A single entity can have several architectures, for instance a fast behavioral model for simulation and a detailed one for synthesis, and you choose which is used when you build the design.

Shape of an architecture

VHDL
architecture <arch_name> of <entity_name> is
  -- declarative part: signals, constants, types, components, functions...
begin
  -- statement part: concurrent statements
end [architecture] [<arch_name>];

Declarative part. You declare things that exist only inside this architecture: internal signals, constants, types, components, and local subprograms. Nothing in this part "does" anything; it only introduces names.

Statement part. After begin come concurrent statements: signal assignments, processes, component instances and generate statements. All of them run in parallel.

Three modeling styles

The same circuit can be described in three styles. They can be mixed in one architecture.

Dataflow uses concurrent signal assignments that mirror the boolean equations:

VHDL
architecture dataflow of mux2 is
begin
  y <= (a and not sel) or (b and sel);
end architecture dataflow;

Behavioral uses processes with sequential statements, closer to software:

VHDL
architecture behavioral of mux2 is
begin
  process (a, b, sel)
  begin
    if sel = '0' then
      y <= a;
    else
      y <= b;
    end if;
  end process;
end architecture behavioral;

Structural instantiates and wires smaller components (a netlist written by hand). It is covered in Structural Design and Components.

All three architectures above describe the same 2-to-1 multiplexer, and a synthesis tool would produce the same hardware for the first two.

Three modeling styles

Dataflow Boolean equations
Behavioral Processes, if and case
Structural Components wired together

Mix them freely inside one architecture.

1 / 2

Internal signals

Signals declared in the declarative part are the wires between parts of your architecture. They are invisible outside.

VHDL
architecture dataflow of full_adder is
  signal x, g1, g2 : std_logic;
begin
  x    <= a xor b;
  sum  <= x xor cin;
  g1   <= a and b;
  g2   <= x and cin;
  cout <= g1 or g2;
end architecture dataflow;

Here x, g1 and g2 are internal nets. Reading x in two places does not duplicate any gate; it is just a wire with two readers (fan-out of 2).

The following stand-in builds the full adder in C from the same internal nets, then checks it against ordinary integer addition for all eight input combinations.

C Stand-in (C): full adder from internal nets

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with scanf or fgets), it gets the next line from this box.

Multiple architectures and configurations

One entity, many architectures:

VHDL
architecture rtl   of adder8 is ... end architecture rtl;
architecture fast  of adder8 is ... end architecture fast;

When you instantiate adder8, the tool needs to know which one to use. By default it picks the most recently analyzed architecture, which can surprise you. You can be explicit in the instance (entity work.adder8(rtl)), or write a configuration:

VHDL
configuration cfg_fast of top is
  for structure
    for u_add : adder8
      use entity work.adder8(fast);
    end for;
  end for;
end configuration cfg_fast;

Configurations are used heavily in verification (swap a slow model for a fast one) and less in FPGA work, where you normally keep one architecture per entity.

Naming and end labels

Architecture names are free: rtl, behavioral, structure, sim. The closing end architecture rtl; repeats the keyword and name; both are optional but helpful, and tools such as GHDL check that they match. Labels on concurrent statements (g1: y <= a and b;) make waveforms and error messages easier to read.

A second view: what "concurrent" means

Statements in the architecture are active whenever the signals on their right-hand side change. This stand-in shows the "sensitivity" idea in C: each statement is a function plus the list of signals it reads, and when a signal changes, only the statements that read it are re-evaluated.

C Stand-in (C): re-evaluate only what changed

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with scanf or fgets), it gets the next line from this box.

The recursive call inside set is a simplification. A real VHDL simulator waits one delta cycle before applying updates, so changes never appear instantly. See Delta Cycles and Simulation Time.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Where do you declare internal signals in an architecture?

    Declarations (signals, constants, types, components) go in the declarative part, between is and begin.
  2. 2. Which style uses only concurrent signal assignments that look like boolean equations?

    Dataflow architectures describe how data flows through logic equations.
  3. 3. If an entity has two architectures and you do not specify one, which is used by default?

    Without a configuration or explicit selection, the last analyzed architecture is used, which is why explicit selection is safer.
  4. 4. What does a configuration declaration do?

    Configurations bind component instances to specific entity-architecture pairs.

Summary

  • An architecture implements an entity: declarations before begin, concurrent statements after.
  • Three styles: dataflow, behavioral and structural, freely mixable.
  • Internal signals are wires visible only inside the architecture.
  • One entity can have many architectures; select one explicitly or with a configuration.
  • Concurrent statements react to changes of the signals they read.

Next: Generics and Constants