Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | 32x 3x 3x | /**
* RegisterUtils
* Shared utilities for register assignment handlers.
*
* Extracted from AccessPatternHandlers.ts and RegisterHandlers.ts to reduce duplication.
*/
/**
* Utilities for register access patterns
*/
class RegisterUtils {
/**
* Check if register is write-only based on access modifier.
*
* Write-only registers include:
* - 'wo': Write-only
* - 'w1s': Write-1-to-set
* - 'w1c': Write-1-to-clear
*/
static isWriteOnlyRegister(accessMod: string | undefined): boolean {
return accessMod === "wo" || accessMod === "w1s" || accessMod === "w1c";
}
/**
* Generate write-only bit range assignment statement.
* Pattern: regName = ((value & mask) << start)
*/
static generateWriteOnlyBitRange(
regName: string,
value: string,
mask: string,
start: string,
): string {
return `${regName} = ((${value} & ${mask}) << ${start});`;
}
/**
* Generate read-modify-write bit range assignment statement.
* Pattern: regName = (regName & ~(mask << start)) | ((value & mask) << start)
*/
static generateRmwBitRange(
regName: string,
value: string,
mask: string,
start: string,
): string {
return `${regName} = (${regName} & ~(${mask} << ${start})) | ((${value} & ${mask}) << ${start});`;
}
}
export default RegisterUtils;
|