-1

In generally, there are two methods as I know what multiplication fixed/floating point multiplication. I'm Hardware Engineer like Verilog.

1.The one way Verilog - Floating points multiplication

2.The another way which is to Shift left "<<" then to shift right " >>"

I think above ways which is the results are all the same. But I'm not sure, So I'm asking here what I want to know which way are esay to use and correct?

Update1.

I think there are some way what multiplication in verilog.

1.way one.

What if I want to multipicate with 3.82 *2.581.
Then we can make integer above fractional numbers like this.
3.98*8  = 31.84.
What if we want only integer result then we could like this way to calculate .
3.98<<7 =3.98 * 2^7  = almost 509.
Then we can get 509 * 8 = 4072
Then we can 31 at 4072>>7.

2.way two. 3.98 = almost 'b11_111110101... At here, we can get to choice a suit depths for calculating multiplication. 8 = 'b1000 11_11111010 * 1000 = (4 int),(0 frac) * (2 int ),(8 frac) 11 1111101000 = 8144 Then we get 8144*2^-8 = 31.8125

update 2

I am confused a multiplication between how can I apply fixed fraction to the integer and Verilog - Floating points multiplication

Which one is better way?

Community
  • 1
  • 1
bural
  • 61
  • 2
  • 11
  • I am not sure what you are asking. are you asking how to do fractional and looking for fixed point vs floating point or how to do fixed point multiplication. your link 1 just describes how to interpret the result of `*`, `<<` then`>>` I think is discussing multiplier implementation, not the interpretation of fixed point data. – Morgan Dec 17 '15 at 15:09
  • @Morgan . I'm asking about the which one multiplication method is better at between first and second. I think both of all above are about multiplication at the fixed point. Am I missing ? – bural Dec 17 '15 at 21:45
  • Better how? Easy to implement, maintain, faster or lower power. Shift add can be split over multiple cycles, so data rates compared to clock rate is also a consideration. – Morgan Dec 17 '15 at 21:48
  • @Morgan but I think. Even shift and add can be split over multiple cycle, but I think those are better than "*" regarding of easy and maintanance , doesn't it? Sometime designware performance are very good, nowdays it just used directly "*" in verilog. – bural Dec 17 '15 at 21:54
  • What is simpler than a single line of code. Mul = a*b; and it allows tools to optimise timing easier than a specific implementation. – Morgan Dec 17 '15 at 21:56
  • @Morgan BTW, if we would calculate the floating point multiplication then should we have to calculate as assume that is fixed point? – bural Dec 18 '15 at 00:05
  • Sorry not sure I followed that, but `*` is not synthesisable for floating point operations only for integer or fixed point. – Morgan Dec 18 '15 at 00:08

1 Answers1

0

The best way to do fixed-point arithmetic is to use a fixed-point library that has (hopefully) been carefully written and debugged. You're using Verilog, so just search for 'verilog fixed point library' in Google. You'll find this

http://opencores.org/project,verilog_fixed_point_math_library

and others. I am not recommending this particular one because I have not used it, but you can see that it has been used by many people.

Graham Asher
  • 1,648
  • 1
  • 24
  • 34