I'm trying to simulate a binary counter that is supposed to be activated by a button B, then count until 40, reset and stop until B gets pushed again. If B is pushed while the counter is working it resets and starts over.
I'm supposed to build this with simple stuff like flip flops. I already have an 8 bit counter available with a clock and Reset input entries.
I know how to read 40 off the counter (2^5+2^3, or when outputs 5 and 3 are true).
I think I need a variable B, for the button, a variable T, which is $$\lnot (C_5.C_3)$$ (C is the counter's outputs, so T will be true while the counter's output isn't 40), and R which is the value of reset. I tried to draw the state diagram:
I'm not sure which are flip flops and which are variables here or even if this is entirely correct. I think I am supposed to use a flip flop for R but I don't really know how to go about it.