VHDL To Help When in Doubt About Syntax or Buidling Blocks
VHDL To Help When in Doubt About Syntax or Buidling Blocks
or buidling blocks.
This is a cheat sheet for vhdl to help when in doubt about syntax or buidling blocks.
8 stars 1 fork
Star Notifications
master Go to file
View code
Table of Contents
Libraries
Entities
Architecture
Process
Assignment
Type Conversion
Operators
Test Bench
Code snippets
Libraries
0. IEEE
https://github.com/ismailelbadawy/vhdl-cheat-sheet 1/10
11/9/22, 9:52 PM GitHub - ismailelbadawy/vhdl-cheat-sheet: This is a cheat sheet for vhdl to help when in doubt about syntax or buidling blocks.
Library ieee;
1. Standard Logic.
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
Entities
1. Declaring an entity:
Here we declare an entity with Three ports an input port called FirstPort an output port
called SecondPort they are both std_logic .
entity EntityName is
port (
FirstPort : in std_logic,
SecondPort : out std_logic,
ThirdPort : inout std_logic_vector(15 downto 0)
);
end entity;
entity EntityName is
-- generics fit here.
generic (n : integer := 16, m : integer := 32);
port(
);
end entity;
https://github.com/ismailelbadawy/vhdl-cheat-sheet 2/10
11/9/22, 9:52 PM GitHub - ismailelbadawy/vhdl-cheat-sheet: This is a cheat sheet for vhdl to help when in doubt about syntax or buidling blocks.
Architecture
1. Writing an architecture
end architecture;
end architecture;
component componentname is
-- if the component has a generic
generic(n : integer := 16);
port(
-- port declaration here.
);
end component;
begin
end architecture;
Process
https://github.com/ismailelbadawy/vhdl-cheat-sheet 3/10
11/9/22, 9:52 PM GitHub - ismailelbadawy/vhdl-cheat-sheet: This is a cheat sheet for vhdl to help when in doubt about syntax or buidling blocks.
Using process
end architecture;
Assignment
1. Normal Assignment
B <= '0';
2. Using when
Type Conversion
https://github.com/ismailelbadawy/vhdl-cheat-sheet 4/10
11/9/22, 9:52 PM GitHub - ismailelbadawy/vhdl-cheat-sheet: This is a cheat sheet for vhdl to help when in doubt about syntax or buidling blocks.
README.md
Operators
Mathematical
Operator Function
** Power
rem Remainder
mod Modulus
https://github.com/ismailelbadawy/vhdl-cheat-sheet 5/10
11/9/22, 9:52 PM GitHub - ismailelbadawy/vhdl-cheat-sheet: This is a cheat sheet for vhdl to help when in doubt about syntax or buidling blocks.
Operator Function
/ Divide
* Multiply
- Subtract
+ Add
Logical Operators
Operator
and
or
not
nor
nand
xor
xnor
Relational Operators
Operator Function
= Equal?
/= Not Equal?
Test Bench
A test bench is an entity with no ports.
https://github.com/ismailelbadawy/vhdl-cheat-sheet 6/10
11/9/22, 9:52 PM GitHub - ismailelbadawy/vhdl-cheat-sheet: This is a cheat sheet for vhdl to help when in doubt about syntax or buidling blocks.
Assert
Wait For
Example
entity testbench is
end testbench;
Code Snippets
Register (1 bit)
end entity;
N-Bits Register
Using the 1 bit register :
entity nreg is
generic ( n : integer := 16);
port(
clk, reset, enable : in std_logic;
input : in std_logic_vector(n-1 downto 0);
output : out std_logic_vector(n-1 downto 0));
end entity;
Tri-state buffer
entity tri_state_buff is
generic(n : integer := 16);
port(
A : in std_logic_vector(n-1 downto 0);
B : out std_logic_vector(n-1 downto 0);
C : in std_logic);
end entity;
https://github.com/ismailelbadawy/vhdl-cheat-sheet 8/10
11/9/22, 9:52 PM GitHub - ismailelbadawy/vhdl-cheat-sheet: This is a cheat sheet for vhdl to help when in doubt about syntax or buidling blocks.
entity FullAdder is
port(
A, B: in std_logic;
Cin: in std_logic;
sum: out std_logic;
Cout: out std_logic);
end entity;
entity NAdder is
generic(n: integer := 8);
port(
A, B: in std_logic_vector(n-1 downto 0);
Cin: in std_logic;
Cout : out std_logic;
sum : out std_logic_vector(n-1 downto 0));
end entity;
https://github.com/ismailelbadawy/vhdl-cheat-sheet 9/10
11/9/22, 9:52 PM GitHub - ismailelbadawy/vhdl-cheat-sheet: This is a cheat sheet for vhdl to help when in doubt about syntax or buidling blocks.
Releases
No releases published
Packages
No packages published
https://github.com/ismailelbadawy/vhdl-cheat-sheet 10/10