The FC16 Forth Core Lab 7 Module F4.1. Lab 7 Hex OpcodeNameFunction 0000NOP No operation 0001DUP Duplicate T and push data stack. N <= T; N2 <= N;

Slides:



Advertisements
Similar presentations
INSTRUCTION SET ARCHITECTURES
Advertisements

WHYP Test Files Lab 9. y1 The WC16 WHYP Core Modifications for Multiplication and Division.
Msc. Ivan A. Escobar Broitman Microprocessors 1 1 The 8051 Instruction Set.
Computer Organization & Assembly Language
Divider Discussion D7.3 Example 20.
Multiplication Discussion Multiplier Binary Multiplication 4 x 4 Multiplier.
Instruction Set Architecture & Design
Data Stack Lecture 8.2 A VHDL Forth Core for FPGAs: Sect. 3.
Return Stack Lecture 8.4 A VHDL Forth Core for FPGAs: Sect. 5.
Project Done By: Apurva Patel Vrajesh Patel Swapna Kalakonda.
TK 2633 Microprocessor & Interfacing Lecture 3: Introduction to 8085 Assembly Language Programming (2) 1 Prepared By: Associate Prof. Dr Masri Ayob.
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.
For Multiplication of Signed Numbers
Division Lecture L6.3. Division
Room: E-3-31 Phone: Dr Masri Ayob TK 2633 Microprocessor & Interfacing Lecture 1: Introduction to 8085 Assembly Language.
Return Stack Lecture L7.3. A 32 x 16 Stack Same as used in the Data Stack in Lab 7.
A Programming Language for the FC16 Forth Core
Multiplication and Division Lab 9. Multiplication 13 x = 8Fh 1101 x
Division Discussion D11.3. Division
Registers Lab 5 Mano and Kime Sections 5-2, 5-3, 5-7.
Arithmetic Logic Unit (ALU) Discussion D4.6. ALU N = negative flag (N=1 if y(n)=0 Z = zero flag (Z = 1 if Y = 0) V = overflow flag C = carry flag.
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.
Other WC16 Instructions Lecture L7.4. OpcodeNameFunctionNumber of Clock Cycles Fetch the byte at address T in RAM and load it into T1 Fetch.
Microcontroller Intel 8051
Lecture 18 Last Lecture Today’s Topic Instruction formats
Forth A stack language.
Ch. 7 Logic, Shift and Rotate instr.
Machine Instruction Characteristics
Microprocessor Dr. Rabie A. Ramadan Al-Azhar University Lecture 7.
Computer Architecture and Organization
A summary of TOY. 4 Main Components Data Processor Control Processor Memory Input/Output Device.
1 Logic, Shift, and Rotate Instructions Read Sections 6.2, 7.2 and 7.3 of textbook.
October 1, 2003Serguei A. Mokhov, 1 SOEN228, Winter 2003 Revision 1.2 Date: October 25, 2003.
What is a program? A sequence of steps
CHAPTER 6 ARITHMETIC, LOGIC INSTRUCTIONS, AND PROGRAMS.
Chapter 7 Bit Manipulation. 7.1 Logical Operations.
Integer Operations Computer Organization and Assembly Language: Module 5.
Microprocessor & Assembly Language
Computer and Information Sciences College / Computer Science Department CS 206 D Computer Organization and Assembly Language.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 251 Introduction to Computer Organization.
CSC 221 Computer Organization and Assembly Language Lecture 06: Machine Instruction Characteristics.
F453 Module 8: Low Level Languages 8.2: Features of Low-Level Languages.
“ INSTRUCTIONS SET OF AVR MICROCONTROLLER ” SIGMA INSTITUTE OF ENGINEERING Prepared By: SR.NO NAME OF STUDENT ENROLLMENT 1 Abhishek Lakhara
Gursharan Singh Tatla INSTRUCTION SET OF 8085 Gursharan Singh Tatla Gursharan Singh Tatla
Unit 1 Instruction set M.Brindha AP/EIE
Classification of Instruction Set of 8051
Assembly Language Programming of 8085
Microprocessor T. Y. B. Sc..
3.Instruction Set of 8085 Consists of 74 operation codes, e.g. MOV
Lecture Set 5 The 8051 Instruction Set.
Introduction to 8085 Instructions
TAO1221 COMPUTER ARCHITECTURE AND ORGANIZATION LAB 3 & 4 Part 2
Machine control instruction
Assembly Language Programming Part 2
CDA 3101 Summer 2007 Introduction to Computer Organization
Data Processing Instructions
Stack and Subroutines Module M17.1 Section 11.2.
Fast, Asynchronous SRAM
Mano and Kime Sections 7-6 – 7-8
Shift & Rotate Instructions)
Introduction to Micro Controllers & Embedded System Design Instruction set Department of Electrical & Computer Engineering Missouri University of Science.
Shift & Rotate Instructions)
Multiplication Discussion 11.1.
DIO2 Board Projects.
Arithmetic and Logic Chapter 5
MIPS Assembly.
ARITHMETIC, LOGIC INSTRUCTIONS, AND PROGRAMS
CS501 Advanced Computer Architecture
Return Stack Lab 8.
Presentation transcript:

The FC16 Forth Core Lab 7 Module F4.1

Lab 7

Hex OpcodeNameFunction 0000NOP No operation 0001DUP Duplicate T and push data stack. N <= T; N2 <= N; 0002SWAP Exchange T and N. T <= N; N <= T; 0003DROP Drop T and pop data stack. T <= N; N <= N2; 0004OVER Duplicate N into T and push data stack. T <= N; N <= T; N2 <= N; 0005ROT Rotate top 3 elements on stack clockwise. T <= N2; N <= T; N2 <= N; 0006-ROT Rotate top 3 elements on stack counter-clockwise. T <= N; N <= N2; N2 <= T; 0007NIP Drop N and pop rest of data stack. T is unchanged. N <= N2; 0008TUCK Duplicate T into N and push rest of data stack. N2 <= T; 0009ROT_DROP Drop N2 and pop rest of data stack. T and N are unchanged. Equivalent to ROT DROP 000AROT_DROP_SWAP Drop N2 and pop rest of data stack. T and N are exchanged. Equivalent to ROT DROP SWAP Data Stack Instructions

Hex OpcodeNameFunction Pop N and add it to T Pop T and subtract it from N Add 1 to T Subtract 1 from T 0014INVERT Complement all bits of T. 0015AND Pop N1 and AND it to T. 0016OR Pop N1 and AND it to T. 0017XOR Pop N1 and AND it to T * Logic shift left T. 0019U2/ Logic shift right T. 001A2/ Arithmetic shift right T. 001BRSHIFT Pop T and shift N1 T bits to the right. 001CLSHIFT Pop T and shift N1 T bits to the left. 001Dmpp multiply partial product (used for multiplication) 001Eshldc shift left and decrement conditionally (used for division) Funit16 Instructions (fcode = lower 6 bits of opcode)

CodeNameFunction 0020TRUE Set all bits in T to ‘1’. 0021FALSE Clear all bits in T to ‘0’. 0022NOT 0= TRUE if all bits in T are ‘0’ < TRUE if sign bit of T is ‘1’. 0024U> T T (unsigned), else T <= FALSE 0025U< T <= TRUE if N < T (unsigned), else T <= FALSE 0026= T <= TRUE if N = T, else T <= FALSE 0027U>= T = T (unsigned), else T <= FALSE 0028U<= T <= TRUE if N1 <= T (unsigned), else T <= FALSE 0029<> T <= TRUE if N /= T, else T <= FALSE 002A> T T (signed), else T <= FALSE 002B< T <= TRUE if N1 < T (signed), else T <= FALSE 002C>= T = T (signed), else T <= FALSE 002D<= T <= TRUE if N1 <= T (signed), else T <= FALSE Funit16 Instructions (cont.) (fcode = lower 6-bits of opcode)

CodeNameFunction 0030>R “To-R” Pop T and push it on return stack. 0031R> “R-from” Pop return stack R and push it into T. “R-fetch” Copy R to T and push register stack 0033R>DROP “R-from-drop” Pop return stack R and throw it away Fetch the byte at address T in RAM and load it into T 0035! Store the byte in N at the address T. Pop both T and N. Fetch the byte at address T in ROM and load it into T. Fetch the 8-bit byte from Port S and load it into T. 0038DIG! Write the 4 hex digits in T to the digit register DigReg 0039LD! Store T to the LED register LDreg. Return Stack, Memory Access, and I/O Instructions

CodeNameFunction 0040LIT Load inline literal to T and push data stack. 0041JMP Jump to inline address 0042JZ Jump if all bits in T are ‘0’ 0043DRJNE Decrement R and jump if R is not zero 0044CALL Call subroutine 0045RET Subroutine return 0046JB1LO Jump if input pin B1 is LO 0047JB2LO Jump if input pin B2 is LO 0048JB3LO Jump if input pin B3 is LO 0049JB4LO Jump if input pin B4 is LO 004AJB1HI Jump if input pin B1 is HI 004BJB2HI Jump if input pin B1 is HI 004CJB3HI Jump if input pin B1 is HI 004DJB4HI Jump if input pin B1 is HI Literal and Transfer Instructions

Multiplication and Division Instructions

Multiplication 13 x = 8Fh 1101 x

Multiplication 1101 x adsh adsh sh adsh

Multiplication UM* ( u1 u2 -- upL upH ) TN N2 mpp (multiply partial product) if N(0) = 1 then adsh else sh end if; All other signed and unsigned multiplication can be derived from UM* : UM* ( u1 u2 - upL upH ) 0 4 FOR mpp NEXT ROT_DROP ;

16 x 16 = 32 Multiply Instruction : UM* ( u1 u2 - upL upH ) 0 16 FOR mpp NEXT ROT_DROP ;

Testing Multiply Instruction : MAIN ( -- ) BEGIN waitB4 get u1LO waitB4 get u1HI waitB4 get u2LO waitB4 get u2HI waitB4 UM*\ multiply DIG!\ display upH waitB4 DIG!\ display upL AGAIN ;

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 y_tmp: STD_LOGIC_VECTOR (width-1 downto 0); variable y2_tmp: STD_LOGIC_VECTOR (width-1 downto 0); variable yvec0: STD_LOGIC; AVector := '0' & a; BVector := '0' & b; CVector := '0' & c; y_tmp := false; y2_tmp := false; yVector := '0' & false; begin

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

Division

Division 8-bit/4-bit = 4: _ numer[8:0] denom[3:0] If denom < numer[7:4] then overflow (quotient won’t fit in 4 bits) Let T = numer[8:4] N = numer[3:0] N2 = denom[3:0]

Division 8-bit/4-bit = 4: sll TN N2 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;

Division 8-bit/4-bit = 4: sll TN N sub1sll sll sub1sll rem quot

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 4 FOR SHLDC NEXT denom quot rem ROT_DROP_SWAP ;

when "11111" =>-- shldc yVector := a & b(width-1); y2_tmp := b(width-2 downto 0) & '0'; if yVector > CVector then yVector := yVector - CVector; y2_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); y2 <= y2_tmp;

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

Testing Divide Instruction : MAIN ( -- ) BEGIN waitB4 get unLLO waitB4 get unLHI waitB4 get unHLO waitB4 get unHHI waitB4 get udLO waitB4 get udHI waitB4 UM/MOD\ divide Dig!\ display uq waitB4 Dig!\ display ur AGAIN ;