Graduate Computer Architecture I VHDL Structure and Testing Michael Sorensen.

Slides:



Advertisements
Similar presentations
Verilog Intro: Part 1.
Advertisements

L18 – VHDL for other counters and controllers. Other counters  More examples Gray Code counter Controlled counters  Up down counter  Ref: text Unit.
History TTL-logic PAL (Programmable Array Logic)
Ring Counter Discussion D5.3 Example 32. Ring Counter if rising_edge(CLK) then for i in 0 to 2 loop s(i)
VHDL ELEC 418 Advanced Digital Systems Dr. Ron Hayne Images Courtesy of Thomson Engineering.
George Mason University ECE 448 – FPGA and ASIC Design with VHDL ECE 448 Lecture 10 Advanced Testbenches.
ELEN 468 Lecture 191 ELEN 468 Advanced Logic Design Lecture 19 VHDL.
Kazi Fall 2006 EEGN 4941 EEGN-494 HDL Design Principles for VLSI/FPGAs Khurram Kazi Some of the slides were taken from K Gaj’s lecture slides from GMU’s.
Simple Testbenches Behavioral Modeling of Combinational Logic
1 Lecture 11 Chap 13: Test Benches Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University.
ECE 332 Digital Electronics and Logic Design Lab Lab 5 VHDL Design Styles Testbenches.
1 Part V: VHDL CODING. 2 Design StructureData TypesOperators and AttributesConcurrent DesignSequential DesignSignals and VariablesState Machines A VHDL.
Introduction to Design Tools COE Review: Tools, functions, design flow Four tools we will use in this course – HDL Designer Suite FPGA Advantage.
Design Verification VHDL ET062G & ET063G Lecture 5 Najeem Lawal 2012.
1 H ardware D escription L anguages Modeling Complex Systems.
VHDL Project I: Introduction to Testbench Design Matthew Murach Slides Available at:
VHDL in 1h Martin Schöberl. AK: JVMHWVHDL2 VHDL /= C, Java,… Think in hardware All constructs run concurrent Different from software programming Forget.
Digital Design with VHDL Presented by: Amir Masoud Gharehbaghi
Fall 08, Oct 31ELEC Lecture 8 (Updated) 1 Lecture 8: Design, Simulation Synthesis and Test Tools ELEC 2200: Digital Logic Circuits Nitin Yogi
George Mason University ECE 545 Lecture 7 Advanced Testbenches.
George Mason University ECE 545 – Introduction to VHDL Variables, Functions, Memory, File I/O ECE 545 Lecture 7.
1 ECE 545 – Introduction to VHDL Dataflow Modeling of Combinational Logic Simple Testbenches ECE 656. Lecture 2.
Copyright(c) 1996 W. B. Ligon III1 Getting Started with VHDL VHDL code is composed of a number of entities Entities describe the interface of the component.
CPE 626 Advanced VLSI Design Lecture 6: VHDL Synthesis Aleksandar Milenkovic
IAY 0600 Digital Systems Design VHDL discussion Verification: Testbenches Alexander Sudnitson Tallinn University of Technology.
Modern VLSI Design 4e: Chapter 8 Copyright  2008 Wayne Wolf Topics VHDL register-transfer modeling: –basics using traffic light controller; –synthesis.
Introduction to Design Tools COE Example design: ALU Recall that the ALUOp is 4 bits – High-order two bits used to determine operation class (ALUOp(3:2))
Reconfigurable Computing - VHDL - Types John Morris Chung-Ang University The University of Auckland.
Introduction to VHDL Simulation … Synthesis …. The digital design process… Initial specification Block diagram Final product Circuit equations Logic design.
Hardware Description Languages Digital Logic Design Instructor: Kasım Sinan YILDIRIM.
Lecture 7 Chap 9: Registers Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University.
15-Dec-15EE5141 Chapter 4 Sequential Statements ä Variable assignment statement ä Signal assignment statement ä If statement ä Case statement ä Loop statement.
George Mason University Simple Testbenches ECE 545 Lecture 4.
VHDL Discussion Sequential Sytems. Memory Elements. Registers. Counters IAY 0600 Digital Systems Design Alexander Sudnitson Tallinn University of Technology.
 Seattle Pacific University EE Logic System DesignCounters-1 Shift Registers DQ clk DQ DQ ShiftIn Q3Q3 Q2Q2 DQ Q1Q1 Q0Q0 A shift register shifts.
1 Part III: VHDL CODING. 2 Design StructureData TypesOperators and AttributesConcurrent DesignSequential DesignSignals and VariablesState Machines A VHDL.
04/26/20031 ECE 551: Digital System Design & Synthesis Lecture Set : Introduction to VHDL 12.2: VHDL versus Verilog (Separate File)
VHDL Discussion Subprograms IAY 0600 Digital Systems Design Alexander Sudnitson Tallinn University of Technology 1.
George Mason University ECE 448 – FPGA and ASIC Design with VHDL VHDL Coding for Synthesis ECE 448 Lecture 12.
Copyright (c) 2003 by Valery Sklyarov and Iouliia Skliarova: DETUA, IEETA, Aveiro University, Portugal.
Lecture 8 Review Combinational Devices –Decoder –Multiplexor (Bhasker p-81) –Shifter –Barrel Shifter (Bhasker p-303)
ECE DIGITAL LOGIC LECTURE 20: REGISTERS AND COUNTERS Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2015, 11/19/2015.
55:032 - Intro. to Digital DesignPage 1 VHDL and Processes Defining Sequential Circuit Behavior.
George Mason University Behavioral Modeling of Sequential-Circuit Building Blocks ECE 545 Lecture 8.
George Mason University Advanced Testbenches Lecture 4.
ECE 448 – FPGA and ASIC Design with VHDL George Mason University ECE 448 Lab 2 Implementing Combinational Logic in VHDL.
CDA 4253 FPGA System Design VHDL Testbench Development Hao Zheng Comp. Sci & Eng USF.
Sequential statements (1) process
Combinational logic circuit
Introduction Introduction to VHDL Entities Signals Data & Scalar Types
CHAPTER 17 VHDL FOR SEQUENTIAL LOGIC
Part IV: VHDL CODING.
ECE 4110–5110 Digital System Design
Sequential-Circuit Building Blocks
CHAPTER 17 VHDL FOR SEQUENTIAL LOGIC
RTL Style در RTL مدار ترتيبي به دو بخش (تركيبي و عناصر حافظه) تقسيم مي شود. مي توان براي هر بخش يك پروسس نوشت يا براي هر دو فقط يك پروسس نوشت. مرتضي صاحب.
IAS 0600 Digital Systems Design
Developing More Advanced Testbenches
CPE 528: Lecture #5 Department of Electrical and Computer Engineering University of Alabama in Huntsville.
Behavioral Modeling of Sequential-Circuit Building Blocks
Sequntial-Circuit Building Blocks
IAS 0600 Digital Systems Design
Figure 8.1. The general form of a sequential circuit.
ECE 545 Lecture 5 Simple Testbenches.
Sequntial-Circuit Building Blocks
4-Input Gates VHDL for Loops
Modelsim Simulation & Example VHDL Testbench
(Simple Testbenches & Arithmetic Operations)
EEL4712 Digital Design (Midterm 1 Review).
Presentation transcript:

Graduate Computer Architecture I VHDL Structure and Testing Michael Sorensen

2 - CSE/ESE 560M – Graduate Computer Architecture I Overview Everything You Always Wanted To Know About Synthesizable VHDL But Where Afraid To Ask by William D. Richard, PhD. Components VHDL 2 Process Structure –ALU using 2 Processes Using Modelsim (Tips) Testing –VHDL Test bench / Test Vectors –Modelsim Do files VHDL Debugging Notes and Tips

3 - CSE/ESE 560M – Graduate Computer Architecture I Everything You Always Wanted To Know Everything You Always Wanted To Know About Synthesizable VHDL But Where Afraid To Ask by William D. Richard, PhD. –It is available on the website, just remember William D. Richard. –It is a great resource for those that don’t have a VHDL book.

4 - CSE/ESE 560M – Graduate Computer Architecture I Components Component AND2 entity and2 is Port ( a : in std_logic; b : in std_logic; s : out std_logic); end and2; architecture Behavioral of and2 is Begin s <= a and b; end Behavioral; Component AND4 entity and4 is Port ( a : in std_logic; b : in std_logic; c : in std_logic; b : in std_logic; s : out std_logic); end and4; architecture Behavioral of and4 is component and2 Port ( a : in std_logic; -- Ports must match b : in std_logic; s : out std_logic); end component; signal temp1, temp2 : std_logic; Begin and2one:and2 port map ( a => a, b => b, s => temp1); and2two:and2 port map ( a => c, b => d, s => temp2); and2three:and2 port map ( a => temp1, b => temp2, s => s); end Behavioral;

5 - CSE/ESE 560M – Graduate Computer Architecture I VHDL 2 Process Structure Benefits –Design Pattern, easily recognized –“Easier” to program –“Easier” to debug –Works best for finite state machines Basics –First process defines what occurs on a rising clock –Second process defines the combinational logic Basics (in terms of finite state machine) –First process sets the state from the next_state on a rising clock –Second process calculates the next_state

6 - CSE/ESE 560M – Graduate Computer Architecture I VHDL 2 Process Structure entity example is Port ( clk : in std_logic; reset : in std_logic; a : in std_logic_vector(31 downto 0); z : out std_logic_vector(31 downto 0)); end example; architecture Behavioral of example is signal a_int, z_int : std_logic_vector(31 downto 0); Begin -- D-Flip Flops process (clk) -- <-- process of only clock begin if clk'event and clk = '1' then-- <-- proper way to trigger on a rising clock edge if reset = '1' then-- <-- proper way to create a reset z <= “ ”; a_int <= “ ”; else a_int <= a; z <= z_int; end if; end process; -- Combinational Logic process (a_int) -- <-- process of signals used in c/l but no clock begin -- z_int <= F(a_int); end process; end Behavioral;

7 - CSE/ESE 560M – Graduate Computer Architecture I ALU using the 2 Processes entity alu32bit is Port ( clk : in std_logic; a : in std_logic_vector(31 downto 0); b : in std_logic_vector(31 downto 0); ctrl : in std_logic_vector(2 downto 0); z : out std_logic_vector(31 downto 0); ovr : out std_logic; zero : out std_logic); end alu32bit; architecture Behavioral of alu32bit is signal a_int, b_int, z_int : std_logic_vector(31 downto 0); signal ctrl_int : std_logic_vector(2 downto 0); signal ovr_int, zero_int : std_logic; signal tmp1, tmp2 : std_logic_vector(31 downto 0); begin process (clk) begin if clk'event and clk = '1' then a_int <= a; b_int <= b; ctrl_int <= ctrl; z <= z_int; ovr <= ovr_int; zero <= zero_int; end if; end process;

8 - CSE/ESE 560M – Graduate Computer Architecture I ALU using the 2 Processes (cont.) process (a_int, b_int, ctrl_int, tmp1, tmp2) begin ovr_int <= '0'; zero_int <= '1'; z_int <= tmp1; case ctrl is when "000" => -- ADD -- REMOVED FOR SPACE REASONS when "001" => --SUBTRACT tmp1 <= a_int - b_int; if tmp1 = " " then zero_int <= '0'; end if; when "010" => --bitwise AND tmp1 <= a_int and b_int; when "011" => --bitwise OR tmp1 <= a_int or b_int; when "100" => --bitwise XOR tmp1 <= a_int xor b_int; when "101" => --shift tmp1 <= to_stdlogicvector(to_bitvector(a_int) sll conv_integer(b_int)); when "110" => --less if a_int < b_int then tmp1 <= " "; else tmp1 <= " "; end if; when others => null; end case; end process; end Behavioral;

9 - CSE/ESE 560M – Graduate Computer Architecture I Using Modelsim (Tips) Commands: –vcom Modelsim’s vhdl compiler. Run Vcom and a GUI pops up to allow you to select files to compile. Make sure you do them in order of dependency. –vsim Start a simulation. Example: vsim alu32bit (notice no.vhd) –quit -sim Exits out of a simulation. For you to recompile if you make changes. –restart -f Restarts a simulation. For you to change your do file and rerun it. Zoom Full, the blue magnify glass, Auto Scales the wave form Change Radix, right click on signals, select Radix –View signals or vectors in Binary, Unsigned, Decimal, etc.

10 - CSE/ESE 560M – Graduate Computer Architecture I Testing (VHDL Test Vectors) To create one select, New Source, VHDL Test Bench OR – Create a new VHDL Module and rewrite Benefit – can be set to check desired results Example: Synchronized And Gate entity syncand2 is Port ( clk : in std_logic; a : in std_logic; b : in std_logic; s : out std_logic); end syncand2; architecture Behavioral of syncand2 is begin process (clk) begin if clk'event and clk = '1' then s <= a and b; end if; end process; end Behavioral;

11 - CSE/ESE 560M – Graduate Computer Architecture I Testing (VHDL Test Vectors) library ieee; use ieee.std_logic_1164.all; entity syncand2tb is -- No Ports for VHDL Test Bench end syncand2tb; architecture stimulus of syncand2tb is component syncand2 Port ( clk : in std_logic; a : in std_logic; b : in std_logic; s : out std_logic); end component; signal clk : std_logic; signal a: std_logic; signal b: std_logic; signal s: std_logic; signal vector_cnt: integer := 1; signal error_flag: std_logic := '0'; type test_record is record -- Declare a record type a: std_logic; -- Signals of component to test b: std_logic; s: std_logic; -- Expected result end record;

12 - CSE/ESE 560M – Graduate Computer Architecture I Testing (VHDL Test Vectors) type test_array is array(positive range <>) of test_record; -- Collect them -- in an array -- The following constant declaration describes the test vectors to be -- applied to the design during simulation, and the expected result after a -- rising clock edge. constant test_vectors : test_array := ( -- a, b, s ('0', '0', '-'), -- RESET (IGNORE THE RESULT) ('0', '0', '0'), ('1', '0', '0'), ('0', '1', '0'), ('1', '1', '1'), ('0', '0', '0') ); begin -- instantiate the component UUT: syncand2 -- instance declared as UUT (Unit Under Testing) port map ( clk => clk, a => a, b => b, s => s); The Test Vectors

13 - CSE/ESE 560M – Graduate Computer Architecture I Testing (VHDL Test Vectors) -- provide stimulus and check the result testrun: process variable vector : test_record; begin for index in test_vectors'range loop vector_cnt <= index; vector := test_vectors(index); -- Get the current test vector -- Apply the input stimulus... a <= vector.a; b <= vector.b; -- Clock (low-high-low) with a 100 ns cycle... clk <= '0'; wait for 25 ns; -- Quarter of the desired clock cycle clk <= '1'; wait for 50 ns; -- Half of the desired clock cycle clk <= '0'; wait for 25 ns; -- Quarter of the desired clock cycle -- Check the results... if (vector.s /= '-'and s /= vector.s) then error_flag <= '1'; assert false report "Output did not match!" severity WARNING; else error_flag <= '0'; end if; end loop; wait; end process; end stimulus;

14 - CSE/ESE 560M – Graduate Computer Architecture I Testing (VHDL Test Vectors) Results

15 - CSE/ESE 560M – Graduate Computer Architecture I Testing (Modelsim Do files) To create a Do file use any standard text editor Example: Synchronized And Gate entity syncand2 is Port ( clk : in std_logic; a : in std_logic; b : in std_logic; s : out std_logic); end syncand2; architecture Behavioral of syncand2 is begin process (clk) begin if clk'event and clk = '1' then s <= a and b; end if; end process; end Behavioral;

16 - CSE/ESE 560M – Graduate Computer Architecture I Testing (Modelsim Do files) Copy generated commands to do file To read bidirectional lines after Freezing them, select Force, set value to Z and set Kind to Deposit force -freeze sim:/syncand2/clk 1 0, 0 {50 ps} -r 100psforce -freeze sim:/syncand2/a 0 0 Set a clockForce a signal

17 - CSE/ESE 560M – Graduate Computer Architecture I Testing (Modelsim Do files) syncand2.do force -freeze sim:/syncand2/clk 1 0, 0 {50 ps} -r 100ps force -freeze sim:/syncand2/a 0 0 force -freeze sim:/syncand2/b 0 0 run 200 force -freeze sim:/syncand2/a 1 0 force -freeze sim:/syncand2/b 0 0 run 100 force -freeze sim:/syncand2/a 0 0 force -freeze sim:/syncand2/b 1 0 run 100 force -freeze sim:/syncand2/a 1 0 force -freeze sim:/syncand2/b 1 0 run 100 force -freeze sim:/syncand2/a 0 0 force -freeze sim:/syncand2/b 0 0 run 200 To run do file from Modelsim command prompt type: VSIM #> do syncand2.do Default unit of time is ns.

18 - CSE/ESE 560M – Graduate Computer Architecture I VHDL DEBUGING NOTES AND TIPS Make backups, at least backup copies of working code before you add features to it. Correct all undefined (red) signals in Modelsim first. Check sensitivity list Check that signals are only modified/driven in one process (or if outside of a process, modified/driven on only one line) If problems are with bidirectional lines make sure that components correctly share line. And if your forcing the line in simulation remember to deposit Z’s before you want to read values from it. Ask Questions!