BE/CS 196a Lab 1: Design and analysis of a DNA

BE/CS 196a Lab 1: Design and analysis of
a DNA-based square root circuit
Note: Download and open in Adobe Acrobat to see the links in this file.
1. Logic circuit design (60 min)
Use Logic Friday (Windows version, Mac version) to design a logic circuit that calculates
the square root of a four-bit binary number, rounding down to the nearest integer.
• Step 1 (10 min): enter the logic function as a truth table (File → New → Truth Table).
• Step 2 (25 min): exercise on Boolean algebra. 1) Minimize the logic function (Operation → Minimize, choose “Exact” mode and “minimize each output independently”).
2) Generate a logic circuit (Operation → Map to Gates, including all gate types except XOR and MUX, and use “Standard Logic ICs” for optimization). 3) Use the
laws of Boolean algebra to prove that the minimized logic function is equivalent to the
automatically generated logic circuit.
Boolean Algebra
Identity law
1x = x
0+x=x
Null law
0x = 0
1+x=1
Idempotent law
xx = x
x+x=x
Inverse law
xx = 0
x+x=1
Commutative law xy = yx
x+y =y+x
Associative law
(xy)z = x(yz)
(x + y) + z = x + (y + z)
Distributive law
x(y + z) = xy + xz x + yz = (x + y)(x + z)
Absorption law
x(x + y) = x
x + xy = x
x+y =x y
De Morgan’s law xy = x + y
Optional exercise on Boolean algebra: can you prove that the circuit automatically
generated by Logic Friday is equivalent to the following circuit?
x1
x2
x3
x4
𝑦2 𝑦1 =
5
1
2
𝑥4 𝑥3 𝑥2 𝑥1
9
3
4
7
11
y1
8
y2
10
6
Figure 1: A four-bit square root circuit.
1
Note that the circuit in Fig. 1 is not the simplest logic circuit for calculating the square
root function, rather, it includes the essential components for constructing arbitrary
logic circuits. For example, 1) it uses five types of logic gates AND, OR, ANDNOT,
NAND, NOR. 2) It includes one gate with three inputs and another gate with two
outputs to demonstrate fan-in (multiple inputs) and fan-out (multiple outputs). 3) It
is a three-layer circuit to demonstrate multiple layers.
• Step 3 (15 min): enter the circuit in Fig. 1 as a gate diagram (File → New → Gate
Diagram), and align the gates and wires in your diagram (Gates → Auto Redraw
Diagram).
• Step 4 (10 min): test the circuit with all 16 possible inputs (Gates → Trace Gate
Logic).
2. DNA strand displacement circuit design and analysis (120 min)
Use Seesaw Compiler to design a DNA strand displacement circuit that implements the
four-bit square root function.
• Step 1 (10 min): enter the four-bit square root circuit in Fig. 1 as an “AND-OR-NOT
circuit”, save the file, and then compile it to a dual-rail AND-OR circuit in which
each input/output signal (e.g. x1 ) is replaced by a pair of signals (e.g. x01 and x11 )
representing logic OFF and ON respectively.
• Step 2 (30 min): use Logic Friday to verify the correctness of the dual-rail circuit.
1) Enter the circuit as logic equations (File → New → Logic Equation). 2) Export
the truth table as a csv file (File → Export Truth Table). 3) Use Excel to re-organize
the order of inputs from x04 x14 to x01 x11 (cut and insert columns), identify if an input
agrees with the dual-rail format (insert a new column to calculate the TRUE or FALSE
value of ∀i, x0i 6= x1i ), and then sort (Sort & Filter → Custom Sort. . . , sort by the new
column on values) and delete the truth table rows with non-dual-rail inputs. 4) Add
two new columns that convert the dual-rail inputs and outputs to integers, sort the
truth table based on the integer inputs, and verify if the outputs correctly calculate
the floor of the square root of the inputs.
• Step 3 (30 min): compile the dual-rail circuit to a seesaw DNA circuit, identify the
sub-circuit that computes y2 = x3 OR x4 (see syntax of a seesaw circuit), and use
EasyEDA to generate a seesaw circuit diagram of the sub-circuit (see instructions for
creating seesaw circuit diagrams with EasyEDA).
• Step 4 (20 min): generate DSD code for the sub-circuit using Seesaw Compiler (Visualize and simulate with DSD), save the file, open it in Visual DSD (BETA version), and
simulate it. Calculate the total number of initial DNA species and the total number
of reactions in the sub-circuit based on the seesaw circuit diagram and the definition
2
of seesaw abstraction, and verify if the numbers agree with the DSD generated initial
species (tab DSD → sub-tab Species) and reactions (tab CRN → sub-tab Reactions).
• Step 5 (15 min): generate Mathematica code for the full square root circuit using
Seesaw Compiler (Simulate with Mathematica), save the file, open it in Mathematica,
and run package. The default simulation is for input 0000. Choose a few different
inputs, change the values in section “Define input value and simulation time”, and
verify if the seesaw DNA circuit correctly computes the square root function.
Mathematica Basics
Coding
Package and Notebook
Evaluate cells: Shift + Enter
Double click cells to show more or less
Select cells and right click to change style
Data structure
Lists
Construct a list: Table and Range
Pick out elements of a list: [[ ]]
Rearrange a list: Flatten and Partition
Graphics
Plot a function: Plot
Plot a list of data: ListPlot
Generate a three-dimensional plot with two variables: Plot3D
Combine several plots: Show
Create an array of plots: GraphicsGrid
Export a plot to PDF, PNG, etc.: Export
Stop a computation Evaluation → Abort Evaluation
Evaluation → Quit Kernel → Local
• Step 6 (15 min): compile the seesaw circuit to DNA sequences, choose a threshold
complex (Thi,j:j -t and Thi,j:j -b) and a gate complex (wi,j and Gi -b), and use NUPACK
to verify if the sequences form desired structures at 100 nM at 25 ◦ C (Analysis →
Results → Equilibrium concentrations → click a complex for its MFE structure).
3