Control Path Design and Lab 3 1 Separating Control From Data The - - PowerPoint PPT Presentation

control path design and lab 3
SMART_READER_LITE
LIVE PREVIEW

Control Path Design and Lab 3 1 Separating Control From Data The - - PowerPoint PPT Presentation

Control Path Design and Lab 3 1 Separating Control From Data The datapath is where data moves from place to place. Computation happens in the datapath No decisions are made here. Things you should find in a datapath Muxes


slide-1
SLIDE 1

Control Path Design and Lab 3

1

slide-2
SLIDE 2

Separating Control From Data

  • The datapath is where data moves from place to

place.

  • Computation happens in the datapath
  • No decisions are made here.
  • Things you should find in a datapath
  • Muxes
  • Registers
  • ALUs
  • Wide busses (34 bits for data. 17 bits for instructions)
  • These components are physically large
  • In a real machine, their spatial relationship are important.
  • Mostly about wiring things up.

2

slide-3
SLIDE 3

Separating Control From Data

  • Control is where decisions are made
  • Things you will there
  • State machines
  • Random lots of complex logic
  • Little state (maybe just a single register)
  • Spatial relationships are harder to reason about or

exploit.

  • Because they are qualitatively so different, we will

use different coding styles for each.

  • These are best practices from people who build real

chips.

  • Following them will save you lots of pain
  • If you don’t follow them, and you have problem, the TAs

and I will tell you to go fix the coding style issues first.

3

slide-4
SLIDE 4

4

Control Datapath Signals controlling the datapath Signals providing information to control Outputs Data inputs Control inputs control outputs clk reset clk reset

slide-5
SLIDE 5

5

Designing the Control Path

  • Identify control lines
  • Inputs from datapath.
  • Outputs to datapath.
  • Draw out the state machine
  • Transitions are defined by inputs from the datapath.
  • Figure out how the output lines should be set for

each state.

  • Implement!
slide-6
SLIDE 6

Identifying Outputs

  • Any element of the control path that has a

control input

  • muxes
  • alus
  • enabled registers
  • Outputs to the outside world that are not data
  • Data valid lines
  • If you designed your datapath correctly, this

should be all of them.

6

slide-7
SLIDE 7

Identify the Inputs

  • These are all the bits of information that the

datapath generates to allow your design to make decisions.

  • If you thought through your datapath carefully,

you should already know what these are.

7

slide-8
SLIDE 8

Draw the State Machine

  • The state machine implements the states that

your datapath can be in.

  • Any activity that takes multiple cycles needs its
  • wn state
  • Blocking on IO
  • Multi-cycle operations.
  • Any time an output control line depends on

anything but the input control lines from the same cycle, you will need one or more new states.

  • State transitions are a function of input lines.
  • Write down the formula for each transition.

8

slide-9
SLIDE 9

Computing Outputs

  • For each state, write down how to compute the
  • utputs from the inputs.
  • This can be different for different states.
  • Make a table that describes how each control

line will be computed in every state.

9

slide-10
SLIDE 10

Implement!

  • Now that you have a complete design, you can

implement.

  • The control unit should be one module with

three always blocks and one register.

  • One block computes the state transitions. (always@(*))
  • One block computes the outputs. (always@(*))
  • One block implements the register for the state. (always

@ (posedge clk)

  • Use ‘localparam’ to define state names. -- No

magic numbers! (0 and 1 are not magic)

10

slide-11
SLIDE 11

Computing State Transitions

11

always @(*) begin // Default is to stay in the same state state_next = state; case ( state ) STATE_1 : if ( something && something_else) state_next = ANOTHER_STATE; ANOTHER_STATE : if ( sky_falls ) state_next = SCREAM; SCREAM : state_next = WAIT; ... endcase end

slide-12
SLIDE 12

Computing Outputs

12

always @(*) begin //Default control signals some_mux_sel_out = SOME_MUX_SEL_X; reg_en_out = 1'b0; case ( state ) STATE_1: begin some_mux_sel_out = 1’b1; end ANOTHER_STATE: if ( sufficient_happiness_in ) begin reg_en_out = 1’b1; end else if ( is_monday_in ) begin reg_en_out = 1’b0; end ... endcase end

slide-13
SLIDE 13

Implementing the State

13

always @(posedge clk) if (reset) state <= WAIT; else state <= state_next;

  • r

dff #( .WIDTH(3) ) state_dff ( .d(state_next), .q(state), .clk(clk), .reset(reset) );

slide-14
SLIDE 14

Trivialscalar State Machine

14

IO READ IO WRITE HALT RUN

WRITE instruction

  • ut_ack

signal READ instruction in_ack signal HALT instruction

DMEM READ

LD instruction the following cycle

  • ther inst

in_ack low

  • ut_ack low
slide-15
SLIDE 15

State Transition Conditions

15

Run halt IO Read IO WRite DMem Read Run Halt IO READ IO Write DMem Read

Current state Next state

slide-16
SLIDE 16

Control line settings

16 Run Halt IO Read IO Write DMem Read run_stall_reset_sel dmem_write_en read_write_req reg_sel regfile_write_en op_code in_req out_req

slide-17
SLIDE 17

17

GCD Example

  • See the slides from last week
  • And the implementation on the web site.