Hi all,
There's been quite a few incremental improvement to the Ice40 Atom in the last few days.
Full details can be found in the git commit logs.
I'll try to summarise these briefly now.
(1) Atom Ice Boot updated
The Atom now starts correctly if the bitstream is loaded into FLASH. The Atom SDDOS ROM image has also been updated with some fixes to improve reliability and compatibility with certain games in the Atom Software Archive.
(2) A full 6522 implementation is now included
A lots of Atom Games (especially the Retro Software titles) make use of 6522 timers/interrupts. The most accurate 6522 implementation I'm aware of is the one maintained by the FPGA Arcade people. Unfortunately it's in VHDL. But I'm getting quick fast now at translating VHDL to Verilog.
(3) Support for 1, 2, 4 and 8MHz CPU speeds
This was part of an general overhaul of the clocking to use a single 25MHz system clock, with synchronous clock enables to slow certain devices down.
The CPU clock speed can be changed on the fly using keys F1..F4.
(4) Support use of LEDs after initialization
The LEDs (outputs) and SPI (inputs) share the same pins on BlackIce. So I've added some bidirectional buffers so these are inputs while the ARM is loading the ROMs, and then outputs after the system has booted successfully.
At the moment the LEDs are:
- LED1 (Blue) indicates the alternative colour palette is selected
- LED2 (Green) indicates SD Card activity
- LED3 (Yellow) indicates the keyboard shift lock is active
- LED4 (Red) indicates reset is active
(5) Test Bench improvements
I'm using iverilog to simulate the design. The test bench pretends to be the ARM, and first loads the ROM images over the SPI (about 6ms). The Atom startup is quite slow, as it spends a lot of time waiting for the 60Hz frame sync pulse.
On my rather elderly workstation, the simulation runs at about 400 processor cycles/second. The test bench runs for 100,000 processor cycles (100ms), and this takes 4 minutes.
During the simulation, the 6502 address and data buses are dumped.
After the ROMs are loaded and reset is released, this is what you see:
Wr: 01xx = xx RST released
Wr: 01xx = xx
Wr: 01xx = xx
Wr: 01xx = 30
Rd: fffc = 3f RST vector read from #FFFC/D
Rd: fffd = ff
Rd: ff3f = a2 LDX @#17
Rd: ff40 = 17
Rd: ff41 = bd LDA #FF9A,X
Rd: ff42 = 9a
Rd: ff43 = ff
Rd: ffb1 = c2
Rd: ff44 = 9d STA #0204, X
Rd: ff45 = 04
Rd: ff46 = 02
Rd: 021b = xx
Wr: 021b = c2
Rd: ff47 = ca DEX
Rd: ff48 = 10 BNE #FF41
Rd: ff48 = 10
Rd: ff49 = f7
Rd: ff4a = 9a
Rd: ff41 = bd LDA #FF9A,X
Rd: ff42 = 9a
Rd: ff43 = ff
Rd: ffb0 = 78
(I've added the disassembly annotations)
To make sense of this, here's a handy atom ROM disassembly:
http://www.acornatom.nl/atom_handleidingen/splitatom/f000.txt
FF3F A2 17 LDX @#17 Set vector table pointer
FF41 BD 9A FF LDA #FF9A,X Get byte from vector data table
FF44 9D 04 02 STA #204,X ..and store in the vector table in RAM
FF47 CA DEX Point to next byte
FF48 10 F7 BPL #FF41 ..and set all 12 vectors = 24 bytes
At the end of the simulation, the state of the screen is dumped and you see:
ACORN ATOM + SDDOS
INTERFACE?
As I'm not simulating the SD card (yet...) this error is expected.
At this point the simulation and real system jump off into the weeds. You can see why by inspecting the simulation.
Rd: ee2f = 00 BRK (after SDDOS Interface? error)
Rd: ee2f = 00
Rd: ee30 = 20
Wr: 01f9 = ee
Wr: 01f8 = 31
Wr: 01f7 = f1
Rd: fffe = b2 BRK vector fetched from #FFFE/F
Rd: ffff = ff
Rd: ffb2 = 85 STA #F2
Rd: ffb3 = ff
Wr: 00ff = ea
Rd: ffb4 = 68 PLA
Rd: ffb5 = 48 PHA
Rd: ffb6 = 29
Rd: 01f7 = f1
Rd: ffb6 = 29
Rd: ffb6 = 29 AND @#10
Rd: ffb7 = 10
Wr: 01f7 = f1
Rd: ffb7 = 10
Rd: ffb8 = d0 BNE #FFC0
Rd: ffb9 = 06
Rd: ffba = a5
Rd: ffc0 = a5 LDA #FF
Rd: ffc1 = ff
Rd: 00ff = ea
Rd: ffc2 = 28 PLP
Rd: ffc3 = 08 PHP
Rd: ffc4 = 6c
Rd: 01f7 = f1
Rd: ffc4 = 6c
Rd: ffc4 = 6c JMP (#0202)
Rd: ffc5 = 02
Wr: 01f7 = f1
Rd: ffc5 = 02
Rd: ffc6 = 02
Rd: 0202 = xx oops! BRK vector not set up at this point
Rd: 0203 = xx
Rd: xxxx = xx
Rd: xxxx = xx
There's also some interesting overlapping of instructions going on. This is probably different to a genuine 6502, as Arlet's core does not claim to by cycle accurate.
Finally, if you want a recommendation for a game to play, try Manic Miner. This is one of Kees van Oss's amazing ports.
This has just been added to the latest version of the archive.
It's quite challenging at 2 or 4MHz!
It's also worth checking out some of the other Retro Software titles:
(Press 6 then F to filter by publisher = Retro Software)
As there's still some remaining space in the iCE40HX8K so I might have a go at implementing Atom SID (a SID based sound card extension for the Atom).
Dave