DREXEL UNIVERSITY, Electrical and Computer Engineering ECE

advertisement
DREXEL UNIVERSITY, Electrical and Computer Engineering
ECE-C302
Practice Problems: Allowed: Notes, reused codes on thumb drive. Not allowed: web (network) access.
Problem 1
PART A (2 pts) Design and implement a decoder to display hexadacimal character on the leftmost
seven-segment display (other displays off), from Switch 3 down to 0.
PART B (4pts): Design and implement a combination lock with hexadecimal key code equal to ECE.
The key is entered in a sequence from left to right. The two button single-step circuit is used
to enter key code. When the correct sequence is entered LED7 will light and at any
instance an incorrect key bit is entered LED0 will light and the combinational lock is idle until reset.
User first apply reset then enter key bit sequence. Wire reset to Switch 7.
entity CombiLock is
port ( ck, reset, b1, b2 : in std_logic;
key_code: in std_logic_vector(3 downto 0);
incorrect, open: out std_logic);
end CombiLock;
PART C (2 pts): User is allowed to make three mistakes in entering key, after three mistakes
the combination lock will cease to function, i.e., user can no longer reset and enter key.
Problem 2
Fig. 1 Four 2-bit Registers - Part A
a) Implement a set of four 2-bit registers (Fig.1) where new contents can be loaded from the switches
(SW7 SW6 for Register 3, SW5 SW4 for Register 2, SW3 SW2 for Register 1, SW1 SW0 for Register 0) and
the current contents are displayed on the LEDs. New contents are loaded when Button 1 (b1) is pressed.
(3 pts)
Entity c_reg_A is
Port ( x: in std_logic_vector(7 downto 0);
z: out std_logic_vector(7 downto 0);
ck, b1: in std_logic);
End c_reg_A;
Fig. 2 Shift left/right Cascading Registers - Part B
b) Implement cascading registers shown in Fig. 2 where each register can be loaded with new contents
from the switches when Button 1 is presses as in Part a. However, to provide a single-step mechanism
for left or right shift, a design where a reset button, say Button 2 is first pressed in order to execute left
or right shift when pressing Button 3 or Button 4, respectively. (5 pts)
Entity c_reg_B is
Port ( x: in std_logic_vector(7 downto 0);
z: out std_logic_vector(7 downto 0);
ck, b1, b2, b3, b4: in std_logic);
Problem 3
SW0
Reset
b1,b2
LEDs
Fig. 1 Combinational Lock - Part A
a) Implement a sequential combination lock with the key “1011”. After a reset user enters key bit (SW0)
reading from left to right. The lock requires two-button single-step mechanism (btn0 and btn1) for
entering the key bits sequentially. When the key bits are entered correctly an LED0 lights up and the lock
freezes. If any key bit is wrong LED7 lights up and the lock freezes. The process can be reset and begins
again. (4 pts)
Entity Lock_A is
Port ( x: in std_logic;
z: out std_logic_vector(1 downto 0);
reset, ck, b0,b1: in std_logic);
End Lock_A;
SW0
Reset
b1,b2
LEDs
SW7
b3,b4
Fig. 2 Programmable Combinational Lock - Part B
b) Implement a sequential lock with a programmable key. The key is a sequence of 4 bits (in general can
be many more). The key is programmed into the lock in a serial fashion at port key (SW7) using the twobutton single-step – btn3 and bth4
Entity Lock_B is
Port ( x: in std_logic_vector(7 downto 0);
z: out std_logic_vector(1 downto 0);
reset, ck, b1, b2, b3, b4: in std_logic);
End Lock_B;
Download