e19293001
e19293001

Reputation: 2901

combinatorial hardware multiplication in verilog

Suppose I have a multiplier code like this,

      module multiply(
        output [63:0] result,
        input [31:0] a,
        input [31:0] b
      );

        assign result = a * b;

      endmodule

This produces a lot of gates.

What preferable method should be used to implement combinatorial multiplier?

Upvotes: 5

Views: 10277

Answers (3)

Marty
Marty

Reputation: 6644

Hardware multipliers are big, you just have to live with it!

Multipliers will get bigger as its input bit widths get bigger. So if you don't need the full 32 bits on one of you operands, then reducing this size to the minimum will reduce the size of the resulting hardware.

If you're multiplying by a fixed number, I think the compiler can make some optimizations to limit the size of the hardware too. Or you can use different encoding schemes for the fixed number such as CSD that will reduce the number of adders in the multiplier, further reducing its area.

If you need loads of multipliers and have a fast clock, maybe you can reuse a single hardware multiplier for many calculations. This means writing some control/pipelining logic to schedule your multiplies, and you might need some memory, but it can save you area overall. You'd be designing a mini-DSP datapath in this case.

Upvotes: 5

osgx
osgx

Reputation: 94175

Generated by verilog multiplier may be non-optimal. There is a lot of research in area of evvective multipliers and adders. And here is one of rather universal and good generator of add/mul: http://www.aoki.ecei.tohoku.ac.jp/arith/mg/algorithm.html

This page has descriptions of many add/mul low-lewel implementations

Upvotes: 1

Ross Rogers
Ross Rogers

Reputation: 24228

If you can forgo the combinatorial requirement, you can do multiplication using an adder and an accumulator, if speed isn't a large concern and you're able to process the operands over multiple clocks. Some low power/low cost/small area processors don't have dedicated multiply instructions in their ISA, or the multiply asm instruction is changed into addition operations by the front-end instruction decoder into addition microcode operations.

If you were to use this methodology, you'd have to create additional signals for the data hand-shake, since the output is no longer valid 1 cycle after the input settles.

Upvotes: 3

Related Questions