From 9ef3587cdb6f58e8f28c6b8ac98ca43255db0d6b Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Thu, 19 Nov 2020 22:32:17 +0000 Subject: Small beauty fixes --- algorithm.tex | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'algorithm.tex') diff --git a/algorithm.tex b/algorithm.tex index c4f59c5..c590b00 100644 --- a/algorithm.tex +++ b/algorithm.tex @@ -274,7 +274,7 @@ But dividing by a constant can often be optimised to a more efficient operation, \texttt{Oshrximm } x\ y = x \div 2^{y} \end{equation*} -As these are the semantics of the \texttt{Oshrximm} instruction, it means that the Verilog statement that is supposed to implement this instruction needs to have the exact same semantics. The na\"{i}ve, implementation would be to just implement it using the Verilog division operator and rely on the hardware synthesis tool to convert that to an efficient implementation. It is quite rare that this will succeed with signed division though, as it cannot be implemented using a single simple shift instruction and the synthesis tool will often fall back to using a division circuit. However, the observation can be made that signed division can be implemented using shifts as shown below, where $>>$ stands for a logical right shift: +As these are the semantics of the \texttt{Oshrximm} instruction, it means that the Verilog statement that is supposed to implement this instruction needs to have the exact same semantics. The na\"{i}ve, implementation would be to just implement it using the Verilog division operator and rely on the hardware synthesis tool to convert that to an efficient implementation. It is quite rare that this will succeed with signed division though, as it cannot be implemented using a single simple shift instruction and the synthesis tool will often fall back to using a division circuit. However, the observation can be made that signed division can be implemented using shifts as shown below, where $\gg$ stands for a logical right shift: \begin{remark} @@ -283,8 +283,8 @@ As these are the semantics of the \texttt{Oshrximm} instruction, it means that t \begin{equation*} x \div 2^y = \begin{cases} - \left\lfloor \frac{x}{2^y} \right\rfloor = x >> y,& \text{if } x \geq 0\\ - \left\lceil \frac{x}{2^y} \right\rceil = - \left\lfloor \frac{-x}{2^y} \right\rfloor = - ( - x >> y ),& \text{otherwise}. + \left\lfloor \frac{x}{2^y} \right\rfloor = x \gg y,& \text{if } x \geq 0\\ + \left\lceil \frac{x}{2^y} \right\rceil = - \left\lfloor \frac{-x}{2^y} \right\rfloor = - ( - x \gg y ),& \text{otherwise}. \end{cases}\\ \end{equation*} \end{remark} -- cgit