CPLD — Part 1: Architecture, Timing, Power, I/O, Toolchains & Model Selection
A complex programmable logic device (CPLD) is a nonvolatile, instant-on programmable logic family built around clustered macrocells and a predictable global interconnect. Compared with SRAM-FPGA fabrics, CPLDs favor deterministic timing, low configuration complexity, wide voltage tolerance, and small-to-medium amounts of glue logic.
If you need a parameter-first, low-friction browse of current parts related to cpld, YY-IC’s index lets you filter by macrocells, I/O voltage, package, and temperature grade without wading through unrelated marketing copy.
1) Where CPLDs Fit (and Where They Don’t)
- Best-fit use cases: reset/boot controllers, interface adaptation (legacy 5 V ⇄ 3.3/1.8 V), GPIO expander with logic, bus glue (ISA/PCI-like to SPI/I²C), power-sequencing state machines, simple counters/timers, protocol bridges at modest clocks, deterministic LED/keypad engines, and “board personality” fuses.
- Borderline/FPGA territory: multi-channel SERDES, DSP pipelines, deep RAMs, video-rate image paths, and anything needing tens of thousands of LUTs or block RAMs.
2) CPLD Architecture in One Picture (Text Version)
- Macrocell: sum-of-products (AND/OR array) feeding an optional flip-flop with set/reset, output enable, and per-macrocell control. Often supports registered and combinational modes.
- Logic Array Blocks (LABs)/Function Blocks: clusters of macrocells sharing local product-term routing and control signals; reduces long global routes.
- Global Interconnect: predictable, sometimes full or near-full crossbar; less congestion variance than FPGA island networks.
- Nonvolatile configuration: flash/EEPROM or antifuse (older): instant-on behavior without external configuration memory; survives power cycling.
3) Deterministic Timing: Why Engineers Still Pick CPLDs
Unlike SRAM FPGAs with complex clock trees and varying placement, CPLDs expose stable timing through macrocells and regular interconnect. This keeps static timing analysis straightforward and design spins short. You can lock down a few global clocks, constrain input/output paths, and be confident that later builds won’t wander by tens of percent due to a placer’s whim.
4) Selection Workflow (Defensible in Design Review)
- Translate the job: number of state machines, counters, decoders, bus bridges; estimate product terms and registers per function; identify asynchronous vs synchronous behavior.
- Resources: macrocells, usable product terms per macrocell, global vs local routing, number of global clocks/resets, availability of PLL/DLL (some newer “CPLD-like” families provide tiny PLLs).
- I/O needs: 5 V tolerance, drive strength, Schmitt triggers, selectable standards (LVCMOS 1.8–3.3 V; sometimes PCI-33 legacy), slew-rate control, on-chip pull-ups.
- Power & thermal: instant-on current, static ICC at room and high temp, dynamic power at your activity factor; are you battery-powered, or line-powered with tight thermal budgets?
- Package & reliability: QFN/TQFP/BGA availability, pitch, board rework policy, −40…+85 °C or extended/automotive, MSL, and AEC-Q100 needs.
- Toolchain & lifetime: license costs, OS support, automation (tcl/CLI), version stability, and vendor lifecycle (NRND/EOL risk).
5) Asynchronous vs Synchronous Styles (and Metastability Budget)
- Prefer synchronous state machines: use one or two globals; add synchronizers on external async inputs (two-flip-flop with low-skew clock).
- Clock-domain crossings: gray-coded counters or handshakes; avoid long combinational chains across domains.
- Metastability MTBF: calculate with your flip-flop’s τ/To; ensure your input clock plus synchronizer depth meets the system FIT target.
6) Power: Static, Dynamic, and “Always-on” Design
- Static ICC: CPLDs have meaningful static current; budget for worst-case temperature and supply corners. Instant-on means “always consumes a bit.”
- Dynamic: activity factor dominates; tame toggling with synchronous enables; gate clocks if the device supports safe clock enables (avoid ripple clocks).
- IO power: large LED banks or wide buses dominate real power; enforce slew control and stronger drive only where necessary.
7) I/O Standards & Level Shifting
- Legacy 5 V interfacing: prefer true 5 V-tolerant inputs; if absent, use resistor dividers or dedicated translators; note ESD/EMI impacts.
- Output drive: check VOH/VOL at your load; LED sinks often need external transistors to protect thermal budget.
- Slew & EMI: slow edges where you can; add series damping (22–47 Ω) on long lines; maintain ground return continuity.
8) Clocking & Resets
- Global clocks: plan two: one main, one spare. Keep all FSMs clocked from a small set to keep STA simple.
- Asserts & releases: asynchronous assert, synchronous release for resets; filter bouncy pushbuttons with small state logic, not RC alone.
9) Security & Configuration
- Nonvolatile devices: no external bitstream to intercept; consider JTAG security options and lock bits where available.
- Field updates: JTAG pads and tag-connect footprints make in-situ updates safe; record IDCODEs/CRC in manufacturing logs.
10) Toolchains & Workflow
- Languages: VHDL/Verilog; prefer synchronous RTL; keep device-specific primitives in wrappers.
- Constraints: define clocks, I/O standards, false/multicycle paths up front; create a golden .sdc/.ucf template for your team.
- Automation: command-line builds with version-pinned tools; store bitstreams with Git LFS and include timing/power reports.
We list exactly one device per vendor to avoid redundancy. Links are technical/product pages (no endorsements implied).
- Intel (Altera) MAX II — EPM240G-TQFP: 240 macrocells, instant-on, low-power glue logic; popular for sequencing and interface adaptation.
- AMD/Xilinx CoolRunner-II — XC2C256-TQFP: 256 macrocells, very low static power “CoolRunner” core; ideal for battery-aware control logic.
- Lattice MachXO2 — XO2-1200HC (CPLD-like flash PLD): 1.2k LUTs, on-chip osc and small PLL; used as “system CPLD” with richer routing and hard resources.
- Microchip (Atmel heritage) — ATF1508AS-PLCC/TQFP: 128 macrocells × 8 function blocks; robust 5 V I/O options on legacy boards.
- Infineon (Cypress heritage) — CY37256VP: 256 macrocells, VersaBlock/VersaRoute architecture; good for bus bridging and keypad/LED matrices.
12) Quick Comparison (Publish-Ready)
| Model |
Brand |
Class |
Macrocells / LUTs |
Core V |
I/O V (typ.) |
Config |
Best-fit uses |
| EPM240G |
Intel |
CPLD |
~240 MC |
1.8/3.3 V |
3.3 V (5 V tolerant per pin spec) |
Flash |
Power sequencing, reset/boot, interface glue |
| XC2C256 |
AMD/Xilinx |
CPLD |
~256 MC |
1.8 V |
1.8–3.3 V |
Flash-like EEPROM |
Low-static control planes, handheld devices |
| MachXO2-1200HC |
Lattice |
Flash PLD (CPLD-like) |
~1200 LUTs |
1.2/1.8 V |
1.2–3.3 V |
Flash (instant-on) |
“System CPLD” with small PLL/osc and richer fabric |
| ATF1508AS |
Microchip |
CPLD |
~128 MC |
5.0/3.3 V (family dep.) |
5 V tolerant (legacy) |
Flash/EEPROM |
Legacy 5 V logic replacement, keypad/LED, bus glue |
| CY37256VP |
Infineon (Cypress) |
CPLD |
~256 MC |
3.3 V |
3.3 V (some 5 V tol.) |
Flash |
Bridge logic, simple protocol adapters, timers |
Parameters are representative; confirm exact I/O tolerance, supply rails, speed grades, and temperature options in the latest datasheets and errata for the precise ordering code.
13) Sizing the Device: A Repeatable Estimation Flow
- Macrocell count: start with one macrocell per output bit of each FSM or registered datapath; add 30–50% headroom for glue terms and enables.
- Product terms: for decoders/state logic, estimate 3–8 product terms per macrocell; review the device’s p-term sharing rules.
- Global signals: ensure enough global clocks/resets; plan one spare clock for ECOs.
- I/O pins: include test pads, JTAG chain, mode straps, and future features; leave ~10% spare.
14) Implementation Patterns (That Actually Ship)
14.1 Power Sequencer (Multi-Rail)
- State machine with timed enables and PG (power-good) inputs; debounce with small counters; enforce brown-out fall-back.
- Expose a “fault-latch” pin to MCU; require clear & restart handshake to re-arm rails.
14.2 Bus Bridge (Legacy ⇄ Modern)
- Registered address decode; dual-edge strobes only if timing allows; insert ready/hold logic with programmable wait states.
- Use Schmitt inputs on noisy lines; series resistors for long busses; verify setup/hold under temperature sweep.
14.3 GPIO + LED Engine
- Time-multiplexed scanning, PWM brightness per bank; consolidate LED sinks to external transistors when current adds up.
15) Static Timing & Constraints (Keep It Boring)
- Define primary clocks with accurate periods; mark input/output delays against external devices; cut false paths (config/status nets).
- Constrain asynchronous input synchronizers; forbid ripple clocks; use clock enables for gated logic.
- Lock pinout early and maintain a single source CSV for the layout team.
16) Power & EMI Hygiene
- Decoupling: one 0.1 µF per VCC pin plus one bulk (4.7–10 µF) per rail near the package; short, wide traces to ground.
- Ground returns: maintain continuity under fast I/Os; add series damping (22–47 Ω) on suspect nets.
- LED banks & relays: separate return paths; snubbers on inductive loads; do not route under crystal footprints.
17) Test & Programming
- JTAG: chain position documented; provide tag-connect pads; include pull-ups/downs per vendor app notes.
- Boundary scan: invaluable for production shorts/opens; keep accessible pins for fixture probing.
- Field image policy: checksum/CRC with version text in a user register; log IDCODEs in production tracker.
18) Quick “Gotchas” Checklist
- Accidental latch inference (combinational processes without full assignments).
- Glitchy asynchronous outputs driving external devices without registers.
- Overusing product terms in a single macrocell → unexpected fitter expansions.
- Pull-ups/pull-downs defaulting to the wrong state on instant-on; document board strap states.
CPLD — Part 2: Execution Guide (Sizing, HDL, STA, PCB/EMI, QA & Troubleshooting)
1) Sizing the Device (Macrocell & Product-Term Math)
1.1 Quick Estimator
| Block |
Signals |
Macrocells (est.) |
Product terms / MC |
Notes |
| Power sequencer FSM |
~10–20 |
8–12 |
3–6 |
Separate async PG inputs via synchronizers |
| Bus decode (8-bit addr) |
~8 |
6–10 |
4–8 |
Thermometer terms if wide ranges |
| GPIO/LED PWM bank |
16–32 |
12–18 |
3–5 |
Share counters; time-multiplex outputs |
| Edge filters/debouncers |
8–16 |
6–10 |
2–4 |
Schmitt inputs + 2-FF sync recommended |
| Subtotal |
— |
32–50 |
— |
Before headroom |
| Headroom (×1.4) |
— |
45–70 |
— |
For ECOs, routing, test |
Rule of thumb: budget 30–50% spare macrocells and 20–30% spare product terms per block to survive fitter choices and last-minute features.
1.2 Synchronizer MTBF Sketch
For a two-FF synchronizer, MTBF ≈ e((T−Tsu)/τ) / (fclk·fdata). Use the vendor’s τ and Tsu; increase depth to three FFs when fclk×fdata is high or FIT targets are strict.
2) Reusable HDL Templates (Copy/Paste)
2.1 Two-Flip-Flop Synchronizer (VHDL)
library ieee; use ieee.std_logic_1164.all;
entity sync2 is
port(clk: in std_logic; din_async: in std_logic; dout_sync: out std_logic);
end entity;
architecture rtl of sync2 is
signal s1, s2: std_logic := '0';
begin
process(clk) begin
if rising_edge(clk) then
s1 <= din_async;
s2 <= s1;
end if;
end process;
dout_sync <= s2;
end architecture;
2.2 Debounced Button with Hold-off (Verilog)
module debounce #(parameter N=18) (input clk, input din, output reg q);
reg [N-1:0] cnt; reg s1, s2;
always @(posedge clk) begin
s1 <= din; s2 <= s1;
if (s2==q) cnt <= 0; else cnt <= cnt + 1;
if (&cnt) q <= s2; // update when counter saturates
end
endmodule
2.3 Minimal Power Sequencer (VHDL)
library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all;
entity pseq is
port(clk: in std_logic; rst_n: in std_logic;
pg: in std_logic_vector(3 downto 0);
en: out std_logic_vector(3 downto 0);
fault: out std_logic);
end entity;
architecture rtl of pseq is
type state_t is (IDLE, EN0, EN1, EN2, EN3, RUN, FAULT);
signal st: state_t := IDLE;
signal t: unsigned(15 downto 0) := (others=>'0');
function done(d: unsigned) return boolean is begin return d=d'hFFF; end;
begin
process(clk) begin
if rising_edge(clk) then
if rst_n='0' then st<=IDLE; t<=(others=>'0'); en<=(others=>'0'); fault<='0';
else
case st is
when IDLE => en<=(others=>'0'); t<=t+1; if done(t) then t:=(others=>'0'); st<=EN0; end if;
when EN0 => en(0)<='1'; if pg(0)='1' then st<=EN1; t:=(others=>'0'); elsif done(t) then st<=FAULT; end if; t<=t+1;
when EN1 => en(1)<='1'; if pg(1)='1' then st<=EN2; t:=(others=>'0'); elsif done(t) then st<=FAULT; end if; t<=t+1;
when EN2 => en(2)<='1'; if pg(2)='1' then st<=EN3; t:=(others=>'0'); elsif done(t) then st<=FAULT; end if; t<=t+1;
when EN3 => en(3)<='1'; if pg(3)='1' then st<=RUN; t:=(others=>'0'); elsif done(t) then st<=FAULT; end if; t<=t+1;
when RUN => if pg/="1111" then st<=FAULT; end if;
when FAULT=> fault<='1'; en<=(others=>'0');
end case;
end if;
end if;
end process;
end architecture;
2.4 8-bit Address Decode with Wait States (Verilog)
module bus_glue(input clk, input rst_n,
input [7:0] addr, input rd, input wr, output reg cs_a, cs_b,
output reg waitn);
reg [1:0] ws;
wire sel_a = (addr[7:4]==4'hA); // A0xx range
wire sel_b = (addr[7:5]==3'b101); // A8–AF range
always @(posedge clk) begin
if(!rst_n) begin cs_a<=0; cs_b<=0; ws<=0; waitn<=1; end
else begin
cs_a <= (rd|wr) & sel_a;
cs_b <= (rd|wr) & sel_b;
if ((rd|wr) & (sel_a|sel_b)) begin
if (ws!=2'd2) begin ws<=ws+1; waitn<=0; end
else begin ws<=0; waitn<=1; end
end else begin ws<=0; waitn<=1; end
end
end
endmodule
2.5 Gray-Code Counter for CDC (VHDL)
library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all;
entity gray_cnt is port(clk: in std_logic; q: out std_logic_vector(7 downto 0)); end;
architecture rtl of gray_cnt is signal b: unsigned(7 downto 0):=(others=>'0'); begin
process(clk) begin if rising_edge(clk) then b<=b+1; end if; end process;
q <= std_logic_vector(b xor (b srl 1));
end;
3) Timing Constraints (SDC/UCF-style, Paste-Ready)
3.1 Define Clocks & Latency
# SDC snippets (adapt vendor syntax as needed)
create_clock -name sysclk -period 20.000 [get_ports CLK] ;# 50 MHz
set_clock_uncertainty 0.150 [get_clocks sysclk]
set_clock_latency -source 0.500 [get_clocks sysclk]
3.2 I/O Delays Against External Devices
# External ADC/DAC timing example
set_input_delay 3.0 -clock sysclk [get_ports {DATA_IN[*]}]
set_output_delay 2.5 -clock sysclk [get_ports {DATA_OUT[*]}]
3.3 Asynchronous & Multicycle Paths
# Cut false paths from asynchronous pushbuttons to everything except synchronizers
set_false_path -from [get_ports {BTN_*}] -to [get_cells *sync2*
Comments