Electrical Engineering › Section V · Programmable logic and data storage › Topic V.2

Programmable logic software, HDLs, and boundary scan

A programmable chip is only as good as the tools that configure it. This topic follows a design from a few lines of VHDL to a working device, then shows how boundary scan tests chips whose pins you cannot even touch.

From idea to configured chip

Nobody sets the thousands of links in a CPLD or the millions of bits in an FPGA by hand. Vendor software, or open-source tools such as Yosys and nextpnr for some FPGA families, carries the design through a fixed sequence called the design flow: design entry, functional simulation, synthesis, implementation, timing simulation and download. Each stage either checks the design or brings it closer to hardware, and a fault found at any stage sends the designer back to fix it.

Design entry and HDLs

Design entry is where the designer describes the logic. Small designs can be drawn as schematics of gates and flip-flops, but most work uses a hardware description language (HDL). The two main HDLs are VHDL, standardised as IEEE 1076 in 1987, and Verilog, created in about 1984 and later standardised as IEEE 1364; SystemVerilog extends Verilog. An HDL describes hardware, not a list of steps: every concurrent statement is a circuit that is always active, so all of them operate at once. The VHDL basics of entity and architecture were introduced in "Karnaugh maps, Quine-McCluskey, and VHDL".

Worked example: a 2-to-1 multiplexer in VHDL

Describe a multiplexer whose output y follows a when the select s is 0, and b when s is 1. Line 1: library ieee; Line 2: use ieee.std_logic_1164.all; Line 3: entity mux2 is port (a, b, s : in std_logic; y : out std_logic); Line 4: end entity mux2; Line 5: architecture dataflow of mux2 is Line 6: begin Line 7: y <= b when s = '1' else a; Line 8: end architecture dataflow; 1. Lines 1 and 2 make the std_logic type available. 2. Lines 3 and 4 declare the ports, the chip's view from outside. 3. Line 7 is one concurrent assignment: y responds whenever a, b or s changes. 4. Check: with s = '1', a = '0' and b = '1', y = '1'.

Functional simulation

Functional simulation tests the logic before any hardware is involved. A testbench, often written in the same HDL, applies input stimulus and the simulator displays the outputs as waveforms or checks them automatically. Gate delays are ignored: the only question is whether the logic is right. For the multiplexer, a testbench steps through all eight combinations of a, b and s and confirms y each time. A designer can also set a breakpoint, a condition that halts the simulation when it occurs, for example when y differs from the expected value.

Synthesis and implementation

Synthesis translates the HDL into a netlist: a list of logic elements, such as gates, LUTs and flip-flops, and the connections between them, optimised for speed or area. The synthesiser also reports constructs it cannot build in hardware. Implementation then maps that netlist onto one particular device. For a CPLD this is called fitting; for an FPGA it is placement, choosing which logic blocks hold each function, and routing, choosing the interconnect paths. Pins are assigned to the ports here. Static timing analysis then checks every path against the clock constraints the designer supplied.

Timing simulation and download

Timing simulation repeats the tests with the real delays extracted from the placed and routed design. It can expose problems a functional simulation hides: glitches, signals arriving too late for the next clock edge, and setup or hold violations at flip-flops. Once the design passes, the tools produce a configuration file, often called a bitstream for an FPGA. Download sends it to the chip, usually from a computer through a USB-to-JTAG cable. A CPLD keeps it in nonvolatile cells; for an SRAM-based FPGA it is normally written to the configuration flash so it reloads at every power-up.

Why boundary scan exists

Modern chips often sit in ball-grid-array packages whose connections are hidden under the package, on boards too dense for test probes. In the 1980s the Joint Test Action Group (JTAG) proposed a way to test such boards from inside the chips themselves, standardised in 1990 as IEEE 1149.1 and still called JTAG. A compliant device places a boundary scan cell between each pin and the core logic. The cells link into a shift register around the chip's edge, so test data can be shifted in, driven onto pins, captured from pins and shifted out through four mandatory pins. The same port is used to program most CPLDs and FPGAs.

The test access port and its registers

The four mandatory pins form the test access port (TAP): TDI (test data in), TDO (test data out), TCK (test clock) and TMS (test mode select); an optional TRST resets the logic. TMS steers the TAP controller, a 16-state machine clocked by TCK. Data shifts from TDI to TDO through one of several registers. The instruction register holds the current instruction. The boundary scan register is the chain of pin cells. The bypass register is a single bit that lets data pass straight through a device that is not being tested. Many devices also have an identification register holding a 32-bit device code.

Worked example: shortening a scan chain

Three devices share one JTAG chain from TDI through U1, U2 and U3 to TDO. Their boundary scan registers hold 150, 96 and 240 cells. Only U3's pins need testing, and TCK runs at 10 MHz. 1. With all boundary registers in the chain, one full shift takes \(150 + 96 + 240 = 486\) clock cycles. 2. Load the BYPASS instruction into U1 and U2, so each adds 1 bit: the path is \(1 + 1 + 240 = 242\) bits. 3. Time per shift: \(242 \div (10 \times 10^6\,\text{Hz}) = 24.2\,\mu\text{s}\), against \(48.6\,\mu\text{s}\) for the full chain. 4. Check: bypassing removed 150 + 96 = 246 bits, and 486 − 246 = 242.

Troubleshooting with simulation and scan

Waveform simulation remains the first troubleshooting tool: compare simulated outputs with the truth table, and use breakpoints to stop at the first wrong value instead of searching long traces. On an assembled board, boundary scan finds wiring faults without probes. With the EXTEST instruction, one device's output cells drive a known pattern onto board traces while a connected device's input cells capture what arrives. A bit stuck at 0 or 1 points to an open or a short to a supply, and two traces that read alike even when driven with opposite values point to a short between them. Many FPGA tools also embed a logic analyser in spare logic to watch internal signals at full speed.

Common mistakes to avoid

First, reading VHDL as a program that runs line by line: concurrent statements are parallel hardware. Second, skipping timing simulation because the functional simulation passed: delays can still break a design. Third, confusing synthesis with implementation: synthesis builds a netlist, and implementation places it in a specific device. Fourth, swapping TDI and TDO: data enters a device on TDI and leaves on TDO. Fifth, forgetting that a bypassed device still adds one bit to the chain length.

Key takeaways

The PLD design flow runs design entry, functional simulation, synthesis, implementation (fitting, or place and route), timing simulation and download. Most entry uses an HDL such as VHDL (IEEE 1076) or Verilog, which describe parallel hardware. Functional simulation checks logic without delays; timing simulation uses real delays. Boundary scan (JTAG, IEEE 1149.1) puts a cell at each pin, linked into a shift register reached through TDI, TDO, TCK and TMS. The instruction, boundary scan and 1-bit bypass registers let boards be tested, and chips programmed, through the same four pins.

Flashcards

Flashcard

Design flow

Entry, functional simulation, synthesis, implementation, timing simulation, download

Loop back whenever a stage finds a fault.

Test your understanding

Question 1 of 5

In the design flow, which stage turns the HDL description into a netlist of gates, LUTs and flip-flops?

Question 2 of 5

A design passes functional simulation but fails in the chip at full clock speed. Which step would most likely have caught this?

Question 3 of 5

Four devices are on one JTAG chain. Three are bypassed and the fourth has a 180-cell boundary scan register. How many bits long is the chain?

Question 4 of 5

Which set lists the four mandatory JTAG test access port pins?

Question 5 of 5

A VHDL architecture contains two concurrent signal assignments, one written above the other. How do they behave in the synthesised hardware?

← Previous topicNext topic →