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

Chapter 2: XST HDL Coding Techniques

R

Accumulators HDL Coding Techniques

This section discusses Accumulators HDL Coding Techniques, and includes:

“About Accumulators”

“Accumulators in Virtex-4 and Virtex-5 Devices”

“Accumulators Log File”

“Accumulators Related Constraints”

“Accumulators Coding Examples”

About Accumulators

An accumulator differs from a counter in the nature of the operands of the add and subtract operation.

In a counter, the destination and first operand is a signal or variable and the other operand is a constant equal to 1: A <= A + 1.

In an accumulator, the destination and first operand is a signal or variable, and the second operand is either:

A signal or variable: A <= A + B

A constant not equal to 1: A <= A + Constant

An inferred accumulator can be up, down, or updown. For an updown accumulator, the accumulated data may differ between the up and down mode:

...

if updown = '1' then a <= a + b;

else

a <= a - c;

...

XST can infer an accumulator with the same set of control signals available for counters. For more information, see “Counters HDL Coding Techniques.”

Accumulators in Virtex-4 and Virtex-5 Devices

Virtex-4 and Virtex-5 devices enable accumulators to be implemented on DSP48 resources. XST can push up to two levels of input registers into DSP48 blocks.

XST can implement an accumulator in a DSP48 block if its implementation requires only a single DSP48 resource. If an accumulator macro does not fit in a single DSP48, XST implements the entire macro using slice logic.

Macro implementation on DSP48 resources is controlled by the “Use DSP48 (USE_DSP48)” constraint or command line option, with a default value of auto. In this mode, XST implements accumulators taking into account DSP48 resources on the device.

In auto mode, to control DSP48 resources for the synthesis use the “DSP Utilization Ratio (DSP_UTILIZATION_RATIO)” constraint. By default, XST tries to utilize all DSP48 resources. For more information, see “DSP48 Block Resources.”

To deliver the best performance, XST by default tries to infer and implement the maximum macro configuration, including as many registers as possible in the DSP48. To shape a macro in a specific way, use the “Keep (KEEP)” constraint. For example, to exclude the first

60

www.xilinx.com

XST User Guide

 

 

10.1

R

Accumulators HDL Coding Techniques

register stage from the DSP48, place “Keep (KEEP)” constraints on the outputs of these registers.

As with other families, for Virtex-4 and Virtex-5, XST reports the details of inferred accumulators at the HDL Synthesis step. But in the Final Synthesis Report, accumulators are no longer visible, because they are implemented within the MAC implementation mechanism.

Accumulators Log File

The XST log file reports the type and size of recognized accumulators during the Macro Recognition step.

...

Synthesizing Unit <accum>.

Related source file is accumulators_1.vhd. Found 4-bit up accumulator for signal <tmp>. Summary:

inferred 1 Accumulator(s). Unit <accum> synthesized.

==============================

HDL Synthesis Report

 

Macro Statistics

 

# Accumulators

: 1

4-bit up accumulator

: 1

==============================

 

...

 

During synthesis, XST decomposes Accumulators on Adders and Registers if they do not contain synchronous load signals. This is done to create additional opportunities for timing optimization. Because of this, Accumulators reported during the Macro Recognition step and in the overall statistics of recognized macros may not appear in the final report. Adders/registers are reported instead.

Accumulators Related Constraints

“Use DSP48 (USE_DSP48)”

“DSP Utilization Ratio (DSP_UTILIZATION_RATIO)”

“Keep (KEEP)”

Accumulators Coding Examples

This section gives the following Accumulators examples:

“4-Bit Unsigned Up Accumulator With Asynchronous Reset”

The coding examples in this section are accurate as of the date of publication. Download updates from ftp://ftp.xilinx.com/pub/documentation/misc/examples_v9.zip.

XST User Guide

www.xilinx.com

61

10.1

Chapter 2: XST HDL Coding Techniques

R

4-Bit Unsigned Up Accumulator With Asynchronous Reset

This section discusses 4-Bit Unsigned Up Accumulator With Asynchronous Reset, and includes:

“4-Bit Unsigned Up Accumulator With Asynchronous Reset Diagram”

“4-Bit Unsigned Up Accumulator With Asynchronous Reset Pin Descriptions”

“4-Bit Unsigned Up Accumulator With Asynchronous Reset VHDL Coding Example”

“4-Bit Unsigned Up Accumulator With Asynchronous Reset Verilog Coding Example”

FDC 4

Q

+

4

C

D

CLR

 

X10533

 

Figure 2-19: 4-Bit Unsigned Up Accumulator With Asynchronous Reset Diagram

Table 2-21: 4-Bit Unsigned Up Accumulator With Asynchronous Reset Pin Descriptions

IO Pins

Description

 

 

C

Positive-Edge Clock

 

 

CLR

Asynchronous Reset (Active High)

 

 

D

Data Input

 

 

Q

Data Output

 

 

4-Bit Unsigned Up Accumulator With Asynchronous Reset VHDL Coding Example

--

-- 4-bit Unsigned Up Accumulator with Asynchronous Reset

--

library ieee;

use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all;

entity accumulators_1 is port(C, CLR : in std_logic;

D : in std_logic_vector(3 downto 0); Q : out std_logic_vector(3 downto 0));

end accumulators_1;

architecture archi of accumulators_1 is

62

www.xilinx.com

XST User Guide

 

 

10.1

R

Accumulators HDL Coding Techniques

signal tmp: std_logic_vector(3 downto 0); begin

process (C, CLR) begin

if (CLR='1') then tmp <= "0000";

elsif (C'event and C='1') then tmp <= tmp + D;

end if; end process;

Q <= tmp;

end archi;

4-Bit Unsigned Up Accumulator With Asynchronous Reset Verilog Coding Example

//

// 4-bit Unsigned Up Accumulator with Asynchronous Reset

//

module v_accumulators_1 (C, CLR, D, Q);

input C, CLR; input [3:0] D; output [3:0] Q; reg [3:0] tmp;

always @(posedge C or posedge CLR) begin

if (CLR)

tmp = 4'b0000; else

tmp = tmp + D;

end

assign Q = tmp; endmodule

XST User Guide

www.xilinx.com

63

10.1

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