參數(shù)資料
型號(hào): CY3125R62
英文描述: Programmable Logic
中文描述: 可編程邏輯
文件頁(yè)數(shù): 3/8頁(yè)
文件大小: 67K
代理商: CY3125R62
CY3120
Document #: 38-03049 Rev. *C
Page 3 of 8
in VHDL often includes well known constructs such as
If...Then...Else, and Case statements. Here is a code
segment from a simple state machine design (soda
vending machine) that uses behavioral VHDL to implement
the design:
LIBRARY ieee;
USE ieee.std_logic_1164.all;
ENTITY drink IS
PORT (nickel,dime,quarter,clock:#in
std_logic;
returnDime,returnNickel,giveDrink:out
std_logic);
END drink;
ARCHITECTURE fsm OF drink IS
TYPE drinkState IS (zero,five,ten,fifteen,
twenty,twentyfive,owedime);
SIGNAL drinkstatus:drinkState;
BEGIN
PROCESS BEGIN
WAIT UNTIL clock = ’1’;
giveDrink <= ’0’;
returnDime <= ’0’;
returnNickel <= ’0’;
CASE drinkStatus IS
WHEN zero =>
IF (nickel = ’1’) THEN
drinkStatus <= five;
ELSIF (dime = ’1’) THEN
drinkStatus <= Ten;
ELSIF (quarter = ’1’) THEN
drinkStatus <= twentyfive;
END IF;
WHEN five =>
IF (nickel = ’1’) THEN
drinkStatus <= ten;
ELSIF (dime = ’1’) THEN
drinkStatus <= fifteen;
ELSIF (quarter = ’1’) THEN
giveDrink <= ’1’;
drinkStatus <= zero
END IF;
-- Several states are omitted in this
-- example. The omitted states are ten,
-- fifteen, twenty, and twentyfive.
WHEN owedime =>
returnDime <= ’1’;
drinkStatus <= zero;
when others =>
-- This makes sure that the state
-- machine resets itself if
-- it somehow gets into an undefined state.
drinkStatus <= zero;
END CASE;
END PROCESS;
END FSM;
VHDL is a strongly typed language. It comes with several
predefined operators, such as + and /= (add, not-equal-to).
VHDL offers the capability of defining multiple meanings for
operators (such as +), which results in simplification of the
code written. For example, the following code segment shows
that “count <= count +1” can be written such that count is a
std_logic_vector, and 1 is an integer.
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE work.std_arith.all;
ENTITY sequence IS
port (clk: in std_logic;
s : inout std_logic);
end sequence;
ARCHITECTURE fsm OF sequence IS
SIGNAL count: std_logic_vector(3 downto 0);
BEGIN
PROCESS BEGIN
WAIT UNTIL clk = ’1’;
CASE count IS
WHEN x“0” | x“1” | x“2” | x“3” =>
s <= ’1’;
count <= count + 1;
WHEN x“4” | x“5” | x“6” | x“7” =>
s <= ’0’;
count <= count + 1;
WHEN x“8” | x“9” =>
s <= ’1’;
count <= count + 1;
WHEN others =>
s <= ’0’;
count <= (others => ’0’);
END CASE;
END PROCESS;
END FSM;
In this example, the + operator is overloaded to accept both
integer and std_logic arguments.
Warp
supports overloading
operators.
Functions
A major advantage of VHDL is the ability to implement
functions. The support of functions allows designs to be
reused by simply specifying a function and passing the appro-
priate parameters.
Warp
features some built-in functions
such as truth-table function (ttf). The ttf is particularly useful
for state machine or look-up table designs. The following
code describes a seven-segment display decoder imple-
mented with the ttf :
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE work.table_std.all;
相關(guān)PDF資料
PDF描述
CY3128R62 Programmable Logic
CY3130R62 Programmable Logic
CY3138R62 Programmable Logic
CY325B LCD Controller
CY338003 ASIC
相關(guān)代理商/技術(shù)參數(shù)
參數(shù)描述
CY3128 制造商:CYPRESS 制造商全稱:Cypress Semiconductor 功能描述:Warp Professional CPLD Software
CY3128R62 制造商:Cypress Semiconductor 功能描述:
CY3130 制造商:CYPRESS 制造商全稱:Cypress Semiconductor 功能描述:Warp Enterprise⑩ VHDL CPLD Software
CY3130R62 制造商:CYPRESS 制造商全稱:Cypress Semiconductor 功能描述:Warp Enterprise⑩ VHDL CPLD Software
CY3138 制造商:CYPRESS 制造商全稱:Cypress Semiconductor 功能描述:Warp Enterprise⑩ Verilog CPLD Software