Altera Nios II C2H Compiler User Manual
Page 50
Advertising

3–10
9.1
Altera Corporation
Nios II C2H Compiler User Guide
November 2009
One-to-One C-to-Hardware Mapping
shows an example of a
switch
statement converted to
equivalent
if-else
statements.
shows the logic that results of translating the
if-else
code
from
Table 3–4. switch Statement Converted to if-else Statements
switch Implementation
if-else Implementation
switch (byte_select)
{
case 1:
out = in & 0x0000ff00;
break;
case 2:
out = in & 0x00ff0000;
break;
case 3:
out = in & 0xff000000;
break;
default:
out = in & 0x000000ff;
}
if (byte_select == 1)
out = in & 0x0000ff00;
else
if (byte_select == 2)
out = in & 0x00ff0000;
else
if (byte_select == 3)
out = in & 0xff000000;
else
out = in & 0x000000ff;
Advertising