CENG3151 BasicVHDL For Lab PDF
CENG3151 BasicVHDL For Lab PDF
Language
Enables hardware modeling from the gate to system level
Used to describe/design a digital circuit
Strongly typed and not case sensitive
If you already have a good VHDL background, then you can skip
this!
VHDL Code
Functional Simulation
4
Code Model
Component
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
Library
[library/packages]
Entity
Entity AND_2input is
Port ( A : in STD_LOGIC;
B : in STD_LOGIC;
C : out STD_LOGIC);
end AND_2input;
Architecture body
C <= A AND B;
[Function Circuits
function]
5
end Behavioral;
are enough!!
Your library could be as below:
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
-- numeric_std is optional:
-- depends on the lab requirement
USE ieee.numeric_std.ALL;
6
ENTITY entity_name IS
PORT(
port_name: port_mode signal_type;
port_name: port_mode signal_type;
...);
END [ENTITY];
Entity_name, port_name: any word except VHDL reserved word
port_mode: IN, OUT
Signal_type: BIT, INTEGER, etc.
7
Circuits
Function
10
11
temp<= '1';
Lab For Computer Architecture - Fall 2016
Data Types
Basic data types for the labs:
Package standard: BIT, BIT_VECTOR, BOOLEAN, INTEGER, etc.
Package std_logic_1164: STD_LOGIC, STD_LOGIC_VECTOR
Package numeric_std: UNSIGNED, SIGNED
Examples of declaration:
SIGNAL a,b: BIT_VECTOR(7 downto 0); -- a, b are 8-bits
SIGNAL x,y: STD_LOGIC_VECTOR(15 downto 0); -- x,y are 16-bits
SIGNAL z: STD_LOGIC_VECTOR(1 to 16); -- 16-bits
SIGNAL c: UNSIGNED(7 downto 0 ); -- 8-bits
a <= "11111111"; --or, you can use the keywork "others"
a <= (OTHERS => '1'); -- a = "1111111"
14
Operators
Assignment operators:
Operator <=: assign a value to a SIGNAL
Operator :=: assign a value to a VARIABLE/CONSTANT
Logical operators:
NOT, AND, NAND, OR, NOR, XOR, XNOR
Arithmetic operators:
Addition(+), Subtraction(-), Multiplication(*), Division(/), etc.
These operators are in the library numeric_std or std_logic_arith (or, the
Operators
Comparison operators
Equal to(=);not equal to(/=); less than(<);greater than(>);less than or
Shift operators:
Shift left logic(SLL); shift right logic(SRL); shift left arithmetic(SLA);
Concatenation operator:
Use for grouping objects and values
Notation: &
16
Operators
Examples:
x <= NOT a AND B; --x='a.b
y <= x SLL 2;
-- if x = "0110", y = 1000
-- if x = "0110", z = 011000
n = m;
-- m, n are unsigned,
-- if n = "10", m = "10" then "n=m" is true
Notations:
- : dont care
z : high impedance
17
Coding Guidelines
No Specific coding guidelines for this lab; however, it is recommended
18
19
20
Warm-up
Using Xilinx ISE in your lab to implement below combinational circuit,
Y = (A AND B) OR C
B
C
21