集成电路技术分享

 找回密码
 我要注册

QQ登录

只需一步,快速开始

搜索
查看: 1255|回复: 4

求高手来看看程序,急

[复制链接]
lomenyellow 发表于 2012-5-20 15:10:20 | 显示全部楼层 |阅读模式


我所写的程序

module prioritylineup(a,b,c,aout,bout,cout);
input a,b,c;
output aout,bout,cout;
if(a)       
begin       
aout=1;        bout=0;        cout=0;        end
else if(!a&&b)       
begin        aout=0;        bout=1;        cout=0;        end
else if(!a&&!b&&c)       
begin        aout=0;        bout=0;        cout=1;        end
else if(!a&&!b&&!c)       
begin        aout=0;        bout=0;        cout=0;        end
endmodule

调试时一直报有两个错
Error (10170): Verilog HDL syntax error at prioritylineup.v(4) near text "if"; expecting an identifier ("if" is a reserved keyword ), or "endmodule", or a parallel statement

Error (10112): Ignored design unit "prioritylineup" at prioritylineup.v(1) due to previous errors


求教如何改正,谢谢

本帖子中包含更多资源

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

x
yoyo_note 发表于 2012-5-20 17:46:46 | 显示全部楼层
verilog 的if,else 等一般写在 always 语句里面

纯逻辑的话,一般用assign
@HDL现场 该用户已被删除
@HDL现场 发表于 2012-5-20 23:00:33 | 显示全部楼层
对,纯逻辑,要用assign. 表示连接到网线上,如果你用always做纯逻辑,也可以。  但不可以单独的写if  else作为模块
smallwind1 发表于 2012-5-23 23:33:21 | 显示全部楼层
module test(
                    input wire a,
                    input wire b,
                    input wire c,
                    output wire aout,
                    output wire bout,
                    output wire cout,
                    );
assign  aout = a?1‘b1:0;
assign  bout = (!a&b)?1‘b1:0;
assign  cout = (!a&!b&c)?1'b1:0;


endmodule
至芯兴洪 发表于 2012-5-25 22:55:22 | 显示全部楼层
楼上这样写,实际上敢这么用吗
您需要登录后才可以回帖 登录 | 我要注册

本版积分规则

关闭

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

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

GMT+8, 2025-6-25 21:01 , Processed in 0.068947 second(s), 21 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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