UCR EE 120A - Counter with Parallel Load

Unformatted text preview:

Counter with Parallel LoadSlide 2Counter Example: 1 Hz Pulse Generator from 60 Hz ClockMultiplier – Array StyleSlide 5Slide 6SubtractorSubtractor Example: Color Space Converter – RGB to CMYKSlide 9Slide 10Slide 11Representing Negative Numbers: Two’s ComplementTen’s ComplementSlide 14Two’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 Display1Counter 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 442Counter 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-counter3Counter 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 counter4Multiplier – Array Style•Can build multiplier that mimics multiplication by hand–Notice that multiplying multiplicand by 1 is same as ANDing with 15Multiplier – Array Style•Generalized representation of multiplication by hand6Multiplier – Array Style•Multiplier design – array of AND gatesA BP*Block symbol+ (5-bit)+ (6-bit)+ (7-bit)000 000a0a1a2a3b0b1b2b30p7..p0pp1pp2pp3pp47Subtractor•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-2ndcolumn0108Subtractor 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)9Subtractor 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 Y10Subtractor 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 (250,200,200)= (200,200,200) + (50,0,0).•(200,200,200) is a dark gray – use black ink11Subtractor Example: Color Space Converter – RGB to CMYK•Call black part K–(200,200,200): K=200–(Letter “B” already used for blue)•Compute minimum of C, M, Y values–Use MIN component designed earlier, using comparator and mux, to compute K–Output resulting K value, and subtract K value from C, M, and Y values–Ex: Input of (250,200,200) yields output of (50,0,0,200)- - -8 8C2 M2 Y2 K88888 88 8MINMINCC M YR GRGB t o CMYBM YKR G B8 8 812Representing Negative Numbers: Two’s Complement•Negative numbers common–How represent in binary?•Signed-magnitude–Use leftmost bit for sign bit•So -5 would be:1101 using four bits10000101 using eight bits •Better way: Two’s complement–Big advantage: Allows us to perform subtraction using addition–Thus, only need adder component, no need for separate subtractor component!13Ten’s Complement•Before introducing two’s complement, let’s consider ten’s complement–But, be aware that computers DO NOT USE TEN’S COMPLEMENT. Introduced for intuition only.–Complements for each base ten number shown to right – Complement is the number that when added results in 1098765432112345678914Ten’s Complement•Nice feature of ten’s complement–Instead of subtracting a number, adding its complement results in answer exactly 10 too much–So just drop the 1 – results in subtracting using addition only4 6107Ð4 +60 10 203 131330 10123456789987654321complements7Ð4=3 7+6=13 3Adding thecomplement results in an answerexactly 10too much – dropping thetenscolumngivestheright answer.--15Two’s Complement is Easy to Compute: Just Invert Bits and Add 1•Hold on!–Sure, adding the ten’s complement achieves subtraction using addition only–But don’t we have to perform subtraction to have determined the complement in the first place? e.g., we only know that the complement of 4 is 6 by subtracting 10-4=6 in the first place.•True – but in binary, it turns out that the two’s complement can be computed easily–Two’s complement of 011 is 101, because 011 + 101 is 1000–Could compute complement of 011 as 1000 – 011 = 101–Easier method: Just invert all the bits, and add 1–The complement of 011 is 100+1 = 101 -- it works!Q: What is the two’s complement of 0101?A: 1010+1=1011(check: 0101+1011=10000)aQ: What is the two’s complement of 0011?A: 1100+1=110116Two’s Complement Subtractor Built with an Adder•Using two’s complement A – B = A + (-B) = A + (two’s complement of B) = A + invert_bits(B) + 1•So build subtractor using adder by inverting B’s bits, and setting carry in to 11cinBAAdderSBAN-bit17Arithmetic-Logic Unit: ALU•ALU: Component that can perform any of various arithmetic (add, subtract, increment, etc.) and logic (AND, OR, etc.)


View Full Document

UCR EE 120A - Counter with Parallel Load

Download Counter with Parallel Load
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 Counter with Parallel Load 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 Counter with Parallel Load 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?