/*----------------------------------------------- * * Associative LMS vector search (C-RAM) * */ #include #include "lms.h" typedef short unsigned int datatype; cuint12 data[VECTORSIZE]; inline cuint sqr(const cint &x) { cuint a(x.bits - 1, UNALIGNED); cuint result(2 * a.bits, UNALIGNED); a = abs(x); result.mult3(a, a); /*result = a * a; */ return (result); } void updateBest(const datatype key[VECTORSIZE], const datatype newdata[VECTORSIZE]) { int v; cuint24 error; cboolean bestrecord; /* find record with LMS fit */ error = 0; for (v = 0; v < VECTORSIZE; v++) error += sqr((data[v]) - key[v]); bestrecord = error.findmin(); /* update record with new value */ cif(bestrecord) for (v = 0; v < VECTORSIZE; v++) data[v] = newdata[v]; cend }