Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
sav08:bitwidth_analysis [2008/05/20 13:57] vkuncak |
sav08:bitwidth_analysis [2008/05/20 18:56] vkuncak |
||
---|---|---|---|
Line 2: | Line 2: | ||
Given a language with signed 64 bit integers, determine as small as possible set of bits needed to store values of variables. | Given a language with signed 64 bit integers, determine as small as possible set of bits needed to store values of variables. | ||
- | * if the bit is small we can use e.g. 'byte' to store it | + | * e.g. if analysis derives that a subset of $\{0,1,2,\ldots,7\}$ is sufficient, then we can use //byte// type to store the value |
- | * it becomes even more important if we generate hardware from C code (saving wires) | + | * the analysis becomes even more important if we generate hardware from C code (saving wires) |
Let B = {-32,-31,...,-1,0,1,...,31} be a set of bits. | Let B = {-32,-31,...,-1,0,1,...,31} be a set of bits. | ||
Line 17: | Line 17: | ||
++++| | ++++| | ||
\[\begin{array}{l} | \[\begin{array}{l} | ||
- | let L = \min(g(y)) + \min(g(z))-1 \\ | + | let\ L = \min(g(y)) + \min(g(z))-1 \\ |
- | let U = \max(g(y)) + \max(g(z))+1 \\ | + | let\ U = \max(g(y)) + \max(g(z))+1 \\ |
- | if (L < 32) \lor (U > 31)\ then\ B \\ | + | if\ (L < 32) \lor (U > 31)\ then\ B \\ |
else\ [L,U] | else\ [L,U] | ||
\end{array} | \end{array} |