You are on page 1of 9


Hanliang Zhu


analysis for digital counters

Huazhong (Central China) University of Science and Technology, Wuhan, Hubei, China

Boston University, Boston, MA 02215, USA (Received February 1982; revised November 1982)

An effective is presented. realized matrix method. Key words:


of analysing reduced without



with the help of a matrix flip-flops,

operation may be

The counters

are composed

of simple J-K

having one J and

one K, with connections straightforwardly

to the simplest complicated

mode so that digital counting logic circuits. techniques,

This computer-aided e.g. the waveform

analysis is easier to use than are the traditional


aided design, digital



analysis, J-K flip-flops

The digital counters to be discussed here consist of simple
J-K flip-flops, having only one J and one K. Simple connec-

any column of A. The matrix derived from Figure 2 is as follows: J3 0 0 1
A= 0 0 0 0 0

K3 0 0 1

J2 0 0 0


Jl 0 1 0 0 0 0

Kl 0 0 1 0 0 0,Ql Q3 Q3 Q2 Q2 Ql

tions are used so that the counting may be performed without intricate logic circuits. Traditionally the waveform method has been used to analyse such digital counters (see Figure I). We are proposing, however, a matrix operational method which will prove to be much more effective. Once the mathematical model is developed, the analysis may be performed directly by the computer, so that the results may be obtained more quickly and accurately.

1 0 0 0 0 0

1 0



Mathematical modelling
A three-bit digital counter which consists of three simple
J-K flip-flops is shown in Figure 2. Without any compli-

(2) The initial state of the counter is decided by the original states of the flip-flops in it, so that: So=


cated logical circuits it may count in cycles of certain beats endlessly. Using a matrix operation we can analyse such a digital counter. The procedure for constructing this mathematical model is as follows. (1) We write out a matrix A which reflects the circuit connections of the counter. A is a square matrix. The number of rows or columns is twice the number of counter bits. The rows are called Q3, @, Q2, D, Ql and Ql and columns are J3, K3, J2, K2, Jl and Kl in the present example. Each element in A has its Boolean value which shows the citcuit connection status: 1 means connection, 0 otherwise. For example, since J2 is connected to Ql the value of the element in the fifth row (Ql) and the third column (J2) should be 1. The rest may be similarly deduced. In accordance with circuit principles there is usually only one 1 in
0307-904X/83/04295-07/$03.00 0 1983 Butterworth & Co. (Publishers) Ltd

Here So is the initial state of the counter and Qso, Q20 and QIo are the original status of flip-flops Q3, Q2 and QI. Let us create a matrix Bo to use in an intermediate operation: Bo = IQ30 Q30 Q20 Q20 Qlo


In the example given, if we set So = 000 thenBo= [OlOlOl]. (3) The next state of a particular counter after receiving a clock pulse is determined by its recent state and by the signals appearing at the J and K inputs of each flip-flop, and these signals are determined by the recent state of the counter and the circuit connections. The product of matrices B and A can indicate those signals mentioned above. Suppose that the matrix indicating the signals on the J and K is called P, so:
P=[J, K3 J2 K2 J1 K,]







Vol. 7, August


and Ki. i 6-3 Figure 3 Counting I cycle graph for octal digit 296 Appl. 0 figure 2 Three-bit digital counter For the initial state mentioned P. Sa=Oll Bz = [Ol lOlO] P. = BOA 000100 I = [010101] 000010 :. 7.. Ji.=B*A= [lllOll] CP then s3= 110 = Figure 7 A simple feedback shift counter and its output waveform B3 [101001] [IlOlOl] P3=B3A= then Sq = 000 I-J 3 0 +. (6) A counting cycle graph can be written down as in Figure 3. 0. K3e=0. 001 = This means that flip-flops 3 and 2 have not changed their status and flip-flop 1 has changed from 0 to 1 after receiving a clock pulse. is the signal on J of the ith flip-flop during its original status. = [000010] si= 111 B1 = [lOlOlO] 0 0 0 001000 Lo 0 0-l therefore P1=BIA=[llllO1] then Sz = 000 o-1 Therefore Jae=O. It is easy to describe the counting process when the initial state of a counter has been changed. :. Modelling. Q4 (5) Following the same procedure. thus it can be seen that the counter shown in Figure 2 works with a 4-beat cycle and can function as a divide-by-four counter. 1 Here state S4 is the same as Se. = BOA = [OOllOO] 1 then : i . is the signal on K of the ith flip-flop during its original status.Research Note -J 4 --K d K Q -J 3 d K Q J 2 8. above. if we set the counter to another initial state Se as: Se=5 = 101 -K . B1 = [OlOl IO] Q. 1983. Math. B1 is written from S. Vol. For example.JlO=O and (4) Then the next state of the counter can be determined by the value of the elements in PO and the excitation logic of the J-K flip-flop: Qil= &Jio + QioKio Here Qie is the original status of the ith flip-flop. K Q J 1 a Q- In our example the next state (state 1) must be: Sl= Q~IQzIQ.: PI = BIA 000100 000010 110001 000000 001000 000000 = [OlOl lo] Q2 = [001010] then Q.. is the next state of the ith flip-flop. KzO= O.JzO= K1e=O. August . we have: then Ba= [100110] therefore P.. :. where an octal digit is being used. Qi.

The same procedures are needed in order to find its counting cycle graph. = B. the respective columns in A will be blanked and A will be a non-square matrix. counting will repeat the process previously explained. The counter shown in Figure 5 is another example.= si= 110 B1 = [lOlOOl] therefore Pi = BIA = [OllO] Then fill in elements in PI: P’.. = BOA = [OOOlOO] then sr = 100 So the counter will ignore any clock pulse and will not change its state of Se = 100. (1) The non-square 0 0 A= P3 = B3A = [OOlO] P. Modelling. 1983. = [101010] then sq= B4= 111 [lOlOlO] [lllO] P4=B4A= Pi= [lllllO] matrix A is: 0 0 1 0 0 0 cl 0 0 1 0 0 then & = 001 B5= 1 0 0 0 0 0 [OlOllO] 0 0 1 0 P.A = [lOOl] p. 7. Then the revised P is obtained: Pb = [101001] figure 5 Digital counter with some fixed high-level inputs so Thereafter. August 297 . It is necessary to point out that if the initial state is: &=4= then B. The assembled counting cycle graph can be obtained after considering all the possible initial states. Vol.= [111001] then sg= 110 =sr APPI. these respective terms should be put into their proper place. Math. After finding P.Research Note 5 (2) If we set se = 000 $ 2-7-o-1 then 4 figure 4 Assembled counting 6 -3 T I 3 I Be = [010101] therefore PO = BOA 0100 0000 0010 0001 1000 0000 cycle graph from figure = [010101] = [OOOl] ‘: I Fill two elements into their proper places in POto correspond to the two Js which are connected to level 1. The J of flip-flops 2 and 3 are connected with level 1. it will be as shown in Figure 4. For the given example. A special symbol (4) is used (see Figure 4) to indicate that state 4 ignores the clock pulse. Modification for fixed high-level signals [lOOllO] therefore P2=B2A= Pi= [llOl] [llllOl] then sa = 010 B3 = [OllOOl] If some of the J and/or the K are connected with fixed logic signal 1 (high level).= [101110] 100 [lOOlOl] 3 then s2 = 101 B1= therefore P..

Research Note O-6-5-2 Figure 6 Counting cycle graph for counter I..6-5. In the same way as was described in the previous section. Modelling.+ ! of Figure 5 therefore P. August . It is a divide-by-five counter. Then Bo must be: Bo= [QB~~B~Q(B-~)~.. This shows that the circuit shown in Figure 8 is not actually a counter .. The general case More generally. 1983.KB~J(~--). The counter shown in Figure 8 provides another example. = [Ol lOlO] then Hence the digital counter shown in Figure 5 works with a 5-beat is not able to respond unceasingly to a clock pulse. Modification for fixed low-level signal If some of the J and/or K are connected to logic level 0 (low level). there is a digital counter which contains B bits and its initial state is: So = QB.Q(B-I)~Q(B-z). QIO QIOQIOI In accordance with the given circuit of this counter a matrix A can be written out and POcan then be calculated as a product of B. we obtain: PA = [001001] $ 0. Vol. JIOKIOI 7-1 1 -0 + O-2-3’ (2) If the initial state of the counter is set as: Se = 000 then Brj = [010101] Figure 9 4-6~ Assembled counting 5 cycle graph from Figure 8 298 Appl. Set various initial states and then the assembled counting cycle is as shown in Figure 7. The counting cycle graph is as shown in Figure 6.A = [010101] 4 After POis revised. (1) The matrix A is: -0 0 A= 0 0 0 0 0 1 0 O_ . .K(B--). 7. = &. . The Boolean values of the elements in POtell us the logic level of the J and K of the given counter: Po=BoA = [JB.. After setting all the necessary initial states. Here the J of flip-flop 2 is connected to level 1 and the J of flip-flop 3 to level 0.. the respective items in A are blanked and A must again be a non-square matrix. it is a straightforward matter to get the total (assembled) counting cycle of this counter (see Figure 9)..~(B-~)o . it is necessary to fill some items into Plater. and A.2 then Sr = 010 Br = [011001] PI = B1A = [OOlO] -14 Figure 7 Assembled counting i-3 cycle graph from Figure 6 and P’1= [001010] then &=Oll Ez = [011010] P2 =&A = [lOlO] and 1 Figure8 Digital counter with a fixed low-level input I P. Math..

Q. . . Sr . then we say this counter IfSj=Si. If Si = Sj_r then we know that this counter will not count any more.+.K) NEXT J P(l. .W*2-l)=CORE B(l. Math. 1983.O)*2-(W1) B(1 ..20) 40 FORJ=lTOB*2 45 FORI=lTOB*2 50 A(I. Y-I. 2.l) = 1 NEXT U 1=1+1 DISP ‘WHERE DOES K(‘W.* S(Y) = 0 FORW=lTOB C=B(l.I) = Q2P. . Si_r obtained previously.W*2)=(B(l. I>= 1 5 GOT0 170 FORU=lTOB*2 A(U.W*2-l)+MOD2 NEXT W I=0 FOR W=Y TO 1 STEP-l IF S(Y) <> S(1) THEN 430 GOT0 445 1=1+1 NEXT W GOT0 500 REM *GET THE CARRY SYSTEM * IFY-I=lTHEN475 DISP ‘THIS IS A’. or that it is a divide-by-0 -i) counter. IF IT GOES TO -02..(n+. Vol.. QU l. After setting all the necessary initial states of this counter...O) + 1) MOD 2 1=1+2 NEXT W REM *MULTIPLY B BY A* Y=l FORK=lTOB*2 M=O FORJ=lTOB*2 M=M+B(l. asfollows. . . works with (j . a total (assembled) counting cycle can be obtained 150 155 160 165 170 175 180 185 190 195 200 205 210 215 220 225 230 235 240 245 255 260 265 270 275 280 285 290 295 300 305 310 315 320 325 330 335 340 345 350 355 360 365 370 375 380 385 390 395 400 405 410 415 420 425 430 435 440 445 450 455 460 465 Computer The program simulation The following program simulating the process of analysing a digital counter was written in BASIC and run successfully on an HP-85 microcomputer: REM *ANALYSIS COUNTER BY MATRIX * 10 REM *PROGRAM NAMED COUNT0 * 15 DISP ‘BITS OF COUNTER B=’ 20 REM *IF THE COUNTER DISCUSSED HAS 3 BITS. n + 1. .O) IS’ INPUT Q2(W. P(1.20). B(1. Modelling.I) = 1 GOT0 230 FOR U= 1 TO B*2 A(U.W. @wbn + Q&n) After getting each Si (j’ E (1..O) B(l .‘.J)*A(J. .1). August 299 .0)* S(0) = 0 FORW=BTO 1 STEP-l DISP ‘THE ORIGINAL STATE Q2 (‘. . . LET B = 3 * 25 INPUT B 30 DIM Q2( 10.’ PAUSE REM *PUSH CONTINUE KEY * Appl.>). If Sj is not equal to any one of Se. LET J (3) =-O(2)* 110 REM *IF 53 GOES TO LEVEL i‘OR 0. ~2(3. then Sj+r should be found continuously.Y)*2-(B-W) B(l. = &An + Qi&in so that &+l= QB(~+I)Q(E-II)(~+I).I) = 1 NEXT U I=Ifl NEXT W REM *INPUT ORIGINAL STATE OF COUNTER* I=1 REM *THE ORIGINAL STATE OF BIT 3 (FROM RIGHT TO LEFT) IS Q2(3.W*2)ANDP(l. LET J(3) = Q(2)..fori=O.. .K)=l NEXT K REM *THE NEXT STATES OF BIT 3 ARE ~2(3.W*2)+1)MOD2 E=B(l. . .‘) GO TO’ REM *THE SAME AS FOR J* INPUT K(W) IF K(W)< 0 THEN K(W) = ABS(K(W)) + 1 IF K(W)=Al THEN 215 IF K(W) = A0 THEN 230 A(K(W).i) beats. j . It fails to be a counter. Si_r..I + 1) = (Q2(W. . ‘BEATS COUNTER.2.20).O) S(O)=S(O)+Q2(W. S(20) 35 DIM A(20.W:) GO TO’ 105 REM *IF 53 GOES TO Q2.Y)=CORE S(Y) = S(Y)+ Q2(B-W+ l. . LET J(3)=Al ORAO* 115 Al=B*2+1 120 AO=O 125 INPUT J(W) 130 IF J(W)< 0 THEN J(W) = ABS(J(W)) + 1 135 IF J(W) = Al THEN 155 140 IF J(W) = A0 THEN 170 145 NJW).J) = 0 55 NEXT I 60 NEXT J 65 I=1 70 FOR W=B to 1 STEP-l 75 Q(w) = 1 80 1=1+2 85 NEXT W 90 I=1 95 FORW=Bto 1 STEP-l 100 DISP ‘WHERE DOES J (’ .W*2-1) D=(P(l.. . Q(E-2). + QB&~) + Q(B--l@p--lpA @(B-1)&i--I)n = @don .K)=M IFM>lTHENP(l.B: We decide S.W*2-1)ANDD Q2(B-W+l. . it is necessaryto compare Si with the Se.2).Fori= Qi(n+. .Q(B-I).Research Note and the next state Sr is determined Sr = accordingly as: QB. .. n. 7. .20). Sr. . .W.

Vol. Modelling. Entering necessary initial states appropriately.0) IS ? 0 THE ORIGINAL STATE Q2( 1 . The program used is suitable for counters which have fewer than 10 bits and fewer than 20 successive counting states.O) IS ‘) 0 STATE Q2(3 .O) IS THIS IS A 4 BEATS COUNTER S(B) 2 S(1) 7 S(2) 0 S(3) 1 S(4) 3 S(5) z(6) 0 (2) Execute the program to analyse the digital counter shown in Figure 5 and set the initial state as Se = 000: BITS OF COUNTER B= 300 Appl. When the program is running. Math. If it is not large enough a revision of the statements may be made to meet the requirements.’ 485 PAUSE 490 REM *PUSH CONTINUE KEY * 495 GOT0 260 500 Y=Y+ 1 505 GOT0 315 510 END THIS IS A 4 BEATS COUNTER S(0) 0 S(1) 1 S(2) 3 S(3) Z(4) 0 S(5) Warning 7 : NULL DATA 0 Set initial state as Se = 010: BITS OF COUNTER B= ? 3 WHERE DOES J(3) GOT0 L(2) WHERE DOES K(3) GOT0 L(2) WHERE DOES J(2) GOT0 L(l) WHERE DOES K(2) GOT0 k(3) WHERE DOES J( 1) GOT0 ? -Q(3) WHERE DOES K( 1) GOT0 k(2) THE ORIGINAL ? 0 THE ORIGINAL ? 1 THE ORIGINAL 0 Notes on the program The number of bits and the original state of the counter are set by the operator.O) IS ? 0 THE ORIGINAL STATE Q2(2. all successive states of the counter after receiving a series of clock pulses are recorded in time. If it really is a counter. August . 7. the question of the number of beats of the counting cycle is answered. the operator can get the total (assembled) counting cycle. 1983. The initiation state of the counter was set as Se= 000: BITS OF COUNTER B= WHERE DOES J(3) GOT0 ‘J Q(2) WHERE DOES K(3) GOT0 L(2) WHERE DOES J(2) GOT0 k(l) WHERE DOES K(2) GOT0 L(3) WHERE DOES J(1) GOT0 ? -Q(3) WHERE DOES K( 1) GOT0 a(2) THE ORIGINAL STATE Q2(3 . The last conclusion is given to show whether the circuit is a counter or not.’ 480 DISP ‘TRY TO SET ANOTHER ORIGINAL STATE. Results of using the program (1) The program was used to analyse the digital counter in Figure 2. After the program has been executed. the operator may consult all the successive states of the counter with the help of the keyboard.0) IS STATE Q2(1 .O) IS STATE Q2(2.Research Note 470 GOT0 260 475 DISP ‘IT IS NOT A COUNTER.

0) IS ? 0 -Q(2) THE ? 0 THE ? 0 THE ? 0 THIS S(0) i(l) i(2) 5 S(3) i(4) i(5) i(6) 6 (3) Execute the program to analyse the digital counter shown in Figure 8 and set the initial state as Se = 100: BITS OF COUNTER B= ? WHERE DOES J(3) G0~0 ? A0 WHERE DOES K(3) GOT0 L(l) WHERE DOES J(2) GOT0 ? Al ORIGINAL STATE Q2(3 . With the help of the method presented all the circuits in reference 1 were tested and verified. and we found another four circuits satisfied all the conditions required in Lo. Control Appl. ‘Decade counters’.’ So it tells us that the method presented in this paper is really useful and effective. Vol. which is written on the basis of this paper. They are all right except one. August 301 . e.l) WHERE DOES J(2) GOT0 ? Al WHERE DOES K(2) GOT0 L(3) WHERE DOES J( 1) GOT0 k(2) WHERE DOES K( 1) GOT0 ? a(2) WHERE DOES K( 1) GOT0 ? -Q(2) THE ORIGINAL STATE Q2(3. otherwise it is divide-by-four only. Lo’ says only 18 basic circuits satisfy all the conditions mentioned. References 1 Lo. the waveform method. Electron. 1983. Modelling. Circuit D shown in Lo’ is wrong. It is easy to find that J2 and K3 are supposed to be connected to Ql rather than 01 for constructing a divide-by-five counter. S.O) IS ? 0 IT IS NOT A COUNTER TRY TO SET ANOTHER OR IGINAL STATE S(O) i(l) Z(2) 5 S(3) 2 S(4) 3 S(5) 3 ORIGINAL STATE Q2(2.0) IS ORIGINAL STATE Q2( 1. should be a replacement for the traditional methods. With the help of computers.Research Note 3 \ WHERE DOES K(2) GOT0 L(3) WHERE DOES J( 1) GOT0 WHERE DOES J(3) GOT0 ? Al WHERE DOES K(3) GOT0 a. Instrum. Math. the analysis becomes much easier and faster. 1977.24. with an algorithm based mainly on matrix operation. N. Using the method discussed in ‘Computer-aided design of digital counters’.0) IS ? 1 THE ORIGINAL STATE Q2(2. 7. In addition. Ind.g.213 IEEE Trans.O) IS THE ORIGINAL STATE Q2( 1 .O) IS IS A 5 BEATS COUNTER Conclusions The computer-aided method of analysis of certain digital counters presented in this paper.

For full details of prices please write to and availability of repnnts. UK The International Journal publishes papers dealing of Systems Science with the theory and Reprints are essential - 0 for the company that wants to distribute impartial comment on its activities to potential customers and clients that wants to up-date its technical staff on new techniques and new technologies 0 for the company practice of mathematical modelling. SCS PROCEEDlNGS are semiannual cloth-bound boohs devoted to particular areas of simulation and modeling. on ‘Systems Science Models in Economics and Related Behavioural Systems: Some Recent Trends and Applications’. simulation langua f. Box 2228 SIMULATION inc. Back issues available. The Mathematics of Large Scale Simulation-and more are soon to come! Indexed and abstracted by several prominent services SIMULATION SCS Proceedings $42 $55 per year per year London & New York 4 John Street. keeping the journal abreast of developments throughout the world. economic. . mathematical methods for formulating models and for verifying and vaildating them. optimization and control. the leading journal devoted to the methods and applications of dynamic modeling and simulation using all types of computers.) (Simulation La Jolla. SIMULATION.’ es and practical applications of modeling and simu atlon In a great variety of fields .O. SIMULATION . engineering and the life and management sciences. Modelling. California 92038 302 Appl. Math. as are details of subscription rates and sample copies. etc. International Journal of Systems Science has established itself as a middle of the road journal. The Reprint Department Butterworth Scientific Limited -Journals Division PO Box63 Westbury House Bury Street Guildford SurreyGU2 5Bl-l England The editor is supported by an international group of eminent workers in all branches of systems science. ecology. The journal includes techniques for discrete and continuous simulation of dynamic systems. the latest being Volume 14. with particular reference to biological. London WC1 N 2ET THE SOCIETY FOR COMPUTER Councils. industrial and transport systems. In the fourteen years of its existence. Subjects explored in past issues included: Mathematical Models of Public Systems.INTERNATIONAL JOURNAL OF Reprints Reprints of all articles in this journal are available in quantities of 100 or more. Number 8.from the “hard” sciences and engineering to management. the monthly publication of the Society for Computer Simulation is the only internationally recognized technical journal devoted to all aspects of simulation and modeling. 7. August 1983. ’ Occasionally the journal publishes special issues. SYSTEMS SCIENCE Edited by Brian Porter University of Salford. from biology. between the extremes of mathematical theory and the more limited reports of applications. August . Systems and Simulation in the Service of Society. P. 1983. Vol. from economics and sociology to process control. simulation. Copies of this issue are available from the publisher. . and medicine to urban planning.

U.A. France.A. U. Japan Aims and Scope The digital computer has placed in the hands of engineers a powerful tool. Poland.00 to the most convenient Elsewhere: address US $375. through sophisticated applications of known techniques to newfields. India.W. and the journal Numerical Methods in Engineering provides a common platform for presentation of papers and exchange of views in this rapidly growing field. West Germany.A. Japan. Boisserie..A. Norway.International Journal for Numerical Methods in Engineering Editors Professor O.S. Maier.. P.A.A. A. Australia. Subscription 1983 Volume For further information De tails 19. Vol.S. France. Olson.J. U.S. S. fluid mechanics. Meek. Marcal. Allwood. Kolar..W.K. Ciarlet. P. H. A. network theory. Arizona. Indeed. Czechoslovakia. V.F.A. Tucson.A. A. Gallagher. can now be solved.F.S. The general numerical methods often cut across professional boundaries.L.J..S. W. Modelling. Editor Lewis. Reddy.A. U. &a/y. Belgium. M.V. Y. G.00 below. Trowbridge. Pian.D. Canada. previously intractable. U.Besseling. France. U.L. U. T. U. 7. Cassell. B. Cook.K. U. Bergan.H.G.D.A. Taylor.T.A. Sweden.A.S.D.W. Schmit. Strang.C.L. T. U. U. Y. U. Austria. J. The trend in many scientific journals of a trivial ‘closed form’ solution in preference to the more general if mathematically less elegant numerical process is reversed as a conscious policy of the journal. Fremond. U.A.S.J. E. U. The general aspects of computer aided design activity clearly fall within the scope of the journal.Evans.. J. Hibbitt. Cella. Hong Kong. Kawai. J.K.. R. P. University College of Swansea.K. Oden. Yamada. J. heat transfer. R. T. J.S. 2..A. G.S. Armand. Wunderlich. Argyris. Contributions will range from those dealing with new formulations of problems showing computational advantages. electronics and optimal system design have much to benefit by cross-fertilization.R. G.S.Samuelsson.. R.. U.A.K.S.A. USA. R.A.. University College of Swansea. U... Warburton. Rodin. U. M.S.. G. H. U. Advisory Editorial Board J..A.. Sander. West Germany.H.Y. Roache. K.. Math. Italy. At the present time papers dealing with the application of such methods are scattered amongst many journals each dealing with its own specialized professional field. 1983. A. J.R. U. Kamel. T.. Nayak.S.K. to noteson special computational techniques. Such subjects as structural analysis.C.M. U.. Finlayson. Atluri. College of Engineering. Belytschko. U. Appl.. Dean. Many real problems of engineering. C.K. School of Engineering. Ho//and.H.S. Monthly and/or a specimen copy please write UK: f 165.A.A. G.S.H. Bathe. publication of complete computer programs will be undertaken if these show a considerable advance.K. U..N.J. H. August S . Hughes. J. U. Clough. U. A. P. S.G.A. Associate Dr. Mang. Professor R.S. D.S. Zienkiewicz.N.. Abel. School of Engineering.J. France... U. Mroz.S.A. Cheung. U. L. University of Arizona. Mitchell... Scotland. R.