chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · web viewsamples an...

70
-- (this is a VHDL comment) -- import std_logic from the IEEE library library IEEE; use IEEE.std_logic_1164.all; -- this is the entity entity ANDGATE is port ( I1 : in std_logic; I2 : in std_logic; O : out std_logic); end entity ANDGATE; -- this is the architecture architecture RTL of ANDGATE is begin O <= I1 and I2; end architecture RTL; D-type flip-flops The D-type flip-flop samples an incoming signal at the rising (or falling) edge of a clock. This example has an asynchronous, active- high reset, and samples at the rising clock edge. DFF : process(RST, CLK) begin if RST = '1' then Q <= '0'; elsif rising_edge(CLK) then Q <= D; end if; end process DFF; Another common way to write edge-triggered behavior in VHDL is with the 'event' signal attribute. A single apostrophe has to be written between the signal name and the name of the attribute. DFF : process(RST, CLK) begin if RST = '1' then Q <= '0';

Upload: vuliem

Post on 13-May-2018

214 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an

-- (this is a VHDL comment) -- import std_logic from the IEEE librarylibrary IEEE;use IEEE.std_logic_1164.all; -- this is the entityentity ANDGATE is port ( I1 : in std_logic; I2 : in std_logic; O : out std_logic);end entity ANDGATE; -- this is the architecturearchitecture RTL of ANDGATE isbegin O <= I1 and I2;end architecture RTL;

D-type flip-flops

The D-type flip-flop samples an incoming signal at the rising (or falling) edge of a clock. This example has an asynchronous, active-high reset, and samples at the rising clock edge.

DFF : process(RST, CLK)begin if RST = '1' then Q <= '0'; elsif rising_edge(CLK) then Q <= D; end if;end process DFF;

Another common way to write edge-triggered behavior in VHDL is with the 'event' signal attribute. A single apostrophe has to be written between the signal name and the name of the attribute.

DFF : process(RST, CLK)begin if RST = '1' then Q <= '0'; elsif CLK'event and CLK = '1' then Q <= D; end if;end process DFF;

Page 2: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an

Example: a counter

The following example is an up-counter with asynchronous reset, parallel load and configurable width. It demonstrates the use of the 'unsigned' type, type conversions between 'unsigned' and 'std_logic_vector' and VHDL generics. The generics are very close to arguments or templates in other traditional programming languages like C++.

library IEEE;use IEEE.std_logic_1164.all;use IEEE.numeric_std.all; -- for the unsigned type entity COUNTER is generic ( WIDTH : in natural := 32); port ( RST : in std_logic; CLK : in std_logic; LOAD : in std_logic; DATA : in std_logic_vector(WIDTH-1 downto 0); Q : out std_logic_vector(WIDTH-1 downto 0));end entity COUNTER; architecture RTL of COUNTER is signal CNT : unsigned(WIDTH-1 downto 0);begin process(RST, CLK) is begin if RST = '1' then CNT <= (others => '0'); elsif rising_edge(CLK) then if LOAD = '1' then CNT <= unsigned(DATA); -- type is converted to unsigned else CNT <= CNT + 1; end if; end if; end process; Q <= std_logic_vector(CNT); -- type is converted back to std_logic_vectorend architecture RTL;

In electronics, a hardware description language or HDL is a specialized computer language used to program the structure, design and operation of electronic circuits, and most commonly, digital logic circuits.A hardware description language enables a precise, formal description of an electronic circuit that allows for the automated analysis, simulation, and simulated testing of an electronic circuit. It also allows for the compilation of an HDL program into a lower level specification of physical electronic components, such as the set of masks used to create an

Page 3: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an

integrated circuit.A hardware description language looks much like a programming language such as C; it is a textual description consisting of expressions, statements and control structures. One important difference between most programming languages and HDLs is that HDLs explicitly include the notion of time.HDLs form an integral part of electronic design automation systems, especially for complex circuits, such as microprocessors

VHDL Operators Highest precedence first, left to right within same precedence group, use parenthesis to control order. Unary operators take an operand on the right. "result same" means the result is the same as the right operand. Binary operators take an operand on the left and right. "result same" means the result is the same as the left operand.** exponentiation, numeric ** integer, result numericabs absolute value, abs numeric, result numericnot complement, not logic or boolean, result same

* multiplication, numeric * numeric, result numeric/ division, numeric / numeric, result numericmod modulo, integer mod integer, result integerrem remainder, integer rem integer, result integer

+ unary plus, + numeric, result numeric- unary minus, - numeric, result numeric

+ addition, numeric + numeric, result numeric- subtraction, numeric - numeric, result numeric& concatenation, array or element & array or element,result array

sll shift left logical, logical array sll integer, result samesrl shift right logical, logical array srl integer, result samesla shift left arithmetic, logical array sla integer, result samesra shift right arithmetic, logical array sra integer, result samerol rotate left, logical array rol integer, result sameror rotate right, logical array ror integer, result same

= test for equality, result is boolean/= test for inequality, result is boolean< test for less than, result is boolean<= test for less than or equal, result is boolean> test for greater than, result is boolean>= test for greater than or equal, result is boolean

and logical and, logical array or boolean, result is sameor logical or, logical array or boolean, result is samenand logical complement of and, logical array or boolean, result is same

Page 4: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an

nor logical complement of or, logical array or boolean, result is samexor logical exclusive or, logical array or boolean, result is samexnor logical complement of exclusive or, logical array or boolean, result is same

Page 5: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 6: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 7: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 8: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 9: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 10: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 11: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 12: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 13: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 14: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 15: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 16: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 17: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 18: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 19: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 20: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 21: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 22: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 23: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 24: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 25: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 26: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 27: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 28: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 29: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 30: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 31: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 32: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 33: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 34: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 35: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 36: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 37: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 38: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 39: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 40: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 41: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 42: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 43: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 44: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 45: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 46: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 47: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 48: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 49: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 50: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 51: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 52: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 53: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 54: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 55: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 56: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 57: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 58: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 59: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 60: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 61: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 62: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 63: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 64: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 65: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 66: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 67: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 68: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an
Page 69: chettinadtech.ac.inchettinadtech.ac.in/.../14-04-23-15-15-18-2413-vettri.docx · Web viewsamples an incoming signal at the rising (or falling) edge of a clock. This example has an