集成电路技术分享

 找回密码
 我要注册

QQ登录

只需一步,快速开始

搜索
查看: 9866|回复: 25

verilog例子1X2的选通器

[复制链接]
encounter 发表于 2010-6-28 00:09:51 | 显示全部楼层 |阅读模式
verilog例子1X2的选通器

1X2的选通器,choose决定输入信号Sign_in从A或B端口输出,得不到想要的结果!
代码如下:
module Select(En,Choose,Sign_in,Out_A,Out_B);
    input En,Choose,Sign_in;
    output Out_A,Out_B;
    reg Out_A,Out_B;
always @ (posedge En)
    if (En==1)
        begin
          if (Choose==0)
           begin
                 Out_A=Sign_in;
                 Out_B=0;
           end
          else
           begin
           Out_B=0;
                 Out_B=Sign_in;
               end
        end
endmodule
ups 发表于 2010-6-28 01:40:03 | 显示全部楼层
posedge en?<br>
那样只能执行一次哦<br>
&nbsp; &nbsp;Out_B=0;<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; Out_B=Sign_in;<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;end<br>
<br>
而且得等其他choose啊什么的准备好了<br>
再posedge en才有效
ATA 发表于 2010-6-28 03:09:24 | 显示全部楼层
同意楼上 ..是不是应该加个 clk
interi 发表于 2010-6-28 03:19:48 | 显示全部楼层
看看你代码的这里:<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; begin<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;Out_B=0;<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; Out_B=Sign_in;<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;end
AAT 发表于 2010-6-28 03:33:34 | 显示全部楼层
...如果改成 always@(en==1) <br>
<br>
然后把第一个if 去掉 怎么样??
HDL 发表于 2010-6-28 05:31:29 | 显示全部楼层
module example( Out_A , Out_B , Sign_In , Sel , En );<br>
<br>
output Out_A;<br>
output Out_B;<br>
input Sign_In;<br>
input Sel;<br>
input En;<br>
<br>
assign Out_A = En &amp; Sel &amp; Sign_In;<br>
assign Out_B = En &amp; ~Sel &amp; Sign_In;<br>
<br>
endmodule
ANG 发表于 2010-6-28 05:34:24 | 显示全部楼层
六楼写的精悍
ICE 发表于 2010-6-28 05:52:20 | 显示全部楼层
牛人!看来得好好学习了。
ATA 发表于 2010-6-28 07:33:20 | 显示全部楼层
always @(en or choose or sign_in)
HANG 发表于 2010-6-28 08:16:14 | 显示全部楼层
牛人呀,看来得好好学习
您需要登录后才可以回帖 登录 | 我要注册

本版积分规则

关闭

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

QQ|小黑屋|手机版|Archiver|集成电路技术分享 ( 京ICP备20003123号-1 )

GMT+8, 2024-5-18 18:49 , Processed in 0.082819 second(s), 23 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表