The University of Alabama in Huntsville ECE Department CPE Midterm Exam Solution March 2, 2006

Similar documents
The University of Alabama in Huntsville ECE Department CPE Midterm Exam Solution Spring 2016

The University of Alabama in Huntsville Electrical and Computer Engineering CPE/EE 422/522 Spring 2005 Homework #6 Solution

Sequential Logic - Module 5

The University of Alabama in Huntsville ECE Department CPE Midterm Exam February 26, 2003

The University of Alabama in Huntsville ECE Department CPE Final Exam Solution Spring 2016

The University of Alabama in Huntsville ECE Department CPE Final Exam Solution Spring 2004

DESCRIPTION OF DIGITAL CIRCUITS USING VHDL

COE 405, Term 062. Design & Modeling of Digital Systems. HW# 1 Solution. Due date: Wednesday, March. 14

CSE 260 Introduction to Digital Logic and Computer Design. Exam 1. Your name 2/13/2014

The University of Alabama in Huntsville ECE Department CPE Final Exam April 28, 2016

FSM Components. FSM Description. HDL Coding Methods. Chapter 7: HDL Coding Techniques

Lecture 7. Standard ICs FPGA (Field Programmable Gate Array) VHDL (Very-high-speed integrated circuits. Hardware Description Language)

COVER SHEET: Total: Regrade Info: 5 (14 points) 7 (15 points) Midterm 1 Spring 2012 VERSION 1 UFID:

DIGITAL LOGIC WITH VHDL (Fall 2013) Unit 6

EEL 4712 Digital Design Test 1 Spring Semester 2008

EL 310 Hardware Description Languages Midterm

VHDL 2 Combinational Logic Circuits. Reference: Roth/John Text: Chapter 2

DIGITAL LOGIC DESIGN VHDL Coding for FPGAs Unit 6

EEL 4712 Digital Design Test 1 Spring Semester 2007

Part 4: VHDL for sequential circuits. Introduction to Modeling and Verification of Digital Systems. Memory elements. Sequential circuits

VHDL Modeling Behavior from Synthesis Perspective -Part B - EL 310 Erkay Savaş Sabancı University

COE 405 Behavioral Descriptions in VHDL

Synthesis from VHDL. Krzysztof Kuchcinski Department of Computer Science Lund Institute of Technology Sweden

IT T35 Digital system desigm y - ii /s - iii

Midterm Exam Thursday, October 24, :00--2:15PM (75 minutes)

Timing in synchronous systems

Test Benches - Module 8

VHDL. VHDL History. Why VHDL? Introduction to Structured VLSI Design. Very High Speed Integrated Circuit (VHSIC) Hardware Description Language

VHDL: RTL Synthesis Basics. 1 of 59

Outline. CPE/EE 422/522 Advanced Logic Design L05. Review: General Model of Moore Sequential Machine. Review: Mealy Sequential Networks.

Sequential Statement

8 Register, Multiplexer and

Two HDLs used today VHDL. Why VHDL? Introduction to Structured VLSI Design

VHDL Examples Mohamed Zaky

Lecture 08 Finite State Machine Design Using VHDL

Department of Electronics & Communication Engineering Lab Manual E-CAD Lab

Summary of FPGA & VHDL


Lecture 4: Modeling in VHDL (Continued ) EE 3610 Digital Systems

Schedule. ECE U530 Digital Hardware Synthesis. Rest of Semester. Midterm Question 1a

ECE Digital Design Laboratory. Lecture 3 Finite State Machines!

COVER SHEET: Total: Regrade Info: 5 (5 points) 2 (8 points) 6 (10 points) 7b (13 points) 7c (13 points) 7d (13 points)

ECE 448 Lecture 4. Sequential-Circuit Building Blocks. Mixing Description Styles

CprE 583 Reconfigurable Computing

ECEU530. Homework 4 due Wednesday Oct 25. ECE U530 Digital Hardware Synthesis. VHDL for Synthesis with Xilinx. Schedule

[VARIABLE declaration] BEGIN. sequential statements

VHDL in 1h. Martin Schöberl

ECE 545 Lecture 6. Behavioral Modeling of Sequential-Circuit Building Blocks. George Mason University

VHDL And Synthesis Review

VHDL for Modeling - Module 10

Assignment. Last time. Last time. ECE 4514 Digital Design II. Back to the big picture. Back to the big picture

VHDL. ELEC 418 Advanced Digital Systems Dr. Ron Hayne. Images Courtesy of Cengage Learning

Concurrent & Sequential Stmts. (Review)

EE 459/500 HDL Based Digital Design with Programmable Logic. Lecture 6 Combinational and sequential circuits

CprE 583 Reconfigurable Computing

Pollard s Tutorial on Clocked Stuff in VHDL

EITF35: Introduction to Structured VLSI Design

Note: Closed book no notes or other material allowed, no calculators or other electronic devices.

VHDL: Modeling RAM and Register Files. Textbook Chapters: 6.6.1, 8.7, 8.8, 9.5.2, 11.2

Sign here to give permission for your test to be returned in class, where others might see your score:

VHDL Simulation. Testbench Design

CPE/EE 422/522. Chapter 8 - Additional Topics in VHDL. Dr. Rhonda Kay Gaede UAH. 8.1 Attributes - Signal Attributes that return a value

EECE 353: Digital Systems Design Lecture 10: Datapath Circuits

A bird s eye view on VHDL!

ECE 545 Lecture 8. Data Flow Description of Combinational-Circuit Building Blocks. George Mason University

SEQUENTIAL STATEMENTS

Problem Set 10 Solutions

UNIT I Introduction to VHDL VHDL: - V -VHSIC, H - Hardware, D - Description, L Language Fundamental section of a basic VHDL code Library :

COVER SHEET: Total: Regrade Info: 7 (6 points) 2 (10 points) 9 (5 points) 8 (12 points) 12 (5 points) 11 (25 points)

VHDL Packages for Synthesis Base Types Standard bit types may be used Typically IEEE 1164 Std. types are used. CPE 528: Session #9

CSE 260 Digital Computers: Organization and Logical Design. Exam 2. Jon Turner 3/28/2012

COVER SHEET: Total: Regrade Info: 1 (8 points) 2 ( 8 points) 3 (16 points) 4 (16 points) 5 (16 points) 6 (16 points) 7 (16 points) 8 (8 points)

Lattice VHDL Training

Writing VHDL for RTL Synthesis

Advanced Training Course on FPGA Design and VHDL for Hardware Simulation and Synthesis. 26 October - 20 November, 2009

Lecture 12 VHDL Synthesis

Hardware Description Language VHDL (1) Introduction

ECE 551 Digital System Design and Synthesis. Instructor: Kewal K. Saluja. Midterm Exam

3 Designing Digital Systems with Algorithmic State Machine Charts

Modeling Complex Behavior

Problem Set 5 Solutions

ECE 459/559 Secure & Trustworthy Computer Hardware Design

310/ ICTP-INFN Advanced Tranining Course on FPGA and VHDL for Hardware Simulation and Synthesis 27 November - 22 December 2006

Hardware Description Languages. Modeling Complex Systems

Digital Systems Design

Control Unit: Binary Multiplier. Arturo Díaz-Pérez Departamento de Computación Laboratorio de Tecnologías de Información CINVESTAV-IPN

COE 405 Design Methodology Based on VHDL

Introduction to VHDL #3

Outline CPE 626. Advanced VLSI Design. Lecture 4: VHDL Recapitulation (Part 2) Signals. Variables. Constants. Variables vs.

State Machine Descriptions

VHDL Testbench. Test Bench Syntax. VHDL Testbench Tutorial 1. Contents

ECE U530 Digital Hardware Synthesis. Course Accounts and Tools

EITF35: Introduction to Structured VLSI Design

DESIGN AND IMPLEMENTATION OF MOD-6 SYNCHRONOUS COUNTER USING VHDL


CSE 260 Introduction to Digital Logic and Computer Design. Exam 1 Solutions

!"#$%&&"'(')"*+"%,%-".#"'/"'.001$$"

In our case Dr. Johnson is setting the best practices

Review of Digital Design with VHDL

VHDL Testbench Design. Textbook chapters 2.19, , 9.5

Transcription:

The University of Alabama in Huntsville ECE Department CPE 526 01 Midterm Exam Solution March 2, 2006 1. (15 points) A barrel shifter is a shift register in which the data can be shifted either by one bit position, as in a normal shift register, or by multiple positions. Design a four-bit barrel shifter that can shift to the right or left by 0, 1, 2, or 3 bits and has clear and parallel load capabilities. If DIR = 0, shift left, shift right. The binary value of S1 and S0 dictate the amount of shift, for example S1S0 = 10 means shift by 2 bit positions. D3 D2 D1 D0 DIR S1 S0 LOAD CLRb CLK Q3 Q2 Q1 Q0 (a) (4 points) Write an entity for the barrel shifter. (c) (11 points) Write an architecture for the barrel shifter entity BARREL is port (D : in std_logic_vector(3 downto 0); CLK, LOAD, CLR, DIR : in std_logic; S : in std_logic_vector(1 downto 0); Q : out std_logic_vector(3 downto 0)); end BARREL; architecture BARREL of BARREL is signal TEMP : std_logic_vector (3 downto 0); process (CLK) if (CLK'event and CLK = '1') then if (CLR = '0') then TEMP <= "0000"; elsif (LOAD = '1') then TEMP <= D; elsif (DIR = '0') then case S is when "00" => TEMP <= TEMP; when "01" => TEMP <= TEMP(2 downto 0) & '0'; when "10" => TEMP <= TEMP(1 downto 0) & "00"; when "11" => TEMP <= TEMP(0) & "000"; when others => TEMP <= TEMP; end case; case S is when "00" => TEMP <= TEMP; when "01" => TEMP <= '0' & TEMP(3 downto 1); when "10" => TEMP <= "00" & TEMP(3 downto 2); when "11" => TEMP <= "000" & TEMP(3); when others => TEMP <= TEMP; end case; Q <= TEMP; end BARREL;

2. (1 point) A function is a primary design unit. (True/False) False 3. (20 points).(a) (12 points) Write a VHDL function to compare two IEEE std_logic_vectors to see whether they are equal. Report an error if any bit in either vector is not 0, 1, or - (don t care), or if the lengths of the vectors are not the same. The function call should pass only the vectors. The function should return TRUE if the vectors are equal, FALSE. When comparing the vectors, consider that 0 = - and 1 = -. Make no assumptions about the index range of the two vectors. (b) (8 points) Show an architecture that includes three calls to the function with the following properties. 1 - returns TRUE, 2 - returns FALSE and 3 - triggers an error message package NEED_IT is function "=" (l, r : in std_logic_vector) return BOOLEAN; end NEED_IT; library ieee; use ieee.std_logic_1164.all; package body NEED_IT is function "=" (l, r : in std_logic_vector) return BOOLEAN is alias L_NEW : std_logic_vector(l'length - 1 downto 0) is L; alias R_NEW : std_logic_vector(r'length - 1 downto 0) is R; variable MATCH : BOOLEAN; assert (L'length = R'length) report "Vectors are not the same length" severity ERROR; MATCH := TRUE; for I in L_NEW'range loop if ((L_NEW(I) /= '0' and L_NEW(I) /= '1' and L_NEW(I) /= '-') or (R_NEW(I) /= '0' and R_NEW(I) /= '1' and R_NEW(I) /= '-')) then report "Vectors have illegal values" severity ERROR; if (L_NEW(I) = '0') then if (R_NEW(I) /= '0' and R_NEW(I) /= '-') then MATCH := FALSE; elsif (L_NEW(I) = '1') then if (R_NEW(I) /= '1' and R_NEW(I) /= '-') then MATCH := FALSE; end loop; return MATCH; end; end NEED_IT; use work.need_it.all; architecture TEST_EQUAL of TEST_EQUAL is signal EQUAL : BOOLEAN; process variable A : std_logic_vector(8 downto 3) := "0-1011"; variable B : std_logic_vector (93 downto 86) := "00000000"; variable C : std_logic_vector(47 to 52) := "011--1"; variable D : std_logic_vector(0 to 5) := "011-10"; EQUAL <= A = B after 10 ns; EQUAL <= transport A = C after 20 ns; EQUAL <= transport A = D after 30 ns; wait; end TEST_EQUAL;

4. (1 point) A process may have both a sensitivity list and wait statements (True/False) False 5. (1 point) In order to specify edge behavior the STABLE attribute is used in concurrent statements. 6. (1 point) A configuration binds an instantiated component to a library model 7. (8 points) Design a two-out-of-five code detector. The device receives as input a 5-bit parallel word. The detector output is a logic 1 for any code word that has exactly two 1 s in it and is a logic 0, otherwise. (a) (2 points) Write a VHDL entity for the detector. (b) (6 points) Write a VHDL architecture for the detector. entity TWO_OF_FIVE is port (I : in std_logic_vector(4 downto 0); O : out std_logic); end TWO_OF_FIVE; architecture BEHAV of TWO_OF_FIVE is process(i) variable ONES_COUNT : integer range 0 to 5; ONES_COUNT := 0; for J in I'range loop if (I(J) = '1') then ONES_COUNT := ONES_COUNT + 1; end loop; if (ONES_COUNT = 2) then O <= '1'; O <= '0'; end BEHAV;

8. (7 points) A clocked T flip-flop with synchronous CLEAR and PRESET operates in the following manner: At the falling edge of CLK, Q = 0 and QB = 1 if CLEAR = 1, Q = 0 and QB = 1 if PRESET = 1 and Q = not Q and QB = not QB if T = 1 and Q and QB remain unchanged if T = 0. The delay associated with CLEAR and PRESET is TPCPQ, the delay associated with T is TPTQ. (a) (2 points) Write an entity for this flip-flop. (b) (5 points) Write an architecture for this flip-flop. entity TFF is generic (TPCPQ, TPTQ : time); port (CLEAR, PRESET, CLK, T : in std_logic; Q, QB : out std_logic); end TFF; architecture BEHAV of TFF is signal TEMP : std_logic; process(clk) if (CLK = '0' and CLK'event) then if (CLEAR = '1') then TEMP <= '0' after TPCPQ; elsif (PRESET = '1') then TEMP <= '1' after TPCPQ; elsif (T = '1') then TEMP <= not TEMP after TPTQ; TEMP <= TEMP; Q <= TEMP; QB <= not TEMP; end BEHAV; 9. (5 points) Consider the following structural VHDL model. entity SMODEL is port (P1 : in BIT; P2 : out BIT; P3 : inout BIT); end SMODEL; architecture STRUCTURE of SMODEL is component UNIT port (C1, C2, : in BIT; C3 : out BIT); end component; U1 : UNIT port map (C1 => P3, C2 => P1, C3 => P2); end STRUCTURE; (a) (3 points) Complete the structural description by giving a legal set of port-to-port connections for entity ports P1, P2, and P3 and component ports C1, C2, and C3. (b) (2 points) Is there more than one possible set of legal port-to-port connections? Yes P1, P3, P2 or P3, P1, P2

10. (10 points) For the following VHDL, assume that A changes to 1 at 5 ns and back to 0 at 12 ns. Give the values of A, B, C, D, E, and F each time a change occurs. Carry this out until no further change occurs. entity prob is port (D : inout bit); end prob; architecture PROB of PROB is signal A, B, C, E, F : bit; P1: process (A, C) B <= A after 2 ns; E <= C after 7 ns; end process P1; C <= A and B after 6 ns; P2: process (C, E) F <= C and E after 4 ns; end process P2; D <= A or B or C or F; end PROB; Time A B C D E F 0 ns 0 0 0 0 0 0 5 ns 1 0 0 0 0 0 5+Δ ns 1 0 0 1 0 0 7 ns 1 1 0 1 0 0 12 ns 0 1 0 1 0 0 14 ns 0 0 0 1 0 0 14+Δ ns 0 0 0 0 0 0 Time Activity Triggered Scheduled Event? 5ns A 0 1 P1 B 1 7ns Yes E 0 12 ns No C C 0 12 ns No D D 1 5+Δ ns Yes 5+Δ D 0 1 None 7 B 0 1 C C 1 13 ns Yes D D 1 7+Δ ns No 12 A 1 0 P1 B 0 14 ns Yes E 0 19 ns No C C 0 18 ns Overwrites C 1 13 ns, No D D 1 12+Δ ns No 14 B 1 0 C C 0 20 ns No D D 0 14+Δ ns Yes 14+Δ D 1 0 None 11. (4 points) (a) (2 points) Specify a DAY_OF_WEEK enumeration data type. (b) (2 points) Write a variable declaration CURRENT_DAY that has a value equal to the current day of the week. package TRY is type DAY_OF_WEEK is (SU, MO, TU, WE, TH, FR, SA); variable CURRENT_DAY : DAY_OF_WEEK := TH; end TRY; 12. (10 points) Design a 2 to 4 decoder with enable. All outputs are tristated when the enable input = 0. When the enable input = 1, one of the four output D0, D1, D2, D3 is selected based on the binary value of the two select inputs S1 and S0. (a) (2 points) Write a VHDL entity. (b) (4 points) Use concurrent signal assignments to implement the architecture. (c) (4 points) Use sequential statements to implement the architecture. Include any necessary library references. library ieee; use ieee.std_logic_1164.all; entity TWO_TO_FOUR is

port (I : in std_logic_vector(1 downto 0); EN : in std_logic; O : out std_logic_vector(3 downto 0)); end TWO_TO_FOUR; architecture CONCURRENT of TWO_TO_FOUR is signal TEMP : std_logic_vector(3 downto 0); with I select TEMP <= "0001" when "00", "0010" when "01", "0100" when "10", "1000" when "11", "0000" when others; O <= TEMP when EN = '1' "ZZZZ"; end CONCURRENT; architecture SEQUENTIAL of TWO_TO_FOUR is process(i) variable TEMP : std_logic_vector(3 downto 0); case I is when "00" => TEMP := "0001"; when "01" => TEMP := "0010"; when "10" => TEMP := "0100"; when "11" => TEMP := "1000"; when others => TEMP := "0000"; end case; if (EN = '1') then O <= TEMP; O <= "ZZZZ"; end SEQUENTIAL; 13. (1 points) Communication is the hardest problem. 14. (6 points) (a) (4 points) Write a declaration of a record data type, PERSONNEL, with fields for last name (LAST) (up to twenty characters); first name (FIRST) (up to twenty characters); middle initial (MID); and social security number (SOC_SEC). (b) (2 points) Write a declaration for a constant MY_PERSONNEL_RECORD that defines your own data, consistent with type PERSONNEL. package MINE is type PERSONNEL is record LAST : string(20 downto 1); FIRST : string(20 downto 1); MID : character; SOC_SEC : integer range 0 to 999999999; end record; constant MY_PERSONNEL_RECORD : PERSONNEL := ("Gaede ", "Rhonda ", 'K', 999274819); end MINE;

15. (10 points) Draw the state diagram for the following state machine. Is it a Moore machine or a Mealy machine? ENTITY state_machine IS PORT (sig_in ; IN BIT; clk : IN BIT; sig_out : OUT BIT); END state_machine; ARCHITECTURE state_machine OF state_machine IS TYPE state_type IS (a, b, c, d, e); SIGNAL current_state, next_state : state_type; BEGIN PROCESS (sig_in, current_state) BEGIN sig_out <= 0 ; next_state <= e; CASE current_state WHEN a => IF sig_in = 0 THEN next_state <= a; ELSE next_state <= d; WHEN b => IF sig_in = 0 THEN next_state <= b; ELSE next_state <= c; WHEN c => IF sig_in = 1 THEN next_state <= a; ELSE next_state <= e; WHEN d => IF sig_in = 0 THEN next_state <= e; WHEN e => IF sig_in = 1 THEN next_state <= c; END CASE; END PROCESS; PROCESS (clk) BEGIN IF (clk EVENT AND clk = 1 ) THEN current_ state <= next_state; END PROCESS; END state_machine; 1/0 d 0/1 1/0 e 0/0 a 1/1 1/0 0/0 c 1/1 b 0/0