EmbDev.net

Forum: FPGA, VHDL & Verilog Simple 16 bit Arithmetic Unit


von Omar Rashad (Guest)


Rate this post
useful
not useful
Hello again, I  have so far wrote and tested the codes for a 16 bit 
adder, and a 16 bit multiplier to be used as components of the AU. I am 
facing a strange error though when compiling the AU code. Here are my 
codes:

Adder:
1
library ieee;
2
use ieee.std_logic_1164.all;
3
use ieee.std_logic_unsigned.all;
4
use ieee.std_logic_arith.all;
5
6
entity FullAdder16Bit is
7
    Port(A,B: IN std_logic_vector(15 DOWNTO 0);
8
         Cin: IN std_logic;
9
         Sum: OUT std_logic_vector(15 DOWNTO 0);
10
         Cout: OUT std_logic);
11
end FullAdder16Bit;
12
13
architecture behavior of FullAdder16bit is
14
15
begin
16
    process(A,B,Cin)
17
    variable carry: std_logic;
18
19
    begin
20
    carry:=Cin;
21
        for i in 0 to 15 loop
22
        carry:= (A(i) and B(i)) or (carry and (A(i) or B(i)));
23
        end loop;
24
    Sum <= A + B + Cin;
25
    Cout <= carry;
26
    end process;
27
end behavior;


Multiplier
1
library ieee;
2
use ieee.std_logic_1164.all;
3
use ieee.std_logic_arith.all;
4
use ieee.std_logic_unsigned.all;
5
6
entity Multiplier16 is
7
  port (A,B: IN std_logic_vector (15 downto 0);
8
        Pro: OUT std_logic_vector (31 downto 0));
9
end Multiplier16;
10
11
architecture behavior of Multiplier16 is
12
begin
13
  Pro <= A*B;
14
end behavior;

And finally, the AU:
1
library ieee;
2
use ieee.std_logic_1164.all;
3
4
entity AU is
5
  port (A,B: IN std_logic_vector (15 downto 0);
6
        Opcode: IN std_logic_vector (2 downto 0);
7
        AU_O: OUT std_logic_vector (31 downto 0));
8
end AU;
9
10
architecture behavior of AU is
11
component FullAdder16Bit
12
  port (A,B: IN std_logic_vector (15 downto 0);
13
        Cin: IN std_logic;
14
        Sum: OUT std_logic_vector (15 downto 0);
15
        Cout: OUT std_logic);
16
end component;
17
18
component Multiplier16 is
19
  port (A,B: IN std_logic_vector (15 downto 0);
20
        Pro: OUT std_logic_vector (31 downto 0));
21
end component;
22
23
signal Pro: std_logic_vector (31 downto 0):= (others => '0');
24
signal Sum: std_logic_vector (15 downto 0);
25
signal Cout: std_logic:= '0';
26
27
begin
28
ADD: FullAdder16Bit port map (A=>A, B=>B, Cin=>'0', Sum=>Sum, Cout=>Cout);
29
MUL: Multiplier16 port map (A=>A, B=>B, Pro=>Pro);
30
31
with Opcode select
32
  AU_O <= "000000000000000" & Cout & Sum when "000",
33
          Pro when "001",
34
          (others => 'Z') when others; 
35
36
end behavior;

AU Test Bench:
1
library ieee;
2
use ieee.std_logic_1164.all;
3
4
entity tb_AU is
5
end tb_AU;
6
7
architecture behavior of tb_AU is
8
component AU
9
  port (A,B: IN std_logic_vector(15 downto 0);
10
        Opcode: IN std_logic_vector(2 downto 0);
11
        AU_O: OUT std_logic_vector(31 downto 0));
12
end component;
13
14
signal A,B: std_logic_vector(15 downto 0);
15
signal Opcode: std_logic_vector(2 downto 0);
16
signal AU_O: std_logic_vector(31 downto 0);
17
18
begin
19
DUT: AU port map (A=>A,B=>B,Opcode=>Opcode,AU_O=>AU_O);
20
21
process
22
begin
23
wait for 0 ns;
24
A <= x"0001"; B <= x"FFFF"; Opcode <= "000";
25
wait for 10 ns;
26
Opcode <= "001";
27
wait for 10 ns;
28
end process;
29
end behavior;
30
31
configuration tb_AU_con of tb_AU is
32
for behavior
33
end for;
34
end tb_AU_con;

When trying to simulate with vcs, I get this error:
Error -- [BADFORMALSPEC] Bad Formal Part Specified'
formal port 'PRO' in component Multiplier16 (AU.vhd:18) cannot be found 
in entity Multiplier16 (Multiplier16.vhd:6)

von Lothar M. (Company: Titel) (lkmiller) (Moderator)


Attached files:

Rate this post
useful
not useful
First:
When you write that:       Pro <= A*B;
Why don't you write that:  Sum <= A+B;

Omar Rashad wrote:
> Error -- [BADFORMALSPEC] Bad Formal Part Specified' formal port 'PRO' in
> component Multiplier16 (AU.vhd:18) cannot be found in entity
> Multiplier16 (Multiplier16.vhd:6)
Something with your project configuration is wrong. With ISIM its 
working fine...

You can skip this last four lines without any problems:
> configuration tb_AU_con of tb_AU is
> for behavior
> end for;
> end tb_AU_con;

von Omar Rashad (Guest)


Rate this post
useful
not useful
Well I do have sum<= a + b + cin in the adder SC. But im also 
calculating the cout with the process. Anyway, that shouldnt affect the 
code since the adder was tested successfully.

Are you saying there is nothing wrong with my code? Should removing the 
last four lines make it work? We are forced to use vcs for simulation...

von Omar Rashad (Guest)


Rate this post
useful
not useful
Problem solved. I just created a new directory and moved all the files 
to it and re compiled and simulated. Works fine! Thanks!

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.