Control Path Design and Lab 3 1 Separating Control From Data datapath is where data moves from place to The 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 Separating Control From Data is where decisions are made Control 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 they are qualitatively so different we will Because 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 reset Control inputs control outputs clk Control Outputs Data inputs Signals controlling the datapath Signals providing information to control Datapath clk reset 4 Designing the Control Path control lines Identify Inputs from datapath Outputs to datapath out the state machine Draw Transitions are defined by inputs from the datapath out how the output lines should be set for Figure each state Implement 5 Identifying Outputs element of the control path that has a Any control input muxes alus enabled registers to the outside world that are not data Outputs Data valid lines you designed your datapath correctly this Ifshould be all of them 6 Identify the Inputs are all the bits of information that the These datapath generates to allow your design to make decisions If you thought through your datapath carefully you should already know what these are 7 Draw the State Machine state machine implements the states that The your datapath can be in activity that takes multiple cycles needs its Any own state Blocking on IO Multi cycle operations time an output control line depends on Any 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 Computing Outputs each state write down how to compute the For outputs from the inputs can be different for different states This a table that describes how each control Make line will be computed in every state 9 Implement that you have a complete design you can Now implement control unit should be one module with The 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 localparam to define state names No Use magic numbers 0 and 1 are not magic 10 Computing State Transitions 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 11 Computing Outputs 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 12 Implementing the State always posedge clk if reset state WAIT else state state next or dff WIDTH 3 state dff d state next q state clk clk reset reset 13 Trivialscalar State Machine other inst RUN HALT instruction HALT in ack signal the following cycle out ack signal LD instruction DMEM READ READ instruction WRITE instruction IO WRITE IO READ in ack low out ack low 14 State Transition Conditions Current state Run halt IO Read IO WRite DMem Read Run Next state Halt IO READ IO Write DMem Read 15 Control line settings run stall reset sel dmem write en read write req reg sel regfile write en op code in req out req Run Halt IO Read IO Write DMem Read 16 GCD Example the slides from last week See And the implementation on the web site 17
View Full Document
Unlocking...