diff options
author | Siddarth Suresh <155843085+SiddarthSuresh98@users.noreply.github.com> | 2025-04-17 10:50:58 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-17 10:50:58 -0400 |
commit | 62b9e280d5d0222710e491dcd28fe26bea915dcd (patch) | |
tree | e1f68ac7a6e4dc481c19346e38ad20d113f13825 /inc/pipe_spec.h | |
parent | b778ccc3e7c2f2ac3c4892a87f5269f342fd895f (diff) | |
parent | 430986b4b1ee1013db070991ce289176f48fa8e8 (diff) |
Merge pull request #52 from bdunahu/bdunahu
[WIP] Partial fixes for changes in DRAM/Cache, including uncovered bug
Diffstat (limited to 'inc/pipe_spec.h')
-rw-r--r-- | inc/pipe_spec.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/inc/pipe_spec.h b/inc/pipe_spec.h index 772314e..d211b72 100644 --- a/inc/pipe_spec.h +++ b/inc/pipe_spec.h @@ -65,4 +65,21 @@ */ #define GET_MID_BITS(k, m, n) GET_LS_BITS((k) >> (m), ((n) - (m))) +/** + * Return the bits from integer K starting at N and ending at M using a bit + * mask, but sign-extends the result. This is required to parse immediates. + * @param the integer to be parsed + * @param the index of the starting bit to be parsed + * @param the index of the ending bit to be parsed + * @return a section of bits from K + */ +// clang-format off +#define GET_BITS_SIGN_EXTEND(k, m, n) \ + ({\ + int _f = GET_MID_BITS(k, m, n); \ + int _w = (n) - (m) - (1); \ + _f = (_f & (1 << (_w - 1))) ? (_f | (-1 << _w)) : _f; \ + }) +// clang-format on + #endif /* DEFINITIONS_H_INCLUDED */ |