集成电路技术分享

 找回密码
 我要注册

QQ登录

只需一步,快速开始

搜索
查看: 10042|回复: 24

verilog两个程序几乎一样,为什么其中一个有问题?

[复制链接]
AAT 发表于 2010-6-27 23:25:24 | 显示全部楼层 |阅读模式
verilog两个程序几乎一样,为什么其中一个有问题?
程序一:
module    test(in1,in2,in3,in4,in5,in6,in7,in8,switch,outdata);
input[3:0]    in1,in2,in3,in4,in5,in6,in7,in8;
input[2:0]    switch;
output[3:0]    outdata;
reg[3:0]    outdata;

always@(in1 or in2 or in3 or in4 or in5 or in6 or in7 or in8 or switch)
    begin
        case(switch)
            3'b000:    outdata=in1;
            3'b001:    outdata=in2;
            3'b010:    outdata=in3;
            3'b011:    outdata=in4;
            3'b100:    outdata=in5;
            3'b101:    outdata=in6;
            3'b110:    outdata=in7;
            3'b111:    outdata=in8;
            default:   outdata=4'bx;
        endcase
    end
        
endmodule
程序二:
module        mux_8(data,sel,q);
input[2:0]           sel;
input[7:0]           data;
output        q;
reg        q;

always @ (sel or data)
        case(sel)
            3'b000    :    q<=data[0];
            3'b001    :    q<=data[1];
            3'b010    :    q<=data[2];
            3'b011    :    q<=data[3];
            3'b100    :    q<=data[4];
            3'b101    :    q<=data[5];
            3'b110    :    q<=data[6];
            3'b111    :    q<=data[7];
            default    :    q<=1‘bx;
        endcase
            
endmodule
为什么程序一有警告:
  Warning (10273): Verilog HDL warning at test.v(19): sign extended using "x" or "z"
去掉default后就好了。而程序二一点问题也没有?
  请高手指教,谢谢
longtime 发表于 2010-6-28 00:10:01 | 显示全部楼层
而且就是把它们的赋值方式改成一样的,还是有同样的问题!
encounter 发表于 2010-6-28 00:18:04 | 显示全部楼层
我只懂VHDl
CCIE 发表于 2010-6-28 00:37:13 | 显示全部楼层
你用什么软件编译的,我用Quartus5.0编译了程序一一下,没有告警
 楼主| AAT 发表于 2010-6-28 01:20:14 | 显示全部楼层
难道是它的问题?&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;default:&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;outdata=4'bx;<br>
你试试改成&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;default:&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;outdata=4'bxxxx;<br>
应该不用这样啊,默认会扩展的啊
ups 发表于 2010-6-28 03:14:33 | 显示全部楼层
没问题啊,modelsim可以通过,也能综合<br>
你用的是什么编译器呢?
UFO 发表于 2010-6-28 03:51:31 | 显示全部楼层
这是一个常见、必然且正常的警告,以下是 Altera给出的说明<br>
<br>
CAUSE: In a Verilog Design File (.v), you used an expression, possibly a constant literal, that was extended. However, the most-significant bit (the sign bit if this expression was a signed expression) of the expression was "x" or "z". As a result, the number was extended with "x" or "z" bits, which may or may not be what you intended to occur. <br>
ACTION: If you intended this behavior to occur, then no action is required. Otherwise, modify the expression or constant so that the most-significant bit is not "x" or "z".
encounter 发表于 2010-6-28 04:11:52 | 显示全部楼层
学习中&lsquo;啊
longt 发表于 2010-6-28 05:50:50 | 显示全部楼层
7楼的说明很好!!
inter 发表于 2010-6-28 06:04:42 | 显示全部楼层
拜托,我英语差,能不能用汉语!<br>
我用的是QuartusII5.1
您需要登录后才可以回帖 登录 | 我要注册

本版积分规则

关闭

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

QQ|小黑屋|手机版|Archiver|fpga论坛|fpga设计论坛 ( 京ICP备20003123号-1 )

GMT+8, 2025-4-30 03:52 , Processed in 0.069839 second(s), 20 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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