© 2003-2008 BYU LC3-DC Page 1 ECEn 224 LC3-DC Designing The LC-3 Control IR PC enaMARMenaPC enaALU enaMDR ALU AB.

Slides:



Advertisements
Similar presentations
Processor Data Path and Control Diana Palsetia UPenn
Advertisements

The Fetch – Execute Cycle
Chapter 5 The LC-3 Instruction Set Architecture l ISA Overview l Operate instructions l Data Movement instructions l Control Instructions l LC-3 data path.
CS25410 Memory Machine Code. Common types of non-rotating memory (1) RAMRandom Access Memory In reality, read/write memory This is usually volatile, meaning.
Chapter 5 The LC-3.
Chapter 4 - ISA 1.The Von Neumann Model. 4-2 The Stored Program Computer 1943: ENIAC Presper Eckert and John Mauchly -- first general electronic computer.
LC-3 Computer LC-3 Instructions
S. Barua – CPSC 240 CHAPTER 5 THE LC-3 Topics Memory organization Registers Instruction set Opcodes.
CHAPTER 4 COMPUTER SYSTEM – Von Neumann Model
LC-3 Instruction Set Architecture (Textbook’s Chapter 5)
Chapter 5 The LC-3 LC-3 Computer Architecture Memory Map
Chapter 6 Programming in Machine Language The LC-3 Simulator
Choice for the rest of the semester New Plan –assembler and machine language –Operating systems Process scheduling Memory management File system Optimization.
Chapters 5 - The LC-3 LC-3 Computer Architecture Memory Map
LC-3 Instruction Set Architecture
Chapters 4 & 5: LC-3 Computer Architecture Machine Instructions Assembly language Programming in Machine and Assembly Language.
Overview von Neumann Model Components of a Computer Some Computer Organization Models The Computer Bus An Example Organization: The LC-3.
Computer Science 210 Computer Organization The Instruction Execution Cycle.
The von Neumann Model – Chapter 4 COMP 2620 Dr. James Money COMP
Spring 2007W. Rhett Davis with slight modification by Dean Brock UNCA ECE 406Slide 1 ECE 406 – Design of Complex Digital Systems Lecture 11: Memories,
Conversion from one number base to another Equation simplification Conversion to/from SOP/POS Minimization using Karnaugh Maps Minterm and Maxterm Equations.
Introduction to Computing Systems from bits & gates to C & beyond Chapter 5 The LC-2 Instruction Set Architecture Operate instructions Data Movement instructions.
Introduction to Computing Systems from bits & gates to C & beyond Chapter 4 The Von Neumann Model Basic components Instruction processing.
Chapter 4 The Von Neumann Model
The von Neumann Model – Chapter 4
Introduction to Computing Systems from bits & gates to C & beyond Chapter 5 The LC-3 Instruction Set Architecture ISA Overview Operate instructions Data.
Chapter 5 The LC Instruction Set Architecture ISA = All of the programmer-visible components and operations of the computer memory organization.
Introduction to Computer Engineering CS/ECE 252, Fall 2009 Prof. Mark D. Hill Computer Sciences Department University of Wisconsin – Madison.
Introduction to Computer Engineering ECE/CS 252, Fall 2010 Prof. Mikko Lipasti Department of Electrical and Computer Engineering University of Wisconsin.
The LC-3. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 5-2 Instruction Set Architecture ISA = All of the.
Review for Final Exam LC3 – Controller FPGAs Multipliers
Chapter 5 The LC Instruction Set Architecture ISA = All of the programmer-visible components and operations of the computer memory organization.
The von Neumann Model – Chapter 4 COMP 2620 Dr. James Money COMP
Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 1 ECE 406 – Design of Complex Digital Systems Lecture 12: Intro to the.
Processor Data Path and Control How they work together.
Von Neumann Model Computer Organization I 1 September 2009 © McQuain, Feng & Ribbens The Stored Program Computer 1945: John von Neumann –
09 MUX Page 1 ECEn/CS 224 Multiplexers Decoders ROMs (LUTs)
Spring 20067W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 1 ECE 406 Design of Complex Digital Systems Lecture 11: Data Converter,
March R. Smith - University of St Thomas - Minnesota ENGR 330: Today’s Class Connecting Hardware to InstructionsConnecting Hardware to Instructions.
Spring 2009W. Rhett DavisNC State UniversityECE 406Slide 1 ECE 406 – Design of Complex Digital Systems Lecture 12: Intro to the LC-3 Micro-architecture.
Introduction to Computing Systems and Programming The LC-2.
Computer Science 210 Computer Organization Machine Language Instructions: Control.
© BYU LC3-3 Page 1 ECEn 224 The LC-3 State Machine.
LC-3 Datapath ECE/CS 252, Fall 2010 Prof. Mikko Lipasti Department of Electrical and Computer Engineering University of Wisconsin – Madison.
Chapter 4 The Von Neumann Model
Computer Science 210 Computer Organization
Introduction to Computer Engineering
Chapter 4 The Von Neumann Model
Computer Science 210 Computer Organization
Chapter 5 The LC-3.
The LC-3 Instruction Set Architecture Data Movement instructions
Chapter 4 The Von Neumann Model
Computer Science 210 Computer Organization
Chapter 5 The LC-3.
Design of the Control Unit for One-cycle Instruction Execution
Computer Science 210 Computer Organization
Topic 6 LC-3.
Introduction to Computer Engineering
Computer Science 210 Computer Organization
Computer Science 210 Computer Organization
Computer Science 210 Computer Organization
Chapter 4 The Von Neumann Model
LC-2: The Little Computer 2
The Stored Program Computer
Basic components Instruction processing
Introduction to Computer Engineering
Introduction to Computer Engineering
Introduction to Computer Engineering
Introduction to Computer Engineering
Instruction Set Architecture
Presentation transcript:

© BYU LC3-DC Page 1 ECEn 224 LC3-DC Designing The LC-3 Control IR PC enaMARMenaPC enaALU enaMDR ALU AB

© BYU LC3-DC Page 2 ECEn 224 The Von Neumann Model Fetch an instruction Execute it Fetch the next instruction continue... Fetch Execute

© BYU LC3-DC Page 3 ECEn 224 The Fetch Cycle 1.PC  MAR 2.PC  PC+1, Mem[MAR]  MDR 3.MDR  IR Fetch0 Fetch1 Fetch2 enaPC ldMAR enaMDR ldIR selPC = “00” ldPC selMDR = ‘1’ ldMDR

© BYU LC3-DC Page 4 ECEn 224 A Note on Timing u In all cases:  Buses are driven and muxes are selected during a state  Registers and memory inputs are latched on the rising clock edge at the end of the state

© BYU LC3-DC Page 5 ECEn 224 Fetch 0 Fetch 1Fetch 2 PC contents are driven onto the Bus enaPC ldMAR CLK CS MAR actually loads on clock edge MAR Fetch0 Fetch1 Fetch2 enaPC ldMAR enaMDR ldIR selPC = “00” ldPC selMDR = ‘1’ ldMDR

© BYU LC3-DC Page 6 ECEn 224 Fetch 0 Fetch 1Fetch 2 Memory is being accessed and generates its output ldMDR CLK CS MDR actually loads on clock edge MDR ldIR Fetch0 Fetch1 Fetch2 enaPC ldMAR enaMDR ldIR selPC = “00” ldPC selMDR = ‘1’ ldMDR

© BYU LC3-DC Page 7 ECEn 224 Fetch 0 Fetch 1Fetch 2 MDR output is driven onto bus ldMDR CLK CS IR actually loads on clock edge MDR ldIR IR Fetch0 Fetch1 Fetch2 enaPC ldMAR enaMDR ldIR selPC = “00” ldPC selMDR = ‘1’ ldMDR

© BYU LC3-DC Page 8 ECEn 224 A Note on PC Incrementing u The PC is always incremented during the fetch process, before the instruction is executed  This means that during instruction execution, PC points to the next instruction to be executed, not the instruction being executed u For a branch or jump, the PC will get loaded with a different value during the execution phase of the instruction u PC relative addressing is relative to the address of the next instruction to be executed

© BYU LC3-DC Page 9 ECEn 224 The Decode State Decode from Fetch2 ADD0LD0 STR0 JSR0 TRAP0 … …………… opCode=0001 opCode=0010 opCode=0111 opCode=0100 opCode=1111 The only state with a conditional branch in the machine…

© BYU LC3-DC Page 10 ECEn 224 The Decoder IR[15:12] BR ADD LD ST JSR AND LDR STR RTI NOT LDI STI JMP reserved LEA TRAP :16 Decoder We could use a decoder to differentiate between instructions

© BYU LC3-DC Page 11 ECEn 224 LEA Instruction  Send DR field from IR as address to the register file (a)  Add the contents of the PC to the sign extended PCoffset9 from the IR to form the effective address (b)  Store the generated address into the DR (c) a b c IR ALU PC AB LEAPCoffset9DR How many clock cycles does all this take?

© BYU LC3-DC Page 12 ECEn 224 The LEA Instruction LEA 1110PCoffset9 DR LEA0 selEAB1 = ‘0’ selEAB2 = “10” selMAR = ‘0’ enaMARM DR = IR[11:9] regWE to Fetch0 u R[DR]  PC + IR[8:0] u Note that the PC Offset is always a 2’s complement (signed) value

© BYU LC3-DC Page 13 ECEn 224 LDR Instruction LDRoffset6DRBaseR  Send BaseR field from IR as address to the register file (a)  Add the contents of BaseR to the sign extended offset6 from the IR to form the destination memory address for the STR (b)  Store the generated address into the MAR (c) a b c IR ALU PC AB

© BYU LC3-DC Page 14 ECEn 224 LDR Instruction LDRindex6DRBaseR  Store the contents of memory to the MDR (d)  Send DR field from IR as address to the register file (e)  Write the contents of the MDR into the DR (f) e IR ALU PC d f AB How many clock cycles does all this take?

© BYU LC3-DC Page 15 ECEn 224 The LDR Instruction u MAR  R[BaseR]+offset6 u MDR  Mem[MAR] u R[DR]  MDR LDR0 SR1 = IR[8:6] selEAB1 = ‘1’ selEAB2 = “01” selMAR = ‘0’ enaMARM ldMAR LDR1 LDR2 enaMDR DR = IR[11:9] regWE to Fetch0 LDR 0110offset6 DR BaseR selMDR = ‘1’ ldMDR

© BYU LC3-DC Page 16 ECEn 224 LDI Instruction LDIPCoffset9DR  Add the contents of the PC to the sign extended PCoffset9 from the IR to form the source memory address for the LDI (a)  Store the generated address into the MAR (b)  Load the memory contents into the MDR (c)  Load the contents of the MDR into the MAR (d) a IR ALU PC AB b c d

© BYU LC3-DC Page 17 ECEn 224 LDI Instruction LDIPCoffset9DR  Load the memory contents into the MDR (e)  Load the contents of the MDR into the DR (f) IR ALU PC AB e How many clock cycles does all this take?

© BYU LC3-DC Page 18 ECEn 224 The LDI Instruction u MAR  PC + IR[8:0] u MDR  Mem[MAR] u MAR  MDR u MDR  Mem[MAR] u R[DR]  MDR LDI0 LDI1 LDI2 enaMDR ldMAR to Fetch0 LDI 1010PCoffset9 DR LDI4 LDI3 enaMDR DR = IR[11:9] regWE selMDR = ‘1’ ldMDR selMDR = ‘1’ ldMDR selEAB1 = ‘0’ selEAB2 = “10” selMAR = ‘0’ enaMARM ldMAR

© BYU LC3-DC Page 19 ECEn 224 STR Instruction  Send BaseR field from IR as address to the register file (a)  Add the contents of BaseR to the sign extended offset6 from the IR to form the destination memory address for the STR (b)  Store the generated address into the MAR (c) a b c IR ALU PC AB STRoffset6SRBaseR

© BYU LC3-DC Page 20 ECEn 224 STR Instruction STRoffset6SRBaseR  Send SR field from IR as address to the register file (d)  Store the contents of SR to the MDR (e)  Perform the memory write (f) d IR ALU PC PASS e f AB How many clock cycles does all this take?

© BYU LC3-DC Page 21 ECEn 224 The STR Instruction u MAR  R[BaseR]+offset u MDR  R[SR] u Write memory STR0 SR1 = IR[8:6] selEAB1 = ‘1’ selEAB2 = “01” selMAR = ‘0’ enaMARM ldMAR STR1 STR2 memWE SR1 = IR[11:9] aluControl = PASS enaALU selMDR = ‘0’ ldMDR to Fetch0 STR 0111offset6 SR BaseR

© BYU LC3-DC Page 22 ECEn 224 STI Instruction STIPCoffset9SR  Add the contents of the PC to the sign extended PCoffset9 from the IR to form the source memory address for the STI (a)  Store the generated address into the MAR (b)  Load the memory contents into the MDR (c)  Load the contents of the MDR into the MAR (d) a IR ALU PC AB b c d

© BYU LC3-DC Page 23 ECEn 224 STI Instruction STIPCoffset9SR  Load the contents of the source register into the MDR (e)  Load the contents of the MDR into the DR (f) IR ALU PC AB PASS e f How many clock cycles does all this take?

© BYU LC3-DC Page 24 ECEn 224 The STI Instruction u MAR  PC + IR[8:0] u MDR  M[MAR] u MAR  MDR u MDR  R[SR] u Write memory enaMDR ldMAR STI 1011PCoffset9 SR SR1 = IR[11:9] aluControl = PASS enaALU selMDR = ‘0’ ldMDR memWE selEAB1 = ‘0’ selEAB2 = “10” selMAR = ‘0’ enaMARM ldMAR selMDR = ‘1’ ldMDR STI0 STI1 STI2 to Fetch0 STI4 STI3

© BYU LC3-DC Page 25 ECEn 224 JSRR Instruction JSRR  Load the contents of the PC into R7 (a)  Load the contents of the base address register into the PC (b) IR ALU PC AB 0 BaseR ‘111’ a b How many clock cycles does all this take?

© BYU LC3-DC Page 26 ECEn 224 The JSRR Instruction u Note: Same opcode as JSR! (determined by IR bit 11) u R7  PC u PC  R[BaseR] enaPC DR = “111”, regWE JSRR BaseR SR1 = IR[8:6] selEAB1 = ‘1’ selEAB2 = “00” selPC = “01” ldPC JSRR1 to Fetch0 JSRR0

© BYU LC3-DC Page 27 ECEn 224 The BR Instruction  Simply check NZP flags with nzp from instruction to decide whether to ldPC or not u Method 1: Could bring nzp flags into FSM as inputs and put comparison into state table… Bad idea  Makes FSM more complicated u Method 2: Do comparison with some external gates and bring single-bit input into FSM….Good idea BR 0000n z p PCoffset

© BYU LC3-DC Page 28 ECEn 224 The BR Instruction BR 0000n z p PCoffset BranchTaken = (n N) + (z Z) + (p P) 1 Bit Condition Code Registers