summaryrefslogtreecommitdiff
path: root/testsuite/vests/vhdl-ams/ashenden/compliant/generators/carry_chain.vhd
blob: faf4b2a9aeb100e9248d8ab5468eb0ccafddc21c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112

-- Copyright (C) 2002 Morgan Kaufmann Publishers, Inc

-- This file is part of VESTs (Vhdl tESTs).

-- VESTs is free software; you can redistribute it and/or modify it
-- under the terms of the GNU General Public License as published by the
-- Free Software Foundation; either version 2 of the License, or (at
-- your option) any later version. 

-- VESTs is distributed in the hope that it will be useful, but WITHOUT
-- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-- FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-- for more details. 

-- You should have received a copy of the GNU General Public License
-- along with VESTs; if not, write to the Free Software Foundation,
-- Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 

library ieee_proposed;  use ieee_proposed.electrical_systems.all;

entity nmos is
  port ( terminal gate, source, drain : electrical );
end entity nmos;

architecture ideal of nmos is
begin
end architecture ideal;

architecture spice_equivalent of nmos is
begin
end architecture spice_equivalent;


library ieee_proposed;  use ieee_proposed.electrical_systems.all;

entity pmos is
  port ( terminal gate, source, drain : electrical );
end entity pmos;

architecture ideal of pmos is
begin
end architecture ideal;



-- code from book

library ieee_proposed;  use ieee_proposed.electrical_systems.all;

entity carry_chain is
  generic ( n : positive );
  port ( terminal clk, c_in, c_out, vdd, vss : electrical;
         terminal p, g : electrical_vector (1 to n) );
end entity carry_chain;

----------------------------------------------------------------

architecture device_level of carry_chain is

  component nmos is
    port ( terminal gate, source, drain : electrical );
  end component nmos;

  component pmos is
    port ( terminal gate, source, drain : electrical );
  end component pmos;

  terminal c_neg : electrical_vector(0 to n-1);

begin

  bit_array : for index in 0 to n generate
    terminal clk_pulldown_drain : electrical;
  begin

    clk_pulldown : component nmos
      port map ( clk, vss, clk_pulldown_drain );

    bit_0 : if index = 0 generate
    begin
      clk_precharge : component pmos
        port map ( clk, c_neg(index), vdd );
      g_pulldown : component nmos
        port map ( c_in, clk_pulldown_drain, c_neg(index) );
    end generate bit_0;

    middle_bit : if index /= 0 and index /= n generate
    begin
      clk_precharge : component pmos
        port map ( clk, c_neg(index), vdd );
      g_pulldown : component nmos
        port map ( g(index), clk_pulldown_drain, c_neg(index) );
      p_pass : component nmos
        port map ( p(index), c_neg(index - 1), c_neg(index) );
    end generate middle_bit;

    bit_n : if index = n generate
    begin
      clk_precharge : component pmos
        port map ( clk, c_out, vdd );
      g_pulldown : component nmos
        port map ( g(index), clk_pulldown_drain, c_out );
      p_pass : component nmos
        port map ( p(index), c_neg(index - 1), c_out );
    end generate bit_n;

  end generate bit_array;

end architecture device_level;

-- end code from book