CENG3420 Lab 3-1: LC-3b Datapath Wei Li Department of Computer - - PowerPoint PPT Presentation

ceng3420 lab 3 1 lc 3b datapath
SMART_READER_LITE
LIVE PREVIEW

CENG3420 Lab 3-1: LC-3b Datapath Wei Li Department of Computer - - PowerPoint PPT Presentation

CENG3420 Lab 3-1: LC-3b Datapath Wei Li Department of Computer Science and Engineering The Chinese University of Hong Kong wli@cse.cuhk.edu.hk Spring 2020 1 / 22 Overview Introduction Lab3-1 Assignment Golden Results 2 / 22 Overview


slide-1
SLIDE 1

CENG3420 Lab 3-1: LC-3b Datapath

Wei Li

Department of Computer Science and Engineering The Chinese University of Hong Kong

wli@cse.cuhk.edu.hk

Spring 2020

1 / 22

slide-2
SLIDE 2

Overview

Introduction Lab3-1 Assignment Golden Results

2 / 22

slide-3
SLIDE 3

Overview

Introduction Lab3-1 Assignment Golden Results

3 / 22

slide-4
SLIDE 4

The Slides are self-contained? NO!

Do please refer to following document:

◮ LC-3b-datapath.pdf ◮ LC-3b-ISA.pdf

3 / 22

slide-5
SLIDE 5

LC-3b Microarchitecture

4 / 22

slide-6
SLIDE 6

Input of Control Structure (7 bits)

◮ R: indicate whether memory data is ready (System_Latches::READY) ◮ BEN: indicate whether BR been taken (System_Latches::BEN) ◮ IR[15:11]: current instruction (System_Latches::IR)

5 / 22

slide-7
SLIDE 7

Output of Control Structure: (35 bits)

◮ 26 bits to control data path ◮ J[5:0], COND[1:0],IRD: generate address of control structure for next clock cycle

6 / 22

slide-8
SLIDE 8

LC-3b Control Structure

7 / 22

slide-9
SLIDE 9

LC-3b Control Structure

7 / 22

slide-10
SLIDE 10

How’s Microsequencer Actually Working?

R PC<−BaseR To 18 12 To 18 To 18 R R To 18 To 18 To 18 MDR<−SR[7:0] MDR <− M IR <− MDR R DR<−SR1+OP2* set CC DR<−SR1&OP2* set CC [BEN] PC<−MDR 32 1 5 1 To 18 To 18 To 18 R R [IR[15:12]] 28 30 R7<−PC MDR<−M[MAR] set CC BEN<−IR[11] & N + IR[10] & Z + IR[9] & P 9 DR<−SR1 XOR OP2* 4 22 To 11

1011 JSR JMP BR 1010

To 10 21 20 1

LDB

MAR<−B+off6 set CC To 18 MAR<−B+off6 DR<−MDR set CC To 18 MDR<−M[MAR] 25 27 3 7 6 2

STW STB LEA SHF TRAP XOR AND ADD RTI

To 8 set CC 14

LDW

MAR<−B+LSHF(off6,1) MAR<−B+LSHF(off6,1) PC<−PC+LSHF(off9,1) 33 35 DR<−SHF(SR,A,D,amt4) NOTES B+off6 : Base + SEXT[offset6] R MDR<−M[MAR[15:1]’0] DR<−SEXT[BYTE.DATA] R 29 18, 19 MDR<−SR To 18 R R M[MAR]<−MDR 16 23 R R 17 To 19 24 M[MAR]<−MDR** MAR<−LSHF(ZEXT[IR[7:0]],1) 15 To 18 PC+off9 : PC + SEXT[offset9] MAR <− PC PC <− PC + 2 *OP2 may be SR2 or SEXT[imm5] ** [15:8] or [7:0] depending on MAR[0] set CC DR<−PC+LSHF(off9,1) 13 31 [IR[11]] R7<−PC PC<−BaseR PC<−PC+LSHF(off11,1) R7<−PC

8 / 22

slide-11
SLIDE 11

How’s Control Store Actually Implemented?

Finite-State-Machine (FSM)

◮ States 10, 11 are empty ◮ 6 bits input enough ◮ Per state, output 35 bits

9 / 22

slide-12
SLIDE 12

How’s Control Store Actually Implemented?

Finite-State-Machine (FSM)

◮ States 10, 11 are empty ◮ 6 bits input enough ◮ Per state, output 35 bits

Hard to implement

9 / 22

slide-13
SLIDE 13

Good News!

◮ Part of FSM has been provided ◮ See file “ucode3”

10 / 22

slide-14
SLIDE 14

Overview

Introduction Lab3-1 Assignment Golden Results

11 / 22

slide-15
SLIDE 15

Operations in One Clock Cycle

In “lc3bsim3-1.c”:

void cycle() { eval_micro_sequencer(); cycle_memory(); eval_bus_drivers(); drive_bus(); latch_datapath_values(); CURRENT_LATCHES = NEXT_LATCHES; CYCLE_COUNT++; }

11 / 22

slide-16
SLIDE 16

Lab3-1 Assignment

◮ Input: CURRENT_LATCHES ◮ Output: NEXT_LATCHES.MICROINSTRUCTION

12 / 22

slide-17
SLIDE 17

Lab3-1 Assignment Tips

13 / 22

slide-18
SLIDE 18

Lab3-1 Assignment Tips (cont.)

Some functions may help:

◮ GetCOND() ◮ GetIRD() ◮ GetJ() ◮ partVal()

14 / 22

slide-19
SLIDE 19

Overview

Introduction Lab3-1 Assignment Golden Results

15 / 22

slide-20
SLIDE 20

Assignment Package

◮ lc3bsim3-1.c, lc3bsim3-1.h: codes to work on ◮ libems3-1.a: library ◮ ucode3: FSM ◮ Makefile ◮ bench: folder with benchmarks

Run the simulator:

  • 1. make, then binary “lc3bsim3-1” is generated
  • 2. ./lc3bsim3-1 ucode3 bench/toupper.cod

15 / 22

slide-21
SLIDE 21

Golden Results – case toupper.cod

  • 1. run 6

Simulating for 6 cycles... MemCycleCnt = 0 MEM_EN = 0, R_W = 0, WE0 = 0, WE1 = 0 MemCycleCnt = 0 MEM_EN = 1, R_W = 0, WE0 = 0, WE1 = 0 MemCycleCnt = 1 MEM_EN = 1, R_W = 0, WE0 = 0, WE1 = 0 MemCycleCnt = 2 MEM_EN = 1, R_W = 0, WE0 = 0, WE1 = 0 MemCycleCnt = 3 MEM_EN = 1, R_W = 0, WE0 = 0, WE1 = 0 MemCycleCnt = 4 MEM_EN = 1, R_W = 0, WE0 = 0, WE1 = 0

16 / 22

slide-22
SLIDE 22

Golden Results – case toupper.cod (cont.)

  • 2. rdump

Current register/bus values :

  • Cycle Count

: 6 PC : 0x3002 IR : 0x0000 STATE_NUMBER : 0x0023 BUS : 0x0000 MDR : 0xe00f MAR : 0x3000 CCs: N = 0 Z = 1 P = 0 Registers: 0: 0x0000 1: 0x0000 2: 0x0000 3: 0x0000 4: 0x0000 5: 0x0000 6: 0x0000 7: 0x0000

17 / 22

slide-23
SLIDE 23

Golden Results – case toupper.cod (cont.)

  • 3. Go on run 1

Simulating for 1 cycles... MemCycleCnt = 1 MEM_EN = 0, R_W = 0, WE0 = 0, WE1 = 0

18 / 22

slide-24
SLIDE 24

Golden Results – case toupper.cod (cont.)

  • 4. rdump

Current register/bus values :

  • Cycle Count

: 7 PC : 0x3002 IR : 0xe00f STATE_NUMBER : 0x0020 BUS : 0xe00f MDR : 0xe00f MAR : 0x3000 CCs: N = 0 Z = 1 P = 0 Registers: 0: 0x0000 1: 0x0000 2: 0x0000 3: 0x0000 4: 0x0000 5: 0x0000 6: 0x0000 7: 0x0000

19 / 22

slide-25
SLIDE 25

Golden Results – case toupper.cod (cont.)

  • 5. Go on run 5

Simulating for 5 cycles... MemCycleCnt = 0 MEM_EN = 0, R_W = 0, WE0 = 0, WE1 = 0 MemCycleCnt = 0 MEM_EN = 0, R_W = 0, WE0 = 0, WE1 = 0 MemCycleCnt = 0 MEM_EN = 0, R_W = 0, WE0 = 0, WE1 = 0 MemCycleCnt = 0 MEM_EN = 1, R_W = 0, WE0 = 0, WE1 = 0 MemCycleCnt = 1 MEM_EN = 1, R_W = 0, WE0 = 0, WE1 = 0

20 / 22

slide-26
SLIDE 26

Golden Results – case toupper.cod (cont.)

  • 6. rdump

Current register/bus values :

  • Cycle Count

: 12 PC : 0x3004 IR : 0xe00f STATE_NUMBER : 0x0021 BUS : 0x0000 MDR : 0x0000 MAR : 0x3002 CCs: N = 0 Z = 0 P = 1 Registers: 0: 0x3020 1: 0x0000 2: 0x0000 3: 0x0000 4: 0x0000 5: 0x0000 6: 0x0000 7: 0x0000

21 / 22

slide-27
SLIDE 27
  • Thanks. For any question:

byu@cse.cuhk.edu.hk wli@cse.cuhk.edu.hk

22 / 22