Volume 03 Beginner 5 sub-modules ~30 min read

Designing a State Machine by Hand

A state diagram says what a machine should do. This volume shows how to build it from real parts - flip-flops and gates - with nothing but pencil and paper. It is the method behind every state machine question in a written exam, and it shows you what your Verilog code turns into.

You will learn
  • How many flip-flops a machine needs, and how to give each state a code
  • The excitation tables of the D, T, JK and SR flip-flops
  • How to fill in and group a Karnaugh map, from zero
  • How to find the output logic of Moore and Mealy machines
  • A full design from a story to gates, done two ways
You need
  • Volume 02: Moore and Mealy machines
  • Truth tables and gates, from sub-module 0.2

3.1 Giving states binary codes

To build a state machine from flip-flops, give each state its own pattern of bits, called its code. The number of flip-flops is the number of bits in the code.

A flip-flop stores one bit. So a state register can only hold patterns of bits - it cannot hold the word "LOCKED". Before we can build anything, every state needs a bit pattern of its own. Choosing those patterns is called state assignment.

How many flip-flops?

In Volume 00 you learned that n bits make 2n patterns. We need at least one pattern per state:

Number of states Flip-flops needed Why
2 1 1 bit gives 2 patterns
3 or 4 2 2 bits give 4 patterns
5 to 8 3 3 bits give 8 patterns
9 to 16 4 4 bits give 16 patterns
Remember

With binary codes, the number of flip-flops is the smallest n for which 2n is at least the number of states.

Naming the bits

We call the flip-flops Q1 and Q0, and write a code with Q1 on the left. So the code 10 means Q1 = 1 and Q0 = 0. The value a bit will have after the next clock edge is written with a small plus: Q1+, spoken "Q1 next".

An example: the edge detector

The Moore edge detector from Volume 02 has three states, so it needs two flip-flops. Here is one choice of codes:

State Code (Q1 Q0)
ZERO 00
EDGE 01
ONE 10
no state 11

Now rewrite the state table with codes in place of names. This is the encoded state table:

Q1 Q0 btn Q1+ Q0+ pulse
00 0 00 0
00 1 01 0
01 0 00 1
01 1 10 1
10 0 00 0
10 1 10 0
11 0 XX X
11 1 XX X

The code 11 belongs to no state. It is an unused code. The machine should never be there, so we do not care what the logic does with it. We write X, which you will learn to use in sub-module 3.3.

Does the choice of codes matter?

Yes. Every choice works, but different codes give different amounts of logic. Two rules of thumb help when designing by hand:

Volume 05 is all about encodings, including the one-hot code you met with the Medvedev traffic light.

Common mistake

Do not forget the unused codes. Three states in two flip-flops leave one code - here 11 - that belongs to no state. It still exists in the hardware, and a strong glitch could one day put the machine there. For now we mark it "don't care". Volume 11 shows how to make sure the machine can never get stuck in it.

Quick check

A machine has 6 states. With binary codes, how many flip-flops does it need, and how many codes are unused?

Show the answer

Answer: A. 2 flip-flops give only 4 codes, too few for 6 states. 3 flip-flops give 8 codes, and 6 of them are used, so 2 are left over.

3.2 Flip-flop excitation tables (D, T, JK, SR)

An excitation table answers a reverse question: "Q must change from this value to that value - what must the flip-flop's inputs be?"

Volume 00 used only the D flip-flop. There are four classic kinds, shown in Figure 3.1. They have different inputs, but all of them store one bit and change only at the clock edge.

Symbols of the D, T, JK and SR flip-flops, each with a clock input marked by a small triangle D T J K S R Q Q' Q Q' Q Q' Q Q' D flip-flop T flip-flop JK flip-flop SR flip-flop Q next = D T = 1 flips Q J sets, K resets S sets, R resets
Figure 3.1 - The four classic flip-flops. The small triangle marks the clock input. Every one stores one bit, Q; the second output, Q', is simply its opposite.

Two ways to read a flip-flop

The usual question is: "given the inputs now, what will Q be after the edge?" The table that answers it is the flip-flop's characteristic table.

When we design, we ask the opposite. We already know how each state bit must change - the encoded state table tells us. We want to know which inputs will cause that change. The table that answers this reverse question is the excitation table.

The D flip-flop

Q+ = D. Whatever you want Q to become, put it on D. The excitation table is almost too simple to write:

Q now Q+ wanted D must be
0 0 0
0 1 1
1 0 0
1 1 1

The T flip-flop

A T flip-flop ("T" for toggle) keeps its value when T = 0, and flips it when T = 1. So T must be 1 exactly when the bit has to change:

Q now Q+ wanted T must be
0 0 0
0 1 1
1 0 1
1 1 0
Think of it like this

A T flip-flop is the push-button lamp from Volume 01. Pressing (T = 1) changes the lamp, whatever state it was in. Not pressing (T = 0) leaves it alone.

The JK flip-flop

A JK flip-flop has two inputs. Its characteristic table is:

J K Q+ In words
0 0 Q keep
0 1 0 reset
1 0 1 set
1 1 Q' toggle

Now read it backwards. Suppose Q is 0 and must stay 0. "Keep" (J = 0, K = 0) works. "Reset" (J = 0, K = 1) also works. So J must be 0, but K can be either value. We write K = X, which means don't care: either value gives the right result. Doing the same for all four changes gives the excitation table:

Q now Q+ wanted J K Why
0 0 0 X keep or reset both give 0
0 1 1 X set or toggle both give 1
1 0 X 1 reset or toggle both give 0
1 1 X 0 keep or set both give 1

Those X values are a gift. As you will see, every X is a place where the logic may be made smaller.

The SR flip-flop

An SR flip-flop has a set input S and a reset input R. S = 1 sets Q to 1, R = 1 resets it to 0, and both 0 keep it. Both 1 at once is not allowed. Its excitation table:

Q now Q+ wanted S R
0 0 0 X
0 1 1 0
1 0 0 1
1 1 X 0

All four on one page

Change in Q D T J K S R
0 to 0 0 0 0 X 0 X
0 to 1 1 1 1 X 1 0
1 to 0 0 1 X 1 0 1
1 to 1 1 0 X 0 X 0
Remember

Real designs - in Verilog, on FPGAs and on chips - use D flip-flops almost every time. JK, T and SR still matter for two reasons: written exams ask about them, and the don't-cares of the JK flip-flop often give smaller logic when you design by hand.

Common mistake

Do not mix up the two tables. The characteristic table goes forwards: inputs in, next Q out. The excitation table goes backwards: the change you want in, the inputs out. When designing, you always use the excitation table.

Quick check

A JK flip-flop holds Q = 1, and Q must become 0 at the next edge. What must J and K be?

Show the answer

Answer: B. Two actions give 0 from Q = 1: reset (J = 0, K = 1) and toggle (J = 1, K = 1). K is 1 in both, and J can be either value. So J = X and K = 1.

Quick check

A T flip-flop holds Q = 0, and Q must stay 0. What must T be?

Show the answer

Answer: A. T = 1 would flip Q to 1. To keep Q at 0, T must be 0. A T flip-flop has no don't-cares in its excitation table.

3.3 Next-state logic with K-maps

A Karnaugh map is a truth table redrawn as a grid, so that circling groups of 1s gives you the simplest gate formula.

The encoded state table tells us what each flip-flop input must be, for every combination of state bits and inputs. Each flip-flop input is therefore a truth table. To build it, we need a formula of AND, OR and NOT gates - a Boolean expression - and we want the smallest one.

How formulas are written

Written Read as Meaning In Verilog
A·B, or AB A and B 1 only when both are 1 A & B
A + B A or B 1 when at least one is 1 A | B
A' not A the opposite of A ~A

The plus sign means OR here, not adding. So 1 + 1 = 1.

From a truth table to a formula

Any truth table can be written in one standard shape. For every row where the output is 1, write the AND of all the inputs, with a ' on each input that is 0 in that row. Then join these terms with OR. The result is a sum of products. Each AND term for a single row is called a minterm, and minterms are numbered by the row's binary value.

Take a function F of A and B that is 1 in rows 01 and 11:

So F = A'·B + A·B. But look closer. B is 1 in both rows, while A is 0 in one and 1 in the other. The output does not depend on A at all, so F is simply B. That is the whole secret of simplifying:

In plain words

When two minterms differ in just one input, that input does not matter. Join them, and drop it.

In a big truth table, pairs like this are hard to spot. A Karnaugh map puts them side by side.

The Karnaugh map

A Karnaugh map, or K-map, is a grid with one cell per row of the truth table. The rows and columns are labelled in Gray code order - 00, 01, 11, 10 - and not in counting order. In Gray order each label differs from its neighbour in one bit, so each cell differs from the cell beside it in exactly one input. The map also wraps around: the left column is a neighbour of the right column.

Here is how to group the 1s:

  1. Circle only 1s. Never include a 0.
  2. Each group must be a rectangle of 1, 2, 4, 8 or 16 cells.
  3. Make each group as large as you can.
  4. Cover every 1 at least once, using as few groups as you can. Groups may overlap.
  5. Groups may wrap around the edges of the map.
  6. A don't care (X) may join a group if it makes the group bigger. You never have to cover an X.

To read a group, look at each input. If it has the same value in every cell of the group, keep it - plain if it is 1, with a ' if it is 0. If it changes inside the group, drop it.

Our edge detector: flip-flop Q1

From the encoded table in sub-module 3.1, Q1+ is 1 in two rows: Q1 Q0 btn = 011 (minterm 3) and 101 (minterm 5). The unused code gives don't-cares at minterms 6 and 7. Figure 3.2 shows the map. We write b for btn to keep the labels short.

Karnaugh map of Q1 next for the edge detector, with two groups Q1 Q0 b 00 01 11 10 0 1 0 0 0 1 1 3 0 2 0 4 1 5 X 7 X 6 Q1+ = Q0·b + Q1·b
Figure 3.2 - The K-map for Q1+. Each small number is the minterm. The green group is Q0·b and the blue group is Q1·b. Both use the don't-care at minterm 7 to become groups of two.

Read the green group, down the 11 column. Q1 is 0 in one cell and 1 in the other, so it drops out. Q0 = 1 and b = 1 in both, so they stay: Q0·b. The blue group, along the bottom row, gives Q1·b in the same way. So:

Remember

Q1+ = Q0·b + Q1·b

Flip-flop Q0

Q0+ is 1 in only one row: 001, minterm 1. Its neighbours - minterms 0, 3 and 5 - are all 0, and the don't-cares at 6 and 7 are not next to it. So it stands alone, as a group of one:

Karnaugh map of Q0 next for the edge detector, with a single-cell group Q1 Q0 b 00 01 11 10 0 1 0 0 1 1 0 3 0 2 0 4 0 5 X 7 X 6 Q0+ = Q1'·Q0'·b
Figure 3.3 - The K-map for Q0+. The only 1 has no neighbouring 1 or X, so it forms a group of one cell, and no input drops out.

A group of one cell keeps every input: Q0+ = Q1'·Q0'·b. With D flip-flops, the inputs are simply D1 = Q1+ and D0 = Q0+, so the next-state logic is done.

Common mistake

The most common K-map mistake is labelling the columns 00, 01, 10, 11 - counting order. Then the middle two columns differ in two bits, not one, and your groups give wrong formulas. Always use 00, 01, 11, 10.

Quick check

Which of these groups is not allowed in a K-map?

Show the answer

Answer: A. Groups must have 1, 2, 4, 8 or 16 cells, so three is not allowed. Split it into two overlapping groups of two instead. Wrapping around the edges and including an X are both fine.

3.4 Output logic

The output logic is found the same way as the next-state logic: write a truth table for each output, then simplify it with a K-map.

Moore outputs: from the state bits only

In a Moore machine, the outputs depend only on the state. So each output's K-map has only the state bits as inputs. For the edge detector, pulse is 1 in EDGE (code 01) and don't-care in the unused code 11:

Karnaugh map of the pulse output for the Moore edge detector Q1 Q0 0 1 0 1 0 0 1 1 0 2 X 3 pulse = Q0
Figure 3.4 - The Moore output pulse depends only on Q1 and Q0. With the don't-care at 11, the group becomes a whole column, and Q1 drops out.

pulse = Q0. The output logic is a single wire. That is no accident: EDGE is the only state whose code has Q0 = 1. A good choice of codes can make the output logic vanish - which is the Medvedev idea from Volume 02.

The whole Moore edge detector, built from the three formulas, looks like this in Verilog:


module edge_moore_gates (
  input  wire clk, rst, b,
  output wire pulse
);
  reg  q1, q0;                        // the state register: 2 flip-flops
  wire d1 = (q0 & b) | (q1 & b);      // Q1+ from Figure 3.2
  wire d0 = ~q1 & ~q0 & b;            // Q0+ from Figure 3.3

  always @(posedge clk)
    if (rst) {q1, q0} <= 2'b00;       // reset to ZERO
    else     {q1, q0} <= {d1, d0};    // move to the next state

  assign pulse = q0;                  // output logic from Figure 3.4
endmodule

Mealy outputs: the inputs join in

In a Mealy machine, the outputs depend on the inputs too, so the inputs appear in the output's truth table. Take the two-state Mealy edge detector. Give ZERO the code 0 and ONE the code 1, so one flip-flop Q is enough:

Q btn Q+ pulse
0 0 0 0
0 1 1 1
1 0 0 0
1 1 1 0

Two things fall straight out of this table. First, Q+ always equals btn, so the flip-flop just stores the button's last value. Second, pulse is 1 in one row only, where Q = 0 and btn = 1, so pulse = Q'·btn. That is exactly the one-flip-flop circuit from the interview question at the end of Volume 02.

Moore version Mealy version
Flip-flops 2 1
Next-state logic Q0·b + Q1·b, and Q1'·Q0'·b none - Q+ = b
Output logic a wire: pulse = Q0 one AND gate: pulse = Q'·b
Common mistake

When you build the K-map for a Mealy output, include the inputs. If you use only the state bits, the map cannot show that the same state gives different outputs for different inputs, and your formula will be wrong.

Quick check

A Moore machine uses the codes A = 00, B = 01, C = 11 and D = 10. Its output z is 1 in states B and C only. What is z?

Show the answer

Answer: A. B (01) and C (11) both have Q0 = 1, and A (00) and D (10) both have Q0 = 0. So z is 1 exactly when Q0 is 1. On a K-map, B and C sit side by side, and their group drops Q1.

3.5 Worked design: from story to gates

Every hand design follows the same seven steps, from a story in words to a circuit of flip-flops and gates.

  1. Understand the story. List the inputs and outputs, and decide Moore or Mealy.
  2. Draw the state diagram.
  3. Write the state table. Check that it has every row.
  4. Give each state a code.
  5. Write the encoded table. Add each flip-flop's inputs from the excitation table.
  6. Simplify each flip-flop input and each output with a K-map.
  7. Build it, and check it. Write the circuit, then test it against the story.

Step 1: the story

A drink machine sells a drink for three coins. It takes one coin at a time. When the third coin goes in, it releases one drink, and its count starts again from zero.

We choose a Moore machine, so that vend is steady for its whole cycle.

Step 2: the state diagram

The machine must remember how many coins it has: none, one or two. It also needs a state in which vend = 1. That gives four states: C0, C1, C2 and VEND. A coin during VEND counts as the first coin of the next drink.

State diagram of a drink machine that vends after three coins, with states C0, C1, C2 and VEND C0 vend=0 C1 vend=0 C2 vend=0 VEND vend=1 1 1 1 0 1 0 0 0 reset
Figure 3.5 - The drink machine. The arrows show the value of coin. VEND is the only state with vend = 1; from VEND, a new coin counts as the first coin of the next drink.

Step 3: the state table

State Next if coin = 0 Next if coin = 1 vend
C0 C0 C1 0
C1 C1 C2 0
C2 C2 VEND 0
VEND C0 C1 1

Four states and one input bit need 4 × 2 = 8 cases, and the table covers all of them.

Step 4: the codes

Four states need two flip-flops, and all four codes are used. Along the main path C0, C1, C2, VEND we choose codes that change one bit at a time: C0 = 00, C1 = 01, C2 = 11, VEND = 10.

Step 5: the encoded table

With D flip-flops, each D input is simply the next value of its bit. The last column numbers each row as a minterm of Q1, Q0 and coin:

Q1 Q0 coin Q1+ Q0+ vend minterm
00 0 00 0 0
00 1 01 0 1
01 0 01 0 2
01 1 11 0 3
11 0 11 0 6
11 1 10 0 7
10 0 00 1 4
10 1 01 1 5

Step 6: simplify

D1 = Q1+ is 1 at minterms 3, 6 and 7:

Karnaugh map of D1 for the drink machine Q1 Q0 coin 00 01 11 10 0 1 0 0 0 1 1 3 0 2 0 4 0 5 1 7 1 6 D1 = Q0·coin + Q1·Q0
Figure 3.6 - D1 for the drink machine. Two groups of two, overlapping at minterm 7.

D0 = Q0+ is 1 at minterms 1, 2, 3, 5 and 6:

Karnaugh map of D0 for the drink machine with three groups Q1 Q0 coin 00 01 11 10 0 1 0 0 1 1 1 3 1 2 0 4 1 5 0 7 1 6 D0 = Q0'·coin + Q0·coin' + Q1'·coin
Figure 3.7 - D0 for the drink machine. The green and blue groups are essential. Minterm 3 can join either its left or its right neighbour - both choices are equally small.

The output vend is 1 only in VEND, code 10, so vend = Q1·Q0'. The full answer:

Remember

D1 = Q0·coin + Q1·Q0
D0 = Q0'·coin + Q0·coin' + Q1'·coin
vend = Q1·Q0'

Minterm 3 could have been covered by Q1'·Q0 instead of Q1'·coin. A K-map can have more than one answer of the same size, and all of them are correct.

Step 7: build it and check it


module drink_gates (
  input  wire clk, rst, coin,
  output wire vend
);
  reg  q1, q0;                              // C0=00 C1=01 C2=11 VEND=10
  wire d1 = (q0 & coin) | (q1 & q0);
  wire d0 = (~q0 & coin) | (q0 & ~coin) | (~q1 & coin);

  always @(posedge clk)
    if (rst) {q1, q0} <= 2'b00;             // reset to C0
    else     {q1, q0} <= {d1, d0};

  assign vend = q1 & ~q0;                   // 1 only in VEND
endmodule

Check it against the story, by hand. Start in C0 = 00 and put in three coins. With q1 = 0, q0 = 0 and coin = 1: d1 = 0 and d0 = 1, so the next state is 01 (C1). From 01 with coin = 1: d1 = 1 and d0 = 1, giving 11 (C2). From 11 with coin = 1: d1 = 1 and d0 = 0, giving 10 - VEND, where vend = 1. The drink comes out after the third coin, as the story says.

Try it yourselfSimulate drink_gates.v with a testbench that inserts coins in different patterns - three in a row, then with gaps, then a coin during VEND. Check that a drink comes out after every third coin.
Open EDA Playground

The same machine with JK flip-flops

Now build it again, with JK flip-flops. The states, codes and next values stay the same. Only the flip-flop inputs change. For each row, look up the change in each bit in the JK excitation table:

Q1 Q0 coin Q1 changes J1 K1 Q0 changes J0 K0
00 0 0 to 0 0 X 0 to 0 0 X
00 1 0 to 0 0 X 0 to 1 1 X
01 0 0 to 0 0 X 1 to 1 X 0
01 1 0 to 1 1 X 1 to 1 X 0
11 0 1 to 1 X 0 1 to 1 X 0
11 1 1 to 1 X 0 1 to 0 X 1
10 0 1 to 0 X 1 0 to 0 0 X
10 1 1 to 0 X 1 0 to 1 1 X

Half of every column is X. Watch what that does to the K-maps:

Karnaugh map of J1 for the drink machine built with JK flip-flops Q1 Q0 coin 00 01 11 10 0 1 0 0 0 1 1 3 0 2 X 4 X 5 X 7 X 6 J1 = Q0·coin
Figure 3.8 - J1 for the JK version. The whole bottom row is don't-care, so the single 1 grows into a group of two.
Karnaugh map of K1 for the drink machine built with JK flip-flops Q1 Q0 coin 00 01 11 10 0 1 X 0 X 1 X 3 X 2 1 4 1 5 0 7 0 6 K1 = Q0'
Figure 3.9 - K1 for the JK version. With the whole top row don't-care, the two 1s grow into a group of four, and two inputs drop out.

So J1 = Q0·coin and K1 = Q0'. In the same way - try it in the practice section - you will find J0 = coin and K0 = Q1·coin. Compare the two designs:

D flip-flops JK flip-flops
Logic for bit 1 Q0·coin + Q1·Q0 J1 = Q0·coin, K1 = Q0'
Logic for bit 0 Q0'·coin + Q0·coin' + Q1'·coin J0 = coin, K0 = Q1·coin
AND gates 5 2
OR gates 2 0

The don't-cares in the JK excitation table made the logic much smaller. That is why exams love JK designs. On a real chip, though, the D flip-flop still wins. A JK flip-flop is itself built from a D flip-flop plus gates, so the gates you save come back inside the flip-flop.

Common mistake

Do not skip step 7. Hand designs are easy to get slightly wrong - one misread cell in a K-map is enough. Always check the finished circuit against the story, by hand or in a simulator, before you trust it.

Quick check

In the drink machine, why were the codes chosen as C0 = 00, C1 = 01, C2 = 11, VEND = 10?

Show the answer

Answer: C. Any assignment works, but codes that change one bit per step - Gray order - often give smaller groups in the K-maps. The only firm rule used here was to give the reset state the code 00.

What you learned

Key words from this volume

Every word below has a plain-English entry in the glossary.

Practice

Practice 1

Finish the JK design

Using the JK table in sub-module 3.5, draw the K-maps for J0 and K0 of the drink machine, and find their formulas.

Show the solution

J0 matters only where Q0 = 0 (minterms 0, 1, 4 and 5); everywhere else it is X. The 1s are at minterms 1 and 5. The X at minterms 3 and 7 let them grow into a group of four, which is the whole half of the map where coin = 1. Q1 and Q0 both change inside that group, so only coin is left: J0 = coin.

K0 matters only where Q0 = 1 (minterms 2, 3, 6 and 7). It is 1 only at minterm 7, where C2 moves to VEND. The X at minterm 5 is next to it, so they form a group of two in the bottom row, with Q1 = 1 and coin = 1: K0 = Q1·coin.

Practice 2

The same machine with T flip-flops

Redesign the drink machine with T flip-flops. Remember that T must be 1 exactly when the bit has to change.

Show the solution

From the encoded table, T1 = 1 where Q1 changes: minterms 3 (01 to 11), 4 (10 to 00) and 5 (10 to 01). T0 = 1 where Q0 changes: minterms 1, 5 and 7.

Karnaugh map of T1 for the drink machine Q1 Q0 coin 00 01 11 10 0 1 0 0 0 1 1 3 0 2 1 4 1 5 0 7 0 6 T1 = Q1·Q0' + Q1'·Q0·coin
Figure 3.10 - T1: minterms 4 and 5 pair up; minterm 3 has no neighbouring 1 and stands alone.

So T1 = Q1·Q0' + Q1'·Q0·coin and, from a second map, T0 = Q0'·coin + Q1·coin. T flip-flops have no don't-cares, so this design is larger than the JK one.

Practice 3

Count the flip-flops

A controller has 11 states. How many flip-flops does it need with binary codes, and how many codes are unused? How many flip-flops would it need with one flip-flop per state?

Show the solution

23 = 8 is too few, and 24 = 16 is enough, so binary needs 4 flip-flops, with 16 - 11 = 5 unused codes. With one flip-flop per state - the one-hot code from Volume 02 - it needs 11 flip-flops. Volume 05 explains why designers sometimes choose the bigger option on purpose.

Interview corner

Interview question 1

Excitation versus characteristic

"What is the difference between the characteristic table and the excitation table of a flip-flop? Write the excitation table of a JK flip-flop."

Show the solution

"The characteristic table gives the next state from the inputs and the present state. The excitation table goes the other way: from the present state and the required next state, it gives the inputs needed - and that is the one used in design. For a JK flip-flop, 0 to 0 needs J = 0 and K = X. 0 to 1 needs J = 1 and K = X. 1 to 0 needs J = X and K = 1. 1 to 1 needs J = X and K = 0." Mention the don't-cares and why they help - that is the point the question is really testing.

Interview question 2

Why Gray order in a K-map?

"Why are the rows and columns of a Karnaugh map in the order 00, 01, 11, 10?"

Show the solution

"So that any two neighbouring cells differ in exactly one input. Two neighbouring 1s then differ only in that input, which means the output does not depend on it, and the pair simplifies to a term without it. In counting order, 01 and 10 would sit side by side while differing in two bits, so groups would give wrong answers. The same reason makes the edges wrap around: 10 and 00 also differ in one bit."

Next, Volume 04 writes state machines the way engineers really do - in Verilog and SystemVerilog - and lets the tools do the K-maps for you.