0

please can anyone help me writing the two conditional statements such that both should give same output...eg:

If I write the in the way mentioned below it is giving the output but with large amount of delay

if(count==3'd2 || i<=16'd8192) begin
  count = 3'd1;
  AL1   = x[i]+x[i+1];
  DL1   = x[i]-x[i+1];
  i     = i+2;
end
else begin
  count = count+1'd1;
  i     = 16'd0;
end

I am getting error if write code in this way...

if (i<=16'd8192) begin
   if (count==3'd2) begin
     count = 3'd1;
     AL1   = x[i]+x[i+1];
     DL1   = x[i]-x[i+1];
     i     = i+2;
   end
   else begin
     count = count+1'd1;
   end
 else begin
   i       = 16'd0;
 end

Please help me out of this

1 Answer 1

1

Was the problem the code was not functionally the same or was it a syntax error?

Both code examples had a trailing end which I have removed when formatting the code in the question.

Verilogs begin end syntax for an if statement is:

if ( condition a ) begin
  // a true
end
else begin
  // a false
end 

With a secondary embedded conditional it would be:

if ( condition a ) begin
  if ( condition b ) begin
    // a & b true
  end
  else begin
    // a true b false
  end 
end
else begin
  // a false
end 

If this was the issue adopting a stricter indentation style when coding will help spot these errors.

Sign up to request clarification or add additional context in comments.

2 Comments

I tried to run the code using second method...but i faced some errors initially ...now i got the output..Thank you Morgan..
@user3178637 Excellent.

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.