[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Rep:Re: [f-cpu] I forgot to tell you...



On Fri, Jul 05, 2002 at 08:13:05AM +0200, Yann Guidon wrote:
> huh, Houston ? i got a little issue...
> 
> Michael Riepe wrote:
> > > but bit 1 is not straight-forward at all). Currently i do it with a
> > > lookup table in the integer world (that's lame but it should simulate
> > > fast ;-D). Then there is a row of 8*(3+3=4) adders to make the byte results,
> > > 4*(4+4=5) adders for the 4 shortint results, 2*(5+5=6) for the two lontgint
> > > results and a final 6+6=7 adder for the full 64-bit result.
> > 
> > You can use my CIAdd procedure from the Generic_Adder package. Here's
> > how to use it:
> > 
> >         function "+" (A, B : in std_ulogic_vector) return std_ulogic_vector is
> >                 use work.Generic_Adder.CIAdd;
> >                 constant w : natural := A'length;
> >                 alias aa : std_ulogic_vector(w-1 downto 0) is A;
> >                 alias bb : std_ulogic_vector(w-1 downto 0) is B;
> >                 variable yy, cc : std_ulogic_vector(w-1 downto 0);
> >                 variable pp, gg : std_ulogic;
> >         begin
> >                 CIAdd(aa, bb, yy, cc, gg, pp);
> >                 -- we only care about yy here
> >                 return yy;
> >         end "+";
> 
> The problem here is that a N+N addition will return a N-bit result.
> I remarked that when Simili elaborated the design and loudly complained
> of a size mismatch...

Oh sorry... I forgot. You can use `gg' as the most significant output
bit. That is, rename the function, change the declaration of yy to

	variable yy : std_ulogic_vector(w downto 0);

and then call

	CIAdd(aa, bb, yy(w-1 downto 0), cc, yy(w), pp);
	return yy;

(cc and pp are still unused dummies).

> How does one manage the cc, gg and pp outputs ? and how do we do
> an aggregate of the result, that is independent of the to/downto (direction) ?

You'll need the other variables if you build an adder with
carry-in/carry-out. `cc' is an `increment vector' for yy (like the
INC EU uses it, but precomputed and with less delay than yy itself).
That is, you can add a carry-in with

	yy := yy xor (cc and (cc'range => Cin));

Carry-out is generated from Cin, gg and pp:

	Cout := gg or (pp and Cin);

If Cin = 0, the sum equals yy and Cout equals gg.

-- 
 Michael "Tired" Riepe <Michael.Riepe@stud.uni-hannover.de>
 "All I wanna do is have a little fun before I die"
*************************************************************
To unsubscribe, send an e-mail to majordomo@seul.org with
unsubscribe f-cpu       in the body. http://f-cpu.seul.org/