Author Topic: programmable address map  (Read 1336 times)

0 Members and 1 Guest are viewing this topic.

Offline redguy

  • Jr. Member
  • **
  • Posts: 54
  • Karma: +148/-0
    • View Profile
programmable address map
« on: January 29, 2018, 12:10 AM »
EDIT: There's a new version.  The major changes are the Disable field was moved to the Type field, a NOP type was added to force a match but not use the table (useful for WRAM, etc, to avoid false SaveRAM matches), and timing was improved a little.

I thought it would be interesting to support a programmable address map.  This is more a proof of concept than something that is useful long term.  Many of the lorom and hirom formats work.  I gave up on trying to support bs-x and star ocean (why does this interleave using the bank address bits?) so they are still hardcoded.  In addition to the basic maps, there is support for a yml format that can be located along with the rom of the same name in order to program a custom address map.  I included an example for Super Ghouls and Ghosts (lorom, no saveram) at the end of this post.  Programming it is not very straightforward and errors usually result in a black screen on start.

The zip file contains new firmware and fpga_base.bit files along with the sample custom address map.

The timing was already pretty tight for the address map generation logic and I only made that worse.  I tried a few fixes, but it's not always obvious what the problem is.  What seems like a good fix to improve things sometimes makes it worse.  One time changing the name of a variable allowed it to successfully finish synthesis...

https://github.com/RedGuyyyy/sd2snes/tree/addrmap
https://github.com/RedGuyyyy/sd2snes/releases/download/addrmap_v3/addrmap_v3.zip

---
# Address Map Definition
# Up to 8 Address map entries which are 8B each.
#
# Mode
#  7:4 0=ROM, 2=RAM (RAM ignore ROMSEL), E=NOP, F=Disable
#  3:0 0=64KB page interleaving (15:0), 1=32KB page interleaving (14:0), ..., 5=2KB page interleaving
#
# Base = 23:8
# Mask = 23:8
# OBase = 23:16
# OMask = 23:8
#
# Match = Mode[7:4] != Disable && (Base == SNES_ADDR[23:8] & Mask)
# Addr = {OBase, 0000} + ({SNES_ADDR[23:16], SNES_ADDR[15-Mode[2:0]:0]} & {OMask,FF})
#
#   [ Mode, Base,     Mask,     OBase,    OMask    ]
- AddrMap:
    [ 0x01, 0x008000, 0x008000, 0x000000, 0x0FFFFF,
      0xFF, 0x000000, 0x000000, 0x000000, 0x000000,
      0xFF, 0x000000, 0x000000, 0x000000, 0x000000,
      0xFF, 0x000000, 0x000000, 0x000000, 0x000000,
      0xFF, 0x000000, 0x000000, 0x000000, 0x000000,
      0xFF, 0x000000, 0x000000, 0x000000, 0x000000,
      0xFF, 0x000000, 0x000000, 0x000000, 0x000000,
      0xFF, 0x000000, 0x000000, 0x000000, 0x000000 ]
« Last Edit: February 03, 2018, 03:52 AM by redguy »

Offline redguy

  • Jr. Member
  • **
  • Posts: 54
  • Karma: +148/-0
    • View Profile
Re: programmable address map
« Reply #1 on: February 02, 2018, 04:53 AM »
Not sure if anyone has a use for this, but I updated it to v2 (see first post).  More effort was spent meeting timing than making the actual changes so it's done for now.

Offline TheShadowRunner

  • Full Member
  • ***
  • Posts: 116
  • Karma: +8/-0
    • View Profile
Re: programmable address map
« Reply #2 on: February 02, 2018, 06:44 PM »
Thanks for this! ^^