FSMs, Multiplication, and Division

Slides:



Advertisements
Similar presentations
1ASM Algorithmic State Machines (ASM) part 1. ASM2 Algorithmic State Machine (ASM) ‏ Our design methodologies do not scale well to real-world problems.
Advertisements

Datorteknik IntegerMulDiv bild 1 MIPS mul/div instructions Multiply: mult $2,$3Hi, Lo = $2 x $3;64-bit signed product Multiply unsigned: multu$2,$3Hi,
CS 151 Digital Systems Design Lecture 37 Register Transfer Level
361 div.1 Computer Architecture ECE 361 Lecture 7: ALU Design : Division.
The Control Unit: Sequencing the Processor Control Unit: –provides control signals that activate the various microoperations in the datapath the select.
1 COMP541 Sequencing and Control Montek Singh Mar 29, 2007.
1 COMP541 State Machines Montek Singh Feb 6, 2007.
EECS 370 Discussion 1 xkcd.com. EECS 370 Discussion Topics Today: – Floating Point – Finite State Machines – Combinational Logic – Sequential Logic 2.
1 COMP541 State Machines Montek Singh Feb 8, 2012.
ECE 4110– Sequential Logic Design
Important Components, Blocks and Methodologies. To remember 1.EXORS 2.Counters and Generalized Counters 3.State Machines (Moore, Mealy, Rabin-Scott) 4.Controllers.
Introduction to State Machine
Integer Operations Computer Organization and Assembly Language: Module 5.
Unit 1 Introduction Number Systems and Conversion.
Multiplication and Division basics
Combinational circuits
CHAPTER 18 Circuits for Arithmetic Operations
Figure 8.1. The general form of a sequential circuit.
Computer Architecture & Operations I
© Copyright 2004, Gaetano Borriello and Randy H. Katz
Lecture 28 Logistics Today
MIPS mul/div instructions
Introduction Introduction to VHDL Entities Signals Data & Scalar Types
Bitfields and Logic Basics
COMP541 Sequential Logic – 2: Finite State Machines
Minimization and Sequential Logic
Binary Addition and Subtraction
CS/COE 0447 (term 2181) Jarrett Billingsley
Morgan Kaufmann Publishers
Synchronous Sequential Circuit Design
The Register File and ALU
Lecture 8: Binary Multiplication & Division
The Interconnect, Control, and Instruction Decoding
LONG DIVISION CAN BE EASY!.
CDA 3101 Summer 2007 Introduction to Computer Organization
Digital Systems Section 14 Registers. Digital Systems Section 14 Registers.
Instructor: Alexander Stoytchev
KU College of Engineering Elec 204: Digital Systems Design
Instructor: Alexander Stoytchev
Lecture 28 Logistics Today
ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN
Bitwise Operations and Bitfields
Theory of Computation Turing Machines.
CSE 370 – Winter Sequential Logic - 1
Lecture 15 Logistics Last lecture Today HW4 is due today
Instructor: Alexander Stoytchev
What Are They? Who Needs ‘em? An Example: Scoring in Tennis
Introduction to Sequential Circuits
CSE 370 – Winter Sequential Logic-2 - 1
Lecture 17 Logistics Last lecture Today HW5 due on Wednesday
CS/COE 0447 Jarrett Billingsley
Multiplication and Division
The Register File and ALU
Instructor: Alexander Stoytchev
Arithmetic and Decisions
Guest Lecture by David Johnston
Latches The second part of CS231 focuses on sequential circuits, where we add memory to the hardware that we’ve already seen. Our schedule will be very.
CSE 370 – Winter Sequential Logic-2 - 1
ECE 352 Digital System Fundamentals
The Verilog Hardware Description Language
Lecture 20 Logistics Last lecture Today Graded HW back today
CHAPTER 18 Circuits for Arithmetic Operations
ECE 352 Digital System Fundamentals
Lecture 17 Logistics Last lecture Today HW5 due on Wednesday
ECE 352 Digital System Fundamentals
Verilog Synthesis & FSMs
EGR 2131 Unit 12 Synchronous Sequential Circuits
ECE 352 Digital System Fundamentals
ECE 352 Digital System Fundamentals
Announcements Assignment 7 due now or tommorrow Assignment 8 posted
Presentation transcript:

FSMs, Multiplication, and Division CS/COE 0447 Jarrett Billingsley

Class announcements what IS project 2 idfk CS447

Finite State Machines CS447

What's an FSM? a Finite State Machine is a machine with a finite number of states. :^) lol jk it's a way of thinking about a sequential process where: there are inputs which can change the state the system has a state (memory) there are outputs based on the state (and maybe on the inputs) should panic? bears seen: 3 bears seen: 2 bears seen: 0 bears seen: 1 yeah ok nah - FSMs come up all the time in programming and hardware design - they're great for controlling simple multiple-step procedures - FSMs are easy to reason about and transform (take CS1511) - by breaking up more complex things into interdependent FSMs you can make it easier to think about your program/circuit CS447

Are flip-flops FSMs? I guess? they're like the simplest possible ones... but it's not really important :B - I just made this slide cause I almost always get this question… CS447

A very simple example off high med low what states can a ceiling fan be in? high, medium, low, and off what are the input and output? the chain and the motor when you pull the chain, it changes state pull pull pull off high med low pull - I don't really know why they go high, medium, low, but they do. - unless it's the one in our bedroom. then it goes medium, medium, low, off. something's broken… CS447

Missing some arrows off high med low at any point in time, which of 2 choices can the input (chain) be? pulled or not-pulled when you don't pull the chain, what happens? off high med low pull no pull no pull no pull no pull this is the full state transition diagram - sometimes we just leave those "stay-in-the-same-state" arrows off, though, to say "if none of the conditions are satisfied, don't change" - but that can get you into trouble - did you mean to stay in the same state? or did you just forget a possibility? every state should be able to handle every input! CS447

Table-a-fying it S In Snext off 1 hi med low off hi hi med med low low we can represent this diagram with a table: S In Snext off 1 hi med low off high med low pull no off hi hi med for the input, let's say: 0 means not pulling 1 means pulling med low low off CS447

State off hi med low Motor power 0% 100% 50% 25% What about the outputs? our fan controller has to control the motor after all we can make a table showing the output(s) for each state note that the input isn't needed at all in this case. State off hi med low Motor power 0% 100% 50% 25% this is a Moore Machine. Mealy Machines let the output depend on the state and inputs. the outputs only depend on the current state! - we'll mostly stick with Moore machines, but sometimes a Mealy machine is more elegant. depends on the situation! CS447

Making a circuit out of it this is a sequential circuit – the state changes over time but the state transition and output tables are combinational here's the general organization of any Moore FSM circuit: state feeds back into transition logic outputs based on state transition logic inputs output logic outputs D Q state register - this pattern is gonna come up over and over as we design circuits… - this is basically how all sequential and combinational circuits come together! CS447

Kinds of FSMs CS447

Counters 0 bears 1 bear 2 bears ≥3 bears counters just count how many of something they've "seen" usually the states form a ring (like the ceiling fan) sometimes they make a line: 0 bears 1 bear 2 bears ≥3 bears bear or cat in this machine, there's no way to "get back" to an earlier state. - that can get real annoying real fast, if you want to count up to large numbers. - but sometimes you need to keep track of a number, and it doesn't have to be part of the FSM itself… there are also as many states as numbers you want to represent… CS447

this is kind of a generator-counter combo. Generators sometimes you have no inputs other than some signal to tell you to go to the next step (what's that signal called?) these are useful for generating a sequence of values. 4 1 2 5 7 8 6 3 9 this is kind of a generator-counter combo. I've used these for sequencing steps in a more complex process (another FSM!). - that would be the clock. CS447

these arrows on the right are unconditional transitions Controllers let's say you want to make a simple vending machine it accepts nickels and dimes and lets you buy 25¢ items 0¢ 5¢ 10¢ 15¢ 20¢ 25¢ 30¢ nickel dime dispense give nickel - unconditional transitions happen… unconditionally… - basically, when the clock signal happens. these arrows on the right are unconditional transitions CS447

Multiplication and Division practical FSMs CS447

Remember this? we used this algorithm to do multiplication: how might we make a circuit to count the steps? for(n bits in multiplier) { if((multiplier & 1) != 0) product += multiplicand multiplicand <<= 1 multiplier >>= 1 } what do we use to make a decision? what do we use to store values? - an FSM to count the steps and sequence the actions… - a MUX or write enable to make the decision… - registers to store the values… CS447

+ 1 A very common pattern D Q have a look at simple_counter.circ this is a very simple FSM. every clock tick, it adds 1 to the value in the register. this is the hardware equivalent of "x = x + 1". this could really be anything though. like… shifting? CS447

So… what are we gonna need we've got 3 variables (+1 for the loop counter) we're doing 2 shifts and (maybe) an add on each loop D Q + product kindaaa…? D Q << 1 multiplicand how do we decide when to add to the product? D Q >> 1 multiplier D Q + 1 loop step how do we know when to start and stop? - well, gee whiz, this feels like a GREAT topic for a LAB doesn't it CS447

Fast multiplication as a circuit remember there were two phases: calculating the partial products summing them calculating the partial products is easy it's just shifts and ANDs in hardware, shifting can be done by just rerouting wires! summing the partial products is easy we use a binary tree of adders! the product just pops out the end. of course, this uses a lot of silicon… have a look at fast_mult_4x4.circ Fun Stuff Partial Products + CS447

subtraction and shifting… Deja vu We used this division algorithm: divisor <<= n (bits in dividend) remainder = dividend quotient = 0 for(n bits in dividend) { divisor >>= 1 if(divisor > remainder) { append 0 to quotient } else { remainder -= divisor append 1 to quotient } another for loop… another if-else… subtraction and shifting… CS447

- >> << + Feels pretty familiar 1 1 1 we've got 3 variables (+1 for the loop counter) we're doing 2 shifts and (maybe) a subtract on each loop D Q - remainder kindaaa…? D Q >> 1 divisor how do we "append a 0 or 1" to the quotient? D Q << 1 quotient D Q + 1 loop step how do we know when to start and stop? - again, labtime - "appending a 0 or 1" is just setting the low bit after shifting left CS447

Their similarity is no coincidence in MIPS, both mul and div use the HI and LO registers this is because in the original design, both algorithms used the same registers, just with different controllers they do some fancy stuff to save bits check out the book – it goes into way too much detail on this, but it's kinda neat your lab will do something similar! hohohoho! CS447