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

Wrong values returned from _XAie_GetRowfromRegOff and _XAie_GetColfromRegOff #16

Open
Yu-Zhewen opened this issue Jan 3, 2025 · 0 comments

Comments

@Yu-Zhewen
Copy link

Yu-Zhewen commented Jan 3, 2025

static inline u8 _XAie_GetRowfromRegOff(XAie_DevInst *DevInst, u64 RegOff)
{
return RegOff &(u64)(~(ULONG_MAX << DevInst->DevProp.RowShift));
}

The provided function is intended to extract the row information from RegOff. However, the current implementation incorrectly extracts only the lower 8 bits (RegOff[7:0]) instead of the intended range, RegOff[ColShift:RowShift].

The correct version is something like this:

 static inline u8 _XAie_GetRowfromRegOff(XAie_DevInst *DevInst, u64 RegOff) 
 { 
	u64 Mask = (u64)(((1U << DevInst->DevProp.ColShift) - 1U) &
			~((1U << DevInst->DevProp.RowShift) - 1U));

	return (u8)((RegOff & Mask) >> (u64)(DevInst->DevProp.RowShift));
 }

I believe the above logic has been misplaced and currently resides in _XAie_GetColfromRegOff. The _XAie_GetColfromRegOff function should also be updated to the following:

 static inline u8 _XAie_GetColfromRegOff(XAie_DevInst *DevInst, u64 RegOff) 
 { 
	return (u8)(RegOff >> (u64)(DevInst->DevProp.ColShift));
 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant