Unformatted text preview:

CountersIncrementerSlide 3Counter Example: 1 Hz Pulse Generator Using 256 Hz OscillatorDown-CounterUp/Down-CounterCounter Example: Light SequencerCounter with Parallel LoadSlide 9Counter Example: 1 Hz Pulse Generator from 60 Hz ClockMultiplier – Array StyleSlide 12Slide 13SubtractorSubtractor Example: Color Space Converter – RGB to CMYKSlide 16Slide 17Slide 18Representing Negative Numbers: Two’s ComplementTen’s ComplementSlide 21Two’s Complement is Easy to Compute: Just Invert Bits and Add 1Two’s Complement Subtractor Built with an AdderArithmetic-Logic Unit: ALURegister FilesRegister File Timing DiagramRegister-File Example: Above-Mirror Display1Counters•N-bit up-counter: N-bit register that can increment (add 1) to its own value on each clock cycle–0000, 0001, 0010, 0011, ...., 1110, 1111, 0000–Note how count “rolls over” from 1111 to 0000•Terminal (last) count, tc, equals1 during value just before rollover•Internal design–Register, incrementer, and N-input AND gate to detect terminal countcnttc C4-bit up-counter400000100010010001101000101...11100111110 00000001ld4-bit registerCtc44 44cnt4-bit up-counter+1aa2Incrementer•Counter design used incrementer•Incrementer design–Could use carry-ripple adder with B input set to 00...001•But when adding 00...001 to another number, the leading 0’s obviously don’t need to be considered -- so just two bits being added per column–Use half-adders (adds two bits) rather than full-adders (adds three bits)0 0 1 10 1 11+carries:unused0000 1(a)(b)a3 a2 a1 a0 1s0s1s2s3coa bco sHAa bco sHAa bco sHAa bco sHAa3co s3s2+1s1s0a2 a1 a03Incrementer•Can build faster incrementer using combinational logic design process–Capture truth table–Derive equation for each output•c0 = a3a2a1a0•...•s0 = a0’–Results in small and fast circuit–Note: works for small N -- larger N leads to exponential growth, like for N-bit adders20001111000011110s10110011001100110s01010101010101010s30000000111111110c00000000000000001a00101010101010101a10011001100110011a30000000011111111Inputs Outputsa200001111000011114Counter Example: 1 Hz Pulse Generator Using 256 Hz Oscillator•Suppose have 256 Hz oscillator, but want 1 Hz pulse–1 Hz is 1 pulse per second -- useful for keeping time–Design using 8-bit up-counter, use tc output as pulse•Counts from 0 to 255 (256 counts), so pulses tc every 256 cyclescnttc C(unused)8-bit up-counter1osc(256 Hz)8p(1 Hz)5Down-Counter•4-bit down-counter–1111, 1110, 1101, 1100, …, 0011, 0010, 0001, 0000, 1111, …–Terminal count is 0000•Use NOR gate to detect–Need decrementer (-1) – design like designed incrementerld4-bit registerCtc44 44cnt4-bit down-counter–16Up/Down-Counter•Can count either up or down–Includes both incrementer and decrementer–Use dir input to select, using 2x1: dir=0 means up–Likewise, dir selects appropriate terminal count valueld4-bit registerCtc444 444cntclrclrdir4-bit up/down counter4 4–1 +11 02x11 04-bit 2x17Counter Example: Light Sequencer•Illuminate 8 lights from right to left, one at a time, one per second•Use 3-bit up-counter to counter from 0 to 7•Use 3x8 decoder to illuminate appropriate light•Note: Used 3-bit counter with 3x8 decoder–NOT an 8-bit counter – why not?lights0 0 00 0 10 1 03-bit up-countercnttc c2 c1 c03x8 dcd i2 i1 i0unused1clk(1Hz)d7 d6 d5 d4 d3 d2 d1 d0a8Counter with Parallel Load•Up-counter that can be loaded with external value–Designed using 2x1 mux – ld input selects incremented value or external value–Load the internal register when loading external value or when countingld4-bit registerCtc44 4cntld+11 04-bit 2x1L 449Counter with Parallel Load•Useful to create pulses at specific multiples of clock–Not just at N-bit counter’s natural wrap-around of 2N•Example: Pulse every 9 clock cycles–Use 4-bit down-counter with parallel load–Set parallel load input to 8 (1000)–Use terminal count to reload•When count reaches 0, next cycle loads 8.–Why load 8 and not 9? Because 0 is included in count sequence: •8, 7, 6, 5, 4, 3, 2, 1, 0  9 countscntldtc CL1clk4410004-bit down-counter10Counter Example: 1 Hz Pulse Generator from 60 Hz Clock•U.S. electricity standard uses 60 Hz signal–Device may convert that to 1 Hz signal to count seconds•Use 6-bit up-counter–Can count from 0 to 63–Create simple logic to detect 59 (for 60 counts)•Use to clear the counter back to 0 (or to load 0)Ctcp1osc(60 Hz)(1 Hz)clrcnt6-bit up counter11Multiplier – Array Style•Can build multiplier that mimics multiplication by hand–Notice that multiplying multiplicand by 1 is same as ANDing with 112Multiplier – Array Style•Generalized representation of multiplication by hand13Multiplier – Array Style•Multiplier design – array of AND gatesA BP*Block symbol+ (5-bit)+ (6-bit)+ (7-bit)000 000a0a1a2a3b0b1b2b30p7..p0pp1pp2pp3pp414Subtractor•Can build subtractor as we built carry-ripple adder–Mimic subtraction by hand–Compute borrows from columns on left•Use full-subtractor component: –wi is borrow by column on right, wo borrow from column on left1 1 000 1 11110-1stcolumn1 1 01000 1 110 11-3rd column1 1 0000 1 1100 11-4thcolumnwoa3a bFSwiwo sb3s3a2a bFSwiwo sb2s2a1a bFSwiwo sb1s1a0a3a2a1a0 b3s3s2s1s0wowib2b1b0a bFSwiwiwo sb0s0(b) (c)4-bit subtractora1 1 00 1 11 1110-2ndcolumn01015Subtractor Example: Color Space Converter – RGB to CMYK•Color–Often represented as weights of three colors: red, green, and blue (RGB)•Perhaps 8 bits each, so specific color is 24 bits–White: R=11111111, G=11111111, B=11111111–Black: R=00000000, G=00000000, B=00000000–Other colors: values in between, e.g., R=00111111, G=00000000, B=00001111 would be a reddish purple–Good for computer monitors, which mix red, green, and blue lights to form all colors•Printers use opposite color scheme–Because inks absorb light–Use complementary colors of RGB: Cyan (absorbs red), reflects green and blue, Magenta (absorbs green), and Yellow (absorbs blue)16Subtractor Example: Color Space Converter – RGB to CMYK•Printers must quickly convert RGB to CMY –C=255-R, M=255-G, Y=255-B–Use subtractors as shown- - -R G B8888888 8 8255 255 255C M Y17Subtractor Example: Color Space Converter – RGB to CMYK•Try to save colored inks–Expensive–Imperfect – mixing C, M, Y doesn’t yield good-looking black•Solution: Factor out the black or gray from the color, print that part using black ink–e.g., CMY of


View Full Document

UCR EE 120A - Counters

Download Counters
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Counters and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Counters 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?