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.
Worked LFSR
- 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.
| Check | Expected | Calculated / simulated |
|---|---|---|
| Reset | 0001 | — |
| First four updates | 0010, 0100, 1001, 0011 | — |
| Distinct nonzero states | 15 | — |
| Cycle duration | 15 µ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
- Update: Next state from 0100.
- Feedback: Entering bit for state 1100.
- Zero: Next state from 0000.
- Period: Full sequence duration at 2 MHz.
- Validation: Information missing from a successful behavior simulation.
Answers and reasoning
- Answer: 1001.
- Answer: 0; 1 XOR 1.
- Answer: 0000.
- Answer: 7.5 µs.
- Answer: Actual routed timing, electrical pin compatibility and configuration behavior, among other hardware conditions.
Continue
- Previous: Digital Logic
- Next: Logic Interfacing
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.