1

I'm new to Verilog and VHDL.

I have been studying Verilog focusing in how to do arithmetic operations, this is for a project that my professor has commended me to study. The idea is to perform a simple equation which content Addition, Subtraction, multiplication and division of REAL numbers such as 1.0058 + 0.1689, in their binary version.

I'm reading a book of Arithmetic in Verilog by Cavanagh. They explain how to make adders, divisors, etc, they take a programming method by "Gates" they use the gates either in Combinational or Sequential Logic.

I understand the book easily, BUT isn't supposed that Verilog already have this +,-,* and even / for making divisions, why so much bothering to implement this with karnaugh and adder ripple carry adder etc, etc?

Why not just declare the variables and make begin...end and make the operations inside the statement with "="?

sujeto1
  • 371
  • 2
  • 4
  • 19
  • 3
    So you can learn how to do "hardware", and not "Verilog". And, of course, Verilog books are almost universally useless. – EML Jan 15 '16 at 14:32

2 Answers2

2

as you mention learning books about computer architecture then my guess is:

It is for didactic reasons.

So you learn that there are always NAND or NOR gates behind everything.

Spektre
  • 49,595
  • 11
  • 110
  • 380
1

To understand hardware arithmetic (twos complement) you are taught using logic gates so you can understand how the bits are being manipulated. Verilog is just used to describe the gates.

One you understand basic arithmetic then there is not much need to go to this level unless your designing custom arithmetic cells.

In verilog RTL it is best to use +, - and * which allows the synthesis tools to pick the best hardware (lowest power, smallest size) that meets your timing constraints. No need for an adder with advanced look ahead to cut down on ripple time which meets 1GHz timing when your circuit only runs at 1MHz.

Your question also mentions real (floating point) numbers, these are not synthesizable in verilog, but can be used in testbenches. If you just need fractional number I suggest you take a look at :

  1. Verilog: fixed-point
  2. Verilog: number bases
  3. Verilog: quantisation
Community
  • 1
  • 1
Morgan
  • 19,934
  • 8
  • 58
  • 84
  • Thanks so much Morgan. Indeed, I decided to implement Fixed-Point instead of Floating Point, Canavagh book also study Floating but in my personal homework, Exact high Precision isn't needed, so I think fixed point is easier to do and less hardware hungry. I'm just guessing cause I'm new in this. Thanks also for the clarification, I wanted to make sure that what it says in the book, is only for "Educative" purpose, Then I'll try to implement it using useful tools like Xilinx ISE or Quartus. – sujeto1 Jan 16 '16 at 10:12
  • @sujeto1 'I think fixed point is easier to do and less hardware hungry' Yes, floating point is quite hardware hungry. Floaitng point can be made to an arbitary precision so you only use the hardware you require rather than implementing a full floating point standard – Morgan Jan 25 '16 at 13:31