Commit Graph

234 Commits

Author SHA1 Message Date
Anton Lydike
c1110b9ce3 [ElfLoader] better formatting for jump and load/store instructions 2021-06-05 15:29:40 +02:00
Anton Lydike
37910018b9 [PrivRV32I] finally correct parsing of load/store instruction args 2021-06-05 15:29:06 +02:00
Anton Lydike
e4537f86d9 [PrivRV32I] implemented csrrwi instruction 2021-06-05 15:28:27 +02:00
Anton Lydike
c770cc05cf [Priv Exceptions] added __str__ as __repr__ alias to CpuTrap to correctly format exceptions when printed 2021-06-05 15:25:39 +02:00
Anton Lydike
3e4920f5d9 [decoder] fixed bug when decoding add/sub instruction 2021-06-05 15:24:40 +02:00
Anton Lydike
849d5f4fc3 [decoder, ElfLoader] decoing an instruction now returns all args as int 2021-06-05 15:24:16 +02:00
Anton Lydike
f9b0bac245 [Priv Exceptions] fixed constructor typo in TimerInterrupt 2021-06-05 09:56:05 +02:00
Anton Lydike
9424390b65 [decoder] Added mret, sret, uret, wfi instruction decoding support 2021-06-05 09:54:58 +02:00
Anton Lydike
198d14d5fb [Priv Exceptions] added __repr__ to CpuTrap class 2021-06-05 09:29:20 +02:00
Anton Lydike
ca3b4099d4 [Priv] moved CSR constants to a separate file 2021-06-05 09:27:03 +02:00
79369889f4 [CSR] fixed method naming for _addr_to_name (now _name_to_addr) 2021-06-04 20:37:08 +02:00
de261c4c43 [Priv] overhauled instruction architecture 2021-06-04 20:36:33 +02:00
c963fe3989 [Priv] small fixes for overlooked things 2021-05-26 18:40:42 +02:00
85af9b992f [PrivCPU] overhaul of instruction cycle, adding more CSR interaction 2021-05-25 23:50:38 +02:00
7239212729 [CSR] adding virtual csr registers 2021-05-25 23:49:37 +02:00
6653ef7e7c [CPU] set correct MISA 2021-05-25 11:14:52 +02:00
a1f29b9d97 [CPU] cleaned up constructor 2021-05-25 11:14:18 +02:00
49b59cd46a [CSR] added read/write checks and unified name to addr resuloution 2021-05-25 10:49:54 +02:00
291f44a192 [CSR] unknown csr names now fail without exception 2021-05-25 10:24:24 +02:00
c4cd83701f [CSR, PrivCPU] Added csr callback registration through decorator 2021-05-24 15:51:05 +02:00
504407c0d9 [CSR] adding callbacks to each csr block 2021-05-24 14:34:35 +02:00
Anton Lydike
db2b0b314b [PrivCPU, PrivRV32I] fix for relative jumps and branches 2021-05-24 10:08:53 +02:00
Anton Lydike
6bd5cd1598 [ElfLoader] better formatting for load and save instructions 2021-05-24 10:08:01 +02:00
Anton Lydike
ed6912a060 [ElfLoader] added bounds check to elf loader and casting binary data to bytearray 2021-05-24 10:07:21 +02:00
Anton Lydike
55be71dcc3 [CSR] added time and timeh csr codes 2021-05-24 10:05:34 +02:00
Anton Lydike
3a79bfdada [ElfLoader] also loading .sdata and .sbss sections now 2021-05-23 12:59:59 +02:00
Anton Lydike
3f11cd84ca [decoder] fixed error with decoding slli type instructions 2021-05-23 12:58:47 +02:00
Anton Lydike
f3959be843 [decoder] now returning instruction number as third return value 2021-05-23 10:44:27 +02:00
Anton Lydike
0475d8d384 [CPU] added instruction XLEN attribute to CPU class to support multiple instruction lengths 2021-05-23 10:42:04 +02:00
Anton Lydike
c9a136d595 [instructions] fixed error in auipc command 2021-05-22 21:05:14 +02:00
Anton Lydike
ee0aac30c4 [instructions] moved regs and mmu to properties to work with janky PrivCPU 2021-05-22 21:04:43 +02:00
Anton Lydike
1bdf2e6efe [mmu] fixed typo in docstring 2021-05-22 21:03:56 +02:00
Anton Lydike
c48a5efee3 [cpu] fixed formatting to include cpu class extensions 2021-05-22 21:03:37 +02:00
Anton Lydike
15da68995c [priv] module now able to load and execute elf binaries 2021-05-22 21:02:36 +02:00
Anton Lydike
a4735db388 Added a decoder module which can deocde some RV32I/M instructions
Some of them even correctly O.o
2021-05-22 21:01:03 +02:00
Anton Lydike
483a3f2416 Priv: [wip] implementing privileged architecture 2021-05-19 12:14:43 +02:00
Anton Lydike
a2e206eaee renamed CPU.__run -> CPU._run, it's now overwriteable by subclasses 2021-05-19 09:51:51 +02:00
1abdc79e5e added additional logging to invalid mmu data access, needs a better exception 2021-04-24 21:48:53 +02:00
Anton Lydike
fa22d76f13 Added libstring and documentation for the general library 2021-04-24 18:32:43 +02:00
Anton Lydike
462639ade7 Added run_ins method to debugger to run an instruction 2021-04-24 18:24:42 +02:00
Anton Lydike
5d484f08cf Minor fixes like imports and edge-case handling 2021-04-24 18:24:11 +02:00
Anton Lydike
f45a37e705 Added MMU.get_bin_containing 2021-04-24 18:23:12 +02:00
Anton Lydike
ff5ba9a7ef made CPU.run_instruction public 2021-04-24 18:20:06 +02:00
Anton Lydike
da895f00cd added stack field to cpu 2021-04-24 18:19:37 +02:00
Anton Lydike
f5f41f4e18 fixed errorneous license text in headers 2021-04-23 21:28:57 +02:00
Anton Lydike
242af5c7a3 implemented mmu.allocate_region and reworked how the stack works 2021-04-23 20:32:19 +02:00
Anton Lydike
bc8c061c6d removed stack pref pseudo-op in preperation for real stack impl 2021-04-23 19:53:06 +02:00
Anton Lydike
0574766a81 lots more documentation cleanup 2021-04-23 18:44:42 +02:00
Anton Lydike
819d57e3c8 preparations for sphinx documentation generation 2021-04-22 15:47:11 +02:00
Anton Lydike
6e6ce90e9a added lots more documentation and copyright notices 2021-04-22 14:29:10 +02:00
Anton Lydike
2a68f16e99 added lots of documentation in pydoc style 2021-04-22 13:57:13 +02:00
Anton Lydike
a1fe631844 improved debugging output on early exit and reformatted cpu file 2021-04-22 13:00:37 +02:00
Anton Lydike
21b974cfbd prettier debug output (colorized) 2021-04-22 12:57:40 +02:00
Anton Lydike
41f5dd0730 better ascii dumps 2021-04-22 12:48:46 +02:00
Anton Lydike
ebfb3a0112 better formatted print outputs 2021-04-22 12:41:07 +02:00
Anton Lydike
18b5ea0570 added launch message where cpu starts execution 2021-04-22 12:40:28 +02:00
Anton Lydike
44ae0bac77 read syscall now behaves like readline instead of read 2021-04-22 11:22:05 +02:00
Anton Lydike
0d9960c01a added add_accept_imm option flag to allow add rd, rs, imm instructions 2021-04-21 21:04:56 +02:00
5da0f8b0fa fixed failure to launch with missing --instruction-sets flag 2021-04-21 20:41:35 +02:00
Anton Lydike
9afbd03733 added .word pseudo op 2021-04-21 20:36:26 +02:00
Anton Lydike
daed3a0205 added proper cpu exit handling 2021-04-21 20:36:10 +02:00
cd17c65ce7 Added instruction set selector to CLI 2021-04-19 12:51:43 +02:00
22a577da59 fixed formatting in verbose cpu output 2021-04-19 12:18:06 +02:00
39d5212d3d added stepping functionality to the debugger 2021-04-19 12:10:24 +02:00
521cb73ad6 better dumping code in debugger 2021-04-19 11:27:31 +02:00
318b62431d catching invalid immediate value now 2021-04-19 11:22:08 +02:00
97525bf8ab fixed cpu __repr__ method 2021-04-19 11:16:05 +02:00
Anton Lydike
7aa67cd4e1 improved instruction parsing in RV32M 2021-04-19 09:48:06 +02:00
Anton Lydike
d8f46c781c finished the RV32I instruction set 2021-04-19 09:00:45 +02:00
Anton Lydike
1abeab6f2d added parse_rs_rs_imm method to InstructionSet, used for branch instructions 2021-04-19 08:53:35 +02:00
Anton Lydike
d40c80cb81 added unsigned options to instruction parsing 2021-04-19 08:37:16 +02:00
Anton Lydike
1957e11f62 added unified instruction parsing 2021-04-19 08:34:39 +02:00
Anton Lydike
2d378f2e0a implemented remu, rem, divu div and mul in RV32M 2021-04-19 00:05:23 +02:00
Anton Lydike
157589548d unified instruction parsing code 2021-04-19 00:04:51 +02:00
Anton Lydike
d3fe6cb1a9 fixed read syscall shadowing of len 2021-04-19 00:04:10 +02:00
Anton Lydike
38cb3f7669 renamed RVM to RV32M 2021-04-18 23:47:08 +02:00
Anton Lydike
7f3fb9b141 fixed bgeu, bltu and bge in RV32I 2021-04-18 23:45:11 +02:00
Anton Lydike
07f097202d added lui instruction to RV32I 2021-04-18 23:44:18 +02:00
Anton Lydike
4c50b8bf06 added .space pseudo op, currently does nothing 2021-04-18 23:43:56 +02:00
Anton Lydike
c6b18dd152 fixed hex check in parse number code 2021-04-18 23:43:39 +02:00
Anton Lydike
d8d53da774 added scaffolding form RVM instruction set 2021-04-18 23:29:12 +02:00
Anton Lydike
3ce42079d4 refactored instruction sets to be modular 2021-04-18 23:14:53 +02:00
Anton Lydike
91a12fd2a8 fixed tokenizer hanging on unknown instruction 2021-04-18 20:36:13 +02:00
Anton Lydike
a3ab418858 fixed formatting in Registers.dump() 2021-04-18 20:32:25 +02:00
Anton Lydike
cd08cd4f70 added syscall interface to debug variables 2021-04-18 20:11:44 +02:00
Anton Lydike
bf4c705297 added symbol lookup helper MMU.symbol(name) 2021-04-18 20:10:08 +02:00
Anton Lydike
ce59d10a3b fixed range selection for LoadedMemorySection.dump 2021-04-18 20:09:47 +02:00
Anton Lydike
4135ffdb32 syscall symbols now work as global symbols 2021-04-18 19:30:25 +02:00
Anton Lydike
8b4ba276a8 fixed saving reference to global_symbol_table in executable loader 2021-04-18 19:29:51 +02:00
Anton Lydike
a1b9cf7f22 provide global syscall symbols if flag is set 2021-04-18 19:19:28 +02:00
Anton Lydike
11568ec9b0 improved arguments, dropped support for no-color output 2021-04-18 19:18:17 +02:00
Anton Lydike
2c5655d65a fixed registers keeping track of last accessed register 2021-04-18 18:56:39 +02:00
Anton Lydike
7cb29c5b89 added escape character deocoding for ascii and asciiz pseudo-ops 2021-04-18 18:49:27 +02:00
Anton Lydike
3bcabfbf78 fixed mmu bounds check for read 2021-04-18 18:48:55 +02:00
Anton Lydike
fc22d4b6a7 added better colors to MMU output 2021-04-18 18:39:48 +02:00
Anton Lydike
09844c8d38 fixed isinstance check in write syscall 2021-04-18 18:39:32 +02:00
Anton Lydike
d6e6856431 changed output color for syscall logs 2021-04-18 18:16:53 +02:00
45b82a3fa9 support for loading multiple executables 2021-04-18 12:59:40 +02:00
cb48d66400 stack allocation now fixed 2021-04-18 12:55:57 +02:00
2b87bbe270 reformat Exceptions.py 2021-04-18 12:12:00 +02:00
8fc519ee86 added global symbol support! 2021-04-18 12:09:38 +02:00
9aaaf7313f added pseudo-op .set name val, and .global symb 2021-04-18 10:38:36 +02:00
db8cc9b00c made instruction methods private to cpu class so not visible from debugger 2021-04-18 10:18:36 +02:00
c3faaaed02 better formatting in memory dump 2021-04-18 09:42:58 +02:00
f43c33b0d7 added __repr__ to MemoryFlags 2021-04-18 09:42:27 +02:00
c4a28c9d1b added __repr__ to MMU and LoadedMemeorySection 2021-04-18 09:37:57 +02:00
4b26ab6774 added __repr__ to CPU class 2021-04-18 09:33:00 +02:00
d56dca3ff4 added better debugging environment 2021-04-18 09:32:37 +02:00
baaaa881bc colored exception messages 2021-04-18 09:21:11 +02:00
34a44860e0 added name field to executables for easy debugging 2021-04-18 09:10:03 +02:00
Anton Lydike
64507a4e7e added mmu dump to dump arbitrary section 2021-04-18 02:12:29 +02:00
Anton Lydike
30bcded998 beautiful section dumps 2021-04-18 02:08:47 +02:00
Anton Lydike
7f59ac9bca better interative shell 2021-04-18 02:08:03 +02:00
Anton Lydike
8d39d79032 made module runnable 2021-04-18 00:43:39 +02:00
Anton Lydike
20db1e02ab implemented instructions sll, slli, srl, srli, sra, srai 2021-04-18 00:25:53 +02:00
Anton Lydike
7d09cb209f reworked memory instruction parsing 2021-04-18 00:24:47 +02:00
Anton Lydike
3c0e357ca0 minor bugfixes and missing members corrected 2021-04-18 00:09:26 +02:00
Anton Lydike
dd79c11b3b implemented instructions and, or, slt, sltu 2021-04-17 23:53:47 +02:00
Anton Lydike
f8e595b46e added instruction xor 2021-04-17 23:43:59 +02:00
Anton Lydike
99de083894 minor instruction fixes such as added assertions 2021-04-17 23:14:56 +02:00
Anton Lydike
5bdd866472 implemented instruction j, added cpu cycle counter 2021-04-17 23:08:09 +02:00
Anton Lydike
97d86108e8 added ebreak/scall aliases to sbreak/scall and replaced dbg with ebreak instruction 2021-04-17 23:05:01 +02:00
Anton Lydike
0aa42d0d1c implemented instructions beq, bne, blt, bge, bltu, bgeu, improved unsigned number handling 2021-04-17 22:59:37 +02:00
Anton Lydike
88c0b77a16 implemented instructions jal, jalr, j, ret, nop 2021-04-17 22:51:28 +02:00
Anton Lydike
5a722c8cf1 implemented syscalls open, read, write, close, exit 2021-04-17 22:50:47 +02:00
Anton Lydike
a483db65c7 more work on syscalls 2021-04-17 21:28:05 +02:00
Anton Lydike
a69cc7d346 moved registers out of CPU file 2021-04-17 20:57:54 +02:00
Anton Lydike
feaf432645 fixed config dataclass 2021-04-17 20:57:21 +02:00
Anton Lydike
9710ed9b8b added Executable.__repr__ and added return self to ExecutableParser.parse 2021-04-17 20:42:22 +02:00
Anton Lydike
93ff8d7186 added unsigned option for int_{from,to}_bytes 2021-04-17 20:28:34 +02:00
Anton Lydike
4159d1609b added run config 2021-04-17 20:24:38 +02:00
6bc939572b parsing and simple running works somewhat 2021-04-17 19:06:24 +02:00
da4ae7c4c1 parsing of tokenized asm into MemorySections works 2021-04-17 13:39:56 +02:00
Anton Lydike
2cee60a17c initial commit 2021-04-16 23:52:13 +02:00