Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

vedic multiplier for 4*4 bits

Status
Not open for further replies.

sushma67

Junior Member level 1
Joined
Jan 6, 2012
Messages
18
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,429
it is showing near port map can anyone check plssss


Code VHDL - [expand]
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
Code for 4*4  vedic multiplier 
Adder
library ieee;
use ieee.std_logic_1164.all;
entity adder is
port(a:in std_logic_vector(3 downto 0);sum:out std_logic;carry:out std_logic);
end adder;
architecture behavior of adder is
signal c0,s0:std_logic:=0;
begin
s0<=a0 xor a1 xor a2;
c0<=(a0 and a1) or (a1 and a2)or( a2 and a1);
sum<=a3 xor s0 xor c0;
carry<=(a3 and s0)or (s0 and c0) or (a3 and c0);
end behaviour;
vedic multiplier
library ieee;
use ieee.std_logic_1164.all;
entity vedic mul is
port(x,y:in std_logic_vector(3 downto 0);r: out std_logic_vector(6 downto 0);cout: out std_logic);
end vedic mul;
architecture behaviour of vedic mul is
signal c:std_logic_vector(15 downto 1);
signal d:std_logic_vector(4 downto 0);
component adder
port(a:in std_logic_vector(3 downto 0);sum:out std_logic;carry:out std_logic);
end component;
begin
r(0)<=x(0) and y(0);
c(1)<=x(0) and y(1);
c(2)<=x(1) and y(0);
c(3)<=x(0) and y(2);
c(4)<=x(1) and y(1);
c(5)<=x(2) and y(0);
c(6)<=x(0) and y(3);
c(7)<=x(1) and y(2);
c(8)<=x(2) and y(1);
c(9)<=x(3) and y(0);
c(10)<=x(1) and y(3);
c(11)<=x(2) and y(2);
c(12)<=x(3) and y(1);
c(13)<=x(2) and y(3);
c(14)<=x(3) and y(2);
c(15)<=x(3) and y(3);
adder port map(c(1),c(2),r(1),d(0));
adder port map(c(3),c(4),c(5),d(0),r(2),d(1));
adder port map(c(6),c(7),c(8),c(9),d(1),r(3),d(2));
adder port map(c(10),c(11),c(12),d(2),r(4),d(3));
adder port map(c(13),c(14),d(3),r(5),d(4));
adder port map(c(15),d(4),r(6),cout);
end behaviour;

 
Last edited by a moderator:

you need to give the adders idividiual labels:

eg:

adder1 : adder port map ();
 


Code VHDL - [expand]
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
library ieee;
use ieee.std_logic_1164.all;
entity adder is
port(a:in std_logic_vector(3 downto 0);
sum:out std_logic;carry:out std_logic);
end adder;
architecture behaviour of adder is
signal c0,s0:std_logic:='0';
begin
s0<=a(0) xor a(1) xor a(2);
c0<=(a(0) and a(1)) or (a(1) and a(2))or( a(2) and a(1));
sum<=a(3) xor s0 xor c0;
carry<=(a(3) and s0)or (s0 and c0) or (a(3) and c0);
end behaviour;
 
--vedic multiplier
library ieee;
use ieee.std_logic_1164.all;
 
entity vedic_mul is
port(x,y:in std_logic_vector(3 downto 0);r: out std_logic_vector(6 downto 0);
cout: out std_logic);
end vedic_mul;
 
architecture behaviour of vedic_mul is
signal c:std_logic_vector(15 downto 1);
signal d:std_logic_vector(4 downto 0);
component adder
port(a:in std_logic_vector(3 downto 0);sum:out std_logic;carry:out std_logic);
end component;
begin
r(0)<=x(0) and y(0);
c(1)<=x(0) and y(1);
c(2)<=x(1) and y(0);
c(3)<=x(0) and y(2);
c(4)<=x(1) and y(1);
c(5)<=x(2) and y(0);
c(6)<=x(0) and y(3);
c(7)<=x(1) and y(2);
c(8)<=x(2) and y(1);
c(9)<=x(3) and y(0);
c(10)<=x(1) and y(3);
c(11)<=x(2) and y(2);
c(12)<=x(3) and y(1);
c(13)<=x(2) and y(3);
c(14)<=x(3) and y(2);
c(15)<=x(3) and y(3);
a1:adder port map(c(1),c(2),r(1),d(0));
a2:adder port map(c(3),c(4),c(5),d(0),r(2),d(1));
a3:adder port map(c(6),c(7),c(8),c(9),d(1),r(3),d(2));
a4:adder port map(c(10),c(11),c(12),d(2),r(4),d(3));
a5:adder port map(c(13),c(14),d(3),r(5),d(4));
a6:adder port map(c(15),d(4),r(6),cout);
end behaviour;



i have cleared many errors in the code but dont know the logic, so couldn't able to clear why the port map of adder mapped with four individual elements, but the actual adder requires a 3 bit vector and sum and carry out. i think the code is logically wrong. Any help?
 
Last edited by a moderator:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top