Exercise set
Digital Logic and Timing Analysis Exercises
Worked computer engineering exercises for digital logic and embedded timing, covering Boolean simplification, propagation delay, setup and hold checks, synchronizers, bus throughput, buffers, sampling, quantization, jitter, interrupt load, timers, PWM, and release evidence.
These exercises practise digital logic and embedded timing analysis as engineering evidence. They cover Boolean simplification, propagation delay, setup and hold timing, clock-domain crossing screens, bus throughput, buffer sizing, sampling, quantization, jitter, interrupt load, timer resolution, PWM resolution, and release checks.
The goal is not only to obtain a number. The goal is to decide whether a digital function can meet its logic, timing, measurement, communication, and fault-response requirements on real hardware.
Assume simplified screening models unless an exercise states otherwise. Real systems should also check process-voltage-temperature corners, clock tolerance, board delay, signal integrity, reset behavior, firmware scheduling, electromagnetic interference, diagnostics, and validation records.
How to Use These Exercises
For each exercise, define:
- the logic path, clock domain, bus, measurement, or firmware task being assessed;
- the required timing, accuracy, throughput, or safe-state behavior;
- the margin between requirement and estimated performance;
- the physical assumptions behind the estimate;
- the evidence needed before release.
The common mistake is treating digital logic as ideal. A Boolean expression can be correct while the implemented circuit fails because of propagation delay, metastability, bus contention, interrupt overload, weak pull-ups, noisy inputs, or insufficient validation.
Exercise 1: Boolean Simplification
A combinational output is defined as:
Simplify the expression.
Solution
Factor out A:
Since:
the output becomes:
Engineering Comment
The simplified logic needs fewer gates and usually less delay, area, and switching power. The review should still check whether the original expression came from a safety requirement, diagnostic condition, or deliberately redundant implementation.
Exercise 2: Propagation Delay of a Logic Path
A combinational path contains three gates with propagation delays:
Estimate the path delay.
Solution
For a simple serial path:
Substitute:
Engineering Comment
This is a nominal path estimate. Real timing must include routing delay, loading, input slew, output drive, temperature, voltage, and the timing model used by the implementation tool.
Exercise 3: Maximum Clock Frequency
A synchronous path has:
Compute the minimum clock period and maximum clock frequency.
Solution
The minimum period is:
Substitute:
Therefore:
So:
Engineering Comment
This path may support 125 MHz under the assumed conditions. A release decision should still check worst-case timing reports, unconstrained paths, clock uncertainty, generated clocks, I/O timing, and whether this path is actually the critical path.
Exercise 4: Setup Slack
A register-to-register path must run with:
The data path and timing terms are:
Compute setup slack.
Solution
Setup slack is:
Substitute:
Engineering Comment
The path has positive setup slack. The 1.20 ns margin is useful, but it should not hide missing constraints, false-path errors, or measurements taken at only one voltage and temperature condition.
Exercise 5: Hold Margin
A hold check has:
Clock skew reduces the available hold margin by:
Compute hold margin:
Solution
Substitute:
Engineering Comment
The hold margin is positive but small. Lowering the clock frequency does not fix hold violations. Hold review needs minimum-delay analysis, clock-tree behavior, routing, constraints, and any clock-domain crossing assumptions.
Exercise 6: Synchronizer Latency
An asynchronous status signal is sampled through a two-flop synchronizer in a destination clock domain running at:
Estimate synchronizer latency using:
Solution
The destination clock period is:
Then:
Engineering Comment
The two-flop synchronizer reduces metastability risk for a single-bit level signal, but it is not a complete solution for multi-bit data, pulses shorter than the destination clock, reset release, or safety-critical event capture.
Exercise 7: Effective Bus Throughput
A serial bus has line rate:
Protocol overhead is:
Estimate effective payload throughput:
Solution
Substitute:
Engineering Comment
This estimate still ignores arbitration, retries, idle time, interrupt service, DMA setup, and driver buffering. For real-time traffic, worst-case transaction time may be more important than average throughput.
Exercise 8: Buffer Size for a Service Gap
A sensor stream produces:
The processor can be busy for a maximum service gap of:
Estimate the minimum buffer size:
Solution
Convert:
Compute:
Engineering Comment
The buffer should be larger than 9.6 kB after accounting for framing, burstiness, interrupt latency, DMA descriptors, watermark policy, and diagnostic logging. Increasing buffer size does not solve a sustained overload where average service rate is too low.
Exercise 9: Sampling and Nyquist Frequency
An embedded system samples a vibration signal at:
Compute the Nyquist frequency and state whether a 2.6 kHz component can be represented without aliasing in the ideal sampling model.
Solution
Nyquist frequency is:
A 2.6 kHz component is above 2.0 kHz, so it violates the ideal Nyquist limit.
Engineering Comment
The input needs a higher sample rate, an anti-alias filter that attenuates 2.6 kHz sufficiently, or a revised measurement requirement. Real anti-alias filters need transition-band margin, not only the mathematical cutoff.
Exercise 10: ADC Quantization Step
An ADC has:
and full-scale range:
Compute the ideal least significant bit size:
Solution
The number of codes is:
Therefore:
So:
Engineering Comment
The ideal quantization step is only one part of measurement quality. Reference accuracy, sensor error, input impedance, settling, grounding, temperature drift, noise, calibration, and firmware scaling may dominate the error budget.
Exercise 11: Jitter as a Fraction of Sampling Period
A control loop samples at:
Measured peak timing jitter is:
Compute relative sample-time error:
Solution
Sampling period:
Convert:
Then:
Therefore:
Engineering Comment
Whether 1.8% is acceptable depends on control bandwidth, phase margin, sensor dynamics, actuator delay, and fault response. Jitter should be measured under realistic interrupt, communication, and logging load.
Exercise 12: Interrupt CPU Load
Three periodic interrupts have the following worst-case execution times:
| Interrupt | Frequency | Execution time |
|---|---|---|
| Timer control | 1.0 kHz | 18 us |
| Encoder capture | 4.0 kHz | 5 us |
| Communication receive | 800 Hz | 12 us |
Estimate total interrupt CPU utilization:
Solution
Timer control:
Encoder capture:
Communication receive:
Total:
Therefore:
Engineering Comment
This interrupt load is moderate, but the calculation does not prove deadline safety. The design must also check priority inversion, disabled-interrupt intervals, nested interrupts, cache effects, bus stalls, shared data, stack margin, and worst-case burst behavior.
Exercise 13: Timer Resolution and Rollover
A 16-bit timer runs from a clock:
with prescaler:
Compute timer tick period and rollover time:
Solution
Tick period:
Rollover time:
Engineering Comment
A 1 us tick gives useful timestamp resolution, but a 65.536 ms rollover must be handled correctly. Firmware should test rollover arithmetic, capture latency, interrupt delay, and clock tolerance.
Exercise 14: PWM Duty Resolution
A PWM timer uses:
so it has 1000 discrete duty counts from 0 to 999. Estimate duty-cycle resolution:
Solution
Compute:
Therefore:
Engineering Comment
Duty resolution is not the same as actuator resolution. Output driver dead time, switching frequency, motor inductance, load dynamics, supply ripple, timer update timing, and safe startup state can dominate actual behavior.
Exercise 15: Release Evidence for a Timing Change
A firmware revision increases the control-loop computation time from:
to:
The loop period is:
The existing timing budget reserved:
of margin. Determine the new margin.
Solution
The computation-time increase is:
The new margin is:
Engineering Comment
The margin remains positive, but release still needs trace evidence under representative load. A timing change should update worst-case execution measurement, interrupt-latency records, stack margin, watchdog assumptions, control-loop validation, and rollback criteria.