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.

Adding Two Numbers In VHDL

Status
Not open for further replies.

jerryt

Junior Member level 3
Joined
Jan 26, 2009
Messages
31
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,608
Using IEEE packages:

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.numeric_std.ALL;

I want to add two numbers of bit length 8 and store the result into as an output of bit length 16. I am getting the following error when trying to compile my design:

# ** Error: D:/Profiles/w30239/My Documents/Miscallaneous/ECE 584/Project/Comp Instantiation Example/GoertzelAlg.vhd(33): (vcom-1272) Length of expected is 16; length of actual is 8.

How do I fix this error if I want to make sure my output (Xk0) is 16 bits but my inputs (x0,x1) coming in are 8 bits?

Thanks for your help!

Here is a snapshot of my code:

entity GoertzelAlg is
Port (x0,x1 : IN signed (7 downto 0);
Xk0 : OUT signed (15 downto 0));
end GoertzelAlg;

architecture Structure of GoertzelAlg is

begin

Xk0 <= x0+x1;

end Structure;
 

Actual length is 8, so you try to change Xk0 : OUT signed (7 downto 0));
Then there will be no error.
:D

---------- Post added at 13:33 ---------- Previous post was at 13:25 ----------

Actual length is 8, so you try to change Xk0 : OUT signed (7 downto 0));
Then there will be no error.
:D
 
  • Like
Reactions: jerryt

    jerryt

    Points: 2
    Helpful Answer Positive Rating
you need to sign-extend the inputs. iirc, "resize(x0,16) + resize(x1,16)"
 
  • Like
Reactions: jerryt

    jerryt

    Points: 2
    Helpful Answer Positive Rating
it is multiplication where the output is the combined length of both inputs (so 8bit x 8bit = 16). For addition you simply need an extra bit, and you can should do what permute suggests (sign extension before adding).
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top