Shop OBEX P1 Docs P2 Docs Learn Events
Propeller II update - BLOG - Page 91 — Parallax Forums

Propeller II update - BLOG

18889919394223

Comments

  • jmgjmg Posts: 15,173
    edited 2013-10-09 18:55
    cgracey wrote: »
    These instructions completely stall the pipeline and are not useful for multi-tasking. What the cog can do afterwards on the pins, though, looks like hardware on the scope - perfect timing. I didn't make an any-edge version, because it seemed practically useless. If you want to trigger on both edges, you can use alternating WAITPOS/WAITNEG's.
    I guess, but this does cost more code. There are DDR and Manchester apps, where any-edge decisions can be useful.

    If this works with a pin mask, you could wait_any_edge(2 pins) as the core of a SW quadrature counter.
    cgracey wrote: »
    I went through a long mental exercise when designing the counters and determined that counting either negative or positive edges was useful, but counting all edges was superfluous, or even sloppy.

    Counting or timing both edges is less common, (usually because of jitter), but capture on any edge can be quite useful.
  • SapiehaSapieha Posts: 2,964
    edited 2013-10-09 19:42
    Hi Chip.

    As I like it --- I still have question on it?
    Can them have ----Time out?


    cgracey wrote: »
    Really interesting idea, jac_goudsmit. Something like that wouldn't even require any more flip-flops. I'll see what I can do there. Wait.. I just realized that it wouldn't catch intervening events, so it's not going to be a solution to the did-a-change-happen? problem.

    I abandoned the course I was on with the extra registers - too big and messy. Instead, I exploited an input-pin mux that was already present for the pin instructions and made an edge detector that stalls the pipeline until the desired edge event occurs. These are only for single-task programs that need to have perfect registration to external (pins) or internal (XCH) events edge events:

    WAITPOS D/#n 'specify pin and wait for positive edge
    WAITNEG D/#n 'specify pin and wait for negative edge

    They work beautifully. They turn the cog into an edge-triggered flip-flop, which jmg would appreciate. These are way simpler to use than WAITPEQ/WAITPNE would be, and they detect the edge event, not just states, so one of them does the trick.

    I think these two instructions will make fast XCH comms a snap. Using these to frame nibble/byte/word moves over I/O pins should make fast inter-Prop2 comms possible, too.
  • cgraceycgracey Posts: 14,155
    edited 2013-10-09 19:56
    Sapieha wrote: »
    Hi Chip.

    As I like it --- I still have question on it?
    Can them have ----Time out?

    Yes!!! That's practically free. I can just borrow the timeout detector from WAITPEQ/WAITPNE. Good thinking! I'll add the any-edge mode, too. That makes three: WAITPOS/WAITNEG/WAITANY. What's a better name: WAITCHG or WAITANY?
  • potatoheadpotatohead Posts: 10,261
    edited 2013-10-09 19:59
    I like WAITCHG. Seems to me it would raise fewer questions than WAITANY would. Change leads somebody right to positive or negative edges by virtue of those instructions being there. WAITANY immediately triggers, "What is any?"
  • Bill HenningBill Henning Posts: 6,445
    edited 2013-10-09 20:00
    WAITCHG I think...

    I am a bit unclear on weather these would work on a specific pin number, or a pin mask like WAITPE/WAITPNE

    if it is a mask, does it block until all pins rise/fall/change, or until just one?

    Can I assume these WAITxxx instructions behave like one cycle instructions, ie release the stall in the following cycle?
    cgracey wrote: »
    Yes!!! That's practically free. I can just borrow the timeout detector from WAITPEQ/WAITPNE. Good thinking! I'll add the any-edge mode, too. That makes three: WAITPOS/WAITNEG/WAITANY. What's a better name: WAITCHG or WAITANY?
  • CircuitsoftCircuitsoft Posts: 1,166
    edited 2013-10-09 20:13
    cgracey wrote: »
    These change-sensing flops would be in the hub circuitry to minimize the flip-flop count.
    Wouldn't this re-create the synthesis clock tree problem you had with clocking on the chip-to-chip comms?
  • SapiehaSapieha Posts: 2,964
    edited 2013-10-09 20:20
    Hi Chip.

    Thanks -- That give much possibility's.

    What on naming --- As You know --- English are not my power language

    cgracey wrote: »
    Yes!!! That's practically free. I can just borrow the timeout detector from WAITPEQ/WAITPNE. Good thinking! I'll add the any-edge mode, too. That makes three: WAITPOS/WAITNEG/WAITANY. What's a better name: WAITCHG or WAITANY?
  • cgraceycgracey Posts: 14,155
    edited 2013-10-09 20:25
    WAITCHG I think...

    I am a bit unclear on weather these would work on a specific pin number, or a pin mask like WAITPE/WAITPNE

    if it is a mask, does it block until all pins rise/fall/change, or until just one?

    Can I assume these WAITxxx instructions behave like one cycle instructions, ie release the stall in the following cycle?

    These are at least 2-clock instructions because they need to develop a 2-clock history for comparison before they can release.

    WAITPOS/WAITNEG/WAITCHG take a pin number as the input, not a mask. WAITPEQ/WAITPNE use 32-bit mask and compare values, instead.
  • cgraceycgracey Posts: 14,155
    edited 2013-10-09 20:26
    Wouldn't this re-create the synthesis clock tree problem you had with clocking on the chip-to-chip comms?

    No. It's all the same clock domain. The whole core is one clock.
  • jmgjmg Posts: 15,173
    edited 2013-10-09 21:40
    cgracey wrote: »
    What's a better name: WAITCHG or WAITANY?

    WaitAny reminds me too much of
    'Press any key'
    'Where's the any key ? '
    So change or delta are better, and CHG packs into 3 letters so WAITCHG is fine.
  • jmgjmg Posts: 15,173
    edited 2013-10-09 21:47
    cgracey wrote: »
    These are at least 2-clock instructions because they need to develop a 2-clock history for comparison before they can release.

    WAITPOS/WAITNEG/WAITCHG take a pin number as the input, not a mask. WAITPEQ/WAITPNE use 32-bit mask and compare values, instead.

    If an edge arrives just before this instruction starts, does it see it ?
    or does the opcode auto-clear an edge detect, which then can catch an edge how close to the opcode start ?
    ie what apertures does this have ?

    If it was just polling a 2FF edge detector, that has single clk outputs, and it could catch an edge arriving close to the same time as the opcode. (given the 2FF parallel pipeline effect)
    An edge arriving before the wait part of the opcode, is discarded as unseen.
  • Timothy D. SwieterTimothy D. Swieter Posts: 1,613
    edited 2013-10-09 21:52
    jmg wrote: »
    WaitAny reminds me too much of
    'Press any key'
    'Where's the any key ? '
    So change or delta are better, and CHG packs into 3 letters so WAITCHG is fine.

    I was going to reply with the same thing. Where is the any key? I am still looking for it. My vote is WAITCHG.
  • RamonRamon Posts: 484
    edited 2013-10-09 22:03
    jmg wrote: »
    I guess, but this does cost more code. There are DDR and Manchester apps, where any-edge decisions can be useful.

    More code in a loop translates in reduced speed. And this could be very usefull for LPDDR (as LPDDR has no minimum operating frequency, unlike DDR). I know that P2 cannot interface directly to the reduced voltage of LPDDR, but maybe other protocols could benefit.
  • RamonRamon Posts: 484
    edited 2013-10-09 22:07
    Ramon wrote: »
    More code in a loop translates in reduced speed. And this could be very usefull for

    I mean that any-edge decisions could be more usefull (not more code and reduced speed).
  • Cluso99Cluso99 Posts: 18,069
    edited 2013-10-09 22:13
    WAITxxx instructions...

    WAITPEQ WAITPNE, WAITPOS, WAITNEG, WAITCHG and WAITCNT and WAITVID

    Are the cccc (conditional execution) bits required???

    I am asking this because I cannot recall using conditionals on these instructions.

    If they were available, this would provide the instruction extension bits for...
    • Optional cnt timeout (instead of using WC)
    • Optional poll versions of these
    • This would free the WC & WZ flags so we would know if it were a timeout (C) and the pin states (Z)
    • We also have the "R" bit available.
    If more than 1 pin was specified (use a mask as for waitpeq/waitpne), then the WAITPOS, WAITNEG, WAITCHG should wait for just 1 of the pins to go POS/NEG/CHG. This then complements the WAITPEQ and WAITPNE nicely.

    Just a thought.
  • potatoheadpotatohead Posts: 10,261
    edited 2013-10-09 22:36
    I've used conditions on WAITVID to control things like sync differences between standards and or to provide different pixel options depending on some data read mid-frame. At higher resolutions and driver complexity levels, time and code space are important.
  • jmgjmg Posts: 15,173
    edited 2013-10-09 22:55
    Cluso99 wrote: »
    ...

    If they were available, this would provide the instruction extension bits for...
    • Optional cnt timeout (instead of using WC)
    • Optional poll versions of these
    • This would free the WC & WZ flags so we would know if it were a timeout (C) and the pin states (Z)
    • We also have the "R" bit available.

    If there are variants possible, then sticky/non sticky could be useful.

    Non sticky is a read-only poll of a 2-D-FF + XOR edge detector. Prior edges are simply missed.

    Sticky has to add a JK FF, so any edge sets and opcode-test clears. Prior edges are caught, but their timing may skewed.
    More resource is needed for sticky, as the opcode now also writes to the edge-cell.
  • dMajodMajo Posts: 855
    edited 2013-10-10 05:15
    cgracey wrote: »
    I went through a long mental exercise when designing the counters and determined that counting either negative or positive edges was useful, but counting all edges was superfluous, or even sloppy.

    If it will be a counter mode available for incremental encoders, counting on both the edges of the A and B signals will quadruple the encoder ppr resolution.
  • SeairthSeairth Posts: 2,474
    edited 2013-10-10 06:59
    cgracey wrote: »
    These instructions completely stall the pipeline and are not useful for multi-tasking.

    All the more reason to support (using the task registers) a cooperative tasking mode! :)
  • SeairthSeairth Posts: 2,474
    edited 2013-10-10 07:45
    With WAITPOS/WAITNEG/WAITCHG, SPI would be almost trivial to implement as a pure software solution. Add two shift registers and a few instructions (see [post=1211433]#235 in the other thread[/post]), you can shift out bits from SRA on one edge and shift in bits to SRB on the other edge. With the hardware support, this would make the loop approximately 8-10 clock cylces (WAITPOS and WAITNEG each take two cylce, the shift instructions each take one cycle, the branch instruction takes a cycle, maybe increment a counter, etc.) giving a throughput of maybe 10-15MHz. It might not be as fast as some would like, but I think it would cover 80% of the use cases out there (at least until the better, faster, strong P3 arrives).

    I'll also point out that the receive UART could also be implemented using the same instructions. However, I am not arguing that the current serial hardware should removed (I don't want to start that conversation again here). I'm just pointing out the possibilities...
  • KC_RobKC_Rob Posts: 465
    edited 2013-10-10 09:33
    Seairth wrote: »
    All the more reason to support (using the task registers) a cooperative tasking mode! :)
    Seairth wrote: »
    With WAITPOS/WAITNEG/WAITCHG, SPI would be almost trivial to implement as a pure software solution. Add two shift registers and a few instructions (see [post=1211433]#235 in the other thread[/post]), you can shift out bits from SRA on one edge and shift in bits to SRB on the other edge. With the hardware support, this would make the loop approximately 8-10 clock cylces (WAITPOS and WAITNEG each take two cylce, the shift instructions each take one cycle, the branch instruction takes a cycle, maybe increment a counter, etc.) giving a throughput of maybe 10-15MHz. It might not be as fast as some would like, but I think it would cover 80% of the use cases out there (at least until the better, faster, strong P3 arrives).

    I'll also point out that the receive UART could also be implemented using the same instructions. However, I am not arguing that the current serial hardware should removed (I don't want to start that conversation again here). I'm just pointing out the possibilities...
    I like how you think, Seairth. You haven't managed to lose your focus, props(!) for that. :)
  • jmgjmg Posts: 15,173
    edited 2013-10-10 12:26
    Seairth wrote: »
    .... giving a throughput of maybe 10-15MHz. It might not be as fast as some would like...

    You are correct it is not as fast as some would like.

    It would seriously limit the edge that P2 has, to make it a me-too struggler.
    Lots of parts can do 10~15MHz, with less CPU used, and less power, than a P2 bit-bashing.

    This approach is fine for adding extra shifters, but the hardware should also support UART/Sync/SPI modes, to whatever limit the pins impose (50MHZ+?)
    If you have used all that already, then move to SW versions.
  • jmgjmg Posts: 15,173
    edited 2013-10-10 12:29
    dMajo wrote: »
    If it will be a counter mode available for incremental encoders, counting on both the edges of the A and B signals will quadruple the encoder ppr resolution.

    I think the counters can now do that in hardware.

    When Chip releases the details, someone could test this new mode in field conditions.
  • Bill HenningBill Henning Posts: 6,445
    edited 2013-10-10 12:38
    +1

    10-15Mhz is not fast enough for many uses.

    I'd like to see clkfreq/2 for spi master, and ideally for slave as well (though it may have to be /3 with an external clock), with the cog only having to deal with 8 bit or larger chunks. That way, fast master/slave drivers can run as a task.
    jmg wrote: »
    You are correct it is not as fast as some would like.

    It would seriously limit the edge that P2 has, to make it a me-too struggler.
    Lots of parts can do 10~15MHz, with less CPU used, and less power, than a P2 bit-bashing.

    This approach is fine for adding extra shifters, but the hardware should also support UART/Sync/SPI modes, to whatever limit the pins impose (50MHZ+?)
    If you have used all that already, then move to SW versions.
  • Cluso99Cluso99 Posts: 18,069
    edited 2013-10-10 15:48
    Currently I am struggling to read 12MHz (using 80MHz clock) because I have to sample every 7/6/7 clocks (6.667). I can do that but no processing is possible. I know the real hardware will double the speed. Some of these instructions will help. So will a serial shifter, especially on the input side.
  • SeairthSeairth Posts: 2,474
    edited 2013-10-10 19:34
    Out of curiosity, how do the WAITPEQ/WAITPNE instructions work internally? Are they just examining the INx register itself, or are is it checking deeper than that? If checking the register, it might be nice to generalize those instructions for any register. Combine this with tasks (and the new changes to the WAITxxx instructions where they don't stall the pipeline), this would allow for an effective synchronization mechanism between tasks.
  • KC_RobKC_Rob Posts: 465
    edited 2013-10-11 07:53
    Heater. wrote: »
    pjv,

    Don't say "interrupt". That word is banned around here.

    Say "event driven". Which is what you always wanted anyway. :)

    It's just a case of having the right events for your threads to wait on.
    Event-driven is certainly the ideal. I suppose its zenith might be an automated system which can launch a cog to process an event. Then, program flow is in no way "interrupted" yet events are processed in a timely, automated manner - sans blocking and code stratagems. This also makes efficient use of cogs, since a cog is used only when the event requires processing.
  • cgraceycgracey Posts: 14,155
    edited 2013-10-11 12:23
    jmg wrote: »
    If an edge arrives just before this instruction starts, does it see it ?
    or does the opcode auto-clear an edge detect, which then can catch an edge how close to the opcode start ?
    ie what apertures does this have ?

    If it was just polling a 2FF edge detector, that has single clk outputs, and it could catch an edge arriving close to the same time as the opcode. (given the 2FF parallel pipeline effect)
    An edge arriving before the wait part of the opcode, is discarded as unseen.

    The trouble is that you don't know what pin to start staring at until the instruction is at pipeline stage 4, so edge monitoring cannot happen early. Well, it could happen early if we had 2 stages of 128 flip-flops that always monitored every pin signal, but 256*8 more flops is too many.
  • David BetzDavid Betz Posts: 14,516
    edited 2013-10-11 12:52
    cgracey wrote: »
    The trouble is that you don't know what pin to start staring at until the instruction is at pipeline stage 4, so edge monitoring cannot happen early. Well, it could happen early if we had 2 stages of 128 flip-flops that always monitored every pin signal, but 256*8 more flops is too many.
    How about if the first time you execute one of these edge detection instructions it always fails to detect an edge no matter what the state of the pin but it remembers what pin is being monitored so it can constantly sample it until the instruction comes around again at which time you return the real result. So, if the pin in the instruction matches the one that is being remembered then you return a real value. If not, you change the pin being remembered and start monitoring that new pin until encountering another instruction checking the same pin. I guess that's a bit convoluted though.
  • jmgjmg Posts: 15,173
    edited 2013-10-11 12:55
    cgracey wrote: »
    The trouble is that you don't know what pin to start staring at until the instruction is at pipeline stage 4, so edge monitoring cannot happen early. Well, it could happen early if we had 2 stages of 128 flip-flops that always monitored every pin signal, but 256*8 more flops is too many.

    Ah ok, so the structure is a 128:1 mux and then a local edge detector ?
    This would have a leading edge blanking scheme, to avoid false-triggering when activated on a pin already hi ?
Sign In or Register to comment.