How do I add a multiplier to the ALU?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How do I add a multiplier to the ALU?

kingpinzs
I was reading a bunch of home brew cpu sites and was wondering how I could add a hardware multiplier?
I know it can be done in software but I figure it would be faster if it is put in the hardware.

Also I read about a look ahead carry to make the adder faster. How could I get started on that?


Thanks
Reply | Threaded
Open this post in threaded view
|

Re: How do I add a multiplier to the ALU?

cadet1620
Administrator
kingpinzs wrote
I was reading a bunch of home brew cpu sites and was wondering how I could add a hardware multiplier?
I know it can be done in software but I figure it would be faster if it is put in the hardware.
Adding a hardware multiplier to the Hack computer is a fairly big task.  You will need to use one of the "always one" bits in the I-instruction to select multiplying in the ALU.  The hardware multiplier itself basically implements the grade-school long multiplication algorithm in binary.  For 16-bit unsigned multiply the 16 partial products are generated by ANDing the multiplicand by each bit of the multiplier, and the partial products are then added using 15 16-bit adders.

That's 256 ANDs, 225 Full Adders, and 15 Half Adders!

--Mark
Reply | Threaded
Open this post in threaded view
|

Re: How do I add a multiplier to the ALU?

cadet1620
Administrator
In reply to this post by kingpinzs
kingpinzs wrote
Also I read about a look ahead carry to make the adder faster. How could I get started on that?
I'd recommend using LogiSim (http://ozark.hendrix.edu/~burch/logisim/) to explore lookahead carry adders.

I was playing with lookahead carry adders in Logisim a couple month ago.  If you'd like my .circ file let me know.

--Mark