Skip to content

Commit 84e332b

Browse files
committed
added popcount function
1 parent 62e2d0c commit 84e332b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

std/func.act

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,16 @@ function find_msb_pos(int<W> x) : int<std::ceil_log2(W)>
134134
}
135135
}
136136

137+
export
138+
template<pint W>
139+
function popcount(int<W> x) : int<std::ceil_log2(W+1)>
140+
{
141+
chp {
142+
self := (+ i : W : x{i})
143+
}
137144
}
138145

146+
}
139147

140148
export
141149
template<pint W; pint N; pint taps[N]>

0 commit comments

Comments
 (0)