0
\$\begingroup\$

this sub-code that read the selection line s4-s1 and take the summation of a,b in the selection line =0000, When running this code in ISE project negotiator it gives syntax error tell " Syntax error near "=" " in the line z=0 in the if statement

can you tell me why ?

module one1(a,b,s1,s2,s3,s4,f );
  input s1,s2,s3,s4;
  input [3:0] a,b;
  output reg [3:0] f;

  reg  z,n,c;

  //0000

  if ({s4,s3,s2,s1} == 4'b0000)
  begin
    assign {c,f}= a+b; 
    if (f==0) 
      z=1;         //here is the error 
    else z=0;
    n=f[3];
  end

endmodule
\$\endgroup\$

1 Answer 1

4
\$\begingroup\$

Two problems:

  1. You need to wrap an always block around your combinational logic. Something like always @* begin

then put your if statement in there.

  1. You can't assign a wire inside an always block. you need a reg.
\$\endgroup\$
1
  • \$\begingroup\$ "you need a reg."... or move the assign statement outside the if block. \$\endgroup\$ Commented Apr 11, 2015 at 18:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.