From: lkcl Date: Wed, 26 Apr 2023 15:25:53 +0000 (+0100) Subject: (no commit message) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0e0093bf40580546fb5487e12e1c8689ba819369;p=libreriscv.git --- diff --git a/openpower/sv/cookbook/pospopcnt.mdwn b/openpower/sv/cookbook/pospopcnt.mdwn new file mode 100644 index 000000000..d28897169 --- /dev/null +++ b/openpower/sv/cookbook/pospopcnt.mdwn @@ -0,0 +1,21 @@ + + +``` +func count8safe(counts *[8]int, buf []uint8) { + for i := range buf { + for j := 0; j < 8; j++ { + counts[j] += int(buf[i] >> j & 1) + } + } +} + +func count16safe(counts *[16]int, buf []uint16) { + for i := range buf { + for j := 0; j < 16; j++ { + counts[j] += int(buf[i] >> j & 1) + } + } +} +``` + +[[!tag svp64_cookbook ]]