a simple question

R

Rafal Pietrak

..... although, not for me at the moment :(

I try to write my first sentences in VHDL. Today, it's one with 4-bit
adder and carry propagation (verbatim included at the end of this post).

Only it doesn't synthesize into a 4-bit adder with carry, but into a 5-bit
one instead. The commented-out lines are my attempt to constrain the
synthesizer to 4-bits, but it appears, that I loose carry in the process :(.

I'd appreciate any hint on 'how to hint' the synthesizer, to GIVE ME THE
CARRY (my apology for the outburst :) from 4-bit adder (and not expand
the adder, as it does). I'd like this because I plan to put this into a
CPLD with 4-bit granularity, and I'd like to make the job for place&route
as easy as possible :).

I'd really appreciate any comment! (including such: "don't do that;
place&route are inteligent beasts - unlike synthesizes, they do an
excelent job and fix easily whatever synthesizer messed up").

-------------------------------------------------
entity test1 is
generic ( MWS : natural := 4;
DataBW : natural := MWS; AddressBW : natural := 2*MWS);
Port ( data : inout std_logic_vector(DataBW-1 downto 0);
addr : out std_logic_vector(AaddressBW-1 downto 0);
clk : in std_logic;
reset : in std_logic);
end test1;

architecture Behavioral of test1 is
signal accu: std_logic_vector(2*MWS-1 downto 0);
alias accu_l: std_logic_vector(MWS-1 downto 0) is accu(MWS-1 downto 0);
alias accu_h: std_logic_vector(MWS-1 downto 0) is accu(2*MWS-1 downto MWS);

begin
process(clk,reset)
variable tmp: std_logic_vector(MWS downto 0);
begin
if (reset = '0') then
accu <= (others => '0');
elsif rising_edge(clk) then
-- tmp := accu_l + data;
tmp := ("0" & accu_l) + data;
accu_l <= tmp;
-- if (tmp(MWS) = '1') then
-- accu_h <= accu_h + 1;
accu_h <= accu_h + tmp(MWS);
-- end if;
end if;
end process;

addr <= accu;

end Behavioral;
 
M

Mike Treseler

Rafal said:
Only it doesn't synthesize into a 4-bit adder with carry, but into a 5-bit
one instead. The commented-out lines are my attempt to constrain the
synthesizer to 4-bits, but it appears, that I loose carry in the process :(.

You haven't declared or used any carry_in.
I'd appreciate any hint on 'how to hint' the synthesizer, to GIVE ME THE
CARRY (my apology for the outburst :) from 4-bit adder (and not expand
the adder, as it does).

That extra bit is the carry out.
I'd like this because I plan to put this into a
CPLD with 4-bit granularity, and I'd like to make the job for place&route
as easy as possible :).

I would start by describing the logic you really want.
I doubt that synthesis needs the hints.
Here's some related examples.

http://groups.google.com/groups?q=vhdl+treseler+resize+result_len

-- Mike Treseler
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top