<- previous index next ->
VHDL is used for structural and functional modeling
of digital circuits.
The geometric modeling is handled by other Cadence programs.
First, simple VHDL statements for logic gates:
logic gates and corresponding VHDL statements
VHDL comments start with -- acting like C++ and Java //
VHDL like C++ and Java end statements with a semicolon ;
VHDL uses "library" and "use" where C++ uses #include Java uses import
VHDL uses ".all" where Java uses ".*"
VHDL uses names similar to Pascal, case insensitive, var is same as Var, VAR
VHDL has a two part basic structure for each circuit
that is more than one gate, the "entity" and the "architecture".
There needs to be a "library" and "use" for features that are used.
The word "port" is used to mean interface.
The term "std_logic" is a type used for one bit.
The term "std_logic_vector" is a type used for more than one bit.
The time from an input changing to when the output may change
is optional. "after 1 ps" indicates 1 pico second.
"after 2 ns" indicates 2 nano seconds.
This circuit is coded as a full adder component in VHDL:
library IEEE;
use IEEE.std_logic_1164.all;
entity fadd is -- full adder stage, interface
port(a : in std_logic;
b : in std_logic;
cin : in std_logic;
s : out std_logic;
cout : out std_logic);
end entity fadd;
architecture circuits of fadd is -- full adder stage, body
begin -- circuits of fadd
s <= a xor b xor cin after 1 ps;
cout <= (a and b) or (a and cin) or (b and cin) after 1 ps;
end architecture circuits; -- of fadd
Notice that entity fadd is ... end entity fadd; is a statement
Notice that architecture circuits of fadd is ... end architecture circuits;
is a statement. The "of fadd" connects the architecture to the entity.
The arbitrary signal names a, b, cin, s, cout were required to
be assigned a type, std_logic in this case, before being used.
Typical for many programming languages.
Now, use a loop to combine 32 fadd into a 32 bit adder:
Note: to use fadd , a long statement must be used
a0: entity WORK.fadd port map(a(0), b(0), cin, sum(0), c(0));
A unique label a0 followed by a colon :
Then entity WORK.fadd naming the entity to be used in WORK library.
Then port map( with actual signals for a, b, cin, s, cout )
Note subscripts for bit numbers in parenthesis, not [] .
The first and last stage are slightly different from the 30
stages in the loop.
add32.vhdl using the fadd above
Another variation of an adder, propagate generate.
add32pg_start.vhdl for HW4
A "main" entity to use the component add32 with test data.
Note: just structure of "entity" then big architecture
entity tadd32 is -- test bench for add32.vhdl
end tadd32; -- no requirement to use "main"
architecture circuits of tadd32 is ...
tadd32.vhdl for main entity for HW4
The output from the write statements in tadd32.vhdl is:
tadd32.chk output of tadd32.vhdl
The additional file tadd32.run was needed to tell the VHDL
simulator how long to run:
tadd32.run used to stop simulation
After using vhdl_cshrc and cds.lib,
the command line commands for the above output were:
ncvhdl -v93 add32.vhdl
ncvhdl -v93 tadd32.vhdl
ncelab -v93 tadd32:circuits
ncsim -batch -logfile tadd32.out -input tadd32.run tadd32
Browse and use as a reference for HW4, HW6, and Project.
You must do the setup exactly as stated in HW4
Sample designs and corresponding VHDL code
VHDL Language Compact Summary
The setup for HW4, HW6 and Project will be covered in the next lecture.
You will be using command lines in a terminal window on linux.gl.umbc.edu
You are given a cs411.tar file that creates the needed directories.
You will be modifying a Makefile for HW4, HW6, and Project parts.
The basic VHDL commands are shown in the starter Makefile Makefile
<- previous index next ->