CS150 Final Exam Review - University of California, Berkeleycs150/fa12/agenda/... · Memory timings...

24
CS150 — Final Exam Review Albert Magyar December 13, 2012

Transcript of CS150 Final Exam Review - University of California, Berkeleycs150/fa12/agenda/... · Memory timings...

Page 1: CS150 Final Exam Review - University of California, Berkeleycs150/fa12/agenda/... · Memory timings I Assuming every fetch is completely random in the address space, might have to

CS150 — Final Exam Review

Albert Magyar

December 13, 2012

Page 2: CS150 Final Exam Review - University of California, Berkeleycs150/fa12/agenda/... · Memory timings I Assuming every fetch is completely random in the address space, might have to

Digital logic

F = Sm(3,4,5,6,8,10,12,14,15)

F = Σm(3, 4, 5, 6, 11, 12, 13, 14)

Page 3: CS150 Final Exam Review - University of California, Berkeleycs150/fa12/agenda/... · Memory timings I Assuming every fetch is completely random in the address space, might have to

Starting a K-map – truth values filled in

0 0 1 0

1 1 0 1

1 1 0 1

0 0 1 0

00

00

01

01

11

11

10

10

AB

CD

Page 4: CS150 Final Exam Review - University of California, Berkeleycs150/fa12/agenda/... · Memory timings I Assuming every fetch is completely random in the address space, might have to

Grouped K-map with red, green, and blue shading

0 0 1 0

1 1 0 1

1 1 0 1

0 0 1 0

00

00

01

01

11

11

10

10

AB

CD

F = BC + BD + BCD

Page 5: CS150 Final Exam Review - University of California, Berkeleycs150/fa12/agenda/... · Memory timings I Assuming every fetch is completely random in the address space, might have to

NAND implementation

Decompose into ternary NAND of three intermediate functions.

F = BC + BD + BCD

F = X + Y + Z

F = (X Y Z )

F = NAND3(X , Y , Z )

Page 6: CS150 Final Exam Review - University of California, Berkeleycs150/fa12/agenda/... · Memory timings I Assuming every fetch is completely random in the address space, might have to

NAND implementation

X = BC =⇒ X = NAND2(B, C )

Y = BD =⇒ Y = NAND2(B, D)

Z = BCD =⇒ Z = NAND3(BCD)

Page 7: CS150 Final Exam Review - University of California, Berkeleycs150/fa12/agenda/... · Memory timings I Assuming every fetch is completely random in the address space, might have to

NAND implementation

Putting it all together:

Page 8: CS150 Final Exam Review - University of California, Berkeleycs150/fa12/agenda/... · Memory timings I Assuming every fetch is completely random in the address space, might have to

CMOS implementation

Use SOP to draw pull-up (taking care to invert each signal)

F = BC + BD + BCD

Page 9: CS150 Final Exam Review - University of California, Berkeleycs150/fa12/agenda/... · Memory timings I Assuming every fetch is completely random in the address space, might have to

CMOS implementation – could be better still (but okay)

Swap parallel for serial to draw pull-down with NMOS.

F = BC + BD + BCD

Page 10: CS150 Final Exam Review - University of California, Berkeleycs150/fa12/agenda/... · Memory timings I Assuming every fetch is completely random in the address space, might have to

FSM

Part a): The purpose of this FSM is to detect the pattern 0110.It does not detect overlapping patterns.

Page 11: CS150 Final Exam Review - University of California, Berkeleycs150/fa12/agenda/... · Memory timings I Assuming every fetch is completely random in the address space, might have to

Part b)

assign out = (current state == STATE 3) && in;

always @(posedge clk) begin

if (rst) current state <= STATE 0;

else current state <= next state;

end

always @(*) begin

case (current state)

STATE 0 : next state = in ? STATE 0 : STATE 1;

STATE 1 : next state = in ? STATE 2 : STATE 1;

STATE 2 : next state = in ? STATE 3 : STATE 1;

default : next state = STATE 0;

endcase

end

Page 12: CS150 Final Exam Review - University of California, Berkeleycs150/fa12/agenda/... · Memory timings I Assuming every fetch is completely random in the address space, might have to

Logic-level implementation

Create per-bit truth tables for next state:

cs1 cs0 in ns00 0 0 1

0 0 1 0

0 1 0 1

0 1 1 0

1 0 0 1

1 0 1 1

1 1 0 0

1 1 1 0

ns0 = cs1 · ¯cs0 + ¯cs1 · in

Page 13: CS150 Final Exam Review - University of California, Berkeleycs150/fa12/agenda/... · Memory timings I Assuming every fetch is completely random in the address space, might have to

Logic-level implementation

cs1 cs0 in ns10 0 0 0

0 0 1 0

0 1 0 0

0 1 1 1

1 0 0 0

1 0 1 1

1 1 0 0

1 1 1 0

ns1 = cs1 · ¯cs0 · in + ¯cs1 · cs0 · in

Page 14: CS150 Final Exam Review - University of California, Berkeleycs150/fa12/agenda/... · Memory timings I Assuming every fetch is completely random in the address space, might have to

Logic-level implementation

Page 15: CS150 Final Exam Review - University of California, Berkeleycs150/fa12/agenda/... · Memory timings I Assuming every fetch is completely random in the address space, might have to

Moore machine: add output high state

Page 16: CS150 Final Exam Review - University of California, Berkeleycs150/fa12/agenda/... · Memory timings I Assuming every fetch is completely random in the address space, might have to

Ready/valid

a.) 4′b0000, 4′b0110, 4′b0110

b.) 0, 4, 5

Page 17: CS150 Final Exam Review - University of California, Berkeleycs150/fa12/agenda/... · Memory timings I Assuming every fetch is completely random in the address space, might have to

Downsampler control

Page 18: CS150 Final Exam Review - University of California, Berkeleycs150/fa12/agenda/... · Memory timings I Assuming every fetch is completely random in the address space, might have to

Downsampler control

Very simple datapath:

I An odd number of inputs would mean that the controllerwould either hang or would combine the first input of the next‘line’ with the last input of the first ‘line.’

I This could be solved by making DataInValid andDataOutValid multi-bit so that there could be an‘end-of-line’ value for valid.

Page 19: CS150 Final Exam Review - University of California, Berkeleycs150/fa12/agenda/... · Memory timings I Assuming every fetch is completely random in the address space, might have to

Downsampler control

Very simple datapath:

I An odd number of inputs would mean that the controllerwould either hang or would combine the first input of the next‘line’ with the last input of the first ‘line.’

I This could be solved by making DataInValid andDataOutValid multi-bit so that there could be an‘end-of-line’ value for valid.

Page 20: CS150 Final Exam Review - University of California, Berkeleycs150/fa12/agenda/... · Memory timings I Assuming every fetch is completely random in the address space, might have to

Memory operations

a.) lui $t0, 0x3000

addiu $t0, $t0, 0x20

lw $t0, 40($t0)

Read – all three masks 4’b0000.

b.) lui $t0, 0x1000

addiu $t0, $t0, 0x20

sb $t0, 43($t0)

Store byte to 0x10000063IMEM 4’b0000, DMEM 4’b0001, ISRMEM 4’b0000

c.) lui $t0, 0x3000

sh $t0, 42($t0)

Store half to 0x30000042IMEM 4’b0011, DMEM 4’b0011, ISRMEM 4’b0000

Page 21: CS150 Final Exam Review - University of California, Berkeleycs150/fa12/agenda/... · Memory timings I Assuming every fetch is completely random in the address space, might have to

Memory timings

Given the 5-3-3-8 200MHz SDRAM as implemented in yourproject, and assuming what is the fastest clock speed that yourMIPS processor could run and never stall waiting for a fetch fromSDRAM? Assume that you can completely redesign the controllogic optimally.

I tCL = tCAS = 5 The time between writing a column addressand the first bit of data coming out – this is the period ofsequential bursts.

I tRCD = 3 Time between writing row address and writingcolumn address.

I tRP = 3 Time between writing precharge command (‘closing’old row) and writing row address (‘opening’ new row).

I tRAS = 8 Time between writing row address (‘opening’ row)and writing precharge (‘closing’ row).

Page 22: CS150 Final Exam Review - University of California, Berkeleycs150/fa12/agenda/... · Memory timings I Assuming every fetch is completely random in the address space, might have to

Memory timings

I Assuming every fetch is completely random in the addressspace, might have to write precharge, wait tRP to write row,wait tRCD to write column, and wait tCL to get data.

I Also, the time tRCD + tCL we have the row open must belonger than tRAS to close the row.

I This has total latency t = 3 + 3 + 5 = 11 in units of 200 MHzclock periods.

I Assuming every fetch is completely random, this latency is alower bound on the minimum CPU clock period.

11 ∗ 5 ns = 55 ns =⇒ fmax = 18.2 MHz

Page 23: CS150 Final Exam Review - University of California, Berkeleycs150/fa12/agenda/... · Memory timings I Assuming every fetch is completely random in the address space, might have to

Memory timings

Given a 5-5-5-12 SDRAM, how fast would its clock need to run tomatch the read cycle time of the SDRAM in problem 1?

tRP + tRCD + tCLf

=t ′RP + t ′RCD + t ′CL

f ′

3 + 3 + 5

200 MHz=

5 + 5 + 5

f ′

f ′ =15

11× 200 MHz

f ′ = 273 MHz

Page 24: CS150 Final Exam Review - University of California, Berkeleycs150/fa12/agenda/... · Memory timings I Assuming every fetch is completely random in the address space, might have to

Memory timings

How long does it take to refresh a single row in the SDRAM inproblem 1?

I Time to refresh is simply tRASI This is why the row must be active for tRAS or longer!