module bit_error_rate(in,ref); input in,ref; voltage in,reg; parameter real period=1 from [0:inf), vth=2.5; integer bits,errors; analog begin @(initial_step) begin bits = 0; errors = 0; end @(timer(0,period)) begin if ((V(in) > vth) != (V(ref) > vth)) errors = errors+1; bits = bits+1; end @(final_step) $strobe("bit error rate = %f%%", 100*errors/bits); end endmodule