For quite a while I had been wanting a member of the TED series. These are the computers from Commodore that employ the TED chip as their heart - the C16, the Plus/4 and their lesser known siblings, the C116, C264 and even C364.
What I really wanted was a Plus/4 because it just looks so good. A real cursor pad and better ergonomics than the C16. But an auction turned up and I got my hands on a untested C16 for an excellent price - it turned out to be fully functional (except a few broken traces on the keyboard matrix), and I upgraded it to 64 KiB and so on. What you'd usually do.
The TED computers share some common functions and are generally compatible with each other. After upgrading my C16 I had been wondering whether it would be possible to add internal function ROMs to the it. Its sibling, the Commodore Plus/4, ships with internal functions ROMs that provide the productivity software suite, but other, more interesting, options are also available. One thing they share is allowing for external function ROMs, on the Plus/4 you can have 32 KiB of internal ROMs (divided into 16 KiB "high" and "low") and the same externally in the cartridge port. The Commodore 16 only allows the external ROMs out of the box.

I wanted to find out if it would be possible to add something internally to the Commodore 16 as well.

Determining feasibility

With these kinds of things you can usually do whatever you dream up, but how much work is it? How much do you have to add to the machine to get it support internal function ROMs? A good place to start is comparing the Plus/4 and C16 schematics.

Plus/4 address decoding circuit
Looking at the Plus/4 schematics, you can see that the circuitry responsible for generating the right chip select signals is fairly straight forward. There are some flip flops for the address lines and some simple combinational logic that produce the chip select signals. The ones I'm interested in are the lines going to pin 22 (output enable) on U25 and U26. Pin 5 on an 74LS139 produces the low function ROM enable signal, and pin 11 on the same IC produces the high function ROM enable signal.

TED banking
If you look closely there's something interesting going on in the circuit. It's not something that particularly interests me, in this quest to support internal function ROMs, but interesting nonetheless. The C1 high and low signals are the external function ROM select signals. But what are the C2 high and low signals? It turns that it's the bank marked as "reserved" in the documentation. The C2 lines are actually available on the cartridge port, so the Plus/4 does actually support 64 KiB of external ROM, without the use of additional circuitry. But that's a project for another day.

C16 address decoding
So that's the Plus/4. What about the C16, which is what I'm really interested in? Well would you look at that! It is virtually identical to the Plus/4 circuit. Interestingly, you can see that the C16 also generates the C2 low and high chip select signals, so this too will support 64 KiB of external function ROMs. The only thing missing from the circuit are the internal function ROMs themselves. Everything else is intact. U14 is also a 74LS139 that produce the chip enable signals. The inputs are exactly the same, and pin 5 and 11 are marked "N.C." for not connected. Since the circuit is otherwise identical, those pins will produce exactly the chip enable signals we need to add internal function ROMs - pin 5 provides the low function ROM enable signal and pin 11 the high function ROM enable signal.

It looks like adding internal function ROMs will be as easy as putting EPROMs on the bus and wiring up the enable signals.

Implementation

The first thing I want to do, is to make sure that pin 5 and 11 on U14 are, in fact, not connected to anything, like ground. Visual inspection of the board suggests that this is indeed the case. Using a multimeter it's possible to determine that the resistance from these pins to ground is 22 MΩ, which is perfectly normal from a logic output to ground. At this point I'm just going to go ahead and put some high and low function ROMs on the bus and connect them to the (almost certainly correctly generated) enable signals.

Function ROM high and low
I grab a couple of 27128's and burn the Plus/4 software package to the two chips.
An easy way to get these on the bus is to stack them on top of the kernal ROM. By the way, there are some absolutely glorious examples out there of stacked chips. Anyway, stacking chips is easy, you just solder all the pins together, not connecting the ones you need to treat differently. I'm just interested in providing a different output enable signal (pin 22 on the 27128) to my new function ROMs, and I bend out those pins slightly.

Stacked ROMs
Moving on to stacking the chips. I test all the connections from the top IC to the bottom one using a continuity tester after soldering. Finally I connect the two output enable signals identified earlier.

The moment has arrived. It looks good in theory, but does it actually work?

It's alive

That's so cute, it thinks it's a Plus/4

Tidying up

OK, the C16 does in fact support internal function ROMs. All Commodore had to do was add a few IC sockets and wire them up, and users would have been able to plug in ROMs themselves. But the C16 was made to be cheap, and adding extra sockets would have increased the board size and supplying empty sockets for the tiny amount of users actually going to populate them? No, doesn't sound like a good idea.
But I am exactly the kind of person who wants to do that. And I would like to be able to easily burn new function ROMs, and having to desolder and resolder the EPROMs from my otherwise fantastic stack doesn't look particularly appealing. Ideally I'd also like to have the JiffyDOS kernal in the machine, and be able to switch in the old kernal if necessary.
At this point, making a board that plugs directly in to the kernal IC socket looks pretty easy. But a board with three or maybe four large IC's on it, sitting on top of a single socket, doesn't seem like a great long term solution, especially not if you're going to move the machine around.
Basically I want to add three ROMs, and with the original kernal that's four 16 KiB ROMs. Which would fit nicely on a single 27512.

"Hmm," he wonders ...

Okay new goal - I decide I now want to be able to put four ROMs into one image like this:

$0000-$3FFF - JiffyDOS Kernal
$4000-$7FFF - Kernal
$8000-$BFFF - Function Low
$C000-$FFFF - Function Hi

There's three output enable signals generated by the motherboard, I call them them /KE (kernal enable, supplied by the kernal IC socket), /FH (function high enable) and /FL (function low enable). An additional signal for selecting JiffyDOS or the regular kernal is needed, which will be supplied by a simple switch and pull up resistor combination, called /JD. All active low.

/JD = JiffyDOS enable (active low)
/KE = kernal enable (active low)
/FL = function low enable (active low)
/FH = function high enable (active low)

The motherboard provides A[13:0], but I need to generate the 27512's A14 and A15 signals somehow. With the ROM layout above, A15 is simply a select line that chooses between kernal or function rom. The A14 line selects between JiffyDOS and regular kernal when /KE is low, and between function ROM low and high when /KE is high. The last part can be done by just selecting /FL when /KE is high - it's not necessary to bring /FH into the equation, because when /FL is low, /FH is high, and when /FL is high, /FH is low.
The /OE signal is pretty simple in comparison, it needs to go low when any of /KE, /FL or /FH are low.
The formulas for these combinational circuits look like this:

This looks like more logic than I'm really hoping for. I'm going to need a few IC's from the 7400 series to do this. Unless ... A14 is basically a multiplexer. And multiplexers contain a fair amount of circuitry that can be configured to produce various useful functions if you drive unnecessary inputs high or low. Maybe there's one that could implement both A14 and /OE at the same time? There's comprehensive list of 7400 IC's on Wikipedia

There's a couple of candidates here, those with two units are optimal (only two combinational circuits need to be implemented), and those ICs have the largest number of inputs. Of those the 74153 looks best, inverting outputs is not something I want at this point. What does the 74153 actually do?

That is quite an impressive amount of circuitry, already it looks much more promising than simple AND or OR gates.
I'll start out by defining that output Y1 is A14 and Y2 is /OE. The two strobe G1 and G2 signals (active high) are not needed, I'll tie those to GND.
Crucially, /KE and /FL are both necessary inputs to the signals I need to generate, so I'll assign those to the A and B inputs, as those are used in each unit.
For the A14 circuit, I'll tie 2C0, 2C1 and 2C2 to GND, which will drive some of the AND gates' outputs low. 2C3 will be connected to /FH, and the remaining AND gate will now perform the function of the A14 circuit, and the OR gate is just a pass through.
For the /OE circuit I'll assign /JD to 1C0 and 1C1, and /FL to 1C2 and 1C3. The third AND will always output 0, because its function includes FL*/FL which is always zero. The fourth AND gate performs /KE*/FL*/FL which trivially reduces to /KE*/FL. The first two AND gates perform FLKE/JD and /FLKE/JD. Since the outputs of these two are OR'ed together, the FL and /FL inputs can be ignored, and together these two AND gates perform the KE*/JD function.


Another experiment

I can't wait to try this out. I burn a 27512 EPROM with the layout defined above and grab a breadboard. I populate it with my EPROM, a 74153 and quite a few wires. I switch on the C16 and ...

Success! I have a 64 KiB EPROM with two kernals and high and low internal function ROMs. I'm ecstatic that this is possible, all that remains is assembling a nice board that I can plug into the C16's kernal socket. It won't be a solderless solution, it will still require soldering some leads to the high and low function ROM enable signals, but I'm certain it will look pretty neat when it's done.

The breadboard implements a circuit much like this one, but the completed board is a topic for another post.