OpenCores
URL https://opencores.org/ocsvn/simple_fm_receiver/simple_fm_receiver/trunk

Subversion Repositories simple_fm_receiver

[/] [simple_fm_receiver/] [trunk/] [source/] [sub_12bit.vhdl] - Blame information for rev 46

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 46 arif_endro
-- ------------------------------------------------------------------------
2 39 arif_endro
-- Copyright (C) 2004 Arif Endro Nugroho
3 46 arif_endro
-- All rights reserved.
4 13 arif_endro
-- 
5 46 arif_endro
-- Redistribution and use in source and binary forms, with or without
6
-- modification, are permitted provided that the following conditions
7
-- are met:
8 13 arif_endro
-- 
9 46 arif_endro
-- 1. Redistributions of source code must retain the above copyright
10
--    notice, this list of conditions and the following disclaimer.
11
-- 2. Redistributions in binary form must reproduce the above copyright
12
--    notice, this list of conditions and the following disclaimer in the
13
--    documentation and/or other materials provided with the distribution.
14 13 arif_endro
-- 
15 46 arif_endro
-- THIS SOFTWARE IS PROVIDED BY ARIF ENDRO NUGROHO "AS IS" AND ANY EXPRESS
16
-- OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17
-- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18
-- DISCLAIMED. IN NO EVENT SHALL ARIF ENDRO NUGROHO BE LIABLE FOR ANY
19
-- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20
-- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21
-- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22
-- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
23
-- STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
24
-- ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25
-- POSSIBILITY OF SUCH DAMAGE.
26 13 arif_endro
-- 
27 46 arif_endro
-- End Of License.
28
-- ------------------------------------------------------------------------
29 2 arif_endro
 
30
library IEEE;
31
use IEEE.STD_LOGIC_1164.ALL;
32
 
33
entity sub_12bit is
34
   port (
35
      addend_12bit           : in  bit_vector (11 downto 0);
36
      subtrahend_12bit       : in  bit_vector (11 downto 0);
37
      subtractor12_output    : out bit_vector (11 downto 0)
38
      );
39
end sub_12bit;
40
 
41
architecture structural of sub_12bit is
42
 
43
   component fulladder
44
      port (
45
      addend        : in   bit;
46
      augend        : in   bit;
47
      carry_in      : in   bit;
48
      sum           : out  bit;
49
      carry         : out  bit
50
      );
51
   end component;
52
 
53
-- internal signal
54
signal c00 : bit;
55
signal c01 : bit;
56
signal c02 : bit;
57
signal c03 : bit;
58
signal c04 : bit;
59
signal c05 : bit;
60
signal c06 : bit;
61
signal c07 : bit;
62
signal c08 : bit;
63
signal c09 : bit;
64
signal c10 : bit;
65
signal c11 : bit;
66
signal c12 : bit;
67
signal augend_12bit    : bit_vector (11 downto 0);
68
signal adder12_output  : bit_vector (11 downto 0);
69
 
70
begin
71
 
72
c00               <= '1'; -- add one to get 2's complement
73
 
74
-- first complement
75
augend_12bit (11) <= not (subtrahend_12bit (11));
76
augend_12bit (10) <= not (subtrahend_12bit (10));
77
augend_12bit (09) <= not (subtrahend_12bit (09));
78
augend_12bit (08) <= not (subtrahend_12bit (08));
79
augend_12bit (07) <= not (subtrahend_12bit (07));
80
augend_12bit (06) <= not (subtrahend_12bit (06));
81
augend_12bit (05) <= not (subtrahend_12bit (05));
82
augend_12bit (04) <= not (subtrahend_12bit (04));
83
augend_12bit (03) <= not (subtrahend_12bit (03));
84
augend_12bit (02) <= not (subtrahend_12bit (02));
85
augend_12bit (01) <= not (subtrahend_12bit (01));
86
augend_12bit (00) <= not (subtrahend_12bit (00));
87
 
88
subtractor12_output <= adder12_output;
89
 
90
fa11 : fulladder
91
   port map (
92
      addend     => addend_12bit(11),
93
      augend     => augend_12bit(11),
94
      carry_in   => c11,
95
      sum        => adder12_output(11),
96
      carry      => c12
97
      );
98
 
99
fa10 : fulladder
100
   port map (
101
      addend     => addend_12bit(10),
102
      augend     => augend_12bit(10),
103
      carry_in   => c10,
104
      sum        => adder12_output(10),
105
      carry      => c11
106
      );
107
 
108
fa09 : fulladder
109
   port map (
110
      addend     => addend_12bit(09),
111
      augend     => augend_12bit(09),
112
      carry_in   => c09,
113
      sum        => adder12_output(09),
114
      carry      => c10
115
      );
116
 
117
fa08 : fulladder
118
   port map (
119
      addend     => addend_12bit(08),
120
      augend     => augend_12bit(08),
121
      carry_in   => c08,
122
      sum        => adder12_output(08),
123
      carry      => c09
124
      );
125
 
126
fa07 : fulladder
127
   port map (
128
      addend     => addend_12bit(07),
129
      augend     => augend_12bit(07),
130
      carry_in   => c07,
131
      sum        => adder12_output(07),
132
      carry      => c08
133
      );
134
 
135
fa06 : fulladder
136
   port map (
137
      addend     => addend_12bit(06),
138
      augend     => augend_12bit(06),
139
      carry_in   => c06,
140
      sum        => adder12_output(06),
141
      carry      => c07
142
      );
143
 
144
fa05 : fulladder
145
   port map (
146
      addend     => addend_12bit(05),
147
      augend     => augend_12bit(05),
148
      carry_in   => c05,
149
      sum        => adder12_output(05),
150
      carry      => c06
151
      );
152
 
153
fa04 : fulladder
154
   port map (
155
      addend     => addend_12bit(04),
156
      augend     => augend_12bit(04),
157
      carry_in   => c04,
158
      sum        => adder12_output(04),
159
      carry      => c05
160
      );
161
 
162
fa03 : fulladder
163
   port map (
164
      addend     => addend_12bit(03),
165
      augend     => augend_12bit(03),
166
      carry_in   => c03,
167
      sum        => adder12_output(03),
168
      carry      => c04
169
      );
170
 
171
fa02 : fulladder
172
   port map (
173
      addend     => addend_12bit(02),
174
      augend     => augend_12bit(02),
175
      carry_in   => c02,
176
      sum        => adder12_output(02),
177
      carry      => c03
178
      );
179
 
180
fa01 : fulladder
181
   port map (
182
      addend     => addend_12bit(01),
183
      augend     => augend_12bit(01),
184
      carry_in   => c01,
185
      sum        => adder12_output(01),
186
      carry      => c02
187
      );
188
 
189
fa00 : fulladder
190
   port map (
191
      addend     => addend_12bit(00),
192
      augend     => augend_12bit(00),
193
      carry_in   => c00,
194
      sum        => adder12_output(00),
195
      carry      => c01
196
      );
197
 
198
end structural;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.