Shop OBEX P1 Docs P2 Docs Learn Events
Can a propeller be used to drive a Z80 at 4 MHz? — Parallax Forums

Can a propeller be used to drive a Z80 at 4 MHz?

cbmeekscbmeeks Posts: 634
edited 2015-05-10 01:26 in Propeller 1
I was thinking of using a propeller to drive a Z80 based computer. The prop would be responsible for the 4 MHz clock and the 8K ROM. Basically the address/data lines would be tied to the prop and the prop could delegate certain tasks such as simulating video memory, external peripherals, etc. Also, it would provide the 4 MHz clock signal.

Is this possible? Or, is 4 MHz simply too fast for bit-banging those pins?

Thanks.

Comments

  • kwinnkwinn Posts: 8,697
    edited 2015-04-23 06:28
    Yes, it's possible, and similar things have already been done.
  • cbmeekscbmeeks Posts: 634
    edited 2015-04-23 06:38
    I haven't tried this yet but I will later on when I have access to my scope. But how fast can those pins be toggled with a prop?

    Thanks.
  • kwinnkwinn Posts: 8,697
    edited 2015-04-23 06:59
    Using a simple pasm program you can toggle a pin at 10MHz. Using the counters I think the highest is 128MHz. Both answers are when using a 5MHz crystal and running the prop at 80MHz. By setting up the counters in a cog to generate the clock for the Z80 you can then use the same cog to monitor the address and data bus to perform I/O or other functions. Prop and Z80 work really well together.
  • cbmeekscbmeeks Posts: 634
    edited 2015-04-23 07:04
    Wow. 10 MHz is more than fast enough for my retro computer.

    And I wouldn't have thought that 128 MHz would have been possible. My scope only goes to 100 MHz. lol

    Now I'm curious, could two cogs be used to "interleave" a high/low signal somehow so that you could double the bandwidth?
  • cbmeekscbmeeks Posts: 634
    edited 2015-04-23 07:32
    Actually, I have a better followup question.

    Let's say I have the Z80 tied to the prop via the addr/data bus. Next, when the Z80 requests address $D000 (or whatever), could the propeller then switch over to maybe an SPI SRAM chip (like on the Propeller Memory Board) and pass the information through? Like a "glue" logic between the prop and Z80?
  • PublisonPublison Posts: 12,366
    edited 2015-04-23 08:11
    cbmeeks wrote: »
    Wow. 10 MHz is more than fast enough for my retro computer.

    And I wouldn't have thought that 128 MHz would have been possible. My scope only goes to 100 MHz. lol

    Now I'm curious, could two cogs be used to "interleave" a high/low signal somehow so that you could double the bandwidth?

    There are a lot of Application Notes you could read about the possibilities of the Prop:

    https://www.parallax.com/download-family/propeller-p8x32a-application-notes

    There. I just gave you a reading assignment for the next week. :)
  • cbmeekscbmeeks Posts: 634
    edited 2015-04-23 08:25
    Thank you. That was a great reference.
  • Brian FairchildBrian Fairchild Posts: 549
    edited 2015-04-23 09:22
    Have a look at other retro computers using a retro chip linked to a more modern one. Most of them drive the clock line from an IO and vary the clock rate as needed to give them enough time to do useful stuff. Using a CMOS Z80 means it doesn't care what the clock rate is.
  • Cluso99Cluso99 Posts: 18,069
    edited 2015-04-23 15:58
    We have a whole Z80 emulation running on the propeller (see the ZiCog thread, the RamBlade thread, and the numerous DracBlade threads). A prop emulates the whole Z80 running slightly above 4MHz.
    There are other threads where the prop has been used to emulate the ROM on a real Z80 and IIRC also the peripherals.

    So what you want to do is possible :)
  • cbmeekscbmeeks Posts: 634
    edited 2015-04-23 16:02
    That's awesome. :-)

    One thing I'm finding difficult is how can I simply toggle a pin at X times per second?

    I'm not finding any tutorials like that.

    I'd prefer C over SPIN if I could.

    Nevermind. Found it.
    #include "simpletools.h"
    
    
    int main() {
    
      square_wave(0, 0, 4000000);
    
      while(1) {
      }    
      
    }
    
  • ElectrodudeElectrodude Posts: 1,658
    edited 2015-04-23 17:52
    You should look into using counters instead. Each cog has two counters that run independently of the cog, and one of them would be perfect for a set-and-forget clock like this one. square_wave uses up an entire cog which could be better used doing something else. Even if you don't need all of the cogs, using counters will use less power.
  • cbmeekscbmeeks Posts: 634
    edited 2015-04-23 18:03
    Oh that's a great idea. Do you have a C example?
  • Cluso99Cluso99 Posts: 18,069
    edited 2015-04-23 18:31
    cbmeeks,
    I think you will find that you will have to get into pasm to do the timing stuff.
    pasm is not that difficult because the language is very regular and you will only use a small portion of the instruction set.

    There is an app note for the counters and there are examples that came with PropTool.
  • davidsaundersdavidsaunders Posts: 1,559
    edited 2015-04-23 19:23
    I seriously doubt that you will get the needed timing from C, even if done completely in COG C.

    You will want to use PASM, the simplest language on the propeller (and its assambly language).
  • cbmeekscbmeeks Posts: 634
    edited 2015-04-24 05:13
    That's fine. I don't have a problem with assembly (been coding 6502 for over 30 years). I just use C more in my day-to-day coding.

    Thanks.
  • Cluso99Cluso99 Posts: 18,069
    edited 2015-04-24 05:45
    Well then you will find pasm easy!
  • DavidZemonDavidZemon Posts: 2,973
    edited 2015-04-24 07:14
    I think you may find inline assembly to be your good and dear friend. Combining that with FCache makes for a great program and you can use CMM or LMM for the non timing-critical pieces.
  • cbmeekscbmeeks Posts: 634
    edited 2015-04-24 07:58
    Cluso99 wrote: »
    Well then you will find pasm easy!

    Well, it's not a matter of being easy. I've done PIC assembly too. The issue is learning yet another platform. lol

    C is ambiguous.
    I think you may find inline assembly to be your good and dear friend. Combining that with FCache makes for a great program and you can use CMM or LMM for the non timing-critical pieces.


    Not familiar with CMM or LMM.
  • Cluso99Cluso99 Posts: 18,069
    edited 2015-04-24 15:52
    No.PIC is not easy, nor are any of the others easy in assembly. However, the Prop bucks this - it really is easy!

    There are only 16 registers, most of which you won't use. No need to learn, nor initialise, a whole lot of registers!!!

    Coupled with that, all instructions are
    conditional opcode destination, [#]source [with carry],[with zero], [no result]
    Only exception if the rdxxxx/wrxxxx instructions.

    Printout the single page cheat sheet (summary), read common instruction brief, and you're done.

    for example, here is a led flash program (spin starting of the program not shown, just a single cog/core program)
    DAT
                  org       0
    entry         mov       dira, #1                'set P0 as output
    :loop         mov       count, delay            'setup delay
                  xor       outa, #1                'invert P0
    :here         djnz      count, #:here           'delay
                  jmp       #:loop
    
    count         long      0
    delay         long      80,000,000              '1s delay (current clock speed 80MHz)
    
    Note I didn't use the lower power option of a waitcnt instruction.

    And here is the rest of the required program to start this cog
    CON
    
      _clkmode = xtal1+pll16x
      _xinfreq = 5_000_000
    
    PUB Main
    
      cognew (@entry, 0)            'start the LED cog
      cogstop(cogid)                'stop this cog
    
    
    That's all there is to it!
  • LawsonLawson Posts: 870
    edited 2015-04-24 16:16
    cbmeeks wrote: »
    Not familiar with CMM or LMM.

    CMM and LMM are the names of two methods the C compiler uses to run compiled code out of Hub ram. LMM is an extremely small interpreter that uses PASM for most of the op-codes. (except for jumps, and interpreter calls) AFIK, CMM is similar, but uses some assumptions to compact PASM op-codes down to 16-bits. (I think the restrictions are fixing the destination, stripping ICZN bits and stripping conditional execution bits) Both interpreters have an overlay loading function, called Fcache, that will insert short bits of ASM inline to run at full speed.

    If you're familiar with C and inline ASM code, I'd assume that everything works the same as usual and that you can ignore all these implementation specific details for now. I.e. don't worry about this stuff till you've filled Hub ram or are optimizing for speed.

    Marty
  • cavelambcavelamb Posts: 720
    edited 2015-05-08 22:35
    From the other trhead...

    the ultimate Z80-Propeller project...

    http://searle.hostei.com/grant/cpm/
  • Toby SeckshundToby Seckshund Posts: 2,027
    edited 2015-05-09 03:00
    I built the CP/M that Grant described and used a Prop1 for the VDU stuff. Whilst I was at it I put on some jumper options to allow for the 7.3MHz clocking to be Xtal or the Prop (separates for the CPU and SIO). It did work off of counters (using the simple OBEX code) but the old Z80 couldn't go much faster than 7MHz anyway. it did give a bit more controll over the serial speeds to / from the SIO though.

    I then got interested in his cheap (pick - and - mix) FPGA version, which would trundle along at +15MHz. Then I moved house and lost the WS setup, I must get back into it all ...
  • cavelambcavelamb Posts: 720
    edited 2015-05-09 14:03
    I've never played with FGPAs.
    But a 15 Mhz Z80 might make it worth while!
    Hope you get it all back up and running again.
  • Toby SeckshundToby Seckshund Posts: 2,027
    edited 2015-05-09 23:26
    Now that the weather is getting better the shed is a viable place to work (and hide). The FPGA bits will allow for faster than 15MHz but that seemed to be the fastest-reliable speed when it was talking to an external SRAM to get the CP/M 64Kb, even though the SRAM recons it's 15nS. I think that Grant may be a "6502 guy" as those seem to be his favorite. He did choose the same M$ basic as was on my much lamented Nascom (so I was always a Z80ite). His articals are very simple to follow along with - they must be for me to almost understand (some of it).

    I still have the Z80B and Prop version, tucked away in a box, and it is faster than Cluso's arrangement (twin Props - with Kbd/VDU), but only about double for all of the extra work that was required (but then, I do like the making of things - rather than actually using them). I made quite a few of the Dracboard / Pullmoll version, these only ran about 2MHz equivalent but were self contained to just the one Prop, I made one into the back of a PC Kbd/ We were all waiting for the Prop2 to come along and then CP/M etc should have been so much easier (but I still like DIP chips - eyes banjaxed!)

    And yes, Heater, I do acknowledge that it was all started by your 8080 stuff ;-)
  • rod1963rod1963 Posts: 752
    edited 2015-05-09 23:47
    Sowerbutts also has a FPGA version of the Z-80 running but his is at 128 Mhz using the T-80 cpu core(from opencores.org). Though he doesn't use SRAM but SDRAM 8MB also running at 128Mhz. It runs CPM 2.2, MPM and UZI.

    http://sowerbutts.com/socz80/
  • Heater.Heater. Posts: 21,230
    edited 2015-05-09 23:59
    Toby,

    ZiCog is still waiting for the Prop II...
  • TorTor Posts: 2,010
    edited 2015-05-10 01:26
    You can still buy new 20 MHz Z80 CPUs (in DIP if you wish). I have a few in some box somewhere. Actually an SBC too. Runs CP/M, but IIRC it's clocked a bit slower than max.

    -Tor
Sign In or Register to comment.