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

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

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
查看: 8028|回复: 3

[求助] 2-4译码器的Verilog - A代码求助

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

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

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

x
现在需要一个verilog - A的译码器代码,两个数字输入和一个Enable信号s(s为零时,输出均为零)信号,四个输出。自己试着写了一个,当四个输入不变时,DC结果是正确的;但当输入为变化的时钟信号时,tran结果就不对了。即当in1 in0分别为00 01 10 11时,输出竟然out3=1,out2=out1=out0=0,且一直不变。还请各路大神不吝赐教!
代码如下:
module dec_2X4 (s, in1, in0, out3, out2, out1, out0);
output out3, out2, out1, out0;
input in1, in0, s;
electrical in1, in0, out3, out2, out1, out0, s;
parameter real trise = 0 from [0:inf);
parameter real tfall = 0 from [0:inf);
parameter real tdel  = 0 from [0:inf);
parameter real vtrans  = 1.2;
parameter real vlogic_high = 1.8;
parameter real vlogic_low  = 0;


    integer a1;
    integer a0;
    integer y3;
    integer y2;
    integer y1;
    integer y0;

    Analog begin
       @ (initial_step) begin
               V(out3) <+ 0;
               V(out2) <+ 0;
               V(out1) <+ 0;
               V(out0) <+ 0;
               a1 = V(in1) > vtrans;
               a0 = V(in0) > vtrans;
       end

        if (V(s) >= vtrans) begin
        y3 = a1 & a0;
        y2 = a1 & !a0;
        y1 = !a1 & a0;
        y0 = !a1 & !a0;
        end
        else begin
        y3 = 0;
        y2 = 0;
        y1 = 0;
        y0 = 0;
        end

V(out3) <+ transition( vlogic_high*y3, tdel, trise, tfall );

V(out2) <+ transition( vlogic_high*y2, tdel, trise, tfall );

V(out1) <+ transition( vlogic_high*y1, tdel, trise, tfall );

V(out0) <+ transition( vlogic_high*y0, tdel, trise, tfall );     
end
endmodule
发表于 2013-6-16 09:52:09 | 显示全部楼层
回复 1# oooeee
周董?
 楼主| 发表于 2013-6-16 09:55:05 | 显示全部楼层
已经解决了。应该加上对四位输入变化的探测语句。
发表于 2022-1-18 17:02:58 | 显示全部楼层
楼主求代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

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

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

GMT+8, 2024-5-6 20:29 , Processed in 0.021811 second(s), 8 queries , Gzip On, Redis On.

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