Closed Rodrigodd closed 5 months ago
Looks like the error is indeed in decoder3. I downloaded old results comparing my decoder and Gekkio decoder and the difference is really in the x35 signal for opcode 0x77:
The x35 command is exactly used to output the value of the A register to the DV bus (Gekkio: s3_oe_areg_torbus). Crap ><
Fixed typo in decoder3, got better, but now the external data bus writes Zz
:)
Also my decoder is now 1 to 1 with the Gekkio decoder:
@Rodrigodd That's all for now :) Please see how it turned out.
Oops, I got the D and DL mixed up. The external data bus is still HighZ.
It turns out I closed #239 early Now I have problems with the external data bus (Z) again. I'll open it back up and go back to the data_mux edits =)
@Rodrigodd Fixed, edits online.
On this Issue, I will do some more research on register and bus connections using your work (but that's for the wiki).
@Rodrigodd, please see I have analyzed circuits and found an additional inverter at the output of Z/W registers 🙈
Tested it in dmg-sim
and everything appears to be working as expected. Thanks again!
From #238. To fix it there, I removed the not operator from the assignment to
Z_in
andW_in
, but I don't know how to confirm if this should be the actual fix, there are many other possible positions where the signal could be inverted or not (the registers could for example store the value of the registers inverted and then straight them when loading).Below is my investigation of the flow of data from the databus to the registers, extracted from
investigating.md
in the linked PR, with added screenshots.HL is inverted in the address bus
H
andL
are stored inReqH
/r3q
andReqL
/r2q
, respectively, inverted.H
can go toabus
,bbus
ordbus
, andL
can go toabus
,bbus
orcbus
. They go to the bus through an inverter, so they have they original value.In this instruction,
H
goes todbus
andL
goes tocbus
.dbus
cbus
go through anBusKeeper
, and them inverted again into theAdressBus
(orA
).From the comments in
IDU.v
, the code expects that the internal register actually holds the straight value of the ISA registers, but they are inverted in the current form. This was also seen in theJP
instruction, and I fix that there by inverting the Zbus, but maybe we need to invert something more fundamental, like the value read from the memory?r3q
->dbus
->BusKeeper
->AddressBus
(inverted)r2q
->cbus
->BusKeeper
->AddressBus
(inverted)Path from databus to register A
D
->DataLatch
->DL
->Z_in
(inverted) ->zbus
->bbus
(straighted) ->bbq
->DV
(inverted) ->Res
->fbus
->RegA
So
RegA
/r1q
contains the inverted value ofA
.In screenshot, the execution of the instruction
LD A, $BC
(3e bc
).Path from databus to register HL
D
->DataLatch
->DL
->W_in
(inverted) ->wbus
->fbus
->RegH
D
->DataLatch
->DL
->Z_in
(inverted) ->zbus
->ebus
->RegL
So
HL
are also stored inverted in the registers.In screenshot, the execution of the instruction
LD HL, $DE80
(21 80 de
).Path from databus to register SP
D
->DataLatch
->DL
->W_in
(inverted) ->wbus
->sph_nd
(inverted) ->SPH
(inverted)D
->DataLatch
->DL
->Z_in
(inverted) ->zbus
->spl_nd
(inverted) ->SPL
(inverted)So
SP
is also stored inverted in the registers.In screenshot, the execution of the instruction
LD SP, $AACC
(31 cc aa
).Path from databus to PC
D
->DataLatch
->DL
->W_in
(inverted) ->wbus
->pch_nd
(inverted) ->PCH
(inverted)D
->DataLatch
->DL
->Z_in
(inverted) ->zbus
->pcl_nd
(inverted) ->PCL
(inverted)So
PC
is also stored inverted in the registers.In screenshot, the execution of the instruction
JP $0112
(c3 12 01
).