P328: Enumeration of all $n$-bit necklaces with fixed density $d$

P328: Enumeration of all $n$-bit necklaces with fixed density $d$
Input:
Two integer $n$ and $d$.
Output:
All $n$-bit necklaces with fixed density $d$.
Complexity:
$O(nN)$ total time and $O(n)$ space.
Comment:
$N$ is the number of solutions. A density of a $n$-bit necklace $T$ is $d$ if $T$ has $d$ ones.
Reference:
[Wang1996] (Bibtex)