1 / 30

Lecture 4 Chap 5 Types

Lecture 4 Chap 5 Types. Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University. Operator Precedence. Miscellaneous **, abs, not multiplying *, /, mod, rem sign +, - adding +, - shifting sll, srl, sla, sra, ror, rol

tarmon
Download Presentation

Lecture 4 Chap 5 Types

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lecture 4 Chap 5 Types Instructors: Fu-Chiung Cheng (鄭福炯) Associate Professor Computer Science & Engineering Tatung University

  2. Operator Precedence Miscellaneous **, abs, not multiplying *, /, mod, rem sign +, - adding +, - shifting sll, srl, sla, sra, ror, rol relational =, /=, <, <=, >, >= logical and, or, nand, nor, xor, xnor

  3. Operator Precedence • Logical operators are the lowest precedence. • Logical operators have the same precedence • It is impossible to mix logic operators. • a <= b or c and d -- illegal • a <= (b or c) and d -- OK • nand and nor cannot be chained • y <= a nand b nand c -- illegal • y <= (a nand b) nand c -- OK • y <= a or b or c -- OK • A. nand and nor are non-associative operators • B. non-inverting operators are associative

  4. Shift operators • Don’t mix Shift operators • a sll 2 srl 2; -- illegal • (a sll 2) srl 2; -- OK use parentheses • (strip off the leftmost two bits of bus a) • shift > logical • if a sll 2 > 5 then … • if (a sll 2) > 5 then

  5. Signed + and - • a + -b; -- illegal. • -a + b; -- OK (-a)+b signed +,- > +,- • -a*b; -- OK -(a*b) signed +,- < *,/ • a + b*c; --OK a+(b*c); • -a mod b; -- OK -(a mod b); • a = 3 b=4 • -a mod 4 = -3 • (-a) mod 4 = 1 • a ** b ** c ==> a ** (b ** c)

  6. Boolean operators • Boolean expression are transferred to sum-of-prducts • form. • Example: • a nand b ==> not a or not b • a nor b ==> not a and not b • a xor b ==> (not a and b) or (a and not b) • a xnor b ==> (a and b) or (not a and not b) (equal)

  7. Comparison Operators • equality test: = and /= xnor gates • ordering test: <, <=, >, >= subtractor • 4-bit equality:

  8. Comparison Operators • 4-bit ordering tester a<b: use subtractor a-b • a<b if msb=1 • optimization can be achieved by removed the unused • subtractor outputs. • other ordering test conversion: • A. a >b ==> b<a • B. a >=b ==> not (a <b) • C. a <=b ==> not (b<a) • a <0: check the msb bit. • a>=0: check the msb bit.

  9. Array Comparison Operators • Array equality: if a’length /= b’length then a /= b • if a’length = b’length • Array inequality = • not (array equality).

  10. Array Comparison Operators • Array less-than: a(2 downto 0) < b(3 downto 0)

  11. Shift operators • Shift left logical 4 bit (sll 4):

  12. Shift operators • Shift right logical 4 bit (srl 4):

  13. Shift operators • Shift left arithemetic 4 bit (sla 4):

  14. Shift operators • Shift right 4 arithmetic bit (sra 4):

  15. Shift operators • rotate left 1 bit (rol 1):

  16. Shift operators • rotate right 1 bit (ror 1):

  17. Arithmetic operators: • + addition • - subtraction • + plus sign • - minus sign • * multiplication • / division • mod modulo arithmetic • rem remainder after division • ** exponentiation • abs absolute value

  18. Arithmetic operators: plus sign • Implement: wire (no circuitry).

  19. Arithmetic operators: minus sign • Implement: 2’s-complementor • A. 1’s complement • B. + 1. • Use ripple-borrow subtractors. • Half-Subtractor: • dif <= x xor bi; • bo <= x or bi; • Truth table:

  20. Arithmetic operators: minus sign • 4-bit 2’s-complementor:

  21. Arithmetic operators: abs • Implement: mux + two complementor.

  22. Arithmetic operators: adder • Implement: ripple-carry adder. • Full-Adder: • sum <= x xor y xor ci; • co <= (x and y) or (x and ci) • or (y and ci);

  23. Arithmetic operators: subtracter • Implement: • ripple-borrow subtracter. • Full-subtracter: • dif <= x xor y xor ci; • bo <= (not x and y) • or (not x and bi) • or (y and bi);

  24. Arithmetic operators: multiplier • Implement: array multiplier • see pp. 94 and 95

  25. Arithmetic operators: divisor • Not fully implementation, support only divide by 2^k • Implement: shifter (unsigned division by 2)

  26. Arithmetic operators: divisor • Not fully implementation, support only divide by 2^k • Implement: shifter + mux (signed division)

  27. Arithmetic operators: modulo • modulo is similar to division (not fully support). • Implement: wire (unsigned and unsigned modulo by 128)

  28. Arithmetic operators: remainder • Implement: mux + modulo

  29. Exponentiation operator: • Implement: only x**2 is allowed. • X**2 = x*x

  30. Concatenation operator: • conatenation operator allow an array to be built up • out of smaller arrays. • Implement: not circuitry required • Example: • signal a,b : std_logic_vector(15 downto 0); • signal z: std_logic_vector(31 downto 0); • … • z <= a & b;

More Related