Docsity

5 Solved Problems Midterm Exam - Artificial Intelligence | ECE 448, Exams of Electrical and Electronics Engineering

Toggle sidebar
bg1
ECE 448
Midterm Exam 1
Thursday, March 8, 2007
Problem 1 (2 points)
For a given below VHDL code, provide solutions to the following problems:
1. Which type of finite state machine, Moore or Mealy, does this code implement?
2. Draw a state diagram of this FSM.
3. Supplement timing waveforms given in the answer sheet with values of the state s and
output q.
library IEEE;
use IEEE.std_logic_1164.all;
entity PROBLEM1 is
port (
CLK: in STD_LOGIC;
d: in STD_LOGIC;
q: out STD_LOGIC_VECTOR (1 downto 0));
end;
architecture PROBLEM1_arch of PROBLEM1 is
type Sreg0_type is (S1, S2, S3, S4);
signal Sreg0: Sreg0_type;
begin Sreg0_machine: process (CLK)
begin if CLK'event and CLK = '1' then
case Sreg0 is
when S1 =>
if d='0' then
Sreg0 <= S1;
else Sreg0 <= S3;
end if;
when S2 =>
if d='1' then
Sreg0 <= S3;
else Sreg0 <= S1;
end if;
when S3 =>
if d='1' then
Sreg0 <= S3;
else Sreg0 <= S4;
end if;
pf3
pf4

Partial preview of the text

Download 5 Solved Problems Midterm Exam - Artificial Intelligence | ECE 448 and more Exams Electrical and Electronics Engineering in PDF only on Docsity!

ECE 448

Midterm Exam 1

Thursday, March 8, 2007

Problem 1 (2 points)

For a given below VHDL code, provide solutions to the following problems:

1. Which type of finite state machine, Moore or Mealy, does this code implement?

2. Draw a state diagram of this FSM.

3. Supplement timing waveforms given in the answer sheet with values of the state s and

output q.

library IEEE; use IEEE.std_logic_1164.all; entity PROBLEM1 is port ( CLK: in STD_LOGIC; d: in STD_LOGIC; q: out STD_LOGIC_VECTOR (1 downto 0)); end; architecture PROBLEM1_arch of PROBLEM1 is type Sreg0_type is (S1, S2, S3, S4); signal Sreg0: Sreg0_type; begin Sreg0_machine: process (CLK) begin if CLK'event and CLK = '1' then case Sreg0 is when S1 => if d='0' then Sreg0 <= S1; else Sreg0 <= S3; end if; when S2 => if d='1' then Sreg0 <= S3; else Sreg0 <= S1; end if; when S3 => if d='1' then Sreg0 <= S3; else Sreg0 <= S4; end if;

when S4 => if d='1' then Sreg0 <= S1; else Sreg0 <= S2; end if; when others => null; end case; end if; end process; q_assignment: q <= "01" when (Sreg0 = S1 and d='0') else "11" when (Sreg0 = S1 and d='1') else "10" when (Sreg0 = S2 and d='1') else "00" when (Sreg0 = S2 and d='0') else "01" when (Sreg0 = S3 and d='1') else "10" when (Sreg0 = S3 and d='0') else "10" when (Sreg0 = S4 and d='1') else "00" when (Sreg0 = S4 and d='0') else "00"; end PROBLEM1_arch;

Problem 2 (2 points)

Write a testbench that generates the following input stimuli. Assume that the signals clk, r

and s are periodical, and the signals resetn and m are non-periodical. The simulation

should be able to continue indefinitely under this assumption. Do your best to minimize

the amount of lines of VHDL code you write, by employing VHDL instructions such as

FOR LOOP, etc.

clk m( 1 ) m( 0 ) r(1 downto 0) s resetn 0 ns 2 00 ns 4 00 ns 6 00 ns 8 00 ns 10 00 ns โ€œ 01 โ€ โ€œ^10 โ€^ โ€œ^11 โ€^ โ€œ^00 โ€^ โ€œ^01 โ€^ โ€œ^10 โ€ clk m( 1 ) m( 0 ) r(1 downto 0) s resetn 0 ns 2 00 ns 4 00 ns 6 00 ns 8 00 ns 10 00 ns โ€œ 01 โ€ โ€œ^10 โ€^ โ€œ^11 โ€^ โ€œ^00 โ€^ โ€œ^01 โ€^ โ€œ^10 โ€

Problem 4 ( 2 points)

Describe the following digital circuit in synthesizable VHDL using dataflow design style

only (no structural description) and a single for-generate scheme for equations (you

need to provide full entity architecture , no entity declaration needed). Assume that the

basic components shown in the diagram are XOR gate and Full Adder, respectively.

Problem 5 (2 points)

What is a minimum number of Spartan 3 Logic Cells (one Logic Cell = ยฝ of a CLB

Slice) necessary to implement

a. 40 - bit register with serial input and parallel output

b. Functions y 1 =x 1 x 2 +x 1 x 3 +x 2 x 3 , y 2 =x 1 x 2 x 3 +x 1 x 4 +x 1 x 5

c. 40 - bit ripple-carry adder

d. 40 - bit shift register with serial input and serial output

e. 4 - to-1 multiplexer

f. 128x16 dual port RAM

Which components of Logic Cells (Multipurpose LUT, Carry & Control, Storage

Element) are used in each case, and in which mode of operation (ROM, RAM, shift-

register, fast carry logic, latch, flip-flop, etc.) they work?