Sunday, 2 September 2012

VHDL IF Statment


if C1 = '0' then
  V := A;
end if;

if C2 = '0' then
  V := B;
  W := C;
  if C3 = '0' then
    X := D;
    Y := E;
  end if;
else
  V := C;
  W := D;
end if;

We can nest if statements. We can also have an if-then-else.
An IF statement will synthesize to a multiplexer. If there is no else part then a multiplexer is still formed. However it is passed through unaltered.

Below we have used elsif to create a nested if statement.

process (C0, C1, C2, A, B, C, D)
begin
  if C0 = '1' then
    F <= A;
  elsif C1 = '1' then
    F <= B;
  elsif C2 = '1' then
    F <= C;
  else
    F <= D;
  end if;
end process;



Reference

This blog post contains notes taken when working through the Doulos Pacemaker tutorial.   Any content copied from the tutorial has been reproduced with permission.  http://www.doulos.com.

No comments:

Post a Comment