200 likes | 362 Views
Lab 3 & 4 Discussion. EE414/514 VHDL Design. September 25. Lab 3 Hint - Package and Library. Library IEEE; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all;
E N D
Lab 3 & 4 Discussion EE414/514 VHDL Design September 25
Lab 3 Hint- Package and Library Library IEEE; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; USE IEEE.Std_LOGIC_1164.all; entity adder is port ( a_in : in std_logic_vector (3 downto 0); b_in : in std_logic_vector (3 downto 0); c_out : out std_logic_vector (3 downto 0)); end adder; architecture adder_arch of adder is begin process (a_in, b_in) variable carry : std_logic_vector (4 downto 0); variable sum :std_logic_vector (3 downto 0); begin carry (0) := '0'; for i in 0 to 3 loop sum (i) := a_in(i) xor b_in(i) xor carry(i); carry (i+1) := (a_in(i) and b_in(i)) or (b_in(i) and carry (i)) or (carry (i) and a_in(i)); end loop; c_out <= sum; end process; end adder_arch; What these two means?
Lab 3 Package and Library Go to library IEEE, You will find: PACKAGE std_logic_1164 IS … FUNCTION "and" ( l : std_ulogic; r : std_ulogic ) RETURN UX01; … END std_logic_1164;
Include User’s Design Lib In Lab 3-Make your library visible to design • Put two design in the same workspace • First design a single byte counter • At the same workspace, design a two-byte counter • Library • First create a library with your design-single byte counter • Attach your library to two-byte counter
Connection of Prototype Boards in Lab 4 Expansion Board Dio2 System Board Digilab2 LCD C O N N E C T O R XC2S200 -PQ208 7-S LED JTAG LED XC95108 CLOCK Keypad Reset Switch JTAG
Features of Prototype Board- System Board Digilab 2 • Spartan2 XC2S200-PQ208 • Select correct devices in Xilinx ISE • Pin location • 50 MHZ CLOCK • Speed of your design • Source of the clock divider • Configuration mode: JTAG • Select JTAG clock as startup clock • Expansion Connector
Function Implemented On System Board -Timer Timer and Clock Divider Module process (CLK, MR) begin if MR = '0' then L1: for count_value in 18 downto 0 loop QOUT(count_value) <= '0'; end loop L1; else if (CLK'event and CLK='1') then QOUT <= QOUT + 1; end if; end if; end process; SWCLK <= QOUT(18); -- using appropriate taps off the counter as divided SMCLK <= QOUT(12); -- clock outputs How to Calculate the factor of Divider ?
Function Implemented On System Board - Example of State Machine State Machine, State Reset, Start_T, … are defined COMB_PROC: process (CLK, MR) -- This is the combinational part begin if (MR = '0') then NS <= RESET; elsif (CLK'event and CLK = '1') then case NS is -- case # appears in () to aid in coding when RESET => -- (1) if S = '0' then NS <= START_T; -- go to this state when the S button is pressed; else NS <= RESET; -- otherwise stay in this same state. end if; when START_T => -- (2)transitional states have the outputs of the corresponding stable state. if S = '1' then NS <= START; else NS <= START_T; end if;
Features of Prototype Board- Expansion Board Dio2 • XC95108 CPLD • Display Units • 16*2 character LCD • 4 seven-segment LED display • 16 LED of various colors • Input Devices • 15-button keypad • 8 slide switches
Block Diagram of Prototype Board- Expansion Board Dio2 Bus for exchange data between Dio2 and Digilab2 boards
How to Access The Interface Units- LCD • Signals • D7-D0 Data Bus • LCD_R/W • LCD_RS • LCD_E
How to Access The Interface Units- LCD Code constant LCD_CMDS : LCD_CMDS_T := ( 0 => "00"&X"01", -- Clear The Display 1 => "00"&X"38", -- Set interface data width,2 line,5*8 dots 2 => "00"&X"0c", -- Set display on, cursor off and blink off 3 => "00"&X"02", -- Return Cursor to Home 4 => "10"&X"4f", -- write the display data “Ohio …” 5 => "10"&X"68", 6 => "10"&X"69", 7 => "10"&X"6f",
How to Access The Interface Units-Keypad, Switches, LED, 7-S LED Display • All these devices are mapped to corresponding address • Read the data from certain address to obtain the status of the input devices, such as keypad and switches • Write the data to certain address to turn on/off LED and modify the display data on 7-S LED display
How to Access The Interface Units-Keypad, Switches, LED, 7-S LED Display Code signal btns : std_logic_vector(14 downto 0); -- 14 push buttons are mapped to bits of the vector signal firstTwoNum,LastTwoNum: std_logic_vector(7 downto 0); -- There are four 7-s LED display units, the first two are mapped to vectorFirstTwoNum -- Another two are mapped to vector LastTwoNum RSTIN=>btns(10), -- Reset input is mapped to “A” button RUNIN=>not btns(11), -- Run input is mapped to “A” button Q3 => FirstTwoNum(3 downto 0), -- Q3 is displayed on 7-S LED Q2 => FirstTwoNum(7 downto 4), -- Q2 is displayed on 7-S LED Q1 => LastTwoNum(3 downto 0), -- Q1 is displayed on 7-S LED Q0 => LastTwoNum(7 downto 4), -- Q0 is displayed on 7-S LED