Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unbounded loop #344

Open
zhuanhao-wu opened this issue May 30, 2022 · 0 comments
Open

Unbounded loop #344

zhuanhao-wu opened this issue May 30, 2022 · 0 comments

Comments

@zhuanhao-wu
Copy link
Collaborator

zhuanhao-wu commented May 30, 2022

There are several places where the generated loops are unbounded according to Vivado, listed as follows, although they might be bounded.

Loop 1

sc_uint<log2rz(4)+1>tgtreg;
for(tgtreg=0; srcreg<4; srcreg++,tgtreg++)
{
    if(!pb_c[srcreg].f)	break;
    else				tmp[tgtreg]=pb_c[srcreg];
}

Loop 2

while(n < fpblk_sz(DIM))
{
	//looking for 0's in a unary substring  INNER LOOP IN ZFP
	if(state&FOUND_1)
	{
		if(state&FIRST_0)			//account for the first 1 seen in the unary substring using the "bits" state variable.
			{state=S2;if(n < fpblk_sz(DIM))bits--;}

		if(n < fpblk_sz(DIM) - 1 && !(state&FOUND_0S))	//Find length of '0's substring. terminate (go->S3) if a '1' is found.
		{
			if((!bits) || (!bits--))			//if bits cannot still be decoded..
				{x[n]=true; state=S3;}			//tally the last bit positively identified and terminate (go->S3).
			else								//however if bits can still be decoded...
			{
				if(stream_window[bitoff++])		//check if '0' is in the current string position
					{x[n]=true; state=S3;} 	//a 1 was found, signifying end of substring (go->S3)
			}
			n++;	//consider next bit in the plane to be decoded
		}

		//accounts for the case when no more 0's could possibly fit in the main string, but substring not explicitly terminated.
		if((n==fpblk_sz(DIM)-1) || (state&FOUND_0S))
		{
			if((n >= fpblk_sz(DIM)-1) && !(state&FOUND_0S))
				{x[n]=true; n++;}			  //force substring end
			state=S3;						  //force substring termination (go->S3)
		}
	}

	//looking for 1's in a unary substring. OUTER LOOP IN ZFP
	if(!(state&FOUND_1))
	{
		if(!bits || (n>=fpblk_sz(DIM)))	//nothing left to search through...
			break;				//exit the unary decoder state machine.
		//account for n = size case? what should happen is that n gets incremented to size and you break here before doing the stuff below.
		if(stream_window[bitoff++])			//A unary substring was found, next find all '0''s after this '1' in the string.
			state=S1;
		else break;	//stop looking for valid unary strings. This is the same as going to S0.
	}

}

Loop 3
(An alternative to this might be an explicit priority decoder.)

ui_t e = 0;
while (rn >> (e + 1))
	e++;

However, these loops might be transformed/rewritten if a constant bound is known, with the following form:

int i;
for(i = 0; i < BOUND; i++) {
  if(original_terminate_condition) break;
  else {
    // original_loop_body; potentially with breaks;
    // increment_to_loop_variable;
  }
}

#329

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant