Lund University / EITF35/ Liang Liu
EITF35: Introduction to Structured VLSI Design
Part 2.1.2: VHDL-2
Liang Liu liang.liu@eit.lth.se
1
EITF35: Introduction to Structured VLSI Design Part 2.1.2: VHDL-2 - - PowerPoint PPT Presentation
EITF35: Introduction to Structured VLSI Design Part 2.1.2: VHDL-2 Liang Liu liang.liu@eit.lth.se 1 Lund University / EITF35/ Liang Liu Outline VHDL Objects VHDL Data Types Operators in VHDL Optimizing VHDL Code Operator
Lund University / EITF35/ Liang Liu
1
Lund University / EITF35/ Liang Liu
2
Lund University / EITF35/ Liang Liu
3
Lund University / EITF35/ Liang Liu
4
Lund University / EITF35/ Liang Liu
5
Lund University / EITF35/ Liang Liu
6 Initial value can be assigned to a register, but in a different way CONSTANT WL: INTEGER := 3; SIGNAL output : bit_vector(WL-1 downto 0);
Lund University / EITF35/ Liang Liu
7
Lund University / EITF35/ Liang Liu
8
Lund University / EITF35/ Liang Liu
9
Lund University / EITF35/ Liang Liu
10
‘1’ ‘0’ ‘X’
Lund University / EITF35/ Liang Liu
11
Lund University / EITF35/ Liang Liu
12
Lund University / EITF35/ Liang Liu
13
Lund University / EITF35/ Liang Liu
library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all; 14
Lund University / EITF35/ Liang Liu
15
Lund University / EITF35/ Liang Liu
library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all; . . . signal s1, s2, s3, s4, s5, s6: std_logic_vector(3 downto 0); signal u1, u2, u3, u4, u5, u6: unsigned(3 downto 0); signal sg: signed(3 downto 0); – Ok u3 <= u2 + u1; --- ok, both operands unsigned –Wrong u5 <= sg; -- type mismatch u6 <= 5; -- type mismatch (integer) – Fix u5 <= unsigned(sg); -- type casting u6 <= to_unsigned(5,4); -- conversion function 16
Lund University / EITF35/ Liang Liu
17
Lund University / EITF35/ Liang Liu
18 How about division by a power of 2?
Lund University / EITF35/ Liang Liu
19
sra b
Lund University / EITF35/ Liang Liu
20
A(2) A(1) A(0) A(1) A(0) A(3)
Lund University / EITF35/ Liang Liu
21
Lund University / EITF35/ Liang Liu
22
Lund University / EITF35/ Liang Liu
23
Lund University / EITF35/ Liang Liu
0’s to the front:
24
Lund University / EITF35/ Liang Liu
25
Lund University / EITF35/ Liang Liu
26
Lund University / EITF35/ Liang Liu
27
Lund University / EITF35/ Liang Liu
Three types of concurrent statements used in dataflow descriptions Boolean Equations when-else with-select-when For concurrent signal assignments For selective signal assignments For conditional signal assignments 28
Lund University / EITF35/ Liang Liu
X
30
Lund University / EITF35/ Liang Liu
31
a,b,c,d,y:std_logic; ... y <= a or c; y <= a and b; y <= c and d;
Lund University / EITF35/ Liang Liu
32
Lund University / EITF35/ Liang Liu
33
Lund University / EITF35/ Liang Liu
r <= a+b when boolean_exp else a+c; write VHDL code that reduces the number
src0 <= b when boolean_exp else c; r <= a + src0; 34
Lund University / EITF35/ Liang Liu
process(a,b,c,d,...) begin if boolean_exp_1 then r <= a+b; elsif boolean_exp_2 then r <= a+c; else r <= d+1; end if end process; 35
Lund University / EITF35/ Liang Liu
process(a,b,c,d,...) begin if boolean_exp_1 then src0 <= a; src1 <= b; elsif boolean_exp_2 then src0 <= a; src1 <= c; else src0 <= d; src1 <= "00000001"; end if; end process; r <= src0 + src1;
a d b c 1
36
Lund University / EITF35/ Liang Liu
37
http://www.eit.lth.se/index.php?ciuid=1027&coursepage=6585 &L=1
Lund University / EITF35/ Liang Liu
38