@(cross ( V(clk)-vth, -1 )) begin
out_scaled = 0;
out_scaled = out_scaled + ((V(vd9) > vtrans) ? 512 : 0);
out_scaled = out_scaled + ((V(vd8) > vtrans) ? 256 : 0);
out_scaled = out_scaled + ((V(vd7) > vtrans) ? 128 : 0);
out_scaled = out_scaled + ((V(vd6) > vtrans) ? 64 : 0);
out_scaled = out_scaled + ((V(vd5) > vtrans) ? 32 : 0);
out_scaled = out_scaled + ((V(vd4) > vtrans) ? 16 : 0);
out_scaled = out_scaled + ((V(vd3) > vtrans) ? 8 : 0);
out_scaled = out_scaled + ((V(vd2) > vtrans) ? 4 : 0);
out_scaled = out_scaled + ((V(vd1) > vtrans) ? 2 : 0);
out_scaled = out_scaled + ((V(vd0) > vtrans) ? 1 : 0);
if(i<N)begin
sum = sum + (V(vpn)*(out_scaled-512));
i = i + 1;
end
else begin
average = sum/N;
sum = 0;
i = 0;
end
end
V(vout9) <+ transition( vout[9], tdel, trise, tfall );
V(vout8) <+ transition( vout[8], tdel, trise, tfall );
V(vout7) <+ transition( vout[7], tdel, trise, tfall );
V(vout6) <+ transition( vout[6], tdel, trise, tfall );
V(vout5) <+ transition( vout[5], tdel, trise, tfall );
V(vout4) <+ transition( vout[4], tdel, trise, tfall );
V(vout3) <+ transition( vout[3], tdel, trise, tfall );
V(vout2) <+ transition( vout[2], tdel, trise, tfall );
V(vout1) <+ transition( vout[1], tdel, trise, tfall );
V(vout0) <+ transition( vout[0], tdel, trise, tfall );
end
endmodule |