Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
xst.pdf
Скачиваний:
141
Добавлен:
11.06.2015
Размер:
5.64 Mб
Скачать

R

VHDL Assert Statements

ADD (A(3), B(3), S2(1), S3);

S <= S3(0) & S2(0) & S1(0) & S0(0); COUT <= S3(1);

end process; end ARCHI;

Recursive Function VHDL Coding Example

XST supports recursive functions. The following coding example represents n! function:

function my_func(x : integer) return integer is begin

if x = 1 then return x;

else

return (x*my_func(x-1)); end if;

end function my_func;

VHDL Assert Statements

This section discusses VHDL Assert Statements, and includes:

“About VHDL Assert Statements”

“SINGLE_SRL Describing a Shift Register”

About VHDL Assert Statements

XST supports Assert statements. Assert statements enable you to detect undesirable conditions in VHDL designs, such as bad values for generics, constants, and generate conditions, or bad values for parameters in called functions. For any failed condition in an Assert statement, XST, according to the severity level, issues a warning message, or rejects the design and issues an error message. XST supports the Assert statement only with static condition.

SINGLE_SRL Describing a Shift Register

The following coding example contains a block, SINGLE_SRL, which describes a shift register. The size of the shift register depends on the SRL_WIDTH generic value. The Assert statement ensures that the implementation of a single shift register does not exceed the size of a single SRL.

Since the size of the SRL is 16 bit, and XST implements the last stage of the shift register using a flip-flop in a slice, then the maximum size of the shift register cannot exceed 17 bits. The SINGLE_SRL block is instantiated twice in the entity named TOP, the first time with SRL_WIDTH equal to 13, and the second time with SRL_WIDTH equal to 18.

SINGLE_SRL Describing a Shift Register VHDL Coding Example

library ieee;

use ieee.std_logic_1164.all;

entity SINGLE_SRL is

generic (SRL_WIDTH : integer := 16); port (

clk : in std_logic; inp : in std_logic;

XST User Guide

www.xilinx.com

487

10.1

Chapter 6: XST VHDL Language Support

R

outp : out std_logic); end SINGLE_SRL;

architecture beh of SINGLE_SRL is

signal shift_reg : std_logic_vector (SRL_WIDTH-1 downto 0); begin

assert SRL_WIDTH <= 17

report "The size of Shift Register exceeds the size of a single SRL" severity FAILURE;

process (clk) begin

if (clk'event and clk = '1') then

shift_reg <= shift_reg (SRL_WIDTH-1 downto 1) & inp; end if;

end process;

outp <= shift_reg(SRL_WIDTH-1); end beh;

library ieee;

use ieee.std_logic_1164.all;

entity TOP is port (

clk : in std_logic;

inp1, inp2 : in std_logic; outp1, outp2 : out std_logic);

end TOP;

architecture beh of TOP is component SINGLE_SRL is

generic (SRL_WIDTH : integer := 16); port(

clk : in std_logic; inp : in std_logic; outp : out std_logic);

end component; begin

inst1: SINGLE_SRL generic map (SRL_WIDTH => 13) port map(

clk => clk, inp => inp1,

outp => outp1 );

inst2: SINGLE_SRL generic map (SRL_WIDTH => 18) port map(

clk => clk, inp => inp2,

outp => outp2 ); end beh;

488

www.xilinx.com

XST User Guide

 

 

10.1

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]