Created
September 22, 2024 23:55
-
-
Save agrif/437d2412c1cff5e1e9b2823eebfa012c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LUI(UnitTest): | |
PROGRAM = """ | |
lui a0, 1 | |
one: | |
lui a1, 0xfffff | |
fs: | |
lui a2, 0xabcde | |
letters: | |
""" | |
CHECKPOINTS = [ | |
('one', {'a0': 1 << 12}), | |
('fs', {'a1': 0xfffff << 12}), | |
('letters', {'a2': 0xabcde << 12}), | |
] | |
class AUIPC(UnitTest): | |
PROGRAM = """ | |
one_pc: | |
auipc a0, 1 | |
one: | |
fs_pc: | |
auipc a1, 0xfffff | |
fs: | |
letters_pc: | |
auipc a2, 0xabcde | |
letters: | |
""" | |
async def testbench(self, ctx): | |
await self.advance_until(ctx, 'one') | |
self.assert_eq(ctx, 'a0', self.symbols['one_pc'] + (1 << 12)) | |
await self.advance_until(ctx, 'fs') | |
self.assert_eq(ctx, 'a1', 0xffff_ffff & (self.symbols['fs_pc'] + (0xfffff << 12))) | |
await self.advance_until(ctx, 'letters') | |
self.assert_eq(ctx, 'a2', 0xffff_ffff & (self.symbols['letters_pc'] + (0xabcde << 12))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment