Skip to main content

Programmable Logic Devices

Learning Targets​

  • Situation: A logic function growing beyond convenient discrete wiring.
  • Targets: Configurable hardware, clocked state, LFSR sequence and timing verification.
  • Starting point: Previous truth tables and counter trace; simulation as the basic exercise.

Configurable Hardware​

  • PAL/PLA: Programmable logic arrays with different resource flexibility.
  • CPLD: Programmable blocks and interconnect.
  • FPGA: Lookup tables, registers, routing, clocks and often memory/arithmetic blocks.
  • Lookup table: Stored Boolean truth table; no CPU instruction sequence.
  • Combinational description: Output assignment for every relevant case; omitted assignment potentially inferring a latch.
  • Clocked description: Register update from pre-edge state; nonblocking assignments in the example.
  • Configuration: Device-dependent retention and startup pin behavior.
  • State machine: State register, next-state logic, outputs and a defined request/reset protocol.
Four flip-flops with feedback XOR of the two high-order bits feeding the low bit, beside a lookup-table and register block
Figure 1. Four flip-flops with feedback XOR of the two high-order bits feeding the low bit, beside a lookup-table and register block.

Worked LFSR​

bnew=q3⊕q2,(q3,q2,q1,q0)next=(q2,q1,q0,bnew)b_{\mathrm{new}}=q_3\oplus q_2,\qquad (q_3,q_2,q_1,q_0)_{\mathrm{next}}=(q_2,q_1,q_0,b_{\mathrm{new}})
  • Seed: 0001.
  • First updates: 0010 → 0100 → 1001 → 0011.
  • Period: Fifteen distinct nonzero states; 15 µs at 1 MHz.
  • Zero seed: Locked at zero under this recurrence.
  • Pseudorandom: Deterministic repeating sequence; no cryptographic unpredictability.
  • Bit convention: q3 most significant; shift direction and taps jointly defining the recurrence.
module lfsr4 (
input wire clk,
input wire reset,
output reg [3:0] q
);
always @(posedge clk) begin
if (reset)
q <= 4'b0001;
else
q <= {q[2:0], q[3] ^ q[2]};
end
endmodule
  • Reset: Active-high synchronous; effective at a rising edge.
  • Hold behavior: Clock enable as an explicit condition around the update.

Implementation Checks​

  • Simulation: Behavior under supplied input vectors.
  • Synthesis: Mapping to hardware resources.
  • Place-and-route: Physical interconnection and delays.
  • Timing analysis: Clock/input/output constraints and worst path slack.
  • Clocking: Dedicated clock resources; enable preferred over casual combinational clock gating.
  • Asynchronous boundary: Synchronization plus coherent-transfer protocol.
  • Hardware pins: Verified package assignment, I/O rail, drive and startup state.
  • Failure recovery: Deliberate zero-state handling if recovery required; no implicit recovery in the example.

Practice​

  • Preparation: HDL simulation or four-column hand table; 1 MHz clock; reset asserted for two rising edges.
  • Prediction: Fifteen-state cycle and zero lock-up.
  • Execution: Reset release between edges; fifteen updates; distinct-state count; separate zero-seed run.
  • Observation: Values and event timing independently checked.
CheckExpectedCalculated / simulated
Reset0001—
First four updates0010, 0100, 1001, 0011—
Distinct nonzero states15—
Cycle duration15 µs—
  • Optional extension: Clock enable held low for three edges; synthesis/timing report on a known platform.
  • Carry forward: Valid internal sequence before external interfacing.

Exercises​

  1. Update: Next state from 0100.
  2. Feedback: Entering bit for state 1100.
  3. Zero: Next state from 0000.
  4. Period: Full sequence duration at 2 MHz.
  5. Validation: Information missing from a successful behavior simulation.
Answers and reasoning
  1. Answer: 1001.
  2. Answer: 0; 1 XOR 1.
  3. Answer: 0000.
  4. Answer: 7.5 µs.
  5. Answer: Actual routed timing, electrical pin compatibility and configuration behavior, among other hardware conditions.

Continue​

Reference​

  • Reading: Paul Horowitz and Winfield Hill, The Art of Electronics, third edition, Chapter 11.
  • Lesson material: Original explanations, calculation examples and exercises; reference sections for further study.