TDEB Top Bar

Trending
Semiconductor Industry News — The Digital Electronics Blog
Follow Us

TDEB Masthead

The Semiconductor Hub

Semiconductors.  Chips and Systems.  Innovation.

Indexed by leading Search Engines, AI and referenced by Engineers worldwide 500+ Articles 10M+ Pageviews 30+ Reports 50+ Citations

Behavioral Synthesis vs RTL: Multi-Cycle Functionality

The Editor's Desk
by
0
Share Facebook X LinkedIn WhatsApp Email

It is a fundamental characteristic of synthesizable RTL code that the complete functionality of each clocked process must be performed within a single clock cycle. Behavioral synthesis lifts this restriction. Clocked processes in synthesizable behavioral code may contain functionality that takes more than one clock cycle to execute.

Behavioral synthesis is today usually called high-level synthesis (HLS): a tool reads an algorithm written in C, C++, SystemC or a behavioral HDL style and produces RTL. This post compares it with hand-written RTL on three points, multi-cycle functionality, loops and memory access, and then works through the numbers.

Multi-cycle functionality

The behavioral synthesis algorithms will create a schedule that determines how many clock cycles will be used. The behavioral synthesis tool automatically creates the finite state machine (FSM) that is required to implement this multi-cycle behavior in the generated RTL code.

In a traditional RTL design process, the designer is responsible for manually decomposing multi-cycle functionality into a set of single-cycle processes. Typically this entails the creation of multiple processes to implement the finite state machine, and the creation of processes for each operation and each output.

A behavioral synthesis tool performs this decomposition for the designer. The multi-cycle behavior can be expressed in a natural way in a single process leading to more efficient design specification and debug.

Loops

Most algorithms include looping structures. Traditional RTL design imposes severe restrictions on the use of loops, or prohibits them outright. Some RTL logic synthesis tools permit for loops with fixed loop indices only. The loop body is restricted to being executed in a single cycle. Parallel hardware is inferred for each loop iteration.

These restrictions require the designer to transform the algorithm into a multi-cycle FSM, adding substantial complexity to the designer's task. Behavioral design manages this complexity for the designer by permitting free use of loops. "While" loops and "for" loops with data-dependent loop indices are fully supported in a behavioral design flow. Loop termination constructs such as the C language "break" and "continue" keywords are permitted.

Memory access

In general, reading and writing to memories requires complex multi-cycle protocols. In RTL design these are implemented as explicit FSMs. Worse, these accesses must usually be incorporated in an already complex FSM implementing an algorithm.

Behavioral synthesis permits them to be represented in an intuitive way as simple array accesses. An array is declared in the native syntax of the behavioral language in use, tool directives are provided to control the mapping of the array to a physical memory element, and the array elements are referenced using the array indexing syntax of the language. The behavioral synthesis tool instantiates the memory element and connects it to the rest of the circuit. It also develops the FSM for the memory access protocol and integrates this FSM with the rest of the algorithm.

When to use which

  • Behavioral synthesis suits datapath-heavy algorithms (filters, transforms, image processing, codecs) where you want to try several architectures quickly from one source.
  • Hand-written RTL still suits control-heavy logic, exact cycle-level interfaces, and blocks where every gate and every cycle must be hand-tuned.

Deep dive: the numbers and details

This part holds the scheduling terms, a worked example with cycle counts and the common pitfalls. Skip it if the overview is all you need.

What the tool actually does

Coussy, Gajski, Meredith and Takach describe the classic HLS steps in An Introduction to High-Level Synthesis, IEEE Design & Test of Computers, vol. 26, no. 4, 2009. In short:

  • Compilation turns the source into a data-flow and control-flow graph.
  • Allocation chooses how many functional units (multipliers, adders, memory ports) to build.
  • Scheduling assigns each operation to a clock cycle, respecting data dependencies, the clock period and the allocated resources.
  • Binding maps each operation to a specific unit and each variable to a register or memory.
  • Generation writes RTL: a datapath plus the FSM that sequences it. This FSM is exactly what the RTL designer would otherwise write by hand.

Two numbers that describe a schedule

Latency is the number of cycles from first input to final output. Initiation interval (II) is the number of cycles between the start of successive loop iterations or successive inputs; II = 1 means a new input every cycle. For a pipelined loop, AMD's Vitis HLS user guide gives the total latency as the iteration latency plus II times (number of iterations minus one) (UG1399, Pipelining Paradigm).

Worked example: an 8-tap dot product

int acc = 0;
for (int i = 0; i < 8; i++)
    acc += coef[i] * x[i];

Assume a multiply takes 2 cycles, an add 1 cycle, and coef and x each live in a single-port RAM with a 1-cycle read. Three architectures from the same source:

DirectiveHardwareApproximate latencyNotes
None (sequential)1 multiplier, 1 adder8 x (1 + 2 + 1) = 32 cyclesRead, multiply, add, one iteration after another
Pipeline, II = 11 multiplier, 1 adder4 + 1 x (8 - 1) = 11 cyclesIteration latency 4, a new iteration each cycle
Fully unrolled8 multipliers, adder tree1 + 2 + 3 = 6 cyclesNeeds 8 reads per array in one cycle, so the arrays must be split into registers or banks

These are illustrative cycle counts; a real tool adds a few cycles for I/O handshakes and depends on the target clock. The point is that the RTL designer would have to write three different FSMs and datapaths to explore these options, while the behavioral source stays the same and only the directives change.

Why the memory port matters

With single-port RAMs, each array can deliver one word per cycle. That caps the pipelined loop at II = 1 and makes full unrolling impossible without partitioning the array. If both coef[i] and x[i] were in the same single-port RAM, two reads per iteration would force II = 2 and the pipelined latency would rise to about 4 + 2 x 7 = 18 cycles. Choosing the memory mapping directive is often the biggest single lever on performance.

Loop-carried dependencies

The accumulator acc depends on its own previous value. If the add takes more than one cycle at the target clock, the next iteration cannot start until the previous add finishes, and the tool will report a larger II than requested. AMD documents this behavior: if the requested II cannot be met, Vitis HLS warns and builds the lowest II it can achieve (UG1399, Pipeline). Common fixes are splitting the sum into partial accumulators or relaxing the clock target.

Common mistakes

  • Writing software, not hardware. Unbounded loops and dynamic memory cannot be synthesized to a fixed schedule; give loops a known maximum trip count.
  • Ignoring the interface. The tool must still be told what protocol each port uses; a mismatch with the surrounding RTL shows up only in integration.
  • Trusting the latency report blindly. Check the generated RTL in simulation with the same test vectors as the C model, and close timing after logic synthesis.

Further reading

The Editor's Desk
About the Author
The Editor's Desk
Share Facebook X LinkedIn WhatsApp Email

Post a Comment

0 Comments

Your comments will be moderated before it appears here.

Post a Comment (0)

#buttons=(Ok, Go it!) #days=(20)

Our website uses cookies to enhance your experience. Learn more
Ok, Go it!