// signal_driver.sv: Driver of signal interface // Copyright (C) 2019 FIT BUT // Author(s): Lukas Kekely // // SPDX-License-Identifier: BSD-3-Clause // Exact match filtering model extended for hashing tables using Jenkins hash class JenkinsHashExactMatch extends ExactMatch #(KEY_WIDTH, DATA_WIDTH); `define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k)))) `define mix(a,b,c) \ a = a-c; a = a^`rot(c, 4); c = c+b; \ b = b-a; b = b^`rot(a, 6); a = a+c; \ c = c-b; c = c^`rot(b, 8); b = b+a; \ a = a-c; a = a^`rot(c,16); c = c+b; \ b = b-a; b = b^`rot(a,19); a = a+c; \ c = c-b; c = c^`rot(b, 4); b = b+a; `define final(a,b,c) \ c = c^b; c = c-`rot(b,14); \ a = a^c; a = a-`rot(c,11); \ b = b^a; b = b-`rot(a,25); \ c = c^b; c = c-`rot(b,16); \ a = a^c; a = a-`rot(c,4); \ b = b^a; b = b-`rot(a,14); \ c = c^b; c = c-`rot(b,24); function int unsigned jenkins_hash_base(int unsigned k[], int unsigned length, int unsigned initval); int unsigned a,b,c,kk; /* Set up the internal state */ a = 32'hdeadbeef + (length<<2) + initval; b = a; c = a; /*------------------------------------------------- handle most of the key */ kk = 0; while (length > 3) begin a += k[kk+0]; b += k[kk+1]; c += k[kk+2]; `mix(a,b,c) length = length - 3; kk = kk + 3; end /*------------------------------------------- handle the last 3 uint32_t's */ /* all the case statements fall through */ if(length >= 3) c = c + k[kk+2]; if(length >= 2) b = b + k[kk+1]; if(length >= 1) a = a + k[kk+0]; /* case 0: nothing left to add */ `final(a,b,c) /*------------------------------------------------------ report the result */ return c; endfunction function int unsigned jenkins_hash(bit [RULE_WIDTH-1 : 0] r, int unsigned initval); int unsigned k[KEY_WORDS]; for(int i = 0; i