Blue | Comments |
Red | Generic Terms |
Yelow | Reserved words and Commands |
Brown | Defines |
Link | Link to other functions |
$generic
$Sqrt='sq_root6',
$T1='uint3',
$T1b='bits3',
$T2='uint6',
$T2b='bits6',
$N='6';
$Sqrt='sq_root8',
$T1='uint4',
$T1b='bits4',
$T2='uint8',
$T2b='bits8',
$N='8';
$Sqrt='sq_root10',
$T1='uint5',
$T1b='bits5',
$T2='uint10',
$T2b='bits10',
$N='10';
$Sqrt='sq_root12',
$T1='uint6',
$T1b='bits6',
$T2='uint12',
$T2b='bits12',
$N='12';
$Sqrt='sq_root14',
$T1='uint7',
$T1b='bits7',
$T2='uint14',
$T2b='bits14',
$N='14';
$Sqrt='sq_root16',
$T1='uint8',
$T1b='bits8',
$T2='uint16',
$T2b='bits16',
$N='16';
$Sqrt='sq_root18',
$T1='uint9',
$T1b='bits9',
$T2='uint18',
$T2b='bits18',
$N='18';
$Sqrt='sq_root32',
$T1='uint16',
$T1b='bits16',
$T2='uint32',
$T2b='bits32',
$N='32';
$in
$T1
$Sqrt ($T2 vsq)
{
$T2b
vsqb = vsq;
$T2b
asq = 0;
$T1b
a = 0;
$T2b
tvsq = 0;
$T1b
v =
for uint5 i
in
[$N/2] {
$T2b nasq1 = ($T2)asq
+ ($T2)a;
$T2b nasq = (nasq1<<2) | ($T2b)1;
$T1b sa = a<<1;
next tvsq = (tvsq<<2) | ((vsqb>>($N-2))
& ($T2b)3);
next vsqb = vsqb<<2;
next a, next
asq =
if (nasq <= tvsq) return
(sa|($T1b)1, nasq)
else
return ( sa, asq<<2);
} return (final(a));
$T1 r = v;
} return
(r);
$end_generic