|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbyucc.jhdl.base.Nameable
byucc.jhdl.base.Node
byucc.jhdl.base.Cell
byucc.jhdl.base.Structural
byucc.jhdl.Logic.LogicGates
byucc.jhdl.Logic.LogicStatic
byucc.jhdl.Logic.Logic
byucc.jhdl.contrib.modgen.IntDivide
Variable width integer divider with the option of signed or unsigned multiply and generic pipeline depth.
Copyright (c) 1999-2000 Brigham Young University. All rights reserved. Reproduction in whole or in part in any form or medium without express permission of Brigham Young University is prohibited. This is a variable width integer divider based on a non-restoring division algorithm that can be pipelined. The divider can produce both a quotient and remainder or a rounded quotient as well as perform both unsigned and signed division.
As seen in the diagram, the divider will calculate the integer quotient and remainder by dividing the dividend value by the divisor value. The clock enable input allows one to stall the pipeline. The divideByZero output will detect invalid results caused by the divisor value being zero.
The dividend, divisor, quotient and remainder wires are all
generic widths with restrictions. Generic width implies that
the module will query the width of these input wires and
construct itself accordingly. In the case of the IntDivide
module genterator although the dividend, divisor, quotient and
remainder widths are generic, there are certain restrictions
with regard to the relationship of their widths. These
restrictions on the relation of their widths are indicated in
the table below for both the non-rounded quotient and rounded
quotient configurations of the divider. To obtain all possible
bits of a quotient its width must be the same as the dividend's
width (if the quotient width is less than the dividend's the
most significant bits are truncated off with no overflow check
being done). In the table below, when a wire is indicated as not
required this means that a null
can be passed into
wires's parameter if the functionality of this signal is not
desired (note that if a null
is passed in for a
wire, optimization is performed, see the
Logic Optimization section below for more explanation).
Wire | Width | Width Restrictions | Required Wire? |
dividend | dvdWidth | 2<= dvdWidth* | Required |
divisor | dvrWidth | 2<= dvrWidth<= dvdWidth | Required |
clk_en | clk_enWidth | clk_enWidth=1 | Not Required** |
quotient | qWidth | 2<= qWidth<= dvdWidth | Not Required*** |
remainder | remWidth | remWidth= dvrWidth | Not Required*** |
divideByZero | divBy0Width | divBy0Width=1 | Not Required |
Wire | Width | Width Restrictions | Required Wire? |
dividend | dvdWidth | 2<= dvdWidth* | Required |
divisor | dvrWidth | 2<= dvrWidth<= dvdWidth | Required |
clk_en | clk_enWidth | clk_enWidth=1 | Not Required** |
quotient | qWidth | 2<= qWidth<= dvdWidth | Required |
remainder | N/A | N/A | Must be null |
divideByZero | divBy0Width | divBy0Width=1 | Not Required |
* Although these widths should be valid structurally for widths greater than 64 bits, the maximum bit width that the behavioral model is valid for is 63 bits.
** Note that if your divider is purely combinational (the
pipedepth parameter into your constructor is zero), the clk_en
wire must be null
.
*** For the non-rounding quotient case, although the quotient
and remainder wire can be individually null
they
cannot both be null
at the same time (in other
words, you must have a useful output).
numOfStages
method or using the method
getNumOfStages
once a divider is instantiated.
pipedepth
parameter of this divider does NOT represent
the latency of the divider but the frequency of a pipeline register.
pipedepth=0
means fully-combinational divider
pipedepth=1
means fully-pipelined divider
(one pipeline register per logic stage).
pipedepth=2
means place a pipeline register every
other stage
pipedepth=3
means place a pipeline register every
third stage
latency
method or by using the
getLatency
method once a divider has been constructed.
Unsigned/Signed Divider | Sign of Dividend | Round Up or Down (Magnitude) | Examples |
Unsigned | N/A | Round Up | 3/6= 1 |
Signed | Positive | Round Up | 3/6= 1, 3/-6= -1 |
Signed | Negative | Round Down | -3/6= 0, -3/-6= 0 |
If any of the wire parameters that can be null
are null
, logic will not be built for any wires or
structure corresponding to these inputs or outputs. Therefore
if the functionality of a signal is not desired it is always
best to pass a null
in for that wire's parameter.
For example, passing a null
in for the remainder
output wire will tell the module not to construct the remainder
correcting hardware. On the other hand, leaving the output
hanging by using the Logic method call nc(divisorWidth) will
cause the remainder logic to be built although it is left
unconnected (because nc() returns a wire and the module doesn't
know the difference between that wire and a connected output
wire). Likewise if one passes a null
in for the
clk_en input wire no clk_en net will be not be connected. In
constrast, tying the clk_en input high with the Logic class
method call vcc() will cause the clock enable net to be hooked
up to every flip-flop although it's obvious that one isn't going
to use the clk_en signal in this case.
Field Summary | |
static CellInterface[] |
cell_interface
Standard JHDL CellInterface. |
protected static boolean |
disableBehavioralModel
|
static int |
DIVIDE_BY_ZERO_INDEX
For indexing divide_by_zero value in the 3 element array compute returns |
static int |
QUOTIENT_INDEX
For indexing the quotient in the 3 element array compute returns |
static int |
REMAINDER_INDEX
For indexing the remainder in the 3 element array compute returns |
Fields inherited from class byucc.jhdl.Logic.Logic |
ABOVE, ALIGN_BOTTOM, ALIGN_CENTER, ALIGN_LEFT, ALIGN_LSB, ALIGN_MSB, ALIGN_RIGHT, ALIGN_TOP, BELOW, DOWN, EAST_OF, LEFT_OF, MAX_PACK, NORTH_OF, ON, ONTOP, ONTOP_OF, RIGHT_OF, SOUTH_OF, TOLEFT, TORIGHT, UNCONSTRAINED, UP, WEST_OF |
Fields inherited from class byucc.jhdl.Logic.LogicGates |
tech_mapper |
Constructor Summary | |
IntDivide(Node parent,
Wire dividend,
Wire divisor,
Wire clk_en,
Wire quotient,
Wire remainder,
Wire divideByZero,
boolean signed,
boolean roundQuotient,
int pipedepth)
Integer divider constructor without a user-defined instance name. |
|
IntDivide(Node parent,
Wire dividend,
Wire divisor,
Wire clk_en,
Wire quotient,
Wire remainder,
Wire divideByZero,
boolean signed,
boolean roundQuotient,
int pipedepth,
java.lang.String instanceName)
Integer divider constructor whose last parameter is a user-defined instance name. |
Method Summary | |
boolean |
cellInterfaceDeterminesUniqueNetlistStructure()
Method to indicate that the netlister can assume that the wires and the bound parameters in the cell interface uniquely determine a cell structure. |
void |
clock()
Clock method is used for behavioral pipelined similuation. |
static void |
compute(BV dividend,
BV divisor,
BV quotient,
BV remainder,
BV divideByZero,
boolean signed,
boolean roundQuotient)
compute method using BVs |
static long[] |
compute(long dividend,
int dvdWidth,
long divisor,
int dvrWidth,
int quotientWidth,
boolean remainderFlag,
boolean divideByZeroFlag,
boolean signed,
boolean roundQuotient)
Compute method that calculates a mathematically accurate calculation of all the outputs of the divider and returns them as a long array of 3 elements. |
static void |
computeQuotient(BV dividend,
BV divisor,
BV quotient,
boolean signed,
boolean roundQuotient)
computeQuotient using BVs |
static long |
computeQuotient(long dividend,
int dvdWidth,
long divisor,
int dvrWidth,
int quotientWidth,
boolean signed,
boolean roundQuotient)
ComputeQuotient method that calculates a mathematically accurate calculation of the quotient the divider would produce out for the given parameters. |
static void |
computeRemainder(BV dividend,
BV divisor,
BV remainder,
boolean signed)
ComputeRemainder using BVs |
static long |
computeRemainder(long dividend,
int dvdWidth,
long divisor,
int dvrWidth,
boolean signed)
ComputeRemainder method provides the correct remainder value that the structural model would generate given the input parameters. |
protected boolean |
defaultSimulationModelIsBehavioral()
The default simulation model is behavioral. |
int |
getLatency()
Method to get the latency of a divider that is already constructed. |
int |
getNumOfStages()
Method to get the number of logic stages of a divider that is already constructed. |
void |
initUserDefinedNode(UserDefinedNode udn)
init method needed for UserDefinedSchematic interface. |
static int |
latency(int dividendWidth,
int quotientWidth,
boolean remainderFlag,
boolean signed,
boolean roundQuotient,
int pipedepth)
The latency method gives the latency in clock cycles of the module with the given input parameters. |
static int |
numOfStages(int dividendWidth,
int quotientWidth,
boolean remainderFlag,
boolean signed,
boolean roundQuotient)
Method that calculates the number of pipelinable logic stages (most stages consist of addsub units). |
void |
paint(UserDefinedNode udn)
paint method for UserDefinedSchematic interface. |
void |
propagate()
Propagate method for combinational behavioral simulation (no registers). |
void |
reset()
Reset method puts zeros on quotient, remainder and divideByZero outputs and clears behavioral delay arrays. |
Methods inherited from class byucc.jhdl.base.Node |
addObservable, addSimulatorCallback, checkAll, delete, getBuildingFlag, getChildren, getChildrenEnumeration, getInstanceName, getParent, getParentCell, getRelatives, getSystem, getWires, optimize, orphanAllowed, printAllChildren, printTree, removeSimulatorCallback, setDefaultClock |
Methods inherited from class byucc.jhdl.base.Nameable |
caseSensitivity, caseSensitivity, disableNameClashChecking, getFullName, getFullNameNoTestBench, getHierNameNoTestBench, getInstanceNo, getInstanceNumber, getLeafName, getLeafName, getRelativeName, getUserName, getUserName, hasUserSpecifiedName, isDescendantOf, setInstanceNumber |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static CellInterface[] cell_interface
protected static boolean disableBehavioralModel
public static final int QUOTIENT_INDEX
public static final int REMAINDER_INDEX
public static final int DIVIDE_BY_ZERO_INDEX
Constructor Detail |
public IntDivide(Node parent, Wire dividend, Wire divisor, Wire clk_en, Wire quotient, Wire remainder, Wire divideByZero, boolean signed, boolean roundQuotient, int pipedepth)
IntDivideException
- Thrown when any of the parameters are
invalid (as described above in the parameter
description).public IntDivide(Node parent, Wire dividend, Wire divisor, Wire clk_en, Wire quotient, Wire remainder, Wire divideByZero, boolean signed, boolean roundQuotient, int pipedepth, java.lang.String instanceName)
IntDivideException
- Thrown when any of the parameters are
invalid (as described above in the parameter description).Method Detail |
public boolean cellInterfaceDeterminesUniqueNetlistStructure()
cellInterfaceDeterminesUniqueNetlistStructure
in class Cell
public void initUserDefinedNode(UserDefinedNode udn)
initUserDefinedNode
in interface UserDefinedSchematic
public void paint(UserDefinedNode udn)
paint
in interface UserDefinedSchematic
public static int latency(int dividendWidth, int quotientWidth, boolean remainderFlag, boolean signed, boolean roundQuotient, int pipedepth)
public int getLatency()
public static int numOfStages(int dividendWidth, int quotientWidth, boolean remainderFlag, boolean signed, boolean roundQuotient)
public int getNumOfStages()
protected boolean defaultSimulationModelIsBehavioral()
defaultSimulationModelIsBehavioral
in class Structural
public void reset()
reset
in interface Clockable
reset
in class Structural
public void clock()
clock
in interface Clockable
clock
in class Structural
public void propagate()
propagate
in interface byucc.jhdl.base.Propagateable
propagate
in class Structural
public static long[] compute(long dividend, int dvdWidth, long divisor, int dvrWidth, int quotientWidth, boolean remainderFlag, boolean divideByZeroFlag, boolean signed, boolean roundQuotient)
public static void compute(BV dividend, BV divisor, BV quotient, BV remainder, BV divideByZero, boolean signed, boolean roundQuotient)
public static long computeQuotient(long dividend, int dvdWidth, long divisor, int dvrWidth, int quotientWidth, boolean signed, boolean roundQuotient)
public static void computeQuotient(BV dividend, BV divisor, BV quotient, boolean signed, boolean roundQuotient)
public static long computeRemainder(long dividend, int dvdWidth, long divisor, int dvrWidth, boolean signed)
public static void computeRemainder(BV dividend, BV divisor, BV remainder, boolean signed)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |