#pragma once namespace M6502CoreUnitTest { class UnitTest { enum class ALU_Operation { None = 0, ANDS, EORS, ORS, SRS, SUMS, }; void ResetPcInputs(); bool PC_Test(uint16_t initial_pc, uint16_t expected_pc, bool inc, const char* test_name); void ResetALUInputs(ALU_Operation op); int TestCompute(uint8_t a, uint8_t b, uint8_t expected, ALU_Operation op, bool bcd, bool carry); size_t BCD_Add(size_t a, size_t b, bool carry_in); M6502Core::M6502 *core; public: UnitTest(); ~UnitTest(); /// /// Checking Program Counter simulator functionality. /// bool PC_UnitTest(); /// /// Checking the operability of the ALU 6502 in different modes. /// /// bool ALU_UnitTest(); /// /// Go through all 6502 decoder values and output them to CSV. /// /// bool DumpDecoder(); /// /// Execute some million cycles and check that their execution time is faster or equal to the real chip. /// The chip in this test is in "pumpkin" mode: it lives, but it does nothing useful. /// /// Desired cycle rate per second (Hz) /// bool MegaCyclesTest(size_t desired_clk); /// /// Checking the decoder (PLA) simulator. /// bool Decoder_Test(); /// /// Checking the instruction register (IR) simulator. /// bool IR_Test(); /// /// Checking the predecoder simulator. /// bool PreDecode_Test(); /// /// Checking the flags register (P) simulator: loading, storing, getters and setters. /// bool Flags_Test(); /// /// Checking the Y/X/S registers simulator. /// bool Regs_Test(); /// /// Checking the ALU extras: sim_HLE, sim_BusMux, getters/setters, BCD hack. /// bool ALU_Extras_Test(); /// /// Checking the HLE program counter simulator (load/store/increment). /// bool PC_HLE_Test(); /// /// Checking the data bus simulator (external bus exchange). /// bool DataBus_Test(); /// /// Checking the address bus simulator (constant generator and output). /// bool AddressBus_Test(); /// /// Checking the interrupt (BRK) processing logic: DORES, B_OUT, BRK6E latches. /// bool BRK_Test(); /// /// Checking the register control logic (Y_SB, SB_Y, X_SB, SB_X, S_ADL, S_SB, SB_S, S_S). /// bool RegsControl_Test(); /// /// Checking the bus control logic (ADL_ABL, ADH_ABH, SB_DB, SB_ADH, DL_ADL, DL_ADH, DL_DB, Z_*). /// bool BusControl_Test(); /// /// Checking the program counter control logic (ADL_PCL, PCL_PCL, PCL_ADL, PCL_DB, ADH_PCH, PCH_PCH, PCH_ADH, PCH_DB). /// bool PCControl_Test(); /// /// Checking the flags control logic (P_DB, DB_P, DBZ_Z, DB_N, IR5_C, DB_C, ACR_C, IR5_D, IR5_I, DB_V, AVR_V, Z_V). /// bool FlagsControl_Test(); /// /// Checking the ALU control logic (n_ACIN, n_DAA, n_DSA, ANDS, EORS, ORS, SRS, SUMS, ADD_SB7, ADD_SB06, ADD_ADL). /// bool ALUControl_Test(); /// /// Checking the branch logic (BRFW, n_BRTAKEN). /// bool BranchLogic_Test(); /// /// Checking the dispatcher (T0, n_T0, n_T1X, FETCH, n_ready, ACRL1, ACRL2, TRES1, n_TRESX, ENDS, ENDX, WR, RMW_T6, RMW_T7, n_1PC). /// bool Dispatcher_Test(); /// /// Checking the random logic as a whole: run a known program and verify the control commands. /// bool RandomLogic_Test(); /// /// Checking the extra cycle counter (T2..T5), both HLE and non-HLE modes. /// bool ExtraCounter_Test(); /// /// Running known programs and checking the internal signals (commands and wires) at specific cycles. /// bool CoreInternals_Integration_Test(); /// /// Checking the public debugging API (getDebug, getUserRegs, get/setDebugSingle, get/setUserRegSingle). /// bool M6502API_Test(); }; }