.. _cmos: ******************* CMOS Logic Circuits ******************* .. Changes: .. + Inverter chains with feedback was added. 1-, 2-, and 3-inverter ring based exercises were added on Oct. 11, 2012. .. 2-, and 3-inverter ring based exercises were removed on Jan. 4, 2013. Objectives ================================================== #. Reinforce basic principles of CMOS logic from ELEC 2210 lecture #. Gain experience with complex CMOS gates #. Learn to construct CMOS transmission gates #. Work with chains of CMOS inverters Required Soft Front Panels (SFPs) ==================================================== #. Function Generator (FGEN) #. Scope #. Digital Writer #. Digital Reader Required Components ============================================= #. 3 x CD4007 (dual CMOS pair plus inverter). You can download or view the data sheet :download:`here <./datasheet/cmos/ti-cd4007ub.pdf>` or :download:`here <./datasheet/cmos/MC14007UB-D.pdf>`. #. 3 x 1K Ohm resistor. .. Commented out #. 3 x 1 :math:`\mu` F capacitor. Overview ============================ CD4007 ----------------- The CD4007 consists of 3 pairs of complimentary MOSFETs, as shown in :num:`figure #fig-cd4007-functional`. Each pair shares a common gate (pins 6,3,10). The substrates of all PMOSFETs are common (pin 14), as well as those of the NMOSFETs (pin 7). For the left pair, one of the two NMOS N+ terminals is tied to the NMOS substrate, and one of the two PMOS P+ terminals is tied to PMOS substrate. The other two pairs are more general purpose. For the right pair, a N+ terminal of the NMOS is tied to a P+ terminal of the PMOS (pin 12). .. _fig-cd4007-functional: .. figure:: images/cmos/cd4007-functional.png :scale: 100 % :alt: CD4007 functional diagram :align: center CD4007 functional diagram. The CD4007 is a very versatile IC with many uses. For example, a single CD4007 can be used to make a chain of 3 inverters, an inverter plus two transmission gates, or a complex logic gate. Inverters and transmission gates are particularly useful for building D flip-flops. Static Discharge ------------------------- While the CD4007 is very versatile, it is also easily damaged by static, like all CMOS electronics. The CD4007 includes diodes to protect it from static discharge, but it can still be damaged if it is not handled carefully. Normally one would use anti-static mats and wrist straps when working with static sensitive electronics. However, we do not have those in the 2210 lab. A low budget way to avoid static discharge is to ground yourself before touching an IC. The ELVIS breadboard includes a metal pad in both top corners labeled "ESD PAD TOUCH TO DISCHARGE." Discharging any built up static charge before picking up a CD4007 will help ensure that you do not have a broken chip half way through the lab. Wiring Notation ----------------------- When specifying wiring between the pins of an IC, engineers often use a shorthand for connections. For example, instead of saying, "connect pin 22 to pin 5 and pin 7," one might write "(22,5,7)". Groups of pins that are not connected are separated by a semicolon. For example, consider (22,5,7);(1,3,18). This notation is often used in datasheets, and is used below as well. Pre lab ================================== #. Study the CD4007 datasheet thoroughly. #. Draw an equivalent circuit for the following wiring description using a CD4007: (1,5,10);(3,8,13);(14,2,11);(7,4,9);(14,Vdd);(7,Ground). You do not have to draw a gate level schematic if you can determine the logic function implemented. If you only give a logic diagram, show pin numbers between logic elements. #. Make a pin-level wiring diagram for a transmission gate using a CD4007. Use the top right PMOSFET and the bottom center NMOSFET shown in :num:`figure #fig-cd4007-functional-small` below. .. _fig-cd4007-functional-small: .. figure:: images/cmos/cd4007-functional-small.png :scale: 100 % :alt: CD4007 functional diagram :align: center CD4007 functional diagram. #. Determine the logic function implemented by the following connections to a CD4007: (2,14);(8,9,4);(12,13,5);(1,11);(14,Vdd);(7,Gnd). Pin 3 is A, pin 10 is B, and pin 6 is C. The output is pin 12,13, or 5. Draw a transistor level diagram and a truth table for the circuit. Lab Exercises ========================================= CMOS Inverter Chain ---------------------- #. Construct 3 inverters using a CD4007 by making the following connections: (4,9,7);(1,5);(8,13);(14,2,11);(14,Vdd);(7,Ground). Use +5v for Vdd. Connect AI0+ to FGEN. Set the function generator to output a 500Hz sine wave, 5vpp, 2.5vdc offset. #. Test each inverter by connecting the function generator to the input and connecting AI1+ to the output. Remember to ground the AI- terminals. The respective input-output pairs are: 6-8,3-5,10-12. You should see 3 waveforms similar to the one shown in :num:`figure #fig-inverter-chain-first`. .. _fig-inverter-chain-first: .. figure:: images/cmos/inverter-chain-first.png :scale: 100 % :alt: inverter output :align: center Output of first inverter. #. Build a chain of 3 inverters by connecting your inverters in the order shown in :num:`figure #fig-inverter-chain`. .. _fig-inverter-chain: .. figure:: images/cmos/inverter-chain.png :scale: 100 % :alt: inverter chain :align: center Inverter chain. #. Keeping the input (from FGEN) at pin 6, connect AI1+ to the output of each inverter (one-after-another) and take a screenshot similar to :num:`figure #fig-inverter-chain-second`. You should take a total of three screenshots, one each, corresponding to each inverter output. .. _fig-inverter-chain-second: .. figure:: images/cmos/inverter-chain-second.png :scale: 100 % :alt: inverter chain output :align: center Output of second inverter. #. Do not dissassemble the inverter chain. It will be reused later. .. topic:: What to do in lab report Show 3 screen shots of inverter outputs. Describe the differences between the screenshots (other than that they are inverted). .. Inverter Chains with Feedback -- Three Inverter Ring Oscillator ---------------------------------------------------------------- In the previous section, we observed the inverter chain operating in an open loop. We will now see the effects of adding a feedback (or closed loop operation) with three inverters in a closed loop. #. For the inverter chain built in the previous step, add a feedback by connecting 12 to 6 as shown in :num:`Figure #fig-three-inverter-ring` below. #. Connect a 1 :math:`\mu` F capacitor at the outputs of each inverter in the chain i.e., pins 8, 5, and 12 as shown in the circuit below. .. _fig-three-inverter-ring: .. figure:: images/cmos/three_inverter_ring.png :scale: 100 % :alt: inverter ring :align: center Three Inverter ring oscillator. #. Connections to the scope are as follows: pin 8 to AI2+, pin 5 to AI1+ and pin 12 to AI0+. AI2-, AI1-, AI0- should be connected to Ground. #. Connect pin 14 to Variable Power Supply VPS+. Use SFP to set VPS to 5V. #. Enable channels AI0, AI1, and AI2 on the 8-channel scope. The 8-channel oscilloscope is available near the bottom end under the Featured instruments tab of instrument launcher (SFP) as shown in :num:`Figure #fig-oscope`. You should observe oscillations at each node with waveforms as shown in the screenshot of :num:`Figure #fig-three-inv-ring-with-five-volt` below. .. _fig-oscope: .. figure:: images/cmos/oscope.png :scale: 60 % :alt: oscope :align: center 8-channel oscilloscope is available under the Featured instruments drop-down menu in the Soft Front Panel. .. _fig-three-inv-ring-with-five-volt: .. figure:: images/cmos/fig-three-inv-ring-with-1uF-at-each-load-5V_PS.png :scale: 60 % :alt: three-inv-ring-with-five-volt :align: center Voltage waveform at each node of the ring oscillator with 5V supply. #. Change the supply voltage first to 10V, then to 2.5V. Take a screenshot in each case. You should see the amplitude and time period of oscillation change in each case as shown in :num:`Figure #fig-three-inv-ring-with-ten-volt` and :num:`Figure #fig-three-inv-ring-with-two-point-five-volt` respectively. How does frequency and amplitude of oscillation vary with supply voltage? .. _fig-three-inv-ring-with-ten-volt: .. figure:: images/cmos/fig-three-inv-ring-with-1uF-at-each-load-10V-PS.png :scale: 60 % :alt: three-inv-ring-with-ten-volt :align: center Voltage waveform at each node of the ring oscillator with 10V supply. .. _fig-three-inv-ring-with-two-point-five-volt: .. figure:: images/cmos/fig-three-inv-ring-with-1uF-at-each-load-2p5V-PS.png :scale: 60 % :alt: three-inv-ring-with-two-point-five-volt :align: center Voltage waveform at each node of the ring oscilator with 2.5V supply. #. Just remove the feedback conncection that you now have from pin 12 to pin 6. Remove all the capacitors. Keep the rest of the connections as it is. You will need it in future exercise on building D-latch. .. topic:: What to do in lab report? Show 3 screenshots corresponding to each supply voltage for the three inverter ring oscillator. Mention how supply voltage changes the frequency of oscillation, and its amplitude. If possible, cite your reasons. CMOS Transmission Gates ------------------------- #. Build a double transmission gate using a new CD4007 chip as shown in :num:`Figure #fig-transmission-gate-schematic`. We will test the two transmission gates by connecting FGEN to the input, and connecting a load of 1k :math:`\Omega` on either (output) sides. #. Connect FGEN to (1,12,5); attach 1k :math:`\Omega` resistors to (2,9) and (4,11) as shown in :num:`Figure #fig-transmission-gate-schematic`. #. Connect pins (2,9) to CH0, and pins (4,11) to CH1. Remember to ground the CH(-) terminals. .. _fig-transmission-gate-schematic: .. figure:: images/cmos/double-tgates.png :scale: 100 % :alt: transmission-gate-schematic :align: center Double transmission gate connections. #. Set the function generator to produce a 500Hz square wave, 5vpp, 2.5vdc offset. #. Connect CLK to DIO7 to set CLK to 0 and 1. Observe the waveforms on CH0 and CH1 for CLK=0 and CLK=1. In each case take a screen-shot. D-latch ----------------------------- We will now combine the double transmission gate built in the previous exercise with inverter chain of the first exercise to build a D-latch as shown in :num:`Figure #fig-dlatch`. The two transmission gates work in tandem to realize the D-latch. During the transparent phase of the latch, i.e. CLK=0, the first transmission gate (left) is ON while the second (right) is OFF. D is transmitted to the output (Q) through the first transmission gate and the two-inverter cascade. During the hold phase of the latch, i.e. CLK=1, the first transmission gate is OFF but the second transmission gate is ON. As a result, any change in the input D is not reflected at the output Q. However, the second transmission gate, which is now turned ON ensures that the previous logic level at Q is retained through the closed loop with the two-inverter cascade. #. Connect pin 9, which serves as D input of the latch to DIO0. Connect pin 4, which serves as Q output of the latch to DIO8. Connect pin 6, which serves as CLK to DIO7. .. _fig-dlatch: .. figure:: images/cmos/D-latch-rev.png :scale: 100 % :alt: dlatch :align: center Schematic of D latch. #. Now insert two inverter chain you built earlier (and retained from the first exercise) to the circuit you have just built. It is shown in the dashed box labeled as chip 2 in :num:`Figure #fig-dlatch` above. #. First apply logic Low to CLK by starting the SFP and turning DIO7 low. Apply logic High to the D input by flipping DIO0 to high. #. Observe the output Q of the latch on DIO8 (by using the digital reader from the SFP). A steady high should appear. Capture a screen shot. #. Apply logic Low to the D input by flipping DIO0 to low. Observe the output on DIO8. This is the transparent phase of the latch. You should see that DIO8 is also low. #. Now apply logic High to CLK by making DIO7 high. Also apply logic High to the D input. #. Observe the DIO8 pin. A steady low should appear inspite of changing D to logic High since the previous value at D-input was low. Capture a screen shot. This is the opaque phase of the latch. Two copies with opposite phase clocks will then make a master-slave D Flip Flop. That is going to be left as a bonus exercise. Bonus Exercise - Building Your Own Master-Slave D Flip Flop from Transistors ----------------------------------------------------------------------------- We have just learned in our lecture that sequential CMOS circuits are implemented in CMOS specific fashion using CMOS transmission gates. A widely used circuit is a master slave D flip flop, which we will build and test below. We will use the D-latch constructed in the previous section as the master latch in our master slave D flip flop. We will now need to construct another D-latch that will serve as slave latch to form our master-slave D Flip-flop as shown in :num:`Figure #fig-d-flip-flop` (Click on the Figure to view a full-size picture). For the complete circuit you will need 4 CD4007 chips. Remember that chips 2 and 4 shown in :num:`Figure #fig-d-flip-flop` need Vdd and Ground connections. Proceed as follows: .. _fig-d-flip-flop: .. figure:: images/cmos/d-flip-flop.png :scale: 100 % :alt: dflop :align: center Schematic of D flip flop. #. Build another set of transmission gates on a third CD4007 chip. For this pair the clock must be inverted, so the wiring is slightly different: (1,5,12);(2,9);(11,4);(3,8,13);(6,10);(7, ground); (14, VDD). Pin 2 or 9 is the D input, pin 4 or 11 is the Q output, and pin 6 is the clock signal. #. Build a second inverter buffer on a fourth CD4007 chip: (4,7);(1,5);(3, 8,13);(14,2);(14,Vdd);(7,Ground). Pin 6 is the input and pin 1 or 5 is the output. #. Complete the slave latch by connecting the buffer on chip 4 to the transmission gates on chip 3. Connect pin 6 on chip 4 to pin 1, 5, or 12 on chip 3. Connect pin 1 or 5 on chip 4 to pin 4 or 11 on chip 3. #. Test your second latch. Does the output follow the input when the clock is high? Will the latch hold both high and low states when the clock is low? #. Connect the output of the first latch to the input of the second latch (connect pin 4 or 11 on chip 1 to pin 2 or 9 on chip 3). Tie the clock signals together (connect pin 6 on chip 1 to pin 6 on chip 3). This combination is a master-slave flip-flop. #. Connect clock to FGEN. Connect the D input to the AO0. Connect AI0 to FGEN. Connect AI1 to the output. #. Download the waveform file :download:`here <./customprograms-auto-dev-name/cmos/5v_square_wave.wdt>`. #. Load the waveform file into the arbitrary waveform generator and check the box the box next to ``Enabled.`` Click run. This waveform is the input data. #. Use the function generator to generate a 5v clock signal (5Vpp, 2.5Vdc offset). #. Use the scope to observe the output and clock. Save a screenshot. Is the flip-flop rising or falling edge triggered? Clean up ------------------------------------------ Please place components back in the correct drawer. Thank you for keeping our lab clean and organized. .. topic:: Feedback You are encouraged to write down your experience with this lab along with any feedback or suggestions. You can also document mistakes or missteps that occurred, e.g. * my oscilloscope ground was not connected to the GROUND of the board, or * my IC was not connected to power, or * my IC was not grounded, or * my IC was broken, or * I couldn't complete all the lab exercises within the designated time. Such information will be used to improve this and future labs and your experience will help future students.