Docsity

EECS303: Advanced Digital Design Homework 4, Exercises of Verilog and VHDL

Toggle sidebar
bg1
Northwestern University Nov 8, 2011
Electrical Engineering and Computer Science Handout #10
EECS303: Advanced Digital Design, Fall 11 Due: Nov 15
Prof. Hai Zhou
Homework 4
You may discuss the assignments with your classmates but need to write down your solutions
independently. Be careful with your handwriting. Unclear solutions will be assumed wrong.
1. (5 pts) What is the difference between a signal and variable assignment?
2. (10 pts) Wait statement is used to temporarily suspend a process. Which one of the
wait statement combinations you would use for each one of the following cases:
(a) a specified time has passed
(b) a specified condition is met
(c) an event occurs which affects one or more signals
3. (10 pts) What is the function of the following piece of code?
-- D IN: in BIT;
-- RESET: in BIT;
-- CLK: in BIT;
-- Q OUT: out BIT;
signal Q1, Q2, Q3 : BIT;
process(CLK, RESET)
begin
if (RESET = โ€™1โ€™) then
Q1 <= โ€™0โ€™;
Q2 <= โ€™0โ€™;
Q3 <= โ€™0โ€™;
elsif (CLKโ€™event and CLK = โ€™1โ€™) then
Q1 <= D IN;
Q2 <= Q1;
Q3 <= Q2;
end if;
end process;
Q OUT <= Q1 and Q2 and (not Q3);
4. (15 pts) What is the function of the following piece of code?
pf3

Partial preview of the text

Download EECS303: Advanced Digital Design Homework 4 and more Exercises Verilog and VHDL in PDF only on Docsity!

Northwestern University Nov 8, 2011 Electrical Engineering and Computer Science Handout # EECS303: Advanced Digital Design, Fall 11 Due: Nov 15 Prof. Hai Zhou

Homework 4

You may discuss the assignments with your classmates but need to write down your solutions independently. Be careful with your handwriting. Unclear solutions will be assumed wrong.

  1. (5 pts) What is the difference between a signal and variable assignment?
  2. (10 pts) Wait statement is used to temporarily suspend a process. Which one of the wait statement combinations you would use for each one of the following cases:

(a) a specified time has passed (b) a specified condition is met (c) an event occurs which affects one or more signals

  1. (10 pts) What is the function of the following piece of code?

-- D IN: in BIT; -- RESET: in BIT; -- CLK: in BIT; -- Q OUT: out BIT;

signal Q1, Q2, Q3 : BIT;

process(CLK, RESET) begin if (RESET = โ€™1โ€™) then Q1 <= โ€™0โ€™; Q2 <= โ€™0โ€™; Q3 <= โ€™0โ€™; elsif (CLKโ€™event and CLK = โ€™1โ€™) then Q1 <= D IN; Q2 <= Q1; Q3 <= Q2; end if; end process;

Q OUT <= Q1 and Q2 and (not Q3);

  1. (15 pts) What is the function of the following piece of code?

entity unknown is port(D: in bit vector(0 to 9); OUTPUT: out bit); constant WIDTH: integer := 10; end unknown;

architecture behavior of unknown is begin process(D) variable tmp: Boolean; begin tmp := false; for i in 0 to Dโ€™length - 1 loop if D(i) = โ€™1โ€™ then tmp := not tmp; end if; end loop; if tmp then OUTPUT <= โ€™1โ€™; else OUTPUT <= โ€™0โ€™; end if; end process; end behavior;

  1. (10 pts) What is the function of the following code?

function val (arg1, arg2: integer) return integer is variable result: integer; begin if arg1 > arg2 then result := arg1; else result := arg2; end if; return result; end val;

  1. (25 pts) Please model the following designs in VHDL. The code does not need to be flawless but the key constructs must be correct.