Re: Functional Test for the NMOS 6502 - request for verifica
Posted: Sat Aug 17, 2013 8:00 am
Michael,
also I don't know the timing for an individual test, the timings you have taken seem to be O.K. for the extent of each test. The ADC/SBC tests are so exhaustive because I didn't come up with a sensible set of test operands. Since I was lazy I decided to just test all combinations. Therefore your number of calls to decimal and binary ADC/SBC tests check routine is correct.
If you run into a timeout again, you could modify the initialization of the binary test. The test starts now at 0 for both operands and carry clear.After you have checked ad2 on a timeout, you could preset ad2 to start with the ending ad2 value of the previous run. Since the first result expected is no longer 0 the resulting flags must be altered.Changed or added lines are marked with ***.
You should always keep in mind, that the test was originally written for an emulator. For the non-exhaustive tests the predefined operands are choosen according to the need to test all possible combinations of resulting processor status bits.
Since logical operations in an emulator rely on the logical operations of the underlying processor, the test does not guarantee the logical functionality of each and every bit in the alu. It assumes the underlying logical operation to be correct if a limited number of patterns come out of the alu with a correct result.
In that sense it leaves a gap where a broken function in a single bit of an fpga core alu may go undetected. I don't know, how likely this is to happen but it is an exposure that you should be aware of.
also I don't know the timing for an individual test, the timings you have taken seem to be O.K. for the extent of each test. The ADC/SBC tests are so exhaustive because I didn't come up with a sensible set of test operands. Since I was lazy I decided to just test all combinations. Therefore your number of calls to decimal and binary ADC/SBC tests check routine is correct.
If you run into a timeout again, you could modify the initialization of the binary test. The test starts now at 0 for both operands and carry clear.
Code: Select all
cld
ldx #ad2 ;for indexed test
ldy #$ff ;max range
lda #0 ;start with adding zeroes & no carry
sta adfc ;carry in - for diag
sta ad1 ;operand 1 - accumulator
sta ad2 ;operand 2 - memory or immediate
sta ada2 ;non zp
sta adrl ;expected result bits 0-7
sta adrh ;expected result bit 8 (carry out)
lda #$ff ;complemented operand 2 for subtract
sta sb2
sta sba2 ;non zp
lda #2 ;expected Z-flag
sta adrf
Code: Select all
cld
ldx #ad2 ;for indexed test
ldy #$ff ;max range
lda #0 ;start with adding zeroes & no carry
sta adfc ;carry in - for diag
sta ad1 ;operand 1 - accumulator
sta adrh ;*** expected result bit 8 (carry out)
lda #$f0 ;*** modify starting op2/result
php ;*** PS -> stack
sta ad2 ;operand 2 - memory or immediate
sta ada2 ;non zp
sta adrl ;expected result bits 0-7
; sta adrh ;*** moved ^^
eor #$ff ;*** now true complemented operand 2 for subtract
sta sb2
sta sba2 ;non zp
pla ;*** stack PS -> A
and #$82 ;*** filter N,Z expected flags
sta adrf
You should always keep in mind, that the test was originally written for an emulator. For the non-exhaustive tests the predefined operands are choosen according to the need to test all possible combinations of resulting processor status bits.
Since logical operations in an emulator rely on the logical operations of the underlying processor, the test does not guarantee the logical functionality of each and every bit in the alu. It assumes the underlying logical operation to be correct if a limited number of patterns come out of the alu with a correct result.
In that sense it leaves a gap where a broken function in a single bit of an fpga core alu may go undetected. I don't know, how likely this is to happen but it is an exposure that you should be aware of.