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


求教如何改正,谢谢

yoyo_note 发表于 2012-5-20 17:46:46

verilog 的if,else 等一般写在 always 语句里面

纯逻辑的话,一般用assign

@HDL现场 发表于 2012-5-20 23:00:33

对,纯逻辑,要用assign. 表示连接到网线上,如果你用always做纯逻辑,也可以。但不可以单独的写ifelse作为模块

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,
                  );
assignaout = a?1‘b1:0;
assignbout = (!a&b)?1‘b1:0;
assigncout = (!a&!b&c)?1'b1:0;


endmodule

至芯兴洪 发表于 2012-5-25 22:55:22

楼上这样写,实际上敢这么用吗
页: [1]
查看完整版本: 求高手来看看程序,急