trax
Newbie level 2
Hi, this is my first time posting. So I'm not sure if this is the right forumn section to post in. If not please redirect me to the correct one. Thanks.
I'm working on a basic game project. But I'm having worrys about synthesizing the program onto the Altera Cyclone II board.
So I basically I want to reduce some redundancy in the coding. In particular I have this for example,
This checks for one variable for multiple conditions. Is there an efficient way to extend the IF statements to check a second variable without going through the condition statements again?
if ( (DrawX = row1) and (DrawY = col2)) then --row1 2 points
G_state <= s1;
exit;
elsif ( (DrawX = row1) and (DrawY = col7)) then
G_state <= s2;
exit;
elsif ( (DrawX = row2) and (DrawY = col1)) then --row2 8 points
G_state <= s3;
exit;
elsif ( (DrawX = row2) and (DrawY = col2)) then
G_state <= s4;
exit;
.
.
.
end if;
if ( (DrawX2 = row1) and (DrawY2 = col2)) then --row1 2 points
G2_state <= s1;
exit;
elsif ( (DrawX2 = row1) and (DrawY2 = col7)) then
G2_state <= s2;
exit;
elsif ( (DrawX2 = row2) and (DrawY2 = col1)) then --row2 8 points
G2_state <= s3;
exit;
elsif ( (DrawX2 = row2) and (DrawY2 = col2)) then
G2_state <= s4;
exit;
.
.
.
end if;
What I mean is, how can I go about exchanging the variables DrawX, DrawY, G_state to their second counter parts, DrawX2, DrawY2, G2_state? Without having to go through the entire IF Condition statements again.
I was thinking along of along the lines of creating 3 dummy variables, and using a loop to go through the steps again but with an exchanged dummy variable. Would this method work? Would it reduce the resources used?
thanks for any help
I'm working on a basic game project. But I'm having worrys about synthesizing the program onto the Altera Cyclone II board.
So I basically I want to reduce some redundancy in the coding. In particular I have this for example,
This checks for one variable for multiple conditions. Is there an efficient way to extend the IF statements to check a second variable without going through the condition statements again?
if ( (DrawX = row1) and (DrawY = col2)) then --row1 2 points
G_state <= s1;
exit;
elsif ( (DrawX = row1) and (DrawY = col7)) then
G_state <= s2;
exit;
elsif ( (DrawX = row2) and (DrawY = col1)) then --row2 8 points
G_state <= s3;
exit;
elsif ( (DrawX = row2) and (DrawY = col2)) then
G_state <= s4;
exit;
.
.
.
end if;
if ( (DrawX2 = row1) and (DrawY2 = col2)) then --row1 2 points
G2_state <= s1;
exit;
elsif ( (DrawX2 = row1) and (DrawY2 = col7)) then
G2_state <= s2;
exit;
elsif ( (DrawX2 = row2) and (DrawY2 = col1)) then --row2 8 points
G2_state <= s3;
exit;
elsif ( (DrawX2 = row2) and (DrawY2 = col2)) then
G2_state <= s4;
exit;
.
.
.
end if;
What I mean is, how can I go about exchanging the variables DrawX, DrawY, G_state to their second counter parts, DrawX2, DrawY2, G2_state? Without having to go through the entire IF Condition statements again.
I was thinking along of along the lines of creating 3 dummy variables, and using a loop to go through the steps again but with an exchanged dummy variable. Would this method work? Would it reduce the resources used?
thanks for any help