you only have 2 state bits, once you get 4, you can do it on a faster clock edge,
So if you consider a quad-state/johnson counter, as a first pass. [easier to follow than binary], and what you are coding is a phase lock, or tracking system counter (TSC) that spins that counter to match the Quad IP. It CAN spin at any speed, normally it will do one phase click, and then many,many idle states until the next phase click is needed
IP.TSC
00.00 01.01 11.11 10.10 are all HOLD or do nothing states, MOST clocks will be here00.01
01.11 11.10 10.00 are all DEC(TSC) by one, and output DEC_EN to the long counter00.10
01.00 11.01 10.11 are all INC(TSC) by one, and output INC_EN to the long counterwhich leaves 4 other states
00.11 01.10 11.00 10.01 as different by TWO clocks, so these are illegal and should never happen in a correct margin design. Take them to a sticky-led, perhaps ?.Once you have that working, you can compact the two TSC bits into the Long counter, two LSBs, by change to binary coding, if you really want to save two FFs :) In a FPGA tho, why bother ? ( In a small CPLD, you might take the effort. )
Also, on read/compare of the long counter, if the system WORD size is less than the counter size, you need to capture ALL bits in one clock, in case the counter rolls over between byte/word reads.
Jim Granville,