Logical Operators:: ECGR 4146/5146 Introduction To VHDL
Logical Operators:: ECGR 4146/5146 Introduction To VHDL
Relational Operators:
Used in conditional statements
= equal to
/= not equal to
< less than
<= less then or equal to
> greater than
>= greater than or equal to
Precedence:
Highest NOT
Relational operators
Lowest Rest of logical operators
Evaluation Rules:
1. Operators evaluated in order of precedence (highest evaluated 1st)
2. Operators of equal precedence evaluated from left to right
3. Deepest nested parentheses evaluated 1st
Because of #2 you should use lots of parentheses
Addition Operators:
Used for adders, subtractors, counters, etc. with bit_vector and
std_logic_vector
+ addition
- subtraction
Note: you should use std_logic_vector and the std_arith package as follows:
library IEEE;
use IEEE.std_logic_1164.all;
use work.std_arith.all;
VHDL Modeling
ECGR 4146/5146 Introduction to VHDL
Data In
PUSH
POP
FIFO
INIT
CLK
FULL
EMPTY
NOPOP
NOPUSH
Data Out
M
PUSH
POP Din
N
FIFO ADD
Control Logic
RAM
ADD 2N words
WE M bits/word
INIT
FULL WE
EMPTY Dout
NOPOP
NOPUSH M
CLK
VHDL Modeling
ECGR 4146/5146 Introduction to VHDL
library ieee;
use ieee.std_logic_1164.all;
use work.std_arith.all;
entity FIFO_LOGIC is
generic (N: integer := 3);
port (clk,push,pop,init: in std_logic;
add: out std_logic_vector(N-1 downto 0);
full,empty,we,nopush,nopop: buffer std_logic);
end FIFO_LOGIC;
architecture RTL of FIFO_LOGIC is
signal wptr, rptr: std_logic_vector(N-1 downto 0);
signal lastop: std_logic;
begin
VHDL Modeling
ECGR 4146/5146 Introduction to VHDL
VHDL Modeling
ECGR 4146/5146 Introduction to VHDL
VHDL Modeling
ECGR 4146/5146 Introduction to VHDL
VHDL Modeling
ECGR 4146/5146 Introduction to VHDL
Sequential Statements:
if-then-else
general format: example:
if (condition) then if (count = “00”) then
do some stuff a <= b;
elsif (condition) then elsif (count = “11”) then
do some other stuff a <= c;
else else
do some junk a <= d;
end if; end if;
elsif and else clauses are optional
BUT incompletely specified if-then-else (no else) implies memory element
case-when
general format: example:
case expression is case count is
when value => when “00” =>
do stuff a <= b;
when value => when “11” =>
do more stuff a <= c;
others => others =>
do junk a <= d;
end case; end case;
for-loop
general format: example:
[label:] for identifier in range loop init: for k in N-1 downto 0 loop
do a bunch of junk Q(k) <= ‘0’;
end loop [label]; end loop init;
note: variable k implied in for-loop and does not need to be declared
while-loop
general format: example:
[label:] while condition loop init: while (k > 0) loop
do silly stuff Q(k) <= ‘0’
end loop [label]; k := k – 1;
end loop init;
note: variable k must be declared as variable in process (between
sensitivity list and begin with format:
variable k: integer := N-1;
VHDL Modeling
ECGR 4146/5146 Introduction to VHDL
Concurrent Statements:
logical operators with signal assignement <=
example: Z <= A and B;
when-else
general format: example:
expression when condition else A <= B when S = “00” else
expression when condition else C when S = “11” else
expression when others; D when others;
with-select-when
we will discuss this one later, after we talk about defining types
VHDL Modeling
ECGR 4146/5146 Introduction to VHDL
Initialization:
All processes (and concurrent statements) evaluated once
then again and again until there are no events in sensitivity list
If explicit initialization is not defined (using := assignment operator)
then a bit is assigned ‘0’ and a std_logic is assigned ‘U’
When no events happen for a given process sensitivity list then that
process is suspended
Simulation cycle:
1. Time is advanced until next entry in time queue where signals are to be
updated (for example, PIs) which cause events on these signals
2. A simulation cycle starts at that point in time and processes & concurrent
statements “sensitive” to events (during the current simulation time) on
those signals will be executed
3. Simulation times for subsequent simulation cycles are determined and
scheduled based on internal signals being updated from processes or
concurrent statements
Note: we will talk about specifying delays later, right now we consider only
delta (δ) delays = infinitesimal delays
4. If there are any δ delay time queues go to Step 2, else go to Step 1
Examples:
Z <= X after 5ns; -- specified delay scheduled as entry in time queue
Z <= X; -- δ delay scheduled as entry in δ delay time queue
VHDL Modeling