portmap problem, implementing the smallest part

OP #5256109
Rate this post
• ▲ useful
▼ not useful
Hello , the smallest component is a halfadder, but its not implemented 
in the example  bellow,
where do i add the code of the half adder
1
sum <= a xor b ;
2
carry <= a and b ;

Thanks
1
--top module(full adder) entity declaration
2
entity fulladder is
3
    port (a : in std_logic;
4
            b : in std_logic;
5
           cin : in std_logic;
6
           sum : out std_logic;
7
           carry : out std_logic
8
         );
9
end fulladder;
10
--top module architecture declaration.
11
architecture behavior of fulladder is
12
--sub-module(half adder) is declared as a component before the keyword "begin".
13
   component halfadder
14
    port(
15
         a : in std_logic;
16
         b : in std_logic;
17
         sum : out std_logic;
18
         carry : out std_logic
19
        );
20
    end component;
21
--All the signals are declared here,which are not a part of the top module.
22
--These are temporary signals like 'wire' in Verilog.
23
signal s1,c1,c2 : std_logic:='0';
24

25
begin
26
--instantiate and do port map for the first half adder.
27
  HA1 : halfadder port map (
28
          a => a,
29
          b => b,
30
          sum => s1,
31
          carry => c1
32
        );
33
--instantiate and do port map for the second half adder.
34
 HA2 : halfadder port map (
35
          a => s1,
36
          b => cin,
37
         sum => sum,
38
         carry => c2
39
        );
40
carry <= c1 or c2;  --final carry calculation
41

42
end;
Moderator (Company: Titel) #5256256
Rate this post
• ▲ useful
▼ not useful
Rock B. wrote:
> where do i add the code of the half adder
You add it in an entity named like the declared and instantiated 
component "halfadder". Someway like this:
1
entity halfadder is
2
  port(
3
    a : in std_logic;
4
    b : in std_logic;
5
    sum : out std_logic;
6
    carry : out std_logic
7
  );
8
end halfadder;
9
:
10
:
11
:
A little hint: the web is full of code doing exactly that.
That Google thing helps you finding it:
https://www.google.com/search?q=vhdl+half+adder+full+adder


BTW: pls read and follow the instructions a few line above every edit 
box and use the [vhdl] tags instead that lines of sparkling stars!

Reply

Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.

Formatting
  • [c]C-Code[/c]
  • [vhdl]VHDL-Code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.