Professional Documents
Culture Documents
INSTRUCTIONS TO CANDIDATES
This exam contains four questions. All questions should be attempted. Each question is
worth a total of 25 marks.
All questions are to be answered in the same book
Non-programmable calculators are allowed
This is a closed book examination
1 of 3
cin
cout
triggered and built entirely from D flip-flops and simple logic gates. All flip-flops must
have their clock inputs connected directly to clk.
Question 3 VHDL (25 marks)
a. (5 marks) The entity for a 2-input AND gate is given below. Write the corresponding
architecture in behavioural VHDL. The name of the entity should be and2.
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity and2 is
port (a, b: in std_logic;
y: out std_logic);
end and2;
b. (10 marks) Write an architecture-entity pair for a 4-input AND gate using only the and2
devices in part a. The name of the entity should be and4. Make sure you declare
and2 as a component and the description is a structural one (zero marks will be
awarded for a behavioural description).
c. (10 marks) Write the architecture-entity pair for a positive edge-triggered 8-bit binary
down counter in VHDL. The counter has a single clock input and produces a single
std_logic_vector output q. Marks will be deducted for solutions which are excessively
complex or long.
Question 4 State Machines (25 marks)
a. (5 marks) A 3-bit Gray code counter advances on positive clock edges and generates
outputs in the sequence: 000, 001, 011, 010, 110, 111, 101, 100. Draw the assigned
state table for a state machine implementing this counter.
b. (10 marks) For the Gray code counter in part a, derive (unoptimised) equations for the
next state as a function of the current state.
c. (10 marks) Consider the following sequence detector. In each clock cycle, one bit is
received on serial_in. When the three most-recently received bits are 101, the
sequence detector should output a 1 on z. Otherwise, it should output a 0.
Draw a state diagram for a state machine implementation of the sequence detector.
Marks will be deducted for solutions which are excessively complex. Clearly state any
assumptions you make.
-- This is the last page --
3 of 3