Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision |
math:start [2022/07/16 20:22] – [Namespace math::fxp] rajit | math:start [2022/07/30 15:40] – [Functions] rajit |
---|
| |
This namespace is used to provide support functions for math operations. | This namespace is used to provide support functions for math operations. |
| |
| ===== Functions ===== |
| |
| <code act> |
| template<pint Worig, Wnew> function sign_extend (int<Worig> x) : int<Wnew>; |
| </code> |
| |
| This function takes an integer ''x'' of width ''Worig'', and sign extends its most significant bit to return a result that has width ''Wnew''. It assumes that ''Wnew'' is at least ''Worig.'' |
| |
| |
| <code act> |
| template<pint Worig, Wnew> function zero_extend (int<Worig> x) : int<Wnew>; |
| </code> |
| |
| This function takes an integer ''x'' of width ''Worig'', and zero extends it to return a result that has width ''Wnew''. It assumes that ''Wnew'' is at least ''Worig.'' |
| |
| |
| |
| |
===== Namespace math::fxp ===== | ===== Namespace math::fxp ===== |
| |
| ==== Functions ==== |
| |
The ''math::fxp'' namespace contains simple definitions for fixed-point arithmetic functions. Functions take two parameters ''A'' and ''B'', and integers use the standard Q-format where the representation Q(A,B) corresponds to A digits for the integer part and B digits for the fractional part. The representation uses 2's complement for negative | The ''math::fxp'' namespace contains simple definitions for fixed-point arithmetic functions. Functions take two parameters ''A'' and ''B'', and integers use the standard Q-format where the representation Q(A,B) corresponds to A digits for the integer part and B digits for the fractional part. The representation uses 2's complement for negative |