How do things change in the middle of a clock? - Page 1
Forum section: electronics / projects

author: NivagSwerdna
author_rank: Super Contributor
timestamp: July 31, 2024, 08:43:36 pm
content: I have been trying to reverse engineer a custom bit of 1980s silicon from an arcade game... pin 1 and pin 2 are external clocks... pin 1 normally gets 18 MHz... pin 2 normally gets a derived signal of 18MHz divided by 3 but with a 1:2 duty cycle... Anyway I have simulated the clocks in software to get approximately the same effectChannel 6 is an outputHow can Channel 6 change when either channel 0 (pin 1) or 1 (pin2) are not transitioning? It's almost like it transitions exactly midway relative to channel 0?The sample rate is 200Mz using my LA2016 analyser; the synthesised input signal is approx 3 MHz so well below the sample rate.Is it possible to derive a clock in the middle?

author: Benta
author_rank: Super Contributor
timestamp: July 31, 2024, 09:03:59 pm
content: Look up "propagation delay".

author: wasedadoc
author_rank: Super Contributor
timestamp: July 31, 2024, 09:11:45 pm
content: Quote from: Benta on July 31, 2024, 09:03:59 pmI don't recall propagation delay being that long back then.

author: tggzzz
author_rank: Super Contributor
timestamp: July 31, 2024, 09:12:46 pm
content: In a purely synchronous system, data signals can change at any time - provided the setup and hold times are not violated.When gates were expensive, all sorts of "dirty" tricks were used. Clock gating has a long and inglorious history!Don't forget to check you aren't doing an artefact caused by the LA sampling relatively too slowly.

author: bson
author_rank: Unknown
timestamp: July 31, 2024, 09:39:00 pm
content: If Channel 0 is 18MHz, then a full cycle is 56ns, and a half cycle 28ns.Channel 6 trails this by half of a half cycle, or about 14ns.14ns isn't out of the ordinary for 1980s 74LS logic. About the same as 74HC/74HCT.A single gate output with significant fanout and hence capacitive loading will easily reach it.

author: Benta
author_rank: Super Contributor
timestamp: July 31, 2024, 09:40:10 pm
content: Quote from: wasedadoc on July 31, 2024, 09:11:45 pmIf the top trace is 18 MHz, period is ~55 ns, high/low time ~28 ns. Propagation delay would then be around 10 ns to get the traces shown.Why don't you do a bit of simple maths before shooting from the hip?EDIT: well, bson pressed "Post" faster than me.

author: NivagSwerdna
author_rank: Super Contributor
timestamp: July 31, 2024, 10:30:27 pm
content: As I said above the clock is simulated in this example... it's around 3.7MHz (i.e. around 6 times less than normal operating frequency)The transition between the low-high of the Channel 0 clock to the derived signal is large... 70nsMaybe it is cumulative propagation delays then.. (I don't need to google that)... I guess 3 gates in series could produce something that large.I will change the clock frequency and see if the delay stays the same... I cannot see how it would work though... since six times the clock...

author: NivagSwerdna
author_rank: Super Contributor
timestamp: July 31, 2024, 10:39:46 pm
content: Here's an example using the real clock... 18.18MHz... with Channel 1 being the divided by 3 derived clock fed in to pin 2Here we see Channel 6 changing 15ns after the low-high on Channel 0Maybe I am correlating the wrong edges?

author: NivagSwerdna
author_rank: Super Contributor
timestamp: July 31, 2024, 10:44:43 pm
content: OK... maybe that makes more sense... The output signal is way behind the input clock and the edge causing the transition is actually the one before I was considering...So with a propagation of 70ns the output is more than a cycle of the fast clock late... sounds feasibleThe circuit is probably something like this one. Channel 6 is derived by a combination of bits from the shift register... maybe an AND of two bits.. so the clocks which appear on pins 1 and 4 of 9D are at least a NAND (9D), a NOR (4D), a shift (1P) and maybe 1M, and a combination... maybe that adds up to 70ns.

author: Benta
author_rank: Super Contributor
timestamp: July 31, 2024, 11:08:21 pm
content: Why are you fixated on the low-high transition of the clock?To my eye, the traces indicate high-low triggering. EDIT: so does the schematic you show. Propagation delay of the 74LS107 is 16 ns typ., which tallies with your first traces.

author: joeqsmith
author_rank: Super Contributor
timestamp: July 31, 2024, 11:25:39 pm
content: Crap LA that you can't adjust the threshold for the logic family? Personally, I would start with a scope and make sure what you are seeing with the LA is real.

author: Benta
author_rank: Super Contributor
timestamp: July 31, 2024, 11:33:59 pm
content: I think the OP already did that to get the 18 MHz results.But then operator error stepped in by just downscaling all the signals to 3 MHz, which won't work. Propagation delays are constant and do not scale.

author: tggzzz
author_rank: Super Contributor
timestamp: July 31, 2024, 11:40:51 pm
content: Looking at that schematic, there is no global clock; there is a series of local clocks, some of which are gated. Hence you have to be very careful defining which (local) clock you are observing. Timing will be well-defined relative to an IC's local clock, but poorly relative tootherlocal clocks.(Bloody difficult trying to refer to an IC that doesn't have a unique identifier, but...)For the 'LS164 counters and anything hanging off their outputs, only the positive edge of the clock on pin 8 is important.That pin 8 clock comes the 'LS74 clock, but negated and delayed by 1 or 2 poorly-defined gate delays (the two 'LS02s). And that is repeated before getting back to the crystal.Hence if you are looking at the crystal, there will be several inversions plus poorly-defined delays between that and the 'LS164 outputs.

author: NivagSwerdna
author_rank: Super Contributor
timestamp: August 01, 2024, 06:28:33 am
content: Quote from: Benta on July 31, 2024, 09:40:10 pmAs stated "the synthesised input signal is approx 3 MHz". With this set-up the period is 265ns. By slowing the clock the delay should be more obvious because as stated it is constant.If I take a rising edge then I see 70ns.

author: NivagSwerdna
author_rank: Super Contributor
timestamp: August 01, 2024, 06:39:10 am
content: Quote from: Benta on July 31, 2024, 11:08:21 pmTo be clear again... the first traces have a clock manufactured in software at around 3.77MHz and any delay between CH0 and CH1 there is a manifestation of the S/W not hardware. The 18MHz traces are real hardware.My obsession is because I am speculating the same shift registers (2x LS164 and a LS74) like the schematic; note the actual custom silicon is black box to me but this is normally how it is done. LS764 are +ve edge triggered.On the schematic 9D and 4D effectively cancel each other out... the NAND meets a NOR. The 6B pair can be ignored; that is a delay which is well expired in the examples. So to me that makes +ve edges significant?

author: tggzzz
author_rank: Super Contributor
timestamp: August 01, 2024, 08:42:28 am
content: Quote from: NivagSwerdna on August 01, 2024, 06:39:10 amAssuming the 'LS107 and 'LS74 don't insert clock edges, the circuit is7A.7 -> delay1 -> 9D.6 -> delay2 -> 4D.4 -> delay3 ->1 P.* -> delay4 -> 1N.8 -> delay5 -> 1L.*Each delay? is poorly defined, e.g.delay1 is 8ns (typ) to 22ns (max), with no (min)delay3 is 17ns (typ) to 32ns (max), with no (min)etcAll of those poorly definedand variabledelays add up, so it can be seen why clock gating is problematic.

author: Benta
author_rank: Super Contributor
timestamp: August 01, 2024, 10:46:10 am
content: Quote from: tggzzz on August 01, 2024, 08:42:28 amYes, it's a very old-fashioned and "dirty" design. Today it would be done using synchronous clocking, although that demands a bit more logic (unimportant now, but significant back then).

author: coppice
author_rank: Super Contributor
timestamp: August 01, 2024, 11:18:36 am
content: Quote from: NivagSwerdna on July 31, 2024, 08:43:36 pmIf you are confused by something like this you really need to stop using a logic analyzer, and look at the actual signals. The logic analyzer takes away all the dynamics, and can greatly confuse the beginner. The reality is there is no digital circuitry. All circuitry described as digital is analogue circuitry trying to look digital. Look at the real signal dynamics with an oscilloscope, and the way all the little delays, slow edges and other not-quite-digital aspects of real signals work out will make sense.

author: NivagSwerdna
author_rank: Super Contributor
timestamp: August 01, 2024, 11:26:36 am
content: I don't really understand the relevance of synchronous clocking in this context. All three parts of the LFSR share a common clock.The LS107 is only relevant in the sense that it derives the divide by three logic but the two clocks into 9D are then NANDed to give a clock which is the 18MHz clock enabled by the other divide clocked but the edges are still really defined in terms of the 18MHz clock?The part that is asynchronous is the propagation through the shift registers and any subsequent combinatorial operation.I will have to dig out my notes but I think CH6 is derived from two output bits of the shift registers ANDed together.

author: NivagSwerdna
author_rank: Super Contributor
timestamp: August 01, 2024, 06:51:48 pm
content: With my scope the traces look a lot more scary... (I only have a 2CH scope)Fast Clock CH0Slow Clock CH1Both ClocksFast Clock and Derived signalFast Clock and Derived signal

author: NivagSwerdna
author_rank: Super Contributor
timestamp: August 01, 2024, 07:08:04 pm
content: You have to use your imagination on those traces but I think these are the intended clocks...So the shift registers are ticked twice for each pixel (6MHz Pixel Clock).The lower trace is what I think should come out of 4D... if I had one... mine is deep in the custom chip.

author: bson
author_rank: Unknown
timestamp: August 03, 2024, 08:59:04 pm
content: Quote from: NivagSwerdna on August 01, 2024, 06:51:48 pmThe cyan trace shows significant capacitive loading... It doesn't hit the high TTL threshold until the next rising clock edge!Sorry, but I just can't figure out how images work on this forum software.

author: NivagSwerdna
author_rank: Super Contributor
timestamp: August 03, 2024, 09:03:19 pm
content: Quote from: bson on August 03, 2024, 08:59:04 pmI agree. Maybe that explains why my attempts to reverse engineer this have been so tricky so far...