LCTRICAL AN COMPUTR NGINRING PARTMNT, OAKLAN UNIVRSITY C-27: igital Logic esign Fall 27 SYNCHRONOUS SUNTIAL CIRCUITS Notes - Unit 6 ASYNCHRONOUS CIRCUITS: LATCHS SR LATCH: R S R t+ t t+ t S restricted SR Latch S R S R SR LATCH WITH NABL: R R' S R t+ t t+ t t t S S' LATCH WITH NABL: This is essentially an SR Latch, where R = not(), S = R' t+ t S' Instructor: aniel Llamocca
LCTRICAL AN COMPUTR NGINRING PARTMNT, OAKLAN UNIVRSITY C-27: igital Logic esign Fall 27 SYNCHRONOUS CIRCUITS: FLIP FLOPS Flip flops are made out of: o A Latch with an enable input. o An dge detector circuit. The figure depicts an SR Latch, where the enable is connected to the output of an dge etector Circuit. The input to the dge etector is a signal called ''. A signal is a square wave with a fied frequency. R T Period Frequency = /T R' SR Flip Flop dge etector S or S' The edge detector circuit generates short-duration pulses during rising (or falling) edges. These pulses act as enable of the Latch. The behavior of the flip flops can be described as that of a Latch that is only enabled during rising (or falling edges). Flip flops classification: o Positive-edge triggered flip flop: The edge detector circuit generates pulses during rising edges. o Negative-edge triggered flip flop: The edge detector circuit generates pulses during falling edges. S S R Positive edge-triggered R Negative edge-triggered SR Flip Flop S R t+ t+ t t S R t+ = SR + t S R = R (S + t S ) = R (S + S )(S + t ) = R S + R t (on the edge) 2 Instructor: aniel Llamocca
LCTRICAL AN COMPUTR NGINRING PARTMNT, OAKLAN UNIVRSITY C-27: igital Logic esign Fall 27 Flip Flop t+ Flip Flop dge etector T Flip Flop t+ = (on the edge) T T T t+ t t t+ = T t (on the edge) JK Flip Flop J K J K J K t+ t t+ = J t + K t (on the edge) t Synchronous/Asynchronous Inputs So far, the flip flops can only change their outputs on the rising (or falling edge). The outputs are usually changed due to a change in the inputs. These inputs are known as synchronous inputs, as the inputs' state is only checked on the rising (or falling) edges. However, in many instances, it is useful to have inputs that force the outputs to a value prn immediately, disregarg the rising (or falling edges). These inputs are known as asynchronous inputs. In the eample, we see a Flip Flop with two asynchronous inputs: o prn: Preset (active low). When prn='', the output q becomes. o : Clear (active low). When ='', the output q becomes. If prn and are both, usually is given priority. A Flip flop could have more than one asynchronous inputs, or none. 3 Instructor: aniel Llamocca
LCTRICAL AN COMPUTR NGINRING PARTMNT, OAKLAN UNIVRSITY C-27: igital Logic esign Fall 27 PRACTIC XRCISS. Complete the timing diagram of the circuit shown below: 2. Complete the VHL description of the circuit shown below: library ieee; use ieee.std_logic_64.all; entity circ is port ( a, b, s,, : in std_logic; q: out std_logic); end circ; architecture a of circ is a b s begin --??? end a; 3. Complete the timing diagram of the circuit shown below. If the frequency of the signal is 25 MH, what is the frequency (in MH) of the signal? '' T 4. Complete the timing diagram of the circuit whose VHL description is shown below: library ieee; use ieee.std_logic_64.all; entity circ is port (,, : in std_logic; q: out std_logic); end circ; architecture a of circ is signal qt: std_logic; begin process (,, ) begin if = then qt <= ; elsif ( event and = ) then if = then qt <= not (qt); end if; end if; end process; q <= qt end a; 4 Instructor: aniel Llamocca
LCTRICAL AN COMPUTR NGINRING PARTMNT, OAKLAN UNIVRSITY C-27: igital Logic esign Fall 27 5. Complete the timing diagram of the circuit shown below: a b Full Adder s y FA cin cout s a b s 6. Complete the VHL description of the synchronous sequential circuit whose truth table is shown below: library ieee; use ieee.std_logic_64.all; entity circ is port ( A, B, C: in std_logic;, : in std_logic; q: out std_logic); end circ; architecture a of circ is begin --??? end a; X A B t+ C t t X X 7. Complete the timing diagram of the circuit shown below: J K y y 8. Complete the timing diagram of the circuit shown below: Latch L L 5 Instructor: aniel Llamocca
LCTRICAL AN COMPUTR NGINRING PARTMNT, OAKLAN UNIVRSITY C-27: igital Logic esign Fall 27 RGISTRS: N-BIT RGISTR: This is a collection of 'n' -type flip flops, where each flip flop independently stores one bit. The flip flops are connected in parallel. They also share the same and signals. n n n- n-2 n- n-2 N-BIT SHIFT RGISTR: This is a collection of 'n' -type flip flops, connected serially. The flip flops share the same and signals. The serial input is called '', and the serial output is called 'dout'. The flip flop outputs (also called the parallel output) are called = n n 2. epeng on how we label the bits, we can have: Right shift register: The input bit moves from the MSB to the LSB, and Left shift register: The input bit moves from the LSB to the MSB. RIGHT SHIFT RGISTR: dout dout n- n-2 n-3 dout n- n-2 n-3 LFT SHIFT RGISTR: dout dout 2 n- dout 2 n- Timing iagram eample: 3 2 3 2 6 Instructor: aniel Llamocca
LCTRICAL AN COMPUTR NGINRING PARTMNT, OAKLAN UNIVRSITY C-27: igital Logic esign Fall 27 Parallel access shift register: This is a shift register in which we can write data on the flip flops in parallel. s_l = shifting operation, s_l = parallel load. The figure below shows a 4-bit parallel access shift register. 3 2 3 s_l 2 s_l Adg enable to flip flops: In many instances, it is very useful to have a signal that controls whether the value of the flip flop is kept. The following circuit represent a flip flop with synchronous enable. When =, the flip flop keeps its value. When =, the flip flop grabs the value at the input. We can thus create n-bit registers and n-bit shift registers with enable. Here, all the flip flops share the same enable input. RGISTR: RIGHT SHIFT RGISTR: LFT SHIFT RGISTR: n n dout dout dout dout n- n-2 n-3 2 n- 7 Instructor: aniel Llamocca
LCTRICAL AN COMPUTR NGINRING PARTMNT, OAKLAN UNIVRSITY C-27: igital Logic esign Fall 27 Parallel access shift register with enable All the flip flops share the same enable input. 3 2 3 s_l 2 s_l 8 Instructor: aniel Llamocca
prn LCTRICAL AN COMPUTR NGINRING PARTMNT, OAKLAN UNIVRSITY C-27: igital Logic esign Fall 27 SYNCHRONOUS COUNTRS Counters are useful for: counting the number of occurrences of a certain event, generate time intervals for task control, track elapsed time between two events, etc. Counters are made of flip flops and combinatorial logic. They are usually designed using Finite State Machines (FSM). Synchronous counters change their output on the edge (rising or falling). ach flip flop shares the same input signal. If the initial count is ero, each flip flop shares the input signal. COUNTR CLASSIFICATION: a) Binary counter: An n bit counter counts from to 2 n. The figure depicts a 2-bit counter. b) Modulus counter: A counter modulo N counts from to N-. Special case: BC (or decade) counter: Counts from to 9. 4 BC counter c) Up/down counter: Counts both up and down, under command of a control input. d) Parallel load counter: The count can be given an arbitrary value. e) Counter with enable: If enable =, the count stops. If enable =, the counter counts. This is usually done by connecting the enable inputs of the flip flops to a single enable. f) Ring counter: Also called one-hot counter (only one bit is at a time). It can be constructed using a shift register. The output of the last stage is fed back to the input to the first stage, which creates a ring-like structure. The asynchronous signal startn sets the initial count to (first bit set to ). ample (4-bits):,,,,, The figure below depicts an n bit ring counter. n- n-2 n-3 startn g) Johnson counter: Also called twisted ring counter. It can be constructed using a shift register, where the output of the last flip flop is fed back to the first stage. The result is a counter where only a single bit has a different value for two consecutive counts. All the flip flops share the asynchronous signal, which sets the initial count to. ample (4 bits):,,,,,,,,, The figure below depicts an n bit Johnson counter. n- n-2 n-3 9 Instructor: aniel Llamocca
MUX LCTRICAL AN COMPUTR NGINRING PARTMNT, OAKLAN UNIVRSITY C-27: igital Logic esign Fall 27 RANOM ACCSS MMORY MULATOR The following sequential circuit represents a memory with 8 addresses, where each address holds a 4-bit data. The memory positions are implemented by 4-bit registers. The reset and signals are shared by all the registers. ata is written or read onto/from one of the registers (selected by the signal address ). Writing onto memory (wr_rd = ): The 4-bit input data (_in) is written into one of the 8 registers. The address signal selects which register is to be written. Here, the 7-segment display must show. For eample: if address =, then _in is written into register 5. Reag from memory (wr_rd = ): The MUX output appears on the 7-segment display (headecimal value). The address signal selects the register from which data is read. For eample: If address =, then data in register 2 must appear on the 7-segment display. If data in register 2 is, then the symbol A appears on the 7-segment display. reset wr_rd _in[3..] 4 2 address[2..] wr_rd 3 ecoder 3 4 4 ecoder: HX to 7 segments 5 3 7 6 7 Instructor: aniel Llamocca
LCTRICAL AN COMPUTR NGINRING PARTMNT, OAKLAN UNIVRSITY C-27: igital Logic esign Fall 27 FINIT STAT MACHINS: Sequential circuits are also called Finite State Machines (FSMs), because the functional behavior of these circuits can be represented using a finite number of states (flip flop outputs). The signal sets the flip flops to an initial state. Classification: - Moore machine: Outputs depend solely on the current state of the flip flops. - Mealy machine: Outputs depend on the current state of the flip flops as well as on the input to the circuit. Only for Mealy Machine Inputs Combinatorial Circuit Flip Flops n (states) Combinatorial Circuit Outputs Any general sequential circuit can be represented by the figure above (Finite State Machine model). A sequential circuit with certain behavior and/or specification can be formally designed using the Finite State Machine method: drawing a State iagram and coming up the citation Table. esigning sequential circuits using Finite State Machines is a powerful method in igital Logic esign. ample: 2-bit gray-code counter with enable and output:,,,,, The output is when the present count is. The count is the same as the states encoded in binary. First step: raw the State iagram and State Table. If we were to implement the state machine in VHL, this is the only step we need. = / / / S S4 / Second step: State Assignment. We assign unique flip flop states to our state labels (S, S2, S3, S4). Notice that this is arbitrary. However, we can save resources if we assign each state to the count that we desire. Then, the output count is just the flip flops outputs. S: = S2: = S3: = S4: = / / S2 / S3 / / PRSNT STAT S S2 S3 S4 S S2 S3 S4 NXT NXT STAT COUNT S S2 S3 S4 S2 S3 S4 S Instructor: aniel Llamocca
LCTRICAL AN COMPUTR NGINRING PARTMNT, OAKLAN UNIVRSITY C-27: igital Logic esign Fall 27 Third step: citation table. Here, we replace the state labels by the flip flop states: PRSNT STAT NXTSTAT (t) (t) (t+) (t+) Fourth step: citation equations and minimiation. (t + ) and (t + ) are the net state of the flip flops, i.e. these signals are to be connected to the inputs of the flip flops. (t+) (t+) (t + ) = + (t + ) = + = Output only depends on the present state. Outputs, are the states and they only depend (in terms of the combinational output circuit) on the present state. Thus, this is a Moore FSM. Fifth step: Circuit implementation. state S S S2 S3 S3 S4 S4 S S2 S2 ample: 2-bit counter with enable and output. The output is when the present count is. The count is the same as the states encoded in binary. First step: raw the State iagram and State Table. If we were to implement the state machine in VHL, this is the only step we need. / PRSNT NXT NXT = / STAT STAT COUNT / / S S4 / / / S2 / S3 / S S2 S3 S4 S S2 S3 S4 S S2 S3 S4 S2 S3 S4 S 2 Instructor: aniel Llamocca
LCTRICAL AN COMPUTR NGINRING PARTMNT, OAKLAN UNIVRSITY C-27: igital Logic esign Fall 27 Second step: State Assignment. We assign unique flip flop states to our state labels (S, S2, S3, S4). Notice that this is arbitrary. However, we can save resources if we assign each state to the count that we desire. Then, the output count is just the flip flops outputs. S: = S2: = S3: = S4: = Third step: citation table. Here, we replace the state labels by the flip flop states: PRSNT STAT NXTSTAT (t) (t) (t+) (t+) Fourth step: citation equations and minimiation. (t + ) and (t + ) are the net state of the flip flops, i.e. these signals are to be connected to the inputs of the flip flops. (t+) (t+) (t + ) = + + (t + ) = + = Output only depends on the present state. Outputs, are the states and they only depend (in terms of the combinational output circuit) on the present state. Thus, this is a Moore FSM. Fifth step: Circuit implementation. state S S S2 S3 S3 S4 S4 S S2 S2 Note: In these 2-bit counters, the states are represented by the outputs of the flip flops:,. They also happen to be the outputs of the FSM. This is common in counters, as the count is usually the same as the flip flop outputs. 3 Instructor: aniel Llamocca
LCTRICAL AN COMPUTR NGINRING PARTMNT, OAKLAN UNIVRSITY C-27: igital Logic esign Fall 27 ample: BC counter. Outputs: (3..),. When the count reaches, becomes. Moore FSM = '' S =,= S2 =,= S3 =2,= S4 =3,= S5 =4,= S =9,= S9 =8,= S8 =7,= S7 =6,= S6 =5,= ample: FSM. Input: w. Output:. This is a Moore FSM as only depends on the present state. = w= w= w= w= w= S = S2 = w= S3 w= S4 w= = = S5 = w= w= w= w= w= w= w= S9 = w= S8 = w= S7 = w= S6 = rstn w state S S S2 S9 S8 S9 S S2 S3 S2 S3 S4 S5 S4 S3 S4 4 Instructor: aniel Llamocca
LCTRICAL AN COMPUTR NGINRING PARTMNT, OAKLAN UNIVRSITY C-27: igital Logic esign Fall 27 ALGORITHMIC STAT MACHIN (ASM) CHARTS: Gray counter, = when = Sequence etector (with overlap) = / / = / / / / S / S2 S / S2 / S3 / / S4 / / S3 / / S6 / / / S5 / / S4 / / S = S = S2 S2 S3 S3 S4 S4 S5 S6 5 Instructor: aniel Llamocca
LCTRICAL AN COMPUTR NGINRING PARTMNT, OAKLAN UNIVRSITY C-27: igital Logic esign Fall 27 XAMPL: ARBITR CIRCUIT Three devices can request access to a certain resource at any time (eample: access to a bus made of tri-state buffers, only one tri-state buffer can be enabled at a time). The FSM can only grant access to one device at a time.there should be a priority level among devices. If the FSM grants access to one device, one must wait until the request signal to that device is deasserted (i.e. set to ero) before granting access to a different device. VIC req priority grant VIC 2 grant2 req2 r r2 r3 FINIT STAT MACHIN g g2 g3 VIC 3 req3 CONTROL CIRCUIT grant3 Algorithmic State Machine (ASM) chart: S = g,g2,g3 r r 2 r 3 S2 S3 S4 g g2 g3 r r 2 r 3 6 Instructor: aniel Llamocca
LCTRICAL AN COMPUTR NGINRING PARTMNT, OAKLAN UNIVRSITY C-27: igital Logic esign Fall 27 Modifying the rate of change of a Finite State Machine: We usually would like to reduce the rate at which FSM transitions occur. A straightforward option is to reduce the frequency of the input. But this is a very complicated problem when a high precision is required. Alternatively, we can reduce the rate at which FSM transitions occur by inclug an enable signal in our FSM: this means inclug an enable to every flip flop in the FSM. For any FSM transition to occur, the enable signal has to be. Then we assert the enable signal only when we need it. The effect is the same as reducing the frequency of the input. The figure below depicts a counter modulo-n (from to N-) connected to a comparator that generates a pulse (output signal ) of one period every time we hit the count N-. The number of bits the counter is given by n = log 2 N. The effect is the same as reducing the frequency of the FSM to f N, where f is the frequency of the. A modulo-n counter is better designed using VHL behavioral description, where the count is increased by every cycle and is generated by comparing the count to N-. A modulo-n counter could be designed by the State Machine method, but this can be very cumbersome if N is a large number. For eample, if N =, we need states. n Inputs FSM Outputs comparator counter to N- =N-? As an eample, we provide the timing diagram of the counter from to N-, when N=. Notice that is only activated when the count reaches. This signal controls the enable of a state machine, so that the FSM transitions only occur every cycles, thereby having the same effect as reducing the frequency by. We can apply the same technique not only to FSMs, but also to any sequential circuit. This way, we can reduce the rate of any sequential circuit (e.g. another counter) by inclug an enable signal of every flip flop in the circuit. 7 Instructor: aniel Llamocca