Hi Marco,
I've just checked your "clone_8722" verilog code against the expected functions from a real 8722 mmu and, as you were looking for some good feedback, I'm going to provide you some.
First of all, there are some inconsistencies in referring to the MMU registers and so to naming the related identifiers in the code:
- you call "MCR" what is actually the "CR" register (i.e. $D500/$FF00)
- you call "CR" what is actually the "RCR" register (i.e. $D506)
- you call "PR" what is actually the "P0L" register (i.e. $D507)
Then, some MMU registers are missing or incomplete:
- "MCR" ($D505) : I/O register, whose signals should be hardwired to external ports (like you did for MC7..MC0, that are connected to the wrong $D500 register at the moment, see above)
- "RCR" ($D506) : bit0-1 the shared size can be 1K, 4K, 8K, 16K (not 1K,2K,4K,8K) and you should also consider bit3 (not just bit2) for shared ram position ("00"=none, "01"=bottom, "10"=top, "11" = both), bit6-7 (video bank, i.e. bit 16-17 for the VIC) should set CS0-CS3 when AEC is set low by VIC for a DMA cycle (so we can say that bit6-7 of either CR or MCR are the "emulated" A16-A17 for a C128 system, driving CS0-CS3 accordingly to AEC)
- "P0H" ($D508) : the "P0" register is split in 2 registers: "P0L" (implemented) and "P0H" (bit 16-19) that is unimplemented in your code (at least you have to implement translation up to bit16-17 for a 256K system)
- "P1L" ($D509) and "P1H" ($D50A) : the "P1" register split in 2 registers like for P0 (see above)
- "VR" ($D50B), I suggest filling its read-only bits (7-4 and 3-0) respectively with constants "0100" (BANK_VERSION=4 i.e. 256K) and "0001" (MMU_VERSION=1)
While "MCR" appears as an I/O register that doesn't relate to translation, I guess you'll want to implement it (and "VR" as well) as your code claims to be a "clone" of the original MMU8722. Moreover, there's an important address translation performed by the MMU when Z80 mode is active (bit0 of MCR=0) regarding Z80BIOS ($0000-$0FFF must become $D000-$DFFF as a Z80 - differently from a 6502 cpu - wants system ROM at the beginning of the available memory)
You can find a quick register reference documentation at
http://www.oxyron.de/html/registers_mmu.html or a complete one at
https://www.pagetable.com/docs/Commodore%20128%20Programmer's%20Reference%20Guide.pdf (page 530) and
https://myoldcomputer.nl/Files/Datasheet/MOS8722.pdfAgain, some external I/O ports are missing:
- AEC (input) to disable address translation (three-stating the TA output, to avoid contention with the VIC) during DMA (when AEC is low)
- ROMBANKLO, ROMBANKHI, IOSELECT (output) to assert the current ROM configuration for the PLA 8721 in relationship to bit5/4, bit3/2, bit1, bit0 of the configuration register ($d500) and the address to translate (respectively for $C000-$FFFF, $8000-$BFFF, $4000-$7FFF, $D000-$DFFF)
- CS2, CS3 (output) in relationship to the bank select (bit 6/7) of the configuration register ($D500)
- Actual MCR bits ($D505) should be exposed (input/output) for the C128 glue logic to work (40/80sense, C64mode, EXROM, GAME, FSDIR, Z80EN), as said before
Finally, regarding your HDL implementation, I would advice you to implement a double port for cpu data (Din,Dout instead of D) and delete remaining unnecessary ports (what you call "CR0..7" are useless)
Let me know if this helps.