|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
各位大神,小弟最近新接触veriloga代码,ADC也只是了解其基本的原理与一些概念,下面这段代码我看不出怎么实现ADC的,我也认真看了,还是入门比较吃力吧,求帮助
The following example, an N-bit analog to digital converter, demonstrates the ability of
the transition function to handle vectors.
module a2d(in, clk, out) ;
parameter bits=8, fullscale=1.0, delay=0, ttime=10n ;
input in, clk ;
output [0:bits-1] out ;
electrical in, clk, out ;
real sample, thresh ;
integer result[0:bits-1], i ;
analog begin
@(cross(V(clk)-2.5, +1) begin
sample = V(in) ;
thresh = full_scale/2.0 ;
for (i=bits-1; i>=0; i=i-1) begin
if (sample > thresh) begin
result[i] = 1 ;
sample = sample - thresh ;
end
else result[i] = 0 ;
sample = 2.0*sample ;
end
end
V(out) <+ transition(result,delay,ttime) ;
end
endmodule |
|