So I've been working on a project to understand microprocessors a little better, it's been a great educational experience, and I have learned a lot especially from here (and the visual6502 simulation, of course). I am basically designing a CPU based almost entirely on the hardware of the 6502, except with a custom ISA and some more liberties with what can be done. The idea though is for it still to make sense cycle-count wise, and to technically be possible to layout on hardware.
Some Interesting Documents
README: https://github.com/TReed0803/kasm/blob/ ... /README.md
Public structures/functions: https://github.com/TReed0803/kasm/blob/ ... /k65/k65.h
Public ISA Header: https://github.com/TReed0803/kasm/blob/ ... /k65/isa.h
Example PLA Signals: https://github.com/TReed0803/kasm/blob/ ... rt/adc.inl
Honestly, I was going to wait longer to share this; there are still some issues, and things I haven't exactly decided on. But it's getting harder and harder to work without feedback, so I figured I would post some important links to the project and see if anyone is able to share some knowledge or can help in any way.
Another reason I was kind of unsure I wanted to share this project is it has a core dependency on another library of mine which I know is Linux-only right now, so it's a difficult project to build right now (and I don't have build instructions in the README, booooo)... Building this isn't the most trivial thing, because it requires some file generation (as you can see in CMakeLists.txt). I plan on automating builds for my projects to make it easier to share binaries in the future, but like I said - getting harder and harder to work without feedback.
Right now, I don't have a functioning assembler, that is a work-in-progress as well. I noticed it was silly to work on the assembler while I still wasn't sure what the final ISA looked like, so I shelved that in an unfinished state for the time being. Right now, I'm using the preprocessor to assemble things via. the pasm.h header in my project. Here is an example of using it from unit tests: k65_art_adc_carry_set
Anyways, here are some of my questions:
1. About the Decode ROM
One of the things I thought would be interesting is having multiple decode ROMs and selecting which we use via the first two bits of the instruction. This is basically how all the instructions are configured, there is an "Instruction Block" which says which decode ROM we use, and then the other 6 bits feed into decode ROMs. I attempted to split it further, by allowing the decode ROM for addressing mode be different from the decode ROM for the logic that happens after memory is retrieved via the addressing modes, but it's all just theoretical. Without putting hardware down I have no idea if this is just a needless complication, or if there is any novelty to this configuration.
I kind of want feedback on that idea in general; is it misinformed? Is it useless? Could it accomplish anything?
2. About Flipping Carry Bit for Subtraction
I'm considering flipping the carry bit for SBC instructions (the reason I name my SBC, SBB is because I was planning on attempting to add a control signal to do this). I presume the reason they didn't do it on the 6502 is because it just costs more transistors. There is something kind of nice about the clean layout of not hiding what an adder does, but I've found myself to be confused and remembering that I need to SEC when I SBC before in my own ISA, so I figured it was frustrating enough to fix it. Does anyone think there'd be any confusion caused by that, or does it sound like a solid change?
3. About the ISA
I tried to make ISA changes that I felt made sense, and were logically sound with the ISA bitset that I have constructed. So adding in some instructions missing from the original 6502 (like TXY, TYX just made sense). But some things either had to be cut, or I wanted a parallel to another instruction and I'm unsure if it'd be useful. Here are a few examples:
+ BIT has a mnemonic similar to it called BIX, which is basically an XOR with Accumulator, and updating zero-flag (as well as sign/overflow like BIT does as well). I feel iffy about this one, but figured I'd throw it out and see if anyone could think of any uses.
+ JMP doesn't have absolute-indirect; instead you get absolute, relative, and zero-page.
+ NOT/NEG were easy additions IMO, and they fit well in the RMW block of instructions.
+ ADX/ADY/SBX/SBY also felt like they made good sense to add based on the ISA layout.
+ Added CLX/CLY because it seemed to fit as an implied instruction in place of LDX/LDY. Thoughts?
I tried really hard to get STZ/STF, but for STZ I couldn't think of a way to make it work without wasting a cycle to get the 0 constant on the bus when I needed it. I could make STZ be absolute/immediate(useless)/zero-page based on my layout, fitting them in the CTL block. However, It didn't seem useful to have these instructions if those were the addressing modes. (Also, the struggle to get a zero on the bus for absolute proved to be difficult since I had to push a cycle through the adder to construct zero, since ADL/ADH were busy...) I can elaborate if needed, otherwise I'd have to add a drain to DB, and I don't know if I can justify the extra hardware for a single instruction and bad addressing modes...
I also thought really hard about SWP (swap nibble). But I basically concluded that I'd have to add a special input mode (from SB or DB) so that I could pass through the adder to properly update the flags. It feels like a lot of hardware complication for little gain, though it could technically be done. Thoughts on this?
I also worked really hard to see if I can add Direct Addressing Mode, or maybe a better equivalent to what I was doing was Base Page vs. Zero Page. Basically I thought it'd be incredibly useful if you could set a register to be used for ABH during zero-page instructions (making them effectively base-page, where base-page could be 0 or any other page). The issue was, while I could fit an instruction in CTL block for configuring the base page (LDB; absolute, immediate, zero-page). I had trouble thinking it'd be worth it because there was no easy way to transfer to/from, push/pull the value, or in general inspect what the set "base page" was (is there a better name for what I'm describing? I want to say direct addressing because of the 65c816 direct page register). Is this a good call, or could it still be useful even without these instructions? Or would you give up TXY/TYX for something like this? It felt like a lot of messing with the hardware for a feature that would be half-baked in the end. Looking for opinions though.
In general, any ISA feedback would be welcome!
That's All!
Again, I welcome any and all feedback. I hope it is appropriate to ask questions about this kind of project on here. Any you are more than welcome to peruse the PLA for K65, however be careful as there is a lot of copy-paste comments in there. I haven't done an editing pass on the PLA headers, so some of them are in good shape, and others are very obviously not.
Thanks!