M65C02A Core
Posted: Sat Jun 28, 2014 4:40 pm
I have released the M65C02A processor core on GitHUB. It provides significant enhancements to the microprogram control structure and the processor logic.
The microprogram structure has been modified to reduce the amount of decode logic required to generate the control signals. As a consequence, the microcode now directly controls most logic structures in the processor. The decoders needed to generate control signals to the logic have been eliminated in most cases, which results in a smaller logic footprint. It also improves the overall speed of the core.
More importantly, the changes to the microprogram structure have allowed the inclusion of additional multiplexers in the data path. The faster control paths gained by moving to unencoded control fields in the microprogram have been traded for additional multiplexers that allow the microprogram direct control of the various address/data path registers. This will allow the microprogram to implement custom functions such as FORTH interpreter functions like NEXT, ENTER, EXIT, etc.
The changes to the logic structures are such that the stack relative addressing mode of the W85C816 can be easily added to the instruction repertoire of the M65C02A core. (These additions can be added without re-synthesizing the core.) The M65C02 core had a dedicated functional unit to support the Rockwell instructions: SMBx/RMBx and BBSx/BBRx. With the new logic structure, these instructions and others, such as the W65C816 PEA/PEI instructions, are directly supported by the new LU (Logic Unit) module. The reduced number of functional units in the M65C0A core's ALU has improved to overall speed. Some of the speed gains have been traded, as indicated above, for additional multiplexers to allow the microprogram more control of the address/data path registers.
I have added two features present on standard processors that I did not previously support. First, I have added support for the SOB (nSO) input pin that standard processors provide to allow external logic to set the V flag on the falling edge of the pin. That function now performs the action defined, but the falling edge detector must be provided by logic external to the core itself. Second, I have included the reset behavior of the 65SC02. To do this, I removed system reset from the PSW and the PC, and initialized the stack pointer to 2 when an external RST is asserted. The reset microprogram will now push the PC, followed by the PSW, to the stack. The three stack pushes place the PC in locations 0x102 (PCH) and 0x101 (PCL), and the PSW in location 0x100. The third push advances the stack pointer to point to location 0x1FF.
Thus, the stack pointer, S, is at the top of the stack page when the processor restarts. This D and I bits are cleared when all four of the traps/interrupts are entered. This modification allows the reset button to be pressed to recover a runaway processor. The monitor/debugger can be used to examine the three lowest locations in the stack page to determine where the processor was when RST
was asserted.
The result is a processor core which is more flexible. I expect to use this core to implement the stack relative and PEA/PEI instructions of the W65C816. Following that, I've been reviewing Brad Rodriquez' Moving FORTH articles and Loeliger's Threaded Interpretive Languages book for ideas that will lead to the implementation of the core of a DTC FORTH interpreter directly in the microcode of the M65C02A core.
I have completed the verification of the core using my test programs. I plan to run Klaus' functional test programs on the core soon as a final check. Klaus' programs helped identify some errors in my stack addressing logic in the M65C02 core. I've incorporated those changes in the current core, and modified my test bench test program to test for those specific conditions. Therefore, I am fairly confident that passing Klaus' functional tests will be pro forma, but I've thought that before as well.
I would appreciate any feedback anyone may have on the M65C02A core.
The microprogram structure has been modified to reduce the amount of decode logic required to generate the control signals. As a consequence, the microcode now directly controls most logic structures in the processor. The decoders needed to generate control signals to the logic have been eliminated in most cases, which results in a smaller logic footprint. It also improves the overall speed of the core.
More importantly, the changes to the microprogram structure have allowed the inclusion of additional multiplexers in the data path. The faster control paths gained by moving to unencoded control fields in the microprogram have been traded for additional multiplexers that allow the microprogram direct control of the various address/data path registers. This will allow the microprogram to implement custom functions such as FORTH interpreter functions like NEXT, ENTER, EXIT, etc.
The changes to the logic structures are such that the stack relative addressing mode of the W85C816 can be easily added to the instruction repertoire of the M65C02A core. (These additions can be added without re-synthesizing the core.) The M65C02 core had a dedicated functional unit to support the Rockwell instructions: SMBx/RMBx and BBSx/BBRx. With the new logic structure, these instructions and others, such as the W65C816 PEA/PEI instructions, are directly supported by the new LU (Logic Unit) module. The reduced number of functional units in the M65C0A core's ALU has improved to overall speed. Some of the speed gains have been traded, as indicated above, for additional multiplexers to allow the microprogram more control of the address/data path registers.
I have added two features present on standard processors that I did not previously support. First, I have added support for the SOB (nSO) input pin that standard processors provide to allow external logic to set the V flag on the falling edge of the pin. That function now performs the action defined, but the falling edge detector must be provided by logic external to the core itself. Second, I have included the reset behavior of the 65SC02. To do this, I removed system reset from the PSW and the PC, and initialized the stack pointer to 2 when an external RST is asserted. The reset microprogram will now push the PC, followed by the PSW, to the stack. The three stack pushes place the PC in locations 0x102 (PCH) and 0x101 (PCL), and the PSW in location 0x100. The third push advances the stack pointer to point to location 0x1FF.
Thus, the stack pointer, S, is at the top of the stack page when the processor restarts. This D and I bits are cleared when all four of the traps/interrupts are entered. This modification allows the reset button to be pressed to recover a runaway processor. The monitor/debugger can be used to examine the three lowest locations in the stack page to determine where the processor was when RST
was asserted.
The result is a processor core which is more flexible. I expect to use this core to implement the stack relative and PEA/PEI instructions of the W65C816. Following that, I've been reviewing Brad Rodriquez' Moving FORTH articles and Loeliger's Threaded Interpretive Languages book for ideas that will lead to the implementation of the core of a DTC FORTH interpreter directly in the microcode of the M65C02A core.
I have completed the verification of the core using my test programs. I plan to run Klaus' functional test programs on the core soon as a final check. Klaus' programs helped identify some errors in my stack addressing logic in the M65C02 core. I've incorporated those changes in the current core, and modified my test bench test program to test for those specific conditions. Therefore, I am fairly confident that passing Klaus' functional tests will be pro forma, but I've thought that before as well.
I would appreciate any feedback anyone may have on the M65C02A core.