| 1 |
29 |
robfinch |
`timescale 1ns / 1ps
|
| 2 |
|
|
|
| 3 |
|
|
// ============================================================================
|
| 4 |
|
|
// __
|
| 5 |
35 |
robfinch |
// \\__/ o\ (C) 2019-2020 Robert Finch, Waterloo
|
| 6 |
29 |
robfinch |
// \ __ / All rights reserved.
|
| 7 |
|
|
// \/_// robfinch@finitron.ca
|
| 8 |
|
|
// ||
|
| 9 |
|
|
//
|
| 10 |
|
|
// This source file is free software: you can redistribute it and/or modify
|
| 11 |
|
|
// it under the terms of the GNU Lesser General Public License as published
|
| 12 |
|
|
// by the Free Software Foundation, either version 3 of the License, or
|
| 13 |
|
|
// (at your option) any later version.
|
| 14 |
|
|
//
|
| 15 |
|
|
// This source file is distributed in the hope that it will be useful,
|
| 16 |
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 17 |
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 18 |
|
|
// GNU General Public License for more details.
|
| 19 |
|
|
//
|
| 20 |
|
|
// You should have received a copy of the GNU General Public License
|
| 21 |
|
|
// along with this program. If not, see .
|
| 22 |
|
|
//
|
| 23 |
|
|
// ============================================================================
|
| 24 |
|
|
|
| 25 |
|
|
// Uncomment the following to generate code with minimum latency.
|
| 26 |
|
|
// Minimum latency is zero meaning all the clock edges are removed and
|
| 27 |
|
|
// calculations are performed in one long clock cycle. This will result in
|
| 28 |
|
|
// the maximum clock rate being really low.
|
| 29 |
|
|
|
| 30 |
35 |
robfinch |
`define MIN_LATENCY 1'b1
|
| 31 |
29 |
robfinch |
|
| 32 |
|
|
// Number of bits extra beyond specified FPWIDth for calculation results
|
| 33 |
|
|
// should be a multiple of four
|
| 34 |
|
|
`define EXTRA_BITS 0
|
| 35 |
|
|
|
| 36 |
35 |
robfinch |
`define FPWID 80
|
| 37 |
|
|
|
| 38 |
|
|
// This file contains defintions for fields to ease dealing with different fp
|
| 39 |
|
|
// FPWIDths. Some of the code still needs to be modified to support FPWIDths
|
| 40 |
|
|
// other than standard 32,64 or 80 bit.
|
| 41 |
|
|
`define MSB (`FPWID-1)
|
| 42 |
|
|
`define EMSB (`FPWID==128 ? 14 : `FPWID==96 ? 14 : `FPWID==80 ? 14 : `FPWID==64 ? 10 : `FPWID==52 ? 10 : `FPWID==48 ? 10 : `FPWID==44 ? 10 : `FPWID==42 ? 10 : `FPWID==40 ? 9 : `FPWID==32 ? 7 : `FPWID==24 ? 6 : 49)
|
| 43 |
|
|
`define FMSB (`FPWID==128 ? (111) : `FPWID==96 ? (79) : `FPWID==80 ? (63) : `FPWID==64 ? (51) : `FPWID==52 ? (39) : `FPWID==48 ? (35) : `FPWID==44 ? (31) : `FPWID==42 ? (29) : `FPWID==40 ? (28) : `FPWID==32 ? (22) : `FPWID==24 ? (15) : (9))
|
| 44 |
|
|
`define FX ((`FMSB+2)*2) // the MSB of the expanded fraction
|
| 45 |
|
|
`define EX (`FX + 1 + `EMSB + 1 + 1 - 1)
|
| 46 |
|
|
|
| 47 |
|
|
// Only uncomment one of the following for the divider
|
| 48 |
|
|
// radix four has a faster cycle time
|
| 49 |
|
|
// radix sixteen uses fewer clock cycles
|
| 50 |
|
|
`define DIV_RADIX4 1'b1
|
| 51 |
|
|
//`define DIV_RADIX16 1'b1
|