ece 44 8 – fpga and asic design with vhdl
DESCRIPTION
ECE 448 Lab 2 Implementing Combinational Logic in VHDL. ECE 44 8 – FPGA and ASIC Design with VHDL. George Mason University. Agenda for today. Part 1: Hands-on Session: Simulation Using Aldec Active-HDL Part 2: Introduction to Lab 2 Part 3: Asserts and Reports - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: ECE 44 8 – FPGA and ASIC Design with VHDL](https://reader035.vdocument.in/reader035/viewer/2022062309/56813dc8550346895da78eed/html5/thumbnails/1.jpg)
ECE 448 – FPGA and ASIC Design with VHDL George Mason University
ECE 448Lab 2
Implementing Combinational Logic in VHDL
![Page 2: ECE 44 8 – FPGA and ASIC Design with VHDL](https://reader035.vdocument.in/reader035/viewer/2022062309/56813dc8550346895da78eed/html5/thumbnails/2.jpg)
Part 1: Hands-on Session:
Simulation Using Aldec Active-HDL
Part 2: Introduction to Lab 2
Part 3: Asserts and Reports
Part 4: Advanced Testbenches with test vectors
stored in arrays of records
Part 5: Advanced Testbenches with test vectors
stored in text files
Part 6: Demos of Lab 1
Agenda for today
![Page 3: ECE 44 8 – FPGA and ASIC Design with VHDL](https://reader035.vdocument.in/reader035/viewer/2022062309/56813dc8550346895da78eed/html5/thumbnails/3.jpg)
ECE 448 – FPGA and ASIC Design with VHDL
Part 1
Hands-on Session
Simulation Using Aldec Active-HDL
![Page 4: ECE 44 8 – FPGA and ASIC Design with VHDL](https://reader035.vdocument.in/reader035/viewer/2022062309/56813dc8550346895da78eed/html5/thumbnails/4.jpg)
Hands-on Session
based on the MLU example
with simple testbench
![Page 5: ECE 44 8 – FPGA and ASIC Design with VHDL](https://reader035.vdocument.in/reader035/viewer/2022062309/56813dc8550346895da78eed/html5/thumbnails/5.jpg)
ECE 448 – FPGA and ASIC Design with VHDL
Part 2
Introduction to Lab 2
![Page 6: ECE 44 8 – FPGA and ASIC Design with VHDL](https://reader035.vdocument.in/reader035/viewer/2022062309/56813dc8550346895da78eed/html5/thumbnails/6.jpg)
Discussion of the Pseudocode,
Requirements, and Hints
![Page 7: ECE 44 8 – FPGA and ASIC Design with VHDL](https://reader035.vdocument.in/reader035/viewer/2022062309/56813dc8550346895da78eed/html5/thumbnails/7.jpg)
Part 1: Example of a Block Diagram(for a different circuit)
![Page 8: ECE 44 8 – FPGA and ASIC Design with VHDL](https://reader035.vdocument.in/reader035/viewer/2022062309/56813dc8550346895da78eed/html5/thumbnails/8.jpg)
Bonus Task
Variable Rotator
Example of a Problem Similar to the Bonus Task
![Page 9: ECE 44 8 – FPGA and ASIC Design with VHDL](https://reader035.vdocument.in/reader035/viewer/2022062309/56813dc8550346895da78eed/html5/thumbnails/9.jpg)
Function
C = A <<< B
A – 4-bit data inputB – 2-bit rotation amount
![Page 10: ECE 44 8 – FPGA and ASIC Design with VHDL](https://reader035.vdocument.in/reader035/viewer/2022062309/56813dc8550346895da78eed/html5/thumbnails/10.jpg)
Interface
4
4
2
A
B
C
![Page 11: ECE 44 8 – FPGA and ASIC Design with VHDL](https://reader035.vdocument.in/reader035/viewer/2022062309/56813dc8550346895da78eed/html5/thumbnails/11.jpg)
Block diagram
C
![Page 12: ECE 44 8 – FPGA and ASIC Design with VHDL](https://reader035.vdocument.in/reader035/viewer/2022062309/56813dc8550346895da78eed/html5/thumbnails/12.jpg)
Fixed Rotation in VHDL
A(3) A(2) A(1) A(0)
A(2) A(1) A(0) A(3)
A<<<1
SIGNAL A : STD_LOGIC_VECTOR(3 DOWNTO 0);SIGNAL ArotL: STD_LOGIC_VECTOR(3 DOWNTO 0);
ArotL <= A(2 downto 0) & A(3);
ArotL
A
![Page 13: ECE 44 8 – FPGA and ASIC Design with VHDL](https://reader035.vdocument.in/reader035/viewer/2022062309/56813dc8550346895da78eed/html5/thumbnails/13.jpg)
ECE 448 – FPGA and ASIC Design with VHDL
Advanced Testbenches
![Page 14: ECE 44 8 – FPGA and ASIC Design with VHDL](https://reader035.vdocument.in/reader035/viewer/2022062309/56813dc8550346895da78eed/html5/thumbnails/14.jpg)
14
Simple Testbench
Processes
Generating
Stimuli
Design Under Test (DUT)
Observed Outputs
![Page 15: ECE 44 8 – FPGA and ASIC Design with VHDL](https://reader035.vdocument.in/reader035/viewer/2022062309/56813dc8550346895da78eed/html5/thumbnails/15.jpg)
15
Advanced Testbench (1)
ProcessesGenerating
InputStimuli
Design Under Test (DUT)
ProcessComparing
Actual Outputs
vs.Expected
Outputs
Design
Correct/Incorrect
Yes/No
![Page 16: ECE 44 8 – FPGA and ASIC Design with VHDL](https://reader035.vdocument.in/reader035/viewer/2022062309/56813dc8550346895da78eed/html5/thumbnails/16.jpg)
16
Advanced Testbench (2)
ProcessesGenerating
InputStimuli
Design Under Test (DUT)
ProcessComparing
Actual Outputs
vs.Expected
Outputs
Design
Correct/Incorrect
Yes/No
Testvector
file(s)
![Page 17: ECE 44 8 – FPGA and ASIC Design with VHDL](https://reader035.vdocument.in/reader035/viewer/2022062309/56813dc8550346895da78eed/html5/thumbnails/17.jpg)
17
Test vectors
Set of pairs: {Input i, Expected Output i}
Input 1, Expected Output 1
Input 2, Expected Output 2
……………………………
Input N, Expected Output N
Test vectors can be:
- defined in the testbench source file
- stored in a data file
![Page 18: ECE 44 8 – FPGA and ASIC Design with VHDL](https://reader035.vdocument.in/reader035/viewer/2022062309/56813dc8550346895da78eed/html5/thumbnails/18.jpg)
18
Representative
Inputs
VHDL Design
Manual Calculations
or
Reference Software Implementation
(C, Java, Matlab )
expected results
Testbench
actual results
= ?
Possible sources of expected results used for comparison
![Page 19: ECE 44 8 – FPGA and ASIC Design with VHDL](https://reader035.vdocument.in/reader035/viewer/2022062309/56813dc8550346895da78eed/html5/thumbnails/19.jpg)
19ECE 448 – FPGA and ASIC Design with VHDL
Part 3
Asserts and Reports
![Page 20: ECE 44 8 – FPGA and ASIC Design with VHDL](https://reader035.vdocument.in/reader035/viewer/2022062309/56813dc8550346895da78eed/html5/thumbnails/20.jpg)
20
Assert
Assert is a non-synthesizable statement
whose purpose is to write out messages
on the screen when problems are found
during simulation.
Depending on the severity of the problem,
The simulator is instructed to continue
simulation or halt.
![Page 21: ECE 44 8 – FPGA and ASIC Design with VHDL](https://reader035.vdocument.in/reader035/viewer/2022062309/56813dc8550346895da78eed/html5/thumbnails/21.jpg)
21
Assert - syntax
ASSERT condition
[REPORT "message“]
[SEVERITY severity_level ];
The message is written when the condition
is FALSE.
Severity_level can be:
Note, Warning, Error (default), or Failure.
![Page 22: ECE 44 8 – FPGA and ASIC Design with VHDL](https://reader035.vdocument.in/reader035/viewer/2022062309/56813dc8550346895da78eed/html5/thumbnails/22.jpg)
22
Assert – Examples (1)
assert initial_value <= max_value
report "initial value too large"
severity error;
assert packet_length /= 0
report "empty network packet received"
severity warning;
assert false
report "Initialization complete"
severity note;
![Page 23: ECE 44 8 – FPGA and ASIC Design with VHDL](https://reader035.vdocument.in/reader035/viewer/2022062309/56813dc8550346895da78eed/html5/thumbnails/23.jpg)
23
Assert – Examples (2)
stim_proc: process
begin
wait for 20 ns
assert false
report "PASSED CHECKPOINT 1"
severity note;
wait for 10 ns;
assert false
report "PASSED CHECKPOINT 2"
severity warning;
![Page 24: ECE 44 8 – FPGA and ASIC Design with VHDL](https://reader035.vdocument.in/reader035/viewer/2022062309/56813dc8550346895da78eed/html5/thumbnails/24.jpg)
24ECE 448 – FPGA and ASIC Design with VHDL
wait for 10 ns;
assert false
report "PASSED CHECKPOINT 3"
severity error;
wait for 10 ns;
assert false
report "PASSED CHECKPOINT 4"
severity failure;
wait;
end process;
Assert – Examples (3)
![Page 25: ECE 44 8 – FPGA and ASIC Design with VHDL](https://reader035.vdocument.in/reader035/viewer/2022062309/56813dc8550346895da78eed/html5/thumbnails/25.jpg)
Example 1
Asserts & Reports
![Page 26: ECE 44 8 – FPGA and ASIC Design with VHDL](https://reader035.vdocument.in/reader035/viewer/2022062309/56813dc8550346895da78eed/html5/thumbnails/26.jpg)
26
Format of messages in Aldec Active-HDL
![Page 27: ECE 44 8 – FPGA and ASIC Design with VHDL](https://reader035.vdocument.in/reader035/viewer/2022062309/56813dc8550346895da78eed/html5/thumbnails/27.jpg)
27
Format of messages in Xilinx ISim
![Page 28: ECE 44 8 – FPGA and ASIC Design with VHDL](https://reader035.vdocument.in/reader035/viewer/2022062309/56813dc8550346895da78eed/html5/thumbnails/28.jpg)
28
Report - syntax
REPORT "message"
[SEVERITY severity_level ];
The message is always written.
Severity_level can be:
Note (default), Warning, Error, or Failure.
![Page 29: ECE 44 8 – FPGA and ASIC Design with VHDL](https://reader035.vdocument.in/reader035/viewer/2022062309/56813dc8550346895da78eed/html5/thumbnails/29.jpg)
29
Report - Examples
report "Initialization complete";
report "Current time = " & time'image(now);
report "Incorrect branch" severity error;
![Page 30: ECE 44 8 – FPGA and ASIC Design with VHDL](https://reader035.vdocument.in/reader035/viewer/2022062309/56813dc8550346895da78eed/html5/thumbnails/30.jpg)
30
library IEEE;use IEEE.STD_LOGIC_1164.all;
entity example_1_tb isend example_1_tb;
architecture behavioral of example_1_tb issignal clk : std_logic := '0';
begin clk <= not clk after 100 ns;process
beginwait for 1000 ns;report "Initialization complete";report "Current time = " & time'image(now); wait for 1000 ns;report "SIMULATION COMPLETED" severity failure;
end process;end behavioral;
Report - Examples
![Page 31: ECE 44 8 – FPGA and ASIC Design with VHDL](https://reader035.vdocument.in/reader035/viewer/2022062309/56813dc8550346895da78eed/html5/thumbnails/31.jpg)
31ECE 448 – FPGA and ASIC Design with VHDL
Part 4
Advanced Testbenches
with Test Vectors
Stored in an Array of Records
![Page 32: ECE 44 8 – FPGA and ASIC Design with VHDL](https://reader035.vdocument.in/reader035/viewer/2022062309/56813dc8550346895da78eed/html5/thumbnails/32.jpg)
32
Advanced Testbench (1)
ProcessesGenerating
InputStimuli
Design Under Test (DUT)
ProcessComparing
Actual Outputs
vs.Expected
Outputs
Design
Correct/Incorrect
Yes/No
![Page 33: ECE 44 8 – FPGA and ASIC Design with VHDL](https://reader035.vdocument.in/reader035/viewer/2022062309/56813dc8550346895da78eed/html5/thumbnails/33.jpg)
33ECE 448 – FPGA and ASIC Design with VHDL
Records
![Page 34: ECE 44 8 – FPGA and ASIC Design with VHDL](https://reader035.vdocument.in/reader035/viewer/2022062309/56813dc8550346895da78eed/html5/thumbnails/34.jpg)
34
Records
TYPE test_vector IS RECORD operation : STD_LOGIC_VECTOR(1 DOWNTO 0); a : STD_LOGIC; b: STD_LOGIC; y : STD_LOGIC;END RECORD;
CONSTANT num_vectors : INTEGER := 16;
TYPE test_vectors IS ARRAY (0 TO num_vectors-1) OF test_vector;
CONSTANT and_op : STD_LOGIC_VECTOR(1 DOWNTO 0) := "00";CONSTANT or_op : STD_LOGIC_VECTOR(1 DOWNTO 0) := "01";CONSTANT xor_op : STD_LOGIC_VECTOR(1 DOWNTO 0) := "10";CONSTANT xnor_op : STD_LOGIC_VECTOR(1 DOWNTO 0) := "11";
![Page 35: ECE 44 8 – FPGA and ASIC Design with VHDL](https://reader035.vdocument.in/reader035/viewer/2022062309/56813dc8550346895da78eed/html5/thumbnails/35.jpg)
35
RecordsCONSTANT test_vector_table: test_vectors :=( (operation => AND_OP, a=>'0', b=>'0', y=>'0'), (operation => AND_OP, a=>'0', b=>'1', y=>'0'), (operation => AND_OP, a=>'1', b=>'0', y=>'0'), (operation => AND_OP, a=>'1', b=>'1', y=>'1'), (operation => OR_OP, a=>'0', b=>'0', y=>'0'), (operation => OR_OP, a=>'0', b=>'1', y=>'1'), (operation => OR_OP, a=>'1', b=>'0', y=>'1'), (operation => OR_OP, a=>'1', b=>'1', y=>'1'), (operation => XOR_OP, a=>'0', b=>'0', y=>'0'), (operation => XOR_OP, a=>'0', b=>'1', y=>'1'), (operation => XOR_OP, a=>'1', b=>'0', y=>'1'), (operation => XOR_OP, a=>'1', b=>'1', y=>'0'), (operation => XNOR_OP, a=>'0', b=>'0', y=>'1'), (operation => XNOR_OP, a=>'0', b=>'1', y=>'0'), (operation => XNOR_OP, a=>'1', b=>'0', y=>'0'), (operation => XNOR_OP, a=>'1', b=>'1', y=>'1'));
![Page 36: ECE 44 8 – FPGA and ASIC Design with VHDL](https://reader035.vdocument.in/reader035/viewer/2022062309/56813dc8550346895da78eed/html5/thumbnails/36.jpg)
36ECE 448 – FPGA and ASIC Design with VHDL
Variables
![Page 37: ECE 44 8 – FPGA and ASIC Design with VHDL](https://reader035.vdocument.in/reader035/viewer/2022062309/56813dc8550346895da78eed/html5/thumbnails/37.jpg)
37
Variables - features
• Can only be declared within processes and subprograms (functions & procedures)
• Initial value can be explicitly specified in the declaration
• When assigned take an assigned value immediately
• Variable assignments represent the desired behavior, not the structure of the circuit
• Can be used freely in testbenches• Should be avoided, or at least used with caution
in a synthesizable code
![Page 38: ECE 44 8 – FPGA and ASIC Design with VHDL](https://reader035.vdocument.in/reader035/viewer/2022062309/56813dc8550346895da78eed/html5/thumbnails/38.jpg)
38
Variables - Example
testing: PROCESS
VARIABLE error_cnt: INTEGER := 0;
BEGINFOR i IN 0 to num_vectors-1 LOOP
test_operation <= test_vector_table(i).operation;test_a <= test_vector_table(i).a;test_b <= test_vector_table(i).b;WAIT FOR 10 ns;IF test_y /= test_vector_table(i).y THEN
error_cnt := error_cnt + 1;END IF;
END LOOP;END PROCESS testing;
![Page 39: ECE 44 8 – FPGA and ASIC Design with VHDL](https://reader035.vdocument.in/reader035/viewer/2022062309/56813dc8550346895da78eed/html5/thumbnails/39.jpg)
Example 2
Testbenches with Test Vectors
Stored in Arrays of Records
![Page 40: ECE 44 8 – FPGA and ASIC Design with VHDL](https://reader035.vdocument.in/reader035/viewer/2022062309/56813dc8550346895da78eed/html5/thumbnails/40.jpg)
40ECE 448 – FPGA and ASIC Design with VHDL
Part 5
Advanced Testbenches
with Test Vectors
Stored in Text Files
![Page 41: ECE 44 8 – FPGA and ASIC Design with VHDL](https://reader035.vdocument.in/reader035/viewer/2022062309/56813dc8550346895da78eed/html5/thumbnails/41.jpg)
41
Advanced Testbench (2)
ProcessesGenerating
InputStimuli
Design Under Test (DUT)
ProcessComparing
Actual Outputs
vs.Expected
Outputs
Design
Correct/Incorrect
Yes/No
Testvector
file(s)
![Page 42: ECE 44 8 – FPGA and ASIC Design with VHDL](https://reader035.vdocument.in/reader035/viewer/2022062309/56813dc8550346895da78eed/html5/thumbnails/42.jpg)
Example 3
Testbenches with Test Vectors
Stored in a Text File
![Page 43: ECE 44 8 – FPGA and ASIC Design with VHDL](https://reader035.vdocument.in/reader035/viewer/2022062309/56813dc8550346895da78eed/html5/thumbnails/43.jpg)
43
Hex format
In order to read/write data in the hexadecimal
notation, replace
read with hread, and
write with hwrite
![Page 44: ECE 44 8 – FPGA and ASIC Design with VHDL](https://reader035.vdocument.in/reader035/viewer/2022062309/56813dc8550346895da78eed/html5/thumbnails/44.jpg)
44ECE 448 – FPGA and ASIC Design with VHDL
Part 6
Lab 1 Demos