Hello All:
I apologize but I messed up my email address yesterday when trying to point it to another account and deactivated my account on this forum as a consequence. Therefore, I've re-registered, and the old MichaelA is the new MichaelM. I will still sign any posts as Michael A.
EE threw down the gaunlet, and rightly so, that I should post any code that I may have. Therefore, I have pulled together the source files for my first core which I briefly described yesterday. I have placed a LGPL license header on all of the source files. I was going to release the attached code through OpenCores, but I don't have what I would consider a self-checking testbench for the core, and I've not completed a detailed design description of the core.
I have included all of the testbenches that I used in the development of the core, but the testbench for the ALU is not up to date. In the process of getting the core's microcode working correctly, I made some changes to the ALU which have not been incorporated into its testbench. Prior to integration of the core's components, the ALU testbench was developed as self-checking. For my second core, which is derived from the first, I spent most of this morning getting the ALU testbench in line with the implementation.
I would appreciate it if someone (EE, BigEd, Arlet) would put it into a repository that the members of the forum may access. I will continue improving the documentation for this core because it will apply to both cores that I am working on.
The following is an abbreviated list of the files that I've put into the attached ZIP archive:
M65C02_Core.v - top level file for a WDC 65C02 compatible core
M65C02_MPC.v - Microprogram Controller for the M65C02 variable microprogram (my re-implementation of the F9408 MPC)
M65C05_ALU.v - ALU core for the M65C02 (contains the A, X, Y, S, and P registers and implements the ALU functions and register transfer logic)
M65C02_BIN.v - Binary mode adder for the ALU
M65C02_BCD.v - BCD mode adder for the ALU
M65C05.ucf - User constraints file setting the clock period constraint for PAR and locking the core module ports to I/O pins of an XC3S200-5FT256 FPGA
M65C02.tcl - TCL file with all project settings for the Xilinx ISE 10.1i SP3 Synthesizer, Mapper, and Place and Route tools
M65C02_Decoder_ROM.coe - Memory coefficient file for the fixed portion of the core's microcode (instruction decode - ALU operation control)
M65C02_Decoder_ROM.txt - Source file for M65C02_Decoder_ROM.coe
M65C02_uPgm_V3.coe - Memory coefficient file for the variable portion of the core's microcode (address mode control)
M65C02_uPgm_V3.txt - source file
tb_M65C02_Core.v - Testbench for the top level (Xilinx ISim Lite and/or ModelsimXE-III 6.3c)
M65C02_RAM.v - Synthesizable (not recommended) Distributed RAM (LUT) used by the top level testbench to simulate single cycle program/data RAM
M65C02_Core.xwv - waveform file for the core testbench
M65C02_Tst2.txt - Memory coefficient file for the M65C02 assembly language test program
M65C02_Tst2.a65 - source file
m65c02.bin - binary output file from the Kingswood A65 Assembler
BIN2TXT.exe - Helper function used to create the M65C02_Tst.txt file from the m65c02.bin file
BIN2TXT.c - C source file
1004-0001 W65C02 Design Description.pdf - Incomplete description of the W65C02 processor and its implementation in the M65C02 core: MAM65C02.zip.
Quote:
The orginally provided MAM65C02.zip file has been removed. An update has been made to the files, and a repository has been created on
GitHub. Follow this
link to download the latest files as a ZIP archive.
This post is getting to be too long, so I'll wrap up by saying that the core supports interrupts in a non-standard manner, and it expects a external interrupt controller to provide the core with an interrupt request and the full 16-bit vector. Thus, the core does not perform an indirect jump through one of the defined vectors of any of the 6502 processors. I make the assumption that it is a core, and that the vectors would normally not be variable, i.e. normally found in ROM. One other note, in the implementation I've provided, the objective is a core performance of 100 MHz in a Xilinx Spartan 3AN part. The core and the ucf achieves that goal, but that level of performance is not what can be achieved in a situation which uses external memory. I used this approach in order to get the microcode debugged. I believe that I've implemented the BCD arithmetic correctly. However, surfing around the web, I am no longer sure that I've correctly determined the overflow flag in the BCD mode. Finally, the BCD mode is implemented in such a manner that BCD mode ADC/SBC instructions stretch the execution cycle by one clock cycle to accomodate the BCD adjustment.
Overall, I am pretty confident that the core executes the WDC W65C02 instructions faithfully. In most cases, the core as implemented saves one clock cycle from most multi-cycle operations. The result is that the core, as implemented, will yield an improvement of approximately 40% for an average W65C02 program. I seem to have misplaced my working notes on this subject, but the Kingswood assembler can be made to output the expected number of clock cycles for each instruction, and that can be compared to the actual cycles that the core uses for each instruction.
I hope that the core I've attached will be useful to some of the forum members.