1 |
14 |
arif_endro |
-- $Id: addacc.vhdl,v 1.3 2005-03-04 08:06:10 arif_endro Exp $
|
2 |
2 |
arif_endro |
-------------------------------------------------------------------------------
|
3 |
|
|
-- Title : Accumulator and Adder
|
4 |
|
|
-- Project : FM Receiver
|
5 |
|
|
-------------------------------------------------------------------------------
|
6 |
|
|
-- File : addacc.vhdl
|
7 |
|
|
-- Author : "Arif E. Nugroho" <arif_endro@yahoo.com>
|
8 |
|
|
-- Created : 2004/10/25
|
9 |
13 |
arif_endro |
-- Last update :
|
10 |
|
|
-- Simulators :
|
11 |
2 |
arif_endro |
-- Synthesizers:
|
12 |
|
|
-- Target :
|
13 |
|
|
-------------------------------------------------------------------------------
|
14 |
|
|
-- Description : Accumulator used in NCO of PLL in FM Receiver
|
15 |
|
|
-------------------------------------------------------------------------------
|
16 |
39 |
arif_endro |
-- Copyright (C) 2004 Arif Endro Nugroho
|
17 |
2 |
arif_endro |
-------------------------------------------------------------------------------
|
18 |
13 |
arif_endro |
--
|
19 |
|
|
-- THIS SOURCE FILE MAY BE USED AND DISTRIBUTED WITHOUT RESTRICTION
|
20 |
|
|
-- PROVIDED THAT THIS COPYRIGHT STATEMENT IS NOT REMOVED FROM THE FILE AND THAT
|
21 |
|
|
-- ANY DERIVATIVE WORK CONTAINS THE ORIGINAL COPYRIGHT NOTICE AND THE
|
22 |
|
|
-- ASSOCIATED DISCLAIMER.
|
23 |
|
|
--
|
24 |
|
|
-------------------------------------------------------------------------------
|
25 |
|
|
--
|
26 |
|
|
-- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
27 |
|
|
-- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
28 |
|
|
-- MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
29 |
|
|
-- EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
30 |
|
|
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
31 |
|
|
-- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
32 |
|
|
-- OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
33 |
|
|
-- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
34 |
|
|
-- OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
35 |
|
|
-- ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
36 |
|
|
--
|
37 |
|
|
-------------------------------------------------------------------------------
|
38 |
2 |
arif_endro |
|
39 |
|
|
library IEEE;
|
40 |
|
|
use IEEE.STD_LOGIC_1164.all;
|
41 |
|
|
|
42 |
|
|
entity addacc is
|
43 |
|
|
port (
|
44 |
|
|
clock : in bit;
|
45 |
|
|
acc : in bit_vector (17 downto 0);
|
46 |
|
|
result : out bit_vector (17 downto 0);
|
47 |
|
|
offset : in bit_vector (17 downto 0)
|
48 |
|
|
);
|
49 |
|
|
end addacc;
|
50 |
|
|
|
51 |
|
|
architecture structural of addacc is
|
52 |
|
|
component adder_18bit
|
53 |
|
|
port (
|
54 |
|
|
addend_18bit : in bit_vector (17 downto 0);
|
55 |
|
|
augend_18bit : in bit_vector (17 downto 0);
|
56 |
|
|
adder18_output : out bit_vector (17 downto 0)
|
57 |
|
|
);
|
58 |
|
|
end component;
|
59 |
|
|
|
60 |
|
|
signal result_adder01 : bit_vector (17 downto 0);
|
61 |
|
|
signal result_adder02 : bit_vector (17 downto 0);
|
62 |
|
|
signal result_adder02_reg : bit_vector (17 downto 0);
|
63 |
|
|
|
64 |
|
|
begin
|
65 |
|
|
adder01 : adder_18bit
|
66 |
|
|
port map (
|
67 |
|
|
addend_18bit => offset,
|
68 |
|
|
augend_18bit => acc,
|
69 |
|
|
adder18_output => result_adder01
|
70 |
|
|
);
|
71 |
|
|
adder02 : adder_18bit
|
72 |
|
|
port map (
|
73 |
|
|
addend_18bit => result_adder01,
|
74 |
|
|
augend_18bit => result_adder02_reg,
|
75 |
|
|
adder18_output => result_adder02
|
76 |
|
|
);
|
77 |
|
|
process (clock)
|
78 |
|
|
begin
|
79 |
|
|
if ((clock = '1') and clock'event) then
|
80 |
|
|
result_adder02_reg <= result_adder02;
|
81 |
|
|
result <= result_adder02;
|
82 |
|
|
end if;
|
83 |
|
|
end process;
|
84 |
|
|
end structural;
|