在线咨询
eetop公众号 创芯大讲堂 创芯人才网
切换到宽版

EETOP 创芯网论坛 (原名:电子顶级开发网)

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
查看: 4524|回复: 4

[求助] ADC的veriloga代码求解

[复制链接]
发表于 2013-6-2 22:07:08 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

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
 楼主| 发表于 2013-6-3 09:11:17 | 显示全部楼层
自己顶一下,坐等大神帮助
发表于 2013-6-3 09:25:06 | 显示全部楼层
这段程序有问题吧,我怎么感觉sample = sample - thresh ;应该改为sample = 2*(sample - thresh )
 楼主| 发表于 2013-6-3 09:38:30 | 显示全部楼层
我的感觉是在这句
if (sample > thresh) begin
result[i] = 1 ;
sample = sample - thresh ;
后面加个thresh=thresh/2。然后把
else result[i] = 0 ;
sample = 2.0*sample 乘以2这句去掉,再加上thresh=thresh/2;跟你说的那个乘以2有点相似。感觉按你说的改也和我说的改效果一样,但是我感觉我这么改是不是更直观点呢,我自己的想法,求交流指导
发表于 2023-9-11 13:23:12 | 显示全部楼层
谢谢
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

站长推荐 上一条 /3 下一条

×

小黑屋| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-4-20 11:42 , Processed in 0.024564 second(s), 8 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
快速回复 返回顶部 返回列表