Friday, February 10, 2017

Building a 68000 Single Board Computer - PCB Layout

Plot of PCB Layout from Kicad

I spent some time learning how to use Kicad's PCB layout software and created an experimental board layout. I had never laid out a circuit before using CAD software before, so there was some learning curve and I may have made some rookie mistakes. The routing was all done using the FreeRouting software. The resulting layout is quite complex but looks pretty good. It is a double-sized board, and based on the board size, it looks like it would cost about US$200 - US$250 to have three high-quality boards made from a supplier like OSH Park, and less from some manufacturers in China. Before I did that I would probably carefully review the layout a little more.

All files can be found at github.

3D Rendering of PCB Layout from Kicad

Expensive? Well, I just saw a Motorola MEX68KCB MC68000 Educational Computer Board show up on eBay. The minimum bid is US$295. It will be interesting to see if it sells.

Sunday, January 22, 2017

Building a 68000 Single Board Computer - Possible Future Enhancements

I've learned a lot with this TS2 project and done much more with that than I had originally hoped. While I have some more things to work on, I think it is time to put it on the back burner for a while and get back to some other projects.

Looking forward, it might be interesting to do a new revision of the board, which I could call revision 2.x (I called my version 2.0 since it revised the original Teesside design).

Here are some thoughts on some possible changes and features in a new version.

Printed Circuit Board Layout

A printed circuit board would make it much easier and faster to assemble than the wirewrap prototype. Professionally manufactured PCBs that are double-sided (or more), silkscreened, and solder masked can be obtained very inexpensively now from a number of vendors. Since the design is now in a CAD system (kicad) which has a PCB layout facility, it should not be too much effort to lay out a board. I've never used kicad for PCB layout or even laid out other than very simple single-sided boards, so this would be a good learning experience. Now that the design is proven, the risk of a PCB layout should be quite low.

Replace Baud Rate Generator With Fixed Clock Oscillator/Counter

The Motorola MC14411 baud rate generator chip used in the current design is a little difficult to obtain and overkill if only one baud rate is ever used. Newer UART chips have on-chip baud rate generators, but assuming the design stayed with the 6850 to remain software compatible, a baud rate generator could be created with simpler and more easily obtained circuitry. This link, for example, shows how to do it with a 74HC4060 and the existing 1.8432 MHz crystal.

Support Higher Baud Rates (Through Jumpers or Software)

It would be desirable to be able to run the serial port at baud rates higher than 9600, when downloading programs for example. A new baud rate generator circuit would allow this, since the 6850 can run at higher rates given a suitable clock.

Add One Or Two PIA, VIA, or PIT Chips

A parallel port would allow controlling hardware. This could be the Motorola 6820 or 6821, the more powerful MOS Technology 6520 or 6522 VIA, or the Motorola 68210 Parallel Interface/Timer (PIT) which was present in the Motorola ECB.

Optionally Support Line Drivers/Receivers For True RS-232 Serial Ports

True serial ports might be desirable for some users, so the line driver/receiver circuitry from the original TS2 could be included as an option. This could be simplified by using a chip like the MAX232 which does not require +/12V supplies.It might also be useful to support hardware handshaking with RTS/CTS, which currently do not connect through to the FTDI connectors.

Add Connectors For External Parallel I/O, Interrupts, Etc.

A connector for some external signals would be useful if there was a parallel port. The interrupt lines could also be available here.

Replace 25LS2548 Chip

The 25LS2548 decoder chip is quite hard to obtain and may be an impediment to people who want to reproduce the circuit. This could be replaced by more commonly available chips. Probably a 74LS138 decoder plus a 74LS06 open collector driver and maybe and another gate or two.

On-board 5 Volt Power Regulator

To allow running off of unregulated power, an on-board 5 volt regulator could be added, either a 78L05 series regulator or a more modern buck converter.

Add an LED Display

A seven segment LED display would be useful for diagnostics and other purposes. This could be driven from a PIA (if present) or with dedicated circuitry (see the Clements book p.649 for a possible approach to drive a 7 segment LED).

Prototype Area

If there is room on the PCB, an area with a grid of 0.1" holes could be provided for prototyping.

Support Either RAM or EPROM/EEPROM In All Sockets

With a few changes, the design could support either RAM or EPROM/EEPROM chips on any of the memory sockets (the boot code would need to be in ROM). This would allow, for example, 48K or RAM for users who only needed 16K of ROM). It might also be handy to optionally (via a jumper) allow the EEPROM devices to be written to.

Support Larger RAM and ROM Chips

Larger RAM and ROM chips (e.g. 27128, 27256, etc.) are available and could be supported to allow more memory. This would impact the memory map and address decoding circuitry and make it more complex. Given more RAM, the board could potentially run a stripped down version of an operating system such as Linux or Minix.

Mass Storage for File System

To run a "real" operating like Linux would require some form of mass storage for the file system. This could be done with some flash memory and some suitable interface, maybe using an SD card interface intended for Arduinos. This is probably more of a version 3.x feature (at which point maybe I could add video, a real-time clock, Ethernet, etc.)

Saturday, January 21, 2017

Building a 68000 Single Board Computer - Books


While there are many excellent web resources on the 68000 microprocessor, this is something of a nostalgia project and printed books still have a lot of appeal. I'd like to mention a few books on the 68000 that I own and have found useful.

Microprocessor Systems Design 68000 Hardware, Software, and Interfacing, Third Edition, by Alan Clements


This is the book that the TS2 design is described in. At almost 1000 pages, it has full coverage of hardware and software for the 68000 series up to and including the 68030. Everything is presenting in logical manner with many diagrams. If you are more interested only in the software side, you can skip the relevant sections. It came with a CD-ROM that includes a number of tools including a 68000 cross-assembler and simulator.

An Introduction to 68000 Assembly Language, by R.A. & J.W. Penfold


This little book represents the opposite end of the spectrum. Aimed at people who might have owned a 68000-based microcomputer like an Apple Macintosh, Commodore Amiga, Atari ST, or Sinclair QL, if presents the basic of 68000 assembly language programming. In it's 100 or so pages it covers the basic programming model, instructions, and address modes and give a few program examples Nothing is specific to a particular computer. It doesn't go into a lot of depth, but meets the goal of a small pocket-sized book that was inexpensive (British Pounds 2.95 at the time).

68000 Assembly Language Programming, Second Edition, Lance A. Leventhal, Doug Hawkins, Gerry Kane, and William D. Cramer.


This book was the 68000 version of a very popular series of books by Osborne that covers assembly language programming (I also have the 6502 version). At almost 500 pages, it provides extensive coverage of the 68000 including architecture, instructions and addressing modes. It includes many diagrams and dozens of detailed basic and advanced code examples. This edition also covers the 68010 and 68020.


On the hardware side I also referred to my Engineer's Notebooks by Forrest M. Mims III to refresh my knowledge on TTL gates and best design practices.

Friday, January 20, 2017

Building a 68000 Single Board Computer - Another Forth



I found another Forth implementation for the 68000 here. This one was distributed by Albert van der Horst from a Forth group in Holland. Unlike eForth that I described in my last blog post, this one
is compatible with the fig-FORTH standard.

It comes with default I/O routines to use a 6850 UART address $10040 (presumably the Motorola ECB), the same as my TS2.

I was able to build it with the VASM assembler with one trivial change. Loading it onto the TS2 over the serial port, it came up and seems to work fine.

Here is a sample session:

TUTOR  1.3 > GO 3648
PHYSICAL ADDRESS=00003648

68000 fig-FORTH V1.0 
1 2 3 4    OK
. 4    OK
+    OK
. 5    OK
* . 1    OK
." HELLO, WORLD! " HELLO, WORLD!    OK

( LARGE LETTER-F)    OK
: STAR 42 EMIT ;    OK
: STARS 0 DO STAR LOOP ;    OK
: MARGIN CR 30 SPACES ;    OK
: BLIP MARGIN STAR ;    OK
: BAR MARGIN 5 STARS ;    OK
: F BAR BLIP BAR BLIP BLIP CR ;    OK


                              *****
                              *
                              *****
                              *
                              *
   OK

I think it's time to dig out my old copy of Starting Forth by Leo Brodie and refresh my knowledge of this programming language.

Building a 68000 Single Board Computer - Forth

Forth is an interesting programming language. It is an imperative, stack-based, language that the programmer extends by defining new commands. Years ago, I used an in-house developed variant of Forth (we called it Alice) for programming test software. It happened to run on 6809 and 68000 processors.

I looked for available implementations for the 68000 and found a few options. One, for example, was written for early Sun workstations that used 68000 series processors. This was in the 1980s when a Unix workstation with a few megabytes of RAM cost tens of thousands of dollars. I got it to assemble with only a few changes but it relies heavily on calls to the Unix operating system to perform i/o, and would not be easy to port to the TS2. It also looks a little too large for the TS2, wanting to have 96K of memory for storing Forth code.

The Easy68K web site has a copy of this version called eForth. Wrtiten by Bill Muench and C. H. Ting around 1990, this version was adapted by Paul R. Santa-Maria to run on the Motorola MC68000 Education Computer Board (ECB).

Both source code and a S record binary file are in the archive. The binary works perfectly on my TS2, since it is compatible with the ECB.

Here is a short sample session:

TUTOR  1.3 > GO 1000
PHYSICAL ADDRESS=00001000

eForth 68k v1.1
1 .S
 1
1 2 3 4 .S
 1 1 2 3 4
+ ok
.S
 1 1 2 7
* ok
.S
 1 1 14
0 32 DUMP
   0   0  0  4 44  0  0 81 46  0  0 80 30  0  0 80 3A  ___D___F___0___:
  10   0  0 8D E4  0  0 83 AC  0  0 83 B6  0  0 83 C0  ___d___,___6___@
  20   0  0 83 CA  0  0 8C BA  0  0 83 DE  0  0 83 E8  ___J___:___^___h ok
 ok

It should build using the VASM assembler with only a few trivial changes, but I didn't need to since it works "out of the box".

Thursday, January 19, 2017

Building a 68000 Single Board Computer - Tiny Basic


Tiny BASIC is a dialect of the BASIC programming language that was originally written by Dennis Allison for early microcomputers including 6502 systems like the KIM-1. It could fit into as little as two or three kilobytes of memory. I earlier blogged about running the 6502 version on my Replica 1 computer.

Tiny Basic spawned a newsletter called Dr. Dobb's Journal of Tiny BASIC Calisthenics and Orthodontia, which evolved into the magazine Dr. Dobb's Journal. In 1985, the 100th issue of Dr. Dobb's Journal published an article by Gordon Brandly describing a Tiny Basic interpreter he had written for the Motorola 68000 microprocessor.

I came across this and thought I would try porting it to my TS2 computer. It turns out that no porting is needed, as it was designed to run on the Motorola MEX68KECB Educational Computer Board, which the TS2 is compatible with. I simply loaded the Motorola S record file and it came up on the console:

TUTOR  1.3 > GO 900
PHYSICAL ADDRESS=00000900

Gordo's MC68000 Tiny BASIC, v1.2

OK
>

The supported Basic keywords are BYE, CALL, FOR, GOSUB, GOTO, IF, INPUT, LET, LIST, LOAD, NEW, NEXT, PEEK, POKE, PRINT, READ, REM, RETURN, RUN, SAVE, STEP, STOP, AND TO. It is quite a limited version of Basic (it is only about 3K in size!), but some programs have been developed for or ported to it. One that comes with the Tiny Basic distribution is a version of the classic Star Trek game. Here is a transcript of a portion of a game:

> RUN
Do you want a difficult game?  (Y or N): N
Stardate 3200:  Your mission is to destroy 5 Klingons in 30 stardates.
There are 3 starbases.
Enterprise in Q-75 S-31
Captain: HELP
R=Report       S=SR. sensor   L=LR. sensor
G=Galaxy map   P=Phaser       T=Torpedo
W=Warp engine  * Please use one of these commands *
Captain: R
Status report:
Stardate      3200
Time Left     30
Condition     Green
Position      Q-75 S-31
Energy        4000
Torpedoes     10
Klingons left  5
Starbases     3
Captain: G
Enterprise in Q-75 S-31
Computer display of galaxy map

1:   0   0   0   0   0   0   0   0

2:   0   0   0   0   0   0   0   0

3:   0   0   0   0   0   0   0   0

4:   0   0   0   0   0   0   0   0

5:   0   0   0   0   0   0   0   0

6:   0   0   0   0   0   0   0   0

7:   0   0   0   0   0   0   0   0

8:   0   0   0   0   0   0   0   0
    ..  ..  ..  ..  ..  ..  ..  ..
     1   2   3   4   5   6   7   8

Captain: S
Enterprise in Q-75 S-31
Short range sensor
1 . . . . . . . .
2 . . . . . . . .
3 E . . . . . . .
4 . . . . . . . .
5 . . . . . . . .
6 . . . . . . . .
7 . . . . . . . .
8 . . . . . . . *
  1 2 3 4 5 6 7 8
Captain: L
Enterprise in Q-75 S-31
Long range sensor
   1   7   7
   1   1   1
 101   5   1
Captain: W
Captain: W
Warp engine
Sector distance: 10
Course (0-360): 180
Enterprise in Q-84 S-61
Klingon attack
218 units hit from Klingon at S-63
160 units hit from Klingon at S-51
143 units hit from Klingon at S-21
124 units hit from Klingon at S-12
3305 units of energy left.
Captain: S
Enterprise in Q-84 S-61
Short range sensor
1 . K . . . . . *
2 K . . . . . . .
3 . . . . . . . .
4 . . . . . . . .
5 K . . . . . . .
6 E . K . . . . .
7 . . . . . . . .
8 * . . . . . . .
  1 2 3 4 5 6 7 8
Captain: W
Warp engine
Sector distance: 1
Course (0-360): 0
**EMERGENCY STOP**
Spock: "To err is Human."
Enterprise in Q-84 S-61
Klingon attack
242 units hit from Klingon at S-63
172 units hit from Klingon at S-51
189 units hit from Klingon at S-21
 83 units hit from Klingon at S-12
2619 units of energy left.
Shield damaged, 4 stardates estimated for repair
Captain: S
Enterprise in Q-84 S-61
Short range sensor
1 . K . . . . . *
2 K . . . . . . .
3 . . . . . . . .
4 . . . . . . . .
5 K . . . . . . .
6 E . K . . . . .
7 . . . . . . . .
8 * . . . . . . .
  1 2 3 4 5 6 7 8
Captain: 

The article about Tiny Basic was also published in a book: Dr. Dobb's Toolbook of 68000 Programming. I'll have to see if I can find a copy of this.

Wednesday, January 18, 2017

Building a 68000 Single Board Computer - Interrupt Control Circuitry (schematic page 9)

See https://github.com/jefftranter/68000/blob/master/TS2/v2/ts2.pdf

The interrupt circuitry being tested on a breadboard
before it was constructed on the wirewrap board.

The interrupt control circuitry surrounding the 68000 is conventional. A 74LS148 eight line to three line priority encoder, U28, converts the seven levels of interrupt request input into a 3-bit code on IPL0* to IPL2*. Note that each interrupt request input must have a pull-up resistor, except IRQ7* which is always driven by U35A.

The function code from the 68000 is decoded by U32, a 74LS138, and the resulting IACK* output is used to enable a second decoder, U33. U33 is also strobed by AS* and converts the information on A01 to A03 during an IACK cycle into one of seven levels of interrupt acknowledge output (IACK1* to IACK7*). Other function code information supplied by U32 that may be useful in debugging the system is the "user/supervisor" memory access codes and the "program/data" bus cycle codes.

The ABORT switch can generate a level 7 interrupt. This is present on the ECB and with the TUTOR firmware can be used to interrupt program execution. The switch is debounced by cross-coupled NAND gates U34A and U34B and then clocks flip-flop U35A high (it has its data input tied high). The Q* output of the flip-flop goes low, and is connected to the IRQ7* input. Note that, unlike interrupts 1 through 6, a level 7 interrupt cannot be masked or disabled. During an interrupt acknowledge cycle for a level 7 interrupt, IACK7* will go low and clear the flip-flop. The IACK7* signal will also ripple through U7D, U34C and U4F, driving VPA* low to indicate to the 68000 to perform an autovectored interrupt operation. The CPU will then use the level 7 autovector interrupt address in RAM.

Interrupts 5 and 6 are connected to the two ACIAs, allowing interrupt driven i/o to be performed if desired (the TS2 and TUTOR monitor programs do not make use of this). These interrupts are used in the same way on the Motorola ECB board. Like level 7, the interrupts are also configured for autovectored operation. The relevant IACK5* or IACK6* signal will go low and in turn drive VPA* low to perform autovectored interrupt handling.

IRQ4* is also available and configured for autovectored operation. Interrupts IRQ1* through IRQ3* are not -- they could be used with vectored interrupts if external circuitry is added for this.

The interrupt circuitry can be tested from the TUTOR monitor. Pressing the ABORT switch should generate a level 7 interrupt which will produce a "SOFTWARE ABORT" message and register dump.


Pulling IRQ5* or IRQ6* low should cause TUTOR to produce "AV#5 TRAP ERROR" and "AV#6 TRAP ERROR" messages, respectively. In order for this to happen the interrupt mask in the status register must be set to enable these interrupts.