8 bit computer without RAM - Page 1
Forum section: electronics / projects

author: ChristofferB
author_rank: Frequent Contributor
timestamp: July 27, 2015, 01:49:16 am
content: Hi again!Okay, so I've been out of the computing 'tronics for 4 months or so, and that means new project!- I'm trying to see how simple one could actually go with a small 8-bit system. I've been messing around with some preliminary designs, and the plan is making a z80 computer that is literally just CPU, EPROM, output latch and whatever MEM/IO decoding logic I need.The EPROM will hold a few bytes of code just outputting patterns or so.Question is- If I don't need to store anything on the fly, would a system like this need RAM? I'd like to keep chipcount at a minimum at first.Thanks!

author: TheMG
author_rank: Frequent Contributor
timestamp: July 27, 2015, 02:32:13 am
content: My question is... why?There is a large variety of 8bit microcontrollers available (such as Microchip PIC) that have EEPROM, RAM, I/O and even the clock oscillator built in. Literally a single-chip solution. They're available in everything from small 8-pin packages to large 40+ pin versions depending on how much I/O you need.Anyways, without RAM it's extremely limiting what you can do. Even something as simple as displaying patterns. Presumably you don't want it to run full-tilt, and want to be able to slow down the time between each pattern. That will require some form of counter, which will need RAM to store values.

author: Kjelt
author_rank: Super Contributor
timestamp: July 27, 2015, 05:29:25 am
content: I think you do not need RAM if the internal registers are sufficient.However this will severely limit you're programming options.

author: Ian.M
author_rank: Super Contributor
timestamp: July 27, 2015, 05:52:36 am
content: I've built one! I once took a microcontroller course and for some dumb reason the assigned project was a RAMless Z80 + Z80 PIO to control a set of model traffic lights for a four way junction with pedestrian crossing.The problem is, no RAM = no conventional stack so no subroutines and no way of returning from an interrupt to where it came from. The constraints usually result in evil spaghetti code.Far more interesting is a ROMless Z80 board. The trick for that is to attach it to a PC printer port and after reset, make it wait for a byte on the printer port on every read from memory. Writes go to memory as normal. This mode is turned off under software control after a bootloader or monitor program has been transferred from the PC.

author: C
author_rank: Super Contributor
timestamp: July 27, 2015, 06:19:55 am
content: http://www.z80.info/zip/z80cpu_um.pdfPage 28 is ram less examplePage 29 adds ramC

author: ChristofferB
author_rank: Frequent Contributor
timestamp: July 27, 2015, 12:36:17 pm
content: Quote from: TheMG on July 27, 2015, 02:32:13 amMy answer is... whynot? - No really, you're absolutely right, there's no "reason" for doing this. My interest in digital electronics dies with anything made after the mid-to-late 80's, so it's simply because I find it more interesting.Quote from: Ian.M on July 27, 2015, 05:52:36 amThat's encouraging! And yes, that ROMless trick is indeed very interesting! - One should be able to do something similar with reading from paper tape..Quote from: C on July 27, 2015, 06:19:55 amHow was I to know that the z80 datasheet had data about the z80?- Yeah, should've consulted that in a little more detailAnd of course it'd be a tiny feat to add some RAM, you could basically just solder it on top of the ROM with a few modwires, and i will at some point.My plan is to make the simplest possible z80 system, that can actually do things, IE. not just running NOPs. I'm using the mem and IO decode scheme as made by Grant Searle, but at this point I don't have anything to communicate via serial, so I won't be adding the UART and/or rs232 interface either. yet.--Christoffer

author: BloodyCactus
author_rank: Frequent Contributor
timestamp: July 27, 2015, 12:51:03 pm
content: no stack makes it seem very pointless. but whatever floats ones boat eh.

author: McBryce
author_rank: Super Contributor
timestamp: July 27, 2015, 01:01:44 pm
content: If you want a challenge and like 80's hardware, then add a floppy controller and get it to boot from a disk.McBryce.

author: Pjotr
author_rank: Frequent Contributor
timestamp: July 27, 2015, 01:05:05 pm
content: Consider the Zilog Z8, It's quite old but it has a 256 byte register stack you can use as ram as well. Also pretty handy to program in assembler for small logic related tasks. It's 20 ago I used those and in those days they came without an embedded EE program prom. Today for simple tasks Atmel Tiny's are the Swiss army knife.

author: Andy Watson
author_rank: Super Contributor
timestamp: July 27, 2015, 01:06:47 pm
content: Omitting the RAM means (at least) one less chip and less address decoding. There was a design for an MSF radio clock (I think it that went by the name of "Rewbichron") that used a Z80 to decode the signal and drive the display all without external RAM.

author: ChristofferB
author_rank: Frequent Contributor
timestamp: July 27, 2015, 01:24:46 pm
content: Quote from: Pjotr on July 27, 2015, 01:05:05 pmI actually have made a z8 machine, with the Z8671 chip which is the z8 with built-in 2k tinybasic. I've ever gotten it properly working though, and the architecture is very very different from most other 8-bit processors- think it's Harvard architecture.Another goal with this, I forgot to mention, is that I want the smallest system that I can develop my z80 assembly programming skills on. Until now, I've been using my ZX spectrum, with a small BASIC program to punch in machine code, but the IO on the speccy is horrible to figure out.Quote from: McBryce on July 27, 2015, 01:01:44 pmThat would be pretty neat, maybe at some stage!

author: T3sl4co1l
author_rank: Super Contributor
timestamp: July 27, 2015, 01:26:58 pm
content: http://seventransistorlabs.com/tmoranwms/Elec_Z80.htmlOnce you've got everything wired up, it's practically a trivial step further to add RAM and more ports.Tim

author: Kalvin
author_rank: Super Contributor
timestamp: July 27, 2015, 01:31:52 pm
content: In the old days, it wasn't uncommon to add more system RAM by piggy-packing and soldering the new chips onto the existing RAM chips and to wire the chip selects separately. It wasn't pretty, but it worked.Selecting an EPROM/FLASH and RAM so that they are pin-compatible makes the piggy-packing possible. Would that be useful, I do not know as you are creating the board from the scratch anyway, so you can add the socket for the RAM.

author: Pjotr
author_rank: Frequent Contributor
timestamp: July 27, 2015, 02:54:49 pm
content: Quote from: ChristofferB on July 27, 2015, 01:24:46 pmFunny you mention the ZX Spectrum. I actually build a lot of controls for art installations with those things. All programmed in assembler. There was a neat 2-pass in-line assembler available for it. But hell, the 2 passes took half an hour with cassette tape as storage. Concerning the bus: That is not all that difficult, near all the processor lines are available there and you can hook up all the Z80 peripherals to it including interrupts. It will be more difficult to find a proper connector I guess.But if your goal is to master assembly coding, I suggest to look for something more more modern. As long as the instruction set of the MCU is clever and neat laid out. The art of assembly coding by itself does not differ much between processors, if it a 6809, a Z80, Z8 or ATmega. Only their structure en mnemonics differ. But definitely stay away from the PIC's, assembly coding is a nightmare with them.Hooking up an Atmel 8-bit controller in a DIP package on a piece of breadboard is a snap. Lots of diy ISP programmers available on the net, although I myself stick with Atmels own $30 USB programmer I got for free from a kind Atmel representative here. And all development tools for PC are free. IAR has even a very good professional assembler for free.Ar do you have particular needs for a Z80 in special?

author: technix
author_rank: Super Contributor
timestamp: July 27, 2015, 03:20:24 pm
content: I don't think it will add too much complexity if you added some RAM. 6116 chips are cheap and that 2K RAM will make your system design a lot easier.By the way, one of my most commonly used SIP cores for my CPLD and FPGA projects, is a SIP-based configuration-free DDR3 controller. When coupled to a DIMM module as used in normal computers (I usually use a 2GB DDR3-1333 SO-DIMM module that was a reject from my computer upgrade) it gives me some (in my case, 2GB) of cheap RAM space.

author: technix
author_rank: Super Contributor
timestamp: July 27, 2015, 03:25:59 pm
content: Quote from: Pjotr on July 27, 2015, 02:54:49 pmIf you would like to learn assembler I would definitely suggest either x86 (including amd64) or ARM (both A32 and A64), the two most used processor architectures in the world. x86 is used in most PCs, servers and supercomputers, and ARM is appearing everywhere, from servers (AMD K12 Opteron) to desktops (Raspberry Pi) to mobile devices (Apple iPhone and Samsung Galaxy S) to embedded platforms (Arduino Due.)Z80 is largely being phasing out in new designs.

author: Pjotr
author_rank: Frequent Contributor
timestamp: July 27, 2015, 03:34:46 pm
content: Quote from: technix on July 27, 2015, 03:25:59 pmOf coarse you can get you potatoes at home with a 20-tons truck. But is that is handy for learning driving?

author: ChristofferB
author_rank: Frequent Contributor
timestamp: July 27, 2015, 03:36:21 pm
content: Quote from: Pjotr on July 27, 2015, 03:34:46 pmHah, yeah, that's basically what I mean. I want it as basic as possible.

author: ChristofferB
author_rank: Frequent Contributor
timestamp: July 27, 2015, 03:36:43 pm
content: No real need for the z80, nope. it was just the processor I had on hand, and the one I'm most familiar with. And again, no doubt that everything becomes smarter with microcontrollers, but I'm trying to keep it very very retro, as the computer electronics in the 70's and 80's is what really interests me.And IN the matter of vintage 8-bit processors, I don't think there is an instruction set neater than that of the z80. maybe the 8088, but the hardware is way more involved.My particular troubles with the zx spectrum (+2), is the I/O decoding. I couldn't really find an empty I/O address, and the ones I tried didn't work.And of course, going x86 or ARM would be wayy more useful, but it's not a skill I need for anything other than personal interest, and if you want to develop your hardware yourself, it gets a bit hard with the more modern processors.

author: technix
author_rank: Super Contributor
timestamp: July 27, 2015, 03:53:52 pm
content: Quote from: ChristofferB on July 27, 2015, 03:36:43 pmNot really - you can design your project around a i80486DX chip - still basic enough, but you are just one recompile away from getting your code from that 486DX to a dual Xeon behemoth computational powerhouse.Also if you are willing to GPL your code, going x86 or ARM will allow you to lift code out of existing projects - UEFI, SeaBIOS, U-boot, and most importantly, Linux kernel. For example, even with only a 486DX, if you want to add a tested and trusted network stack, you can just use the code from Linux kernel and you are good to go.Thanks to the flexibility of U-boot, even with your home-grown bus architecture around an x86 or ARM chip, you can always get a full blown Linux running on it if the chip supports all the required features (MMU). This will reduce a lot of code you will have to write, and save you a lot of time.

author: ChristofferB
author_rank: Frequent Contributor
timestamp: July 27, 2015, 04:00:52 pm
content: Quote from: technix on July 27, 2015, 03:53:52 pmI suppose that's right, and as I mentioned earlier, there are no "real" reasons to use hardware as antiquated as I do, but that's just what interests me the most.And I'm really not aiming for anything as advanced as that. Right now, software-wise, if the end goal is a small bootloader and maybe some tinybasic; even that's way above my ambitions. I might do an x86 project at some point, but that's far in the future right now.

author: zapta
author_rank: Super Contributor
timestamp: July 27, 2015, 04:06:56 pm
content: Quote from: ChristofferB on July 27, 2015, 01:24:46 pmWithout RAM you will not be able to use half of the instructions ;-)

author: ChristofferB
author_rank: Frequent Contributor
timestamp: July 27, 2015, 04:09:55 pm
content: Quote from: zapta on July 27, 2015, 04:06:56 pmI knoow, I never said it was agoodidea, and RAM is probably the first expansion I'll make

author: eas
author_rank: Frequent Contributor
timestamp: July 27, 2015, 04:11:00 pm
content: Quote from: zapta on July 27, 2015, 04:06:56 pmBonus simplification!

author: ChristofferB
author_rank: Frequent Contributor
timestamp: July 27, 2015, 04:13:56 pm
content: Did someone say "Reduced Instruction Set Computing" ?

author: Pjotr
author_rank: Frequent Contributor
timestamp: July 27, 2015, 04:27:47 pm
content: Quote from: ChristofferB on July 27, 2015, 03:36:43 pmCan't remember exactly how I did it 30 years ago but it shouldn't be a problem. Controlled whole array's of LED's, AD and DA converters with it. If you search the net for "zx spectrum i/o map" I am sure something useful will come up.Hé, you could hook up a printer, extra RS232 ports and a fantastic "Super tape drive" (that only worked a few times) from Sinclair itself to the extension connector.

author: SeanB
author_rank: Super Contributor
timestamp: July 27, 2015, 04:47:58 pm
content: How about the 8155 RIOT? 256 bytes of ram, some IO and a timer, and you can interface it almost directly to the Z80.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: July 27, 2015, 05:09:36 pm
content: Learning?Start with AVR. No contest.It's available, it's common, it's well documented (if not always by the manufacturer... but Atmel is no Microchip, let's just say that!), and it's easy to learn (nearly orthogonal -- i.e., instructions with a given input/output mode, follow the same scoping (reg/imm/mem) rules, for the most part), and it's practical (AVR is current gen, if not the most popular perhaps?).Z80 I'd say is a close second, because it's also easy to use, but has the advantage of being more user-friendly: the instructions do more. AVR is RISC style (load-store architecture), meaning to do the least of almost any elementary operation takes three instructions or so. Z80 has some of that as well, but it's more powerful. And also slower (the original being 3-4 clock cycles per instruction cycle, with the longest instructions taking several instruction cycles to complete).BTW, I think eZ80 is different, so don't dive into that, expecting classic Z80.Once you know an instruction set, you can move on to heavier and more thoroughly demented things, like x86...Doing DOS programs in MASM is pretty easy, but you most likely will not be doing full Windows applications with 32 bit instructions (or 64, for that matter), and floating point and SIMD extensions. At best, those should be left to the core inner loops, with a good trusted compiler filling in everything around. And anyway, almost all things done on that serious of a level, are done relatively quickly -- the CPU operates on what data it has available locally (top level caches), then finishes, waiting for more data from the lower level caches. It's not so important to hand-optimize inner loops for this reason. Optimization today is more about cache size and prediction, being able to get data to the CPU just as it needs it. A poorly written algorithm can waste so much time if it's grabbing data randomly. That, and multiprocessor design (using other CPU cores to share the effort, or doing it on the GPU for that matter).Tim

author: C
author_rank: Super Contributor
timestamp: July 27, 2015, 05:26:46 pm
content: Quote from: ChristofferB on July 27, 2015, 03:36:43 pmTo cure this problem, do like others have done. Add a input to the expansion buss that will disable all on board decoding. One system went further and had a signalON_Board_Decode, an OR of chip selects. Using this signal allowed non fighting add on boards.An Intel development system back then used the following idea. On boot all memory reads came from rom/eprom and memory writes went to ram. The first stage of boot program was1. Set HL register to FFFF2. Jump if HL = 03. Read memory using HL as address.4. Write memory using HL as address.5. DEC HL6. goto #2A simple block copy of rom to ram starting at highest address. By going from high to low allowed adding unknown roms and allowed for roms that decoded to many address blocks.Step#2 jumped to code that allowed patching rest of boot program, Adding more boot devices or init code.The system when ready wrote FF to IO address FF which set a flip-flop changing read from rom to read from ram. It also removed flip-flop from IO space.The developer using this system had a reset able ram based system.

author: ChristofferB
author_rank: Frequent Contributor
timestamp: July 27, 2015, 05:58:17 pm
content: Quote from: SeanB on July 27, 2015, 04:47:58 pmI completely forgot about that. that'd be a good low-chipcount compromize! Thanks!Quote from: C on July 27, 2015, 05:26:46 pmThat's pretty darn smart.I don't want to do a whole lot of work with my ZX spectrum at this point, since The cassette interface died on it, and I'm not at all long enough to make a custom ROM for it. so I can't really use it.

author: C
author_rank: Super Contributor
timestamp: July 27, 2015, 07:27:54 pm
content: If I was building a Z80 today, I would not be thinking small ram or no ram. Huge static rams are not that expensive. You can connect rams greater then 64K to a Z80. Think cheap Huge that you can work with.With access to any kind of mass storage you do not need much rom. My "Lobo Max80' could boot from floppys of almost any size and type & SCSI hard drive or network. The boot rom is 512 bytes. Back then almost any other choice for rom would have required adding a wait state for a slow rom.Designers of Z80's often forget that a write can go to more then one place.An example would be read from ram, write to ram & display ram. Saves time delay syncing with video ram for reads.The Max80 used this idea to make working with bank switching ram easer, gaining speed at almost no hardware cost.C

author: Pjotr
author_rank: Frequent Contributor
timestamp: July 27, 2015, 08:26:56 pm
content: It's what your goals are. If it's just learning assembly coding, you can simply do with a small debug monitor rom or a bootstrap loader rom, 32K - 64K static ram chip, a serial interface peripheral chip and an address decoder. Develop your code on a PC or whatever and download it in the small Z80 system ram through the debug monitor rom / bootstrap loader and run it.

author: ChristofferB
author_rank: Frequent Contributor
timestamp: July 27, 2015, 10:43:40 pm
content: Quote from: Pjotr on July 27, 2015, 08:26:56 pmThat's the plan, more or less.Okay, this is a rather different problem, though on the same project. I got the system I described together, and made a (very) small program to run from ROM.basically puts some value in register A, outputs it, new value, loop. The output port is not decoded: it's just the IORQ and WRITE signals NANDed together to the CLK input on a 74LS374 that then outputs the data bus on some LEDS.Clock is good, running 30 Hz for debug, memrq, addresses and data flickers as expected, but the /IORQ doesn't change, thus not latching. Here's the code, I'm hoping one of you could tell if this is a software thing or a wiring/damaged chip thing.Code:0001 0000 ;**************************************************************************0002 0000 ;* *0003 0000 ;* WorkDammit-32 ROM V.1.0 *0004 0000 ;* *0005 0000 ;**************************************************************************0006 0000 ;* Very simple bit pattern output to port. As of now, *0007 0000 ;* system outputs on all ports simultaneous (no address) *0008 0000 ;* To be run with very slow clock, no pauses! *0009 0000 ;* *0010 0000 ;**************************************************************************0011 0000 ;* *0012 0000 ;* Coded by Christoffer B *0013 0000 ;* 27-07-2015 *0014 0000 ;**************************************************************************0015 00000016 0000 .org 0000H ;start at address 0000 in ROM0017 0000 3E FF TEST:LDA,00FFH ; Load FF into register a, use sneaky 0's0018 0002 D3 00OUT(00H),A ; output value of reg. a via port 00H0019 00040020 0004 3CINCA ;A++0021 0005 D3 00OUT(00H),A ; output value of reg. a via port 00H0022 0007 3CINCA ;A++0023 0008 D3 00OUT(00H),A ; output value of reg. a via port 00H0024 000A 3CINCA ;A++0025 000B D3 00OUT(00H),A ; output value of reg. a via port 00H0026 000D 3E 55LDA,0055H ; Load FF into register a, use sneaky 0's0027 000F D3 00OUT(00H),A ; output value of reg. a via port 00H0028 0011 3E AALDA,00AAH ; Load FF into register a, use sneaky 0's0029 0013 D3 00OUT(00H),A ; output value of reg. a via port 00H0030 0015 C3 00 00JP0000H ;infinite loop0031 00180032 0018 .end ;this ends the programtasm: Number of errors = 0Thanks in advance!

author: C
author_rank: Super Contributor
timestamp: July 28, 2015, 12:09:29 am
content: IORQ is active low. Normally written as /IORQWR is active low. Normally written as /WRYour code should cause /IORQ and /WR to pulse low at same time.if not look for a short.74LS374 CK pin needs a low to high change to latch data.Note: For Z80 data is valid before both go low and stays valid for a short time when ether goes high.A NAND gate would create a low to high change on output when /IORQ goes low or /WR goes low or both go low.So a memory write would also create a low to high change.A NOR gate would create a low to high change when both become low.C

author: ChristofferB
author_rank: Frequent Contributor
timestamp: July 28, 2015, 12:39:49 am
content: Quote from: C on July 28, 2015, 12:09:29 amSorry, should've clarified that; I wrote IORQ and WR because I inverted them, then fed them to a NAND gate, creating an OR gate. but yes, that should be a NOR. That still doesn't explain the never-changing IORQ line. No shorts, /IORQ measures a couple of MOHM to both rails AND surrounding pins. hmm.

author: C
author_rank: Super Contributor
timestamp: July 28, 2015, 12:58:19 am
content: If you have nothing connected to /IORQ and it does not pulse low with that program then probably bad Z80The first bad Z80 I came across cost $500 new with the replacement costing $350 and it was in a home built system.When playing with electronics it is a good idea to add protection if you can.To keep from blowing a Z80 you could use buffer chips to protect the Z80 from your play/debug.C.

author: ChristofferB
author_rank: Frequent Contributor
timestamp: July 28, 2015, 01:09:40 am
content: Well on the bright side they aren't 500$ anymore- Yeah, that's what I was afraid of. And in most books on microcomputer design, every data, address and control signal is buffered, of course that's the proper way of doing it.

author: ChristofferB
author_rank: Frequent Contributor
timestamp: July 28, 2015, 01:18:44 am
content: Nope, zx spectrum sais CPU is fine. damn.

author: C
author_rank: Super Contributor
timestamp: July 28, 2015, 01:57:34 am
content: zx spectrum might not use any IO in the IO address space.If it does then trace all connections to /IORQ pin,Could you be putting to great of load on the /IORQ pin?What all do you have connected to this pin?C

author: matseng
author_rank: Frequent Contributor
timestamp: July 28, 2015, 04:33:56 am
content: Quote from: Kalvin on July 27, 2015, 01:31:52 pmYup, did that back in the late 1970s, if I remember correctly it was 2102 RAMs (1024x1 bit) that I piggybacked eight of in a stack and peeled out the data pin on each of them to get a 8 bit wide databus. Compact and nice. :-)

author: Pjotr
author_rank: Frequent Contributor
timestamp: July 28, 2015, 07:02:10 am
content: Lots of info:http://www.z80.info/index.htmThere you will also find the romless method C described and a small Pascal program to get the code from PC into the Z80 system through the PC's parallel port.

author: HKJ
author_rank: Super Contributor
timestamp: July 28, 2015, 10:50:02 am
content: If you just want to play with z80 assembler, why build hardware when you can get z80 emulators for free?There is a list on the z80 size:http://www.z80.info/z80emu.htm

author: ChristofferB
author_rank: Frequent Contributor
timestamp: July 28, 2015, 11:30:43 am
content: Quote from: C on July 28, 2015, 01:57:34 amChecked /IORQ with a scope and it flickers along happily. should be good.And it's driving a single 74LS04 gate. Should be fine I think.Quote from: HKJ on July 28, 2015, 10:50:02 amThat's true, but a bit like cheating!