My (effectively one-line) implementation above was derived from first-principle:
Given a desired target level 0 <= T <= 1, control the output O in {1,0}, such that O on on average is T. Do this by integrating the error T - O over time and switching O such that the sum of (T - O) is finite.
S = O = 0
loop:
S = S + (T - O)
O = (S >= 0)
In fixed point arithmetic this becomes even simpler (assume N-bit arith) S = Sf * 2^N = Sf << N. As |S| <= 1, N+2 bits is sufficient S = O = 0
loop:
D = T + (~O + 1) << N === T + (O << N) + (O << (N+1))
S = S + D
O = 1 & ~(S >> (N+1))
and that's the Verilog below module pdm(clk, level, O);
parameter N = 16;
input wire clk;
input wire [N-1:0] level;
output wire O;
reg [N+1:0] sigma = 0;
assign O = ~sigma[N+1];
always @(posedge clk) sigma <= sigma + {O,O,level};
endmodule
I’ll grant you that PWM is a bit more intuitive. I bet there is a more thorough comparison between them but I haven’t seen it.