WHYP Test Files Lab 9. y1 The WC16 WHYP Core Modifications for Multiplication and Division.

Slides:



Advertisements
Similar presentations
A Simple Microcontroller VHDL Tutorial R. E. Haskell and D. M. Hanna T6: VHDL State Machines.
Advertisements

Multi-Base Calculator CSE378 Final Project By Matthew Lehn & Yanqing Zhu December 17, 2001 Professor Haskell.
Lab 6 Program Counter and Program ROM Mano & Kime Sections 7-1 – 7-6.
Digilab DIO2 LCD Module F5.1. DIO2 circuit board block diagram.
The FC16 Forth Core Lab 7 Module F4.1. Lab 7 Hex OpcodeNameFunction 0000NOP No operation 0001DUP Duplicate T and push data stack. N
Return Stack Lecture L7.3. A 32 x 16 Stack Same as used in the Data Stack in Lab 7.
Basic Gates Discussion D2.1. Basic Gates NOT Gate AND Gate OR Gate XOR Gate NAND Gate NOR Gate XNOR Gate.
A Programming Language for the FC16 Forth Core
Programming Example Lecture 8.6 A VHDL Forth Core for FPGAs: Sect. 7.
Multiplication and Division Lab 9. Multiplication 13 x = 8Fh 1101 x
Design of Embedded Systems Using 68HC12(11) Microcontrollers - R. E. Haskell 68HC12 Arithmetic Chapter 3.
Registers Lab 5 Mano and Kime Sections 5-2, 5-3, 5-7.
Data Stack Instructions Lab 7. Data Stack WHYP Data Stack Instructions DUP( n -- n n ) SWAP( a b -- b a ) DROP( a -- ) OVER( a b -- a b a ) ROT( a.
(BASIC MATH) QUIZ. START!! Click Here!! 1. What is Addition? a. The act or process of adding numbers. The act or process of adding numbers. b. The act.
Addition & Subtraction Add Plus More than Subtract Difference Take away Altogether Minus Less than +-
SQUARE ROOT METHOD. Simplify Radicals A. Single Ex.
How to work out Integers using BEDMAS
Addition, Subtraction, Multiplication, and Division of Integers
CSE1301 Computer Programming Lecture 5: C Primitives 2 Corrections.
© T Madas. Fill in this negative multiplication table. [the numbers multiplied are all whole negative & positive numbers]
Dividing fractions 4/5 ÷ 7/8 = ?. When you are dividing fractions, invert the divisor. In other words, flip the right fraction. 4/5 ÷ 7/8 8/7= ?
Variables and Algebraic Expressions 1-3. Vocabulary Variable- a letter represents a number that can vary. Constant- a number that does not change. Algebraic.
Decimals. Addition & Subtraction Example Find: Solution: = = =18.32 – =
177 8 Start by setting up the problem like this. It looks just like the traditional long division method, except for the long line that is drawn to the.
Table of Contents Dividing Rational Expressions Use the following steps to divide rational expressions. 1.Take the reciprocal of the rational expression.
Other Arithmetic Functions Section 4-5
INTEGER RULES. Adding Integers Adding IntegersRule # 1: Same Signs When adding integers with same signs, you add the numbers and write the common sign.
$100 $200 $300 $400 $100 $200 $300 $400 $300 $200 $100 Writing variable equations Find variables in addition equations Find variables in subtraction.
2-1 Variables and Expressions Course 1 Lesson Presentation Lesson Presentation Problem of the Day Problem of the Day 2-1 Variables and Expressions Course.
Hangman Division (Partial Quotient)
Variables and Expressions #4. A variable is a letter or symbol that represents a quantity that can change. A constant is a quantity that does not change.
Vocabulary Variable Constant Algebraic Expression Evaluate.
2.2 Addition of Real Numbers 2.3 Subtraction of Real Numbers Objectives: -add real numbers using a number line or addition rules -Subtract real numbers.
Multiplication
Distributive Property of Multiplication 306 x 2
Multiplication table. x
Assembly Language Assembly Language
Multiplication
Multiplication and Division by Powers of Ten
Multiplication and Division
Partial Quotients Help Students build on multiplies of ten and find easy multiples of the divisor.
Powers of 10 Add 1 to the power Subtract 1 from the power
Multiplication by small constants (pp. 139 – 140)
Enhancing Data Path M 4-bit Reg X A L U
Dots 5 × TABLES MULTIPLICATION.
Dots 5 × TABLES MULTIPLICATION.
Dots 2 × TABLES MULTIPLICATION.
5 × 7 = × 7 = 70 9 × 7 = CONNECTIONS IN 7 × TABLE
5 × 8 = 40 4 × 8 = 32 9 × 8 = CONNECTIONS IN 8 × TABLE
Partial Quotients Help Students build on multiplies of ten and find easy multiples of the divisor.
DIO2 Board Projects.
Dots 3 × TABLES MULTIPLICATION.
Dots 6 × TABLES MULTIPLICATION.
4 × 6 = 24 8 × 6 = 48 7 × 6 = CONNECTIONS IN 6 × TABLE
5 × 6 = 30 2 × 6 = 12 7 × 6 = CONNECTIONS IN 6 × TABLE
Dots 2 × TABLES MULTIPLICATION.
Dots 4 × TABLES MULTIPLICATION.
Number Lines.
10 × 8 = 80 5 × 8 = 40 6 × 8 = CONNECTIONS IN 8 × TABLE MULTIPLICATION.
3 × 12 = 36 6 × 12 = 72 7 × 12 = CONNECTIONS IN 12 × TABLE
x/÷ Numbers Year 3-4 – Multiply and divide a multiple of 10
Multiply and divide Expressions
Do Now Simplify. 1. 5(7) – (18 – 11)  (40 – 35) (12 – 4)
What do you think it means? Before:
5 × 12 = × 12 = × 12 = CONNECTIONS IN 12 × TABLE MULTIPLICATION.
Multiplication and Division of Integers
Multiplying and Dividing Decimals
5 × 9 = 45 6 × 9 = 54 7 × 9 = CONNECTIONS IN 9 × TABLE
3 × 7 = 21 6 × 7 = 42 7 × 7 = CONNECTIONS IN 7 × TABLE
Dots 3 × TABLES MULTIPLICATION.
Presentation transcript:

WHYP Test Files Lab 9

y1 The WC16 WHYP Core Modifications for Multiplication and Division

Used only for DIO2 Board 7 different test programs

CodeNameFunction 001Dmpp multiply partial product (used for multiplication) 001Eshldc shift left and decrement conditionally (used for division) Table 1 New Funit Instructions

-- Function Unit instructions constant plus: opcode := X"0010"; -- + constant minus: opcode := X"0011"; -- - constant plus1: opcode := X"0012"; constant minus1: opcode := X"0013"; constant invert: opcode := X"0014"; -- INVERT constant andd: opcode := X"0015"; -- AND constant orr: opcode := X"0016"; -- OR constant xorr: opcode := X"0017"; -- XOR constant twotimes: opcode := X"0018"; -- 2* constant u2slash: opcode := X"0019"; -- U2/ constant twoslash: opcode := X"001A"; -- 2/ constant rshift: opcode := X"001B"; -- RSHIFT constant lshift: opcode := X"001C";-- LSHIFT constant mpp: opcode := X"001D";-- mpp constant shldc: opcode := X"001E";-- shldc opcodes.vhd

Multiply partial product when mpp => tload <= '1'; nload <= '1'; nsel <= "10"; fcode <= icode(5 downto 0); mpp

variable AVector: STD_LOGIC_VECTOR (width downto 0); variable BVector: STD_LOGIC_VECTOR (width downto 0); variable CVector: STD_LOGIC_VECTOR (width downto 0); variable yVector: STD_LOGIC_VECTOR (width downto 0); variable y1_tmp: STD_LOGIC_VECTOR (width-1 downto 0); AVector := '0' & a; BVector := '0' & b; CVector := '0' & c; y1_tmp := false; yVector := '0' & false; begin In Funit2

when "011101" =>-- mpp if b(0) = '1' then yVector := AVector + CVector; else yVector := AVector; end if; y <= yVector(width downto 1); y1 <= yVector(0) & b(width-1 downto 1); mpp (multiply partial product) if N(0) = 1 then adsh else sh end if; TN N2

: UM* ( u1 u2 - upL upH ) 0 mpp mpp ROT_DROP ; 16 x 16 = 32 Multiplication

Shift left and decrement conditionally when shldc=> tload <= '1'; nload <= '1'; nsel <= "10"; fcode <= icode(5 downto 0); shldc

Division : UM/MOD ( unumL unumH udenom -- urem uquot ) All other signed and unsigned division operations can be derived as WHYP words from UM/MOD TN N2 TN -ROT\ udenom unumL unumH SHLDC SHLDC \ denom quot rem ROT_DROP_SWAP ;

when "011110" =>-- shldc yVector := a & b(width-1); y1_tmp := b(width-2 downto 0) & '0'; if yVector > CVector then yVector := yVector - CVector; y1_tmp(0) := '1'; end if; for I in 0 to 3 loop sll T & N; if T[8:4] > N2 then T := T - (0 & N2); N(0) := ‘1’; end if; end loop; sll TN N2 y <= yVector(width-1 downto 0); y1 <= y1_tmp;

32 / 16 = 16:16 Division : UM/MOD ( unL unH ud -- ur uq ) -ROT shldc shldc ROT_DROP_SWAP ;

WHYP Test Files sdigtest.whp-- tests the switches and 7-segment displays hex2asc.whp-- converts hex to ascii minmax.whp-- finds the min and max of two numbers mul.whp-- multiplies two 16-bit numbers div.whp-- divides a 32-bit number by a 16-bit number fact16.whp-- computes the factorial of a number leap.whp-- checks if a year is a leap year

SDigtest.whp \ Test of JB4HI, JB4LO, and DIG! : main( -- ) BEGIN waitB4 DIG! AGAIN ;

Hex2asc.whp \ Convert hex to ASCII HEX : hex2asc ( n -- asc ) 0F AND \ mask upper nibble DUP 9 > \ if n > 9 IF 37 + \ add $37 ELSE 30 + \ else add $30 THEN ; : main( -- ) BEGIN waitb4 DUP DIG! waitb4 hex2asc DIG! AGAIN ;

Minmax.whp \MIN MAX : MIN( n1 n2 -- min ) OVER OVER >\ n1 n2 f IF\ n1 n2 SWAP\ n2 n1 THEN DROP ;\ min : MAX( n1 n2 -- max ) OVER OVER <\ n1 n2 f IF\ n1 n2 NIP\ n2 ELSE DROP\ n1 THEN ; : main( -- ) BEGIN waitB4 DUP DIG! waitB4 DUP DIG! waitB4 OVER OVER MIN DIG! waitB4 MAX DIG! AGAIN ;

Mul.whp : UM* ( u1 u2 - upL upH ) 0 mpp mpp ROT_DROP ; : MAIN ( -- ) BEGIN waitB4 get u1HI DUP DIG! 8 LSHIFT waitB4 get u1LO OR DUP DIG! waitB4 get u2HI DUP DIG! 8 LSHIFT waitB4 get u2LO OR DUP DIG! waitB4 UM*\ multiply DIG!\ display upH waitB4 DIG!\ display upL AGAIN ;

Div.whp : UM/MOD ( unL unH ud -- ur uq ) -ROT shldc shldc ROT_DROP_SWAP ; : MAIN ( -- ) BEGIN waitB4 get unHHI DUP DIG! 8 LSHIFT waitB4 get unHLO OR DUP DIG! waitB4 get unLHI DUP DIG! 8 LSHIFT waitB4 get unLLO OR DUP DIG! SWAP\ numerator waitB4 get udHI DUP DIG! 8 LSHIFT waitB4 get udLO OR\ denominator DUP DIG! waitB4 UM/MOD\ divide DIG!\ display uq waitB4 DIG!\ display ur AGAIN ;

Fact16.whp \ Example of BEGIN...WHILE...REPEAT : UM* ( u1 u2 - upL upH ) 0 mpp mpp ROT_DROP ; : *( n1 n2 -- n3 ) UM* DROP ; : factorial ( n -- n! ) 1 2 ROT \ x i n BEGIN \ x i n OVER OVER <= \ x i n f WHILE \ x i n -ROT TUCK \ n i x i * SWAP \ n x' i 1+ ROT \ x' i' n REPEAT \ x i n DROP DROP ; \ x : main( -- ) BEGIN waitB4 DUP DIG! waitB4 factorial DIG! AGAIN ;

Leap.whp \ leap year : UM/MOD ( unumL unumH udenom - urem uquot ) -ROT 16 FOR shldc NEXT ROT_DROP_SWAP ; : U/MOD( n1 n2 -- urem uquot ) >R 0 R> UM/MOD ; : MOD( n1 n2 -- urem ) U/MOD DROP ;

Leap.whp (cont.) : ?leap ( year -- flag ) DUP 400 MOD 0= IF DROP TRUE ELSE DUP 100 MOD 0= IF DROP FALSE ELSE 4 MOD 0= IF TRUE ELSE FALSE THEN THEN ; : main( -- ) BEGIN waitB4 DUP DIG! 8 LSHIFT waitB4 OR DUP DIG! waitB4 ?leap DIG! AGAIN ; Note: A year is a leap year if it is divisible by 4, but not by 100, or if it is divisible by 400.