module mux ( in1 , in2 , sel , out1 );
input wire [31:0] in1 , in2;
output reg [31:0] out;
input wire sel;
case (sel)
0 : begin out1 <= in1 ; end
default : begin out1 <= in2 ; end
endcase
endmodule
错误是:
**错误:(vlog-13069)C:/Modeltech_pe_edu_10.4a/examples/mux.v(9):near&#34;&lt; =&#34 ;:语法错误,意外&lt; =。< / p>
**错误:C:/Modeltech_pe_edu_10.4a/examples/mux.v(9):( vlog-13205)在&#39; out1&#39;之后的范围内发现语法错误。是否缺少&#39; ::&#39;?
答案 0 :(得分:1)
两个错误:
out
应为out1
case
语句必须位于always
块此外,对于组合逻辑,您应该使用阻止分配(=
)。
module mux ( in1 , in2 , sel , out1 );
input wire [31:0] in1 , in2;
output reg [31:0] out1;
input wire sel;
always @(*) begin
case (sel)
0 : begin out1 = in1 ; end
default : begin out1 = in2 ; end
endcase
end
endmodule