Exam1 (Example With Solutions)
Exam1 (Example With Solutions)
1. A Moore model finite state machine that acts as a “1011” sequence detector is to be designed using behavioral
VHDL. Your design should detect overlapping sequences. Assume the input is named A, the output is named Z
and that an active low reset signal (reset_n) asynchronously resets the machine. The VHDL ENTITY construct
is given. Write the corresponding VHDL ARCHITECTURE construct to implement the FSM. Implement positive
edge triggered flip-flops.
(a) Draw the Moore model state diagram for the FSM.
LIBRARY ieee;
USE ieee.std_logic_1164.all;
ENTITY seqdetect_fsm IS
PORT (A : IN STD_LOGIC;
Clk : IN STD_LOGIC;
reset_n : IN STD_LOGIC;
Z : OUT STD_LOGIC);
END seqdetect_fsm;
2. Write a behavioral VHDL description for a 4-bit shift register. The shift register is to be negative edge triggered.
Sin is a serial input to the most significant bit of the shift register. Sout is a serial output from the least
significant bit of the shift register. En_n is an active low enable. sreg is the 4-bit register. Write only the VHDL
ARCHITECTURE construct. The VHDL ENTITY construct is given below.
LIBRARY ieee;
USE ieee.std_logic_1164.all;
ENTITY shiftreg is
PORT ( CLK : IN STD_LOGIC;
En_n : IN STD_LOGIC;
Sin : IN STD_LOGIC;
Sout : OUT STD_LOGIC);
END shiftreg;
PROCESS(clk)
BEGIN
IF FALLING_EDGE(CLK) THEN
IF (En_n=’0’) THEN
Sout <= sreg(0);
sreg <= Sin & sreg(3 DOWNTO 1);
END IF;
END IF;
END PROCESS;
END Behavior;
3. A given FPGA uses 2-input lookup tables to implement Boolean functions. Show a section of a programmed
FPGA that implements the function f(x,y,z)=Σm(0,1,2,5,7).
4. Draw a diagram for typical output circuitry in a PLA. Describe each component.
The D flip-flop provides storage capability for the PLA block, allowing
sequential circuits to be implemented. The multiplexer selects either
registered or non-registered outputs from the PLA. The tri-state gate
allows the output to have tri-state capabilities. Feedback into the
programmable AND plane is provided as well.
The list contains all signals that can be used to activate the process.
6. Give the VHDL statement to implement the logic function in problem 4 using a selected assignment statement.
Define any signals used in the statement.
7. Write a behavioral VHDL description for a 2-to-1 multiplexer. Model the multiplexer as a process block Write
only the VHDL ARCHITECTURE construct. The VHDL ENTITY construct is given below.
LIBRARY ieee;
USE ieee.std_logic_1164.all;
ENTITY mux2to1 IS
PORT ( w : IN STD_LOGIC_VECTOR(1 DOWNTO 0);
s : IN STD_LOGIC;
f : OUT STD_LOGIC );
END mux2to1;