This project contains the VHDL designs developed for LAB07 of the course
Electronics Programmable Systems (EPS).
The objective is to design a synchronous digital circuit that generates:
CLK_L→ a clock signal with frequency CLK ÷ 16CLK_SF→ a phase-shifted version ofCLK_L, where the shift is programmable over 0–360° using a 4-bit inputDIG_DELAY
Both designs are written for synthesis on a
Xilinx Spartan-3 XC3S200 (VQ100, –4) FPGA device.
fpga-phase-shifted-clock/
├── README.md
├── docs/
│ └── EPS_LAB07_20220510.pdf
└── src/
├── EPS07a.vhd -- Part A implementation
└── LAB07B.vhd -- Part B implementation
The full lab specification is included in:
docs/EPS_LAB07_20220510.pdf
It describes the assignment requirements, input/output behavior, timing, and FPGA target device.
EPS07a implements:
- A clock divider generating
CLK_L = CLK ÷ 16from the system clockCLK - A programmable phase shifter generating
CLK_SF - A
LOADmechanism that latches a new delay value (DIG_DELAY)
and keeps the phase constant until the next load pulse
Typical ports (names may differ slightly depending on your version):
CLK— system clockRESET— reset inputDIG_DELAY(3 downto 0)— 4-bit phase shift controlLOAD— strobe to update delayCLK_L— divided clock outputCLK_SF— phase-shifted clock output
- A synchronous counter divides
CLKby 16 to generateCLK_L. - A delay/offset register defines the phase shift of
CLK_SFrelative toCLK_L. - The delay register is updated only when
LOADis asserted, so the phase relationship stays constant between load events. - All logic is synchronous to
CLK, fully synthesizable and suitable for static timing analysis.
LAB07B.vhd implements the same external behavior as Part A but using a different internal design approach.
It is used to:
- Demonstrate an alternative synchronous architecture for the same problem
- Compare resource usage (LUTs, FFs, etc.)
- Compare maximum clock frequency and timing margins between two valid solutions
Part B:
- Generates
CLK_L = CLK ÷ 16 - Generates
CLK_SFwith the same frequency and programmable phase shift - Uses the same
DIG_DELAYandLOADinterface to control phase shift - Keeps the phase fixed until the next
LOAD
The following ASCII timing diagrams illustrate the expected behavior of the design.
CLK : ┌─┐ ┌─┐ ┌─┐ ┌─┐ ┌─┐ ┌─┐ ┌─┐ ┌─┐ ┌─┐ ┌─┐ ...
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
──┘ └───┘ └───┘ └───┘ └───┘ └───┘ └───┘ └───┘ └───┘ └───┘ └────
CLK_L : ┌─────────┐ ┌─────────┐
│ │ │ │
──┘ └───────────┘ └─────────── (period = 16 × T_CLK)
CLK_L toggles every 8 cycles of CLK, giving a full period of 16 CLK cycles.
Assume:
DIG_DELAY = 0→CLK_SFis in phase withCLK_LDIG_DELAY = 4→CLK_SFlagsCLK_Lby 4 counts (90° for a 16‑step delay)
DIG_DELAY = "0000" (0)
LOAD : ____┌─┐_______________________________________________
^ value "0000" is loaded here
CLK_L : ┌───────┐ ┌───────┐ ┌───────┐
│ │ │ │ │ │
_______┘ └_______┘ └_______┘ └____
CLK_SF : ┌───────┐ ┌───────┐ ┌───────┐
│ │ │ │ │ │
_______┘ └_______┘ └_______┘ └____
(in phase with CLK_L when DIG_DELAY = 0)
Now with a non‑zero delay:
DIG_DELAY = "0100" (4)
LOAD : _____________┌─┐_______________________________________
^ value "0100" is loaded here
CLK_L : ┌───────┐ ┌───────┐ ┌───────┐
│ │ │ │ │ │
___________┘ └_______┘ └_______┘ └____
CLK_SF : ┌───────┐ ┌───────┐ ┌───────┐
│ │ │ │ │ │
_______________┘ └_______┘ └_______┘ └
<---- 4 internal delay steps ---->
(phase shift relative to CLK_L)
After LOAD is asserted, CLK_SF transitions are shifted by a number of internal counter steps proportional to DIG_DELAY.
The phase relationship remains constant until the next LOAD pulse.
- Create a new FPGA project (Xilinx ISE/Vivado) targeting
Spartan-3 XC3S200, VQ100, –4. - Add into the project:
src/EPS07a.vhdfor the Part A implementation, orsrc/LAB07B.vhdfor the Part B implementation.
- Set the top‑level entity accordingly (
EPS07aorLAB07B, depending on your code). - Create a VHDL testbench to drive:
CLK(system clock)RESETDIG_DELAYLOAD
- Run behavioral simulation:
- Verify division by 16 on
CLK_L - Verify phase shift of
CLK_SFwhenDIG_DELAYandLOADchange
- Verify division by 16 on
- Run synthesis, implementation, and timing analysis:
- Check maximum clock frequency
- Compare area and timing between Part A and Part B
- Synchronous digital design in VHDL
- Clock division and clock‑like signal generation
- Programmable digital phase shifting using counters and delay logic
- FPGA synthesis and timing analysis on a Spartan‑3 device
- Comparison of different architectures implementing the same specification
Hamed Nahvi