SE-VGA

techav

Tinkerer
Nov 30, 2021
17
43
13
github.com
@Kai Robinson suggested I share this here, originally posted to Tumblr on May 25, 2021 --

SE-VGA​

Inspired by recent work on creating modern reproductions of the Mac SE logic board and following my previous CPLD VGA generator project, I’ve been working on a PDS card for the Mac SE that mirrors its video on a VGA monitor.

I’m using a similar approach to the [bbraun] project, which used an stm32f4 to watch the SE’s CPU bus for writes to the SE frame buffer memory addresses. Instead of using a microcontroller I’m using an Atmel ATF1508AS CPLD to monitor the SE CPU bus for writes to the frame buffer addresses and storing the data in a pair of 32kB SRAM chips. The CPLD then reads back the video data to generate a 640x480 monochrome VGA signal with the SE video in letterboxed in its original 512x342 resolution.

image

image

The circuit itself is fairly straightforward. The CPLD runs everything off a single clock signal from a can oscillator, and uses the pair of SRAM chips for video memory. Other than those four chips, there are a few passive components. It’s simple enough I could have built one with point-to-point wiring or even wire-wrap. But, to reduce debugging and the potential for noise disrupting the SE’s normal operation, I decided to lay out and order some small PCBs.

I got these from JLC for $2 plus shipping and they arrived in just under two weeks. Build was easy enough. I used the drag solder technique with a lot of flux to solder on the 100 pin QFP package CPLD and it went on with no problems. Everything else is through-hole.

I tried to take a methodical approach to build and debug. I started with just the CPLD and clock to make sure it could generate a proper sync signal that was recognized by my monitor. That much worked without issue, so I moved on to testing if it could read data from its VRAM bus and display it. This part took some work with a logic analyzer and a few rounds of updates, but eventually I was able to tie one VRAM Data pin high and get it to display lines.

From there, I added the VRAM sockets to test if it could properly read from VRAM and display its contents. SRAM powers on to random contents, and when I added the SRAM to the board and powered it on, I was greeted with a screen of random pixels. VRAM was working, and the video generator was displaying a stable, consistent image.

image

image

At this point there was only one thing left to do — solder on the (expensive!) DIN 41612 connector and test it out in the SE.

image

image

image

Well, it was half working.

I had half of the image on screen, so it was clearly recognizing CPU write cycles, storing it in VRAM, and recalling it in sequence. I quickly found and corrected a bug in the code looking for the 68000 lower data strobe (!LDS), and inverted the final output and tried again.

image

It … Wasn’t quite right. It started out fine while Mac OS was booting. There was a little noise in the image, but not too bad … until it reached the Finder. By the time it was finished booting, it was flashing, alternating between valid video data and a garbage data. The garbage data seemed to be encroaching on the valid data as well, the longer the system ran.

The first bug didn’t take long to find. The classic Macs, including the SE actually support double-buffered video. They have a primary frame buffer and an alternate frame buffer, selected by setting or clearing one output bit on the VIA chip. I designed the card to support both frame buffers, and to also watch the CPU bus for writes to the specific VIA bit that controls frame buffer selection. I had calculated the VIA address wrong though, so it was swapping between frame buffers when it shouldn’t have and that’s what was causing the flashing.

I still had the problem of garbage data being displayed however. This one took a while to figure out, and I’m actually still not sure how it was happening to begin with.

The logic analyzer showed that every so often a VRAM write cycle would overlap with a VRAM read cycle. The VRAM write state machine shouldn’t have allowed that to happen, but it was. Unable to find anything that would cause the cycles to overlap, o added a test to delay the write cycle if it detected a current read cycle.

The result?

image

No more garbage data.

I really can’t believe it. I wasn’t sure I could get this to work, and I wasn’t sure it would fit into a CPLD with only 128 macrocells. To top it off, this is my first real project using System Verilog instead of VHDL.

It’s not perfect yet. There is one column of garbage data being displayed on the left of the image, and it looks like the last column off the right is also ending up on the left. But, it is completely useable.

I’m not finished with this project yet. I want to bump it up to XGA resolution (1024x768), which would allow the SE video to be pixel doubled and take up more of the screen. The 65MHz clock necessary for XGA is hard to come by, so I’m thinking about spinning up a rev 2 board that uses an FPGA instead of a small CPLD.

This has been a fun project. It’s always so exciting for a project to have visible results.

I have the project on GitHub if anyone is interested in taking a closer look.
 

techav

Tinkerer
Nov 30, 2021
17
43
13
github.com
Originally posted to Tumblr on July 27, 2021 --

Rev 2​

image

I’ve been working on laying out a Rev 2 board. It’s proven to be quite a bit more challenging than the first.

I had a few goals for the second revision:
  • Fix a few bugs from the first board
  • Change resolution to 1024x768
  • Add support for more than just SE PDS
The first was minor, mostly just cleaning up some poor design decisions around the output voltage shifter.

The second is something I mentioned already as on my to-do list. Instead of displaying the Mac 512x342 image surrounded by a black box in a 640x480 frame, it would be better to pixel-double the image to 1024x684 and display it letterboxed in a 1024x768 frame. This requires a 65MHz clock, which is not that common for can oscillators. After some digging around, I’ve decided to use a common 13MHz crystal with a configurable clock multiplier set to 5x for the 65MHz pixel clock.

The last change was a suggestion from [Kai Robinson] — add a footprint for the 68000 CPU so the board could be inserted in place of the CPU, leaving the SE PDS slot free for an accelerator. This has the added bonus of making the board compatible with the Plus and 512k models as well.

The first two changes were easy. That last one though has been a challenge. The 68000 signals are reversed from the layout of the PDS slot. Every signal had to cross itself. In addition, on the Plus, there is no room beyond the CPU without running into the tops of the RAM SIMMs. I tried putting the PDS connector on one end and the 68000 footprints on the other, but never could get all of the signals past the CPLD without adding layers. I completely started over on routing this board half a dozen times.

Finally, I came up with this layout that puts the PDS connector between the 68000 footprint for the board, and a socket footprint to hold the 68000. The right-angle DIN 41612 connector needs a little space where the board rests against the back edge of the connector for stability; the bottom pins for the 68000 board connector fit into this space.

While I was working on it, I also changed to surface-mount SRAM chips. Not only are these parts cheaper than, DIP, they’re much lower-profile. That would allow this board to be used with a straight DIN 41612 connector in early SE units that don’t support vertical PDS cards. In this arrangement, the board would be installed component-side down towards the SE motherboard, so thinner is better.

I’ve spent the last couple days just cleaning up the ground pours and silkscreen layers. I think I’ve done all I can at this point, time to place the order. The last boards just took a couple weeks to arrive. As of right now, the CPLD is back-ordered for … a couple weeks. Perhaps if I order now they’ll all come in around the same time.

In the meantime, the CPLD configuration will need significant rework to support the new output resolution.
 

techav

Tinkerer
Nov 30, 2021
17
43
13
github.com
Originally posted to Tumblr on October 19, 2021 --

SE-XGA​

I’ve been working on the new revision of my SE-VGA project I mentioned previously.

SE-VGA rev2 boards, unassembled

SE-VGA first assembled rev2 board

These new boards use nearly all surface-mount parts, instead of the through-hole parts used on the first boards. The biggest functional change is the can oscillator has been replaced with a 13MHz crystal and a selectable clock multiplier — this allows a 65MHz pixel clock for running 1024x768@60 resolution (XGA) instead of the 640x480@60 (VGA) from the first boards. The Mac 512x342 resolution can be pixel doubled to fit into an XGA frame, with small black boarders (letterboxing) top and bottom.

I’ve rewritten the logic from scratch. The original logic was overly-complicated and I wasn’t able to adapt it to the new resolution. Of course they means a whole lot of debugging, and brings to fore a problem with moving to small surface-mount components — no place to attach test leads.

Adding small wires to a rev2 SE-VGA board for debugging. The wires are taped down to prevent them from coming loose.

I soldered some 30ga wire-wrap wire to key signals (in this case the VRAM control signals) so I could watch them with a logic analyzer for debugging. These pins are quite small, no larger than the wire itself. Soldering to them was finicky and took a few attempts. I taped the wires down to prevent them from pulling out while working.

An SE-VGA rev2 board assembled for use on early classic Macs, being tested for clearance on a Mac Plus motherboard.

Another big difference with these new boards is they support not just the Mac SE, but also older 68000 Macs as well. Here I’ve assembled one for a Mac Plus and I’m testing its fit around other components on the Mac Plus motherboard.

The logic is coming along well. I’ve encountered many of the same problems I had with writing the VGA logic and had to solve them all over again. At this point it does show the whole frame of video, but I have some random glitches with VRAM writes, and some of my timing is a little off. It is working as a proof of concept though. I should be able to clean up the logic and get it running smoothly.

This project has some interesting firsts for me. It’s the first project I’ve ever designed a second revision and ordered a second round of boards for. It’s also the first project I’ve ever made more than one of. Depending on how things go I might actually do a third board revision to clean up anything I find not working reliably.
 

demik

Tinkerer
Oct 11, 2021
31
29
18
Nice, I've heard about this possibility but never managed to meet someone who did it. Good job !

Are you using an USB Blaster to program it ?
 

techav

Tinkerer
Nov 30, 2021
17
43
13
github.com
I built a parallel port programmer following a diagram in an old Atmel datasheet. Requires an XP machine with a proper parallel port to run AtmelISP V6.

I recently read that openocd supports the USB Blaster and the Atmel chips. I need to try it. Would save the step of copying to an old computer.
 

alxlab

Active Tinkerer
Sep 23, 2021
287
305
63
www.alxlab.com
Hey techav glad you decided to post here! I've been following this project and your accelerator project and their both awesome :)

I had a question regarding screen mirroring on old BW Macs that isn't entirely related to your approach for mirroring but maybe you would have some thoughts on.

I currently have a Power R Model 2703 with basically takes the video signals from the Mac SE logic board cable and converts it to a 512 x 342, 22.25Khz hsync and 60Hz vsync over a db9 connector with CGA pinout for green, hsync and vsync.

@Stephen has made the schematic for the Power R Model 2702 made for the Plus. A similar was also made by daniel at http://www.waveguide.se/?article=compact-mac-video-adapter

Would it be possible to use you 1024x768 scaling on the video signal generated by the Power R adapters? Is my understanding correct that it's more difficult to handle the analog signal from the Power R adapter than the digital signals from the PDS slot to convert?
 

techav

Tinkerer
Nov 30, 2021
17
43
13
github.com
Would it be possible to use you 1024x768 scaling on the video signal generated by the Power R adapters? Is my understanding correct that it's more difficult to handle the analog signal from the Power R adapter than the digital signals from the PDS slot to convert?
You'd want RGB2HDMI or something like a traditional Extron video scaler for that.

I'm not working with the original video signals at all. I'm caching the video buffer data as the CPU writes it to main memory and generating my own video & sync signals from scratch.

A video scaler that works from a video stream is much harder. It requires using a PLL to lock into the sync signals, then buffering the incoming video data one pixel at time as it streams in, then generating the scaled output video signal. Well beyond my current skill level.
 
  • Like
Reactions: Kai Robinson

Mu0n

Active Tinkerer
Oct 29, 2021
578
532
93
Quebec
www.youtube.com
Awesome progress and it's pretty funny all this happens as I've just finished soldering/assembling 2 units of RGB2HDMI this week and am about to test it out on a Classic 1.