User:Ashmanskas/p364/verilog notes testbench

From LaPET electronics

Jump to: navigation, search

Test bench Verilog code

/*
 * verilog_notes.v
 *
 * Typed-up version, with test bench, of code snippets from
 * positron.hep.upenn.edu/p364/verilog_notes.html
 *
 * begun 2010-11-09 by Bill Ashmanskas, ashmansk@hep.upenn.edu
 */

`default_nettype none
`timescale 1ns / 1ps


module mux2to1_v1 (
    input  wire S, A, B,
    output wire OUT
);
    wire notS, AandnotS, BandS;
    not (notS, S);
    and (AandnotS, A, notS);
    and (BandS, B, S);
    or  (OUT, AandnotS, BandS);
endmodule


module mux2to1_v2 (
    input  wire S, A, B,
    output wire OUT
);
    wire notS, AandnotS, BandS;
    assign notS = ~S;
    assign AandnotS = A & notS;
    assign BandS = B & S;
    assign OUT = AandnotS | BandS;
endmodule


module mux2to1_v3 (
    input  wire S, A, B,
    output wire OUT
);
    wire notS = ~S;
    wire AandnotS = A & notS;
    wire BandS = B & S;
    assign OUT = AandnotS | BandS;
endmodule


module mux2to1_v4 (
    input  wire S, A, B,
    output wire OUT
);
    assign OUT = (A & ~S) | (B & S);
endmodule


module mux2to1_v5 (
    input  wire S, A, B,
    output wire OUT
);
    assign OUT = S ? B : A;
endmodule


module mux2to1_4bit_v1 (
    input  wire       S,
    input  wire [3:0] A,
    input  wire [3:0] B,
    output wire [3:0] OUT
);
    mux2to1_v5 mux0 (S, A[0], B[0], OUT[0]);
    mux2to1_v5 mux1 (S, A[1], B[1], OUT[1]);
    mux2to1_v5 mux2 (S, A[2], B[2], OUT[2]);
    mux2to1_v5 mux3 (S, A[3], B[3], OUT[3]);
endmodule


module mux2to1_4bit_v2 (
    input  wire       S,
    input  wire [3:0] A,
    input  wire [3:0] B,
    output wire [3:0] OUT
);
    assign OUT = S ? B : A;
endmodule


module mux2to1_Nbit #(parameter N=1)
(
    input  wire         S,
    input  wire [N-1:0] A,
    input  wire [N-1:0] B,
    output wire [N-1:0] OUT
 );
    assign OUT = S ? B : A;
endmodule


module dff (
    input  wire clk,
    input  wire d,
    output wire q
);
    reg	qreg=0;
        always @ (posedge clk) begin
            qreg <= d;
	end
    assign q = qreg;
endmodule


module dffe (
    input  wire clk,
    input  wire ena,
    input  wire d,
    output wire q
);
    reg qreg=0;
    always @ (posedge clk) begin
        if (ena) qreg <= d;
    end
    assign q = qreg;
endmodule


module counter_v1 (
    input  wire       clk,
    output wire [5:0] q
);
    dffe ff0 (.clk(clk), .q(q[0]), .d(~q[0]), .ena(1));
    dffe ff1 (.clk(clk), .q(q[1]), .d(~q[1]), .ena(q[0]==1));
    dffe ff2 (.clk(clk), .q(q[2]), .d(~q[2]), .ena(q[1:0]==3));
    dffe ff3 (.clk(clk), .q(q[3]), .d(~q[3]), .ena(q[2:0]==7));
    dffe ff4 (.clk(clk), .q(q[4]), .d(~q[4]), .ena(q[3:0]==15));
    dffe ff5 (.clk(clk), .q(q[5]), .d(~q[5]), .ena(q[4:0]==31));
endmodule


module counter_v2 (
    input  wire       clk,
    output wire [5:0] q
);
    dffe ff0 (.clk(clk), .q(q[0]), .d(~q[0]), .ena(1));
    dffe ff1 (.clk(clk), .q(q[1]), .d(~q[1]), .ena(q[0]=='b1));
    dffe ff2 (.clk(clk), .q(q[2]), .d(~q[2]), .ena(q[1:0]=='b11));
    dffe ff3 (.clk(clk), .q(q[3]), .d(~q[3]), .ena(q[2:0]=='b111));
    dffe ff4 (.clk(clk), .q(q[4]), .d(~q[4]), .ena(q[3:0]=='b1111));
    dffe ff5 (.clk(clk), .q(q[5]), .d(~q[5]), .ena(q[4:0]=='b11111));
endmodule


module counter_v3 (
    input  wire       clk,
    output wire [5:0] q
);
    dffe ff0 (.clk(clk), .q(q[0]), .d(~q[0]), .ena(1));
    dffe ff1 (.clk(clk), .q(q[1]), .d(~q[1]), .ena(q[0]=='h1));
    dffe ff2 (.clk(clk), .q(q[2]), .d(~q[2]), .ena(q[1:0]=='h3));
    dffe ff3 (.clk(clk), .q(q[3]), .d(~q[3]), .ena(q[2:0]=='h7));
    dffe ff4 (.clk(clk), .q(q[4]), .d(~q[4]), .ena(q[3:0]=='hf));
    dffe ff5 (.clk(clk), .q(q[5]), .d(~q[5]), .ena(q[4:0]=='h1f));
endmodule


module counter_v4 (
    input  wire       clk,
    output wire [5:0] q
);
    dffe ff0 (.clk(clk), .q(q[0]), .d(~q[0]), .ena(1));
    dffe ff1 (.clk(clk), .q(q[1]), .d(~q[1]), .ena(~q[0]==0));
    dffe ff2 (.clk(clk), .q(q[2]), .d(~q[2]), .ena(~q[1:0]==0));
    dffe ff3 (.clk(clk), .q(q[3]), .d(~q[3]), .ena(~q[2:0]==0));
    dffe ff4 (.clk(clk), .q(q[4]), .d(~q[4]), .ena(~q[3:0]==0));
    dffe ff5 (.clk(clk), .q(q[5]), .d(~q[5]), .ena(~q[4:0]==0));
endmodule


module dffe_Nbit #(parameter N=1)
(
    input  wire         clk,
    input  wire         ena,
    input  wire [N-1:0] d,
    output wire [N-1:0] q
 );
    reg [N-1:0]	qreg=0;
    always @ (posedge clk) begin
        if (ena) qreg <= d;
    end
    assign q = qreg;
endmodule


module counter_v5 (
    input  wire       clk,
    output wire [5:0] q
);
    wire [5:0] ff_data = q+1;
    dffe_Nbit #(.N(6)) ff (.clk(clk), .q(q), .ena(1), .d(ff_data));
endmodule


module counter_v6 (
    input  wire       clk,
    output wire [5:0] q
);
    dffe_Nbit #(.N(6)) ff (.clk(clk), .q(q), .ena(1), .d(q+1));
endmodule


module counter_v7 (
    input  wire       clk,
    output wire [5:0] q
);
    reg [5:0] qreg=0;
    always @ (posedge clk) begin
        qreg <= qreg+1;
    end
    assign q = qreg;
endmodule


module shiftreg_v1 (
    input  wire       clk,
    input  wire       d,
    output wire [5:0] q
 );
    wire [5:0] ff_data;
    assign ff_data[5:1] = q[4:0];
    assign ff_data[0] = d;
    dffe_Nbit #(.N(6)) ff (.clk(clk), .q(q), .ena(1), .d(ff_data));
endmodule


module shiftreg_v2 (
    input  wire       clk,
    input  wire       d,
    output wire [5:0] q
);
    wire [5:0] ff_data = {q[4:0],d};
    dffe_Nbit #(.N(6)) ff (.clk(clk), .q(q), .ena(1), .d(ff_data));
endmodule


module shiftreg_v3 (
    input  wire       clk,
    input  wire       d,
    output wire [5:0] q
);
    dffe_Nbit #(.N(6)) ff (.clk(clk), .q(q), .ena(1), .d({q[4:0],d}));
endmodule


module shiftreg_v4 (
    input  wire       clk,
    input  wire       d,
    output wire [5:0] q
);
    reg [5:0] qreg=0;
    always @ (posedge clk) begin
        qreg[5:0] <= {qreg[4:0],d};
    end
    assign q = qreg;
endmodule


module hexdigit (
    input  wire [3:0] num,  // the hex digit to be displayed
    output wire [6:0] segs  // LED segments (active low)
);
    assign segs = 
        num=='h0 ? 'b1000000 :
        num=='h1 ? 'b1111001 :
        num=='h2 ? 'b0100100 :
        num=='h3 ? 'b0110000 :
        num=='h4 ? 'b0011001 :
        num=='h5 ? 'b0010010 :
        num=='h6 ? 'b0000010 :
        num=='h7 ? 'b1111000 :
        num=='h8 ? 'b0000000 :
        num=='h9 ? 'b0010000 :
        num=='ha ? 'b0001000 :
        num=='hb ? 'b0000011 :
        num=='hc ? 'b1000110 :
        num=='hd ? 'b0100001 :
        num=='he ? 'b0000110 :
        num=='hf ? 'b0001110 :
                   'b1111111 ;
endmodule


module verilog_notes_tb;
    reg  [3:0] AA=0, BB=0;
    reg        A=0, B=0, S=0;
    wire       out1, out2, out3, out4, out5;
    wire [3:0] out6, out7, out8;
    mux2to1_v1 mux1 (.S(S), .A(A), .B(B), .OUT(out1));
    mux2to1_v2 mux2 (.S(S), .A(A), .B(B), .OUT(out2));
    mux2to1_v3 mux3 (.S(S), .A(A), .B(B), .OUT(out3));
    mux2to1_v4 mux4 (.S(S), .A(A), .B(B), .OUT(out4));
    mux2to1_v5 mux5 (.S(S), .A(A), .B(B), .OUT(out5));
    mux2to1_4bit_v1 mux6 (.S(S), .A(AA), .B(BB), .OUT(out6));
    mux2to1_4bit_v2 mux7 (.S(S), .A(AA), .B(BB), .OUT(out7));
    mux2to1_Nbit #(.N(4)) mux8 (.S(S), .A(AA), .B(BB), .OUT(out8));
    reg clk=0, ena=0;
    wire odff, odffe;
    dff i_dff (.clk(clk), .q(odff), .d(!odff));
    dffe i_dffe (.clk(clk), .q(odffe), .d(!odffe), .ena(odff));
    wire [5:0] oc1, oc2, oc3, oc4, oc5, oc6, oc7;
    counter_v1 c1 (.clk(clk), .q(oc1));
    counter_v2 c2 (.clk(clk), .q(oc2));
    counter_v3 c3 (.clk(clk), .q(oc3));
    counter_v4 c4 (.clk(clk), .q(oc4));
    counter_v5 c5 (.clk(clk), .q(oc5));
    counter_v6 c6 (.clk(clk), .q(oc6));
    counter_v7 c7 (.clk(clk), .q(oc7));
    reg clk1=0;
    wire [5:0] osr1, osr2, osr3, osr4;
    shiftreg_v1 sr1 (.clk(clk1), .d({osr1,osr2,osr3,osr4}==0), .q(osr1));
    shiftreg_v2 sr2 (.clk(clk1), .d(osr1[5]), .q(osr2));
    shiftreg_v3 sr3 (.clk(clk1), .d(osr2[5]), .q(osr3));
    shiftreg_v4 sr4 (.clk(clk1), .d(osr3[5]), .q(osr4));
    reg [3:0]  num=0;
    wire [6:0] segs;
    hexdigit hex1 (.num(num), .segs(segs));
    integer i=0;
    initial begin
	/*
	 * Exercise 1-bit multiplexers
	 */
	for (i=0; i<8; i=i+1) begin
	    #100;
	    A = i>>0 & 1;
	    B = i>>1 & 1;
	    S = i>>2 & 1;
	    #100;
	    $display("S=%1d A=%1d B=%1d O= %1d %1d %1d %1d %1d",
		     S, A, B, out1, out2, out3, out4, out5);
	end
	/*
	 * Exercise 4-bit and N-bit multiplexers
	 */
	for (i=0; i<'h200; i=i+1) begin
	    #100;
	    AA = i>>0 & 'b1111;
	    BB = i>>4 & 'b1111;
	    S = i>>8 & 1;
	    #100;
	    $display("S=%1d AA=%1x BB=%1x O= %1x %1x %1x",
		     S, AA, BB, out6, out7, out8);
	end
	/*
	 * Exercise counters
	 */
	for (i=0; i<100; i=i+1) begin
	    #100;
	    clk = 1;
	    #100;
	    clk = 0;
	    $display("i=%1d oc= %1d %1d %1d %1d %1d %1d %1d",
		     i, oc1, oc2, oc3, oc4, oc5, oc6, oc7);
	end
	/*
	 * Exercise shift registers
	 */
	for (i=0; i<50; i=i+1) begin
	    #100;
	    clk1 = 1;
	    #100;
	    clk1 = 0;
	    $display("i=%1d osr= %6b %6b %6b %6b",
		     i, osr4, osr3, osr2, osr1);
	end
	/*
	 * Exercise LED segment encoder
	 */
	for (i=0; i<16; i=i+1) begin
	    num = i[3:0];
            #100;
	    $display("");
	    $display("");
	    $display("%0x: %7b", i, segs);
	    $display("  %s ", segs[0] ? " " : "-");
	    $display(" %s %s", segs[5] ? " " : "|", segs[1] ? " " : "|");
	    $display("  %s ", segs[6] ? " " : "-");
	    $display(" %s %s", segs[4] ? " " : "|", segs[2] ? " " : "|");
	    $display("  %s ", segs[3] ? " " : "-");
	    $display("");
	end
    end
endmodule

Test bench output

S=0 A=0 B=0 O= 0 0 0 0 0
S=0 A=1 B=0 O= 1 1 1 1 1
S=0 A=0 B=1 O= 0 0 0 0 0
S=0 A=1 B=1 O= 1 1 1 1 1
S=1 A=0 B=0 O= 0 0 0 0 0
S=1 A=1 B=0 O= 0 0 0 0 0
S=1 A=0 B=1 O= 1 1 1 1 1
S=1 A=1 B=1 O= 1 1 1 1 1
S=0 AA=0 BB=0 O= 0 0 0
S=0 AA=1 BB=0 O= 1 1 1
S=0 AA=2 BB=0 O= 2 2 2
S=0 AA=3 BB=0 O= 3 3 3
S=0 AA=4 BB=0 O= 4 4 4
S=0 AA=5 BB=0 O= 5 5 5
S=0 AA=6 BB=0 O= 6 6 6
S=0 AA=7 BB=0 O= 7 7 7
S=0 AA=8 BB=0 O= 8 8 8
S=0 AA=9 BB=0 O= 9 9 9
S=0 AA=a BB=0 O= a a a
S=0 AA=b BB=0 O= b b b
S=0 AA=c BB=0 O= c c c
S=0 AA=d BB=0 O= d d d
S=0 AA=e BB=0 O= e e e
S=0 AA=f BB=0 O= f f f
S=0 AA=0 BB=1 O= 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 O= f f f
S=0 AA=0 BB=a O= 0 0 0
S=0 AA=1 BB=a O= 1 1 1
S=0 AA=2 BB=a O= 2 2 2
S=0 AA=3 BB=a O= 3 3 3
S=0 AA=4 BB=a O= 4 4 4
S=0 AA=5 BB=a O= 5 5 5
S=0 AA=6 BB=a O= 6 6 6
S=0 AA=7 BB=a O= 7 7 7
S=0 AA=8 BB=a O= 8 8 8
S=0 AA=9 BB=a O= 9 9 9
S=0 AA=a BB=a O= a a a
S=0 AA=b BB=a O= b b b
S=0 AA=c BB=a O= c c c
S=0 AA=d BB=a O= d d d
S=0 AA=e BB=a O= e e e
S=0 AA=f BB=a O= f f f
S=0 AA=0 BB=b O= 0 0 0
S=0 AA=1 BB=b O= 1 1 1
S=0 AA=2 BB=b O= 2 2 2
S=0 AA=3 BB=b O= 3 3 3
S=0 AA=4 BB=b O= 4 4 4
S=0 AA=5 BB=b O= 5 5 5
S=0 AA=6 BB=b O= 6 6 6
S=0 AA=7 BB=b O= 7 7 7
S=0 AA=8 BB=b O= 8 8 8
S=0 AA=9 BB=b O= 9 9 9
S=0 AA=a BB=b O= a a a
S=0 AA=b BB=b O= b b b
S=0 AA=c BB=b O= c c c
S=0 AA=d BB=b O= d d d
S=0 AA=e BB=b O= e e e
S=0 AA=f BB=b O= f f f
S=0 AA=0 BB=c O= 0 0 0
S=0 AA=1 BB=c O= 1 1 1
S=0 AA=2 BB=c O= 2 2 2
S=0 AA=3 BB=c O= 3 3 3
S=0 AA=4 BB=c O= 4 4 4
S=0 AA=5 BB=c O= 5 5 5
S=0 AA=6 BB=c O= 6 6 6
S=0 AA=7 BB=c O= 7 7 7
S=0 AA=8 BB=c O= 8 8 8
S=0 AA=9 BB=c O= 9 9 9
S=0 AA=a BB=c O= a a a
S=0 AA=b BB=c O= b b b
S=0 AA=c BB=c O= c c c
S=0 AA=d BB=c O= d d d
S=0 AA=e BB=c O= e e e
S=0 AA=f BB=c O= f f f
S=0 AA=0 BB=d O= 0 0 0
S=0 AA=1 BB=d O= 1 1 1
S=0 AA=2 BB=d O= 2 2 2
S=0 AA=3 BB=d O= 3 3 3
S=0 AA=4 BB=d O= 4 4 4
S=0 AA=5 BB=d O= 5 5 5
S=0 AA=6 BB=d O= 6 6 6
S=0 AA=7 BB=d O= 7 7 7
S=0 AA=8 BB=d O= 8 8 8
S=0 AA=9 BB=d O= 9 9 9
S=0 AA=a BB=d O= a a a
S=0 AA=b BB=d O= b b b
S=0 AA=c BB=d O= c c c
S=0 AA=d BB=d O= d d d
S=0 AA=e BB=d O= e e e
S=0 AA=f BB=d O= f f f
S=0 AA=0 BB=e O= 0 0 0
S=0 AA=1 BB=e O= 1 1 1
S=0 AA=2 BB=e O= 2 2 2
S=0 AA=3 BB=e O= 3 3 3
S=0 AA=4 BB=e O= 4 4 4
S=0 AA=5 BB=e O= 5 5 5
S=0 AA=6 BB=e O= 6 6 6
S=0 AA=7 BB=e O= 7 7 7
S=0 AA=8 BB=e O= 8 8 8
S=0 AA=9 BB=e O= 9 9 9
S=0 AA=a BB=e O= a a a
S=0 AA=b BB=e O= b b b
S=0 AA=c BB=e O= c c c
S=0 AA=d BB=e O= d d d
S=0 AA=e BB=e O= e e e
S=0 AA=f BB=e O= f f f
S=0 AA=0 BB=f O= 0 0 0
S=0 AA=1 BB=f O= 1 1 1
S=0 AA=2 BB=f O= 2 2 2
S=0 AA=3 BB=f O= 3 3 3
S=0 AA=4 BB=f O= 4 4 4
S=0 AA=5 BB=f O= 5 5 5
S=0 AA=6 BB=f O= 6 6 6
S=0 AA=7 BB=f O= 7 7 7
S=0 AA=8 BB=f O= 8 8 8
S=0 AA=9 BB=f O= 9 9 9
S=0 AA=a BB=f O= a a a
S=0 AA=b BB=f O= b b b
S=0 AA=c BB=f O= c c c
S=0 AA=d BB=f O= d d d
S=0 AA=e BB=f O= e e e
S=0 AA=f BB=f O= f f f
S=1 AA=0 BB=0 O= 0 0 0
S=1 AA=1 BB=0 O= 0 0 0
S=1 AA=2 BB=0 O= 0 0 0
S=1 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 8
S=1 AA=b BB=8 O= 8 8 8
S=1 AA=c BB=8 O= 8 8 8
S=1 AA=d BB=8 O= 8 8 8
S=1 AA=e BB=8 O= 8 8 8
S=1 AA=f BB=8 O= 8 8 8
S=1 AA=0 BB=9 O= 9 9 9
S=1 AA=1 BB=9 O= 9 9 9
S=1 AA=2 BB=9 O= 9 9 9
S=1 AA=3 BB=9 O= 9 9 9
S=1 AA=4 BB=9 O= 9 9 9
S=1 AA=5 BB=9 O= 9 9 9
S=1 AA=6 BB=9 O= 9 9 9
S=1 AA=7 BB=9 O= 9 9 9
S=1 AA=8 BB=9 O= 9 9 9
S=1 AA=9 BB=9 O= 9 9 9
S=1 AA=a BB=9 O= 9 9 9
S=1 AA=b BB=9 O= 9 9 9
S=1 AA=c BB=9 O= 9 9 9
S=1 AA=d BB=9 O= 9 9 9
S=1 AA=e BB=9 O= 9 9 9
S=1 AA=f BB=9 O= 9 9 9
S=1 AA=0 BB=a O= a a a
S=1 AA=1 BB=a O= a a a
S=1 AA=2 BB=a O= a a a
S=1 AA=3 BB=a O= a a a
S=1 AA=4 BB=a O= a a a
S=1 AA=5 BB=a O= a a a
S=1 AA=6 BB=a O= a a a
S=1 AA=7 BB=a O= a a a
S=1 AA=8 BB=a O= a a a
S=1 AA=9 BB=a O= a a a
S=1 AA=a BB=a O= a a a
S=1 AA=b BB=a O= a a a
S=1 AA=c BB=a O= a a a
S=1 AA=d BB=a O= a a a
S=1 AA=e BB=a O= a a a
S=1 AA=f BB=a O= a a a
S=1 AA=0 BB=b O= b b b
S=1 AA=1 BB=b O= b b b
S=1 AA=2 BB=b O= b b b
S=1 AA=3 BB=b O= b b b
S=1 AA=4 BB=b O= b b b
S=1 AA=5 BB=b O= b b b
S=1 AA=6 BB=b O= b b b
S=1 AA=7 BB=b O= b b b
S=1 AA=8 BB=b O= b b b
S=1 AA=9 BB=b O= b b b
S=1 AA=a BB=b O= b b b
S=1 AA=b BB=b O= b b b
S=1 AA=c BB=b O= b b b
S=1 AA=d BB=b O= b b b
S=1 AA=e BB=b O= b b b
S=1 AA=f BB=b O= b b b
S=1 AA=0 BB=c O= c c c
S=1 AA=1 BB=c O= c c c
S=1 AA=2 BB=c O= c c c
S=1 AA=3 BB=c O= c c c
S=1 AA=4 BB=c O= c c c
S=1 AA=5 BB=c O= c c c
S=1 AA=6 BB=c O= c c c
S=1 AA=7 BB=c O= c c c
S=1 AA=8 BB=c O= c c c
S=1 AA=9 BB=c O= c c c
S=1 AA=a BB=c O= c c c
S=1 AA=b BB=c O= c c c
S=1 AA=c BB=c O= c c c
S=1 AA=d BB=c O= c c c
S=1 AA=e BB=c O= c c c
S=1 AA=f BB=c O= c c c
S=1 AA=0 BB=d O= d d d
S=1 AA=1 BB=d O= d d d
S=1 AA=2 BB=d O= d d d
S=1 AA=3 BB=d O= d d d
S=1 AA=4 BB=d O= d d d
S=1 AA=5 BB=d O= d d d
S=1 AA=6 BB=d O= d d d
S=1 AA=7 BB=d O= d d d
S=1 AA=8 BB=d O= d d d
S=1 AA=9 BB=d O= d d d
S=1 AA=a BB=d O= d d d
S=1 AA=b BB=d O= d d d
S=1 AA=c BB=d O= d d d
S=1 AA=d BB=d O= d d d
S=1 AA=e BB=d O= d d d
S=1 AA=f BB=d O= d d d
S=1 AA=0 BB=e O= e e e
S=1 AA=1 BB=e O= e e e
S=1 AA=2 BB=e O= e e e
S=1 AA=3 BB=e O= e e e
S=1 AA=4 BB=e O= e e e
S=1 AA=5 BB=e O= e e e
S=1 AA=6 BB=e O= e e e
S=1 AA=7 BB=e O= e e e
S=1 AA=8 BB=e O= e e e
S=1 AA=9 BB=e O= e e e
S=1 AA=a BB=e O= e e e
S=1 AA=b BB=e O= e e e
S=1 AA=c BB=e O= e e e
S=1 AA=d BB=e O= e e e
S=1 AA=e BB=e O= e e e
S=1 AA=f BB=e O= e e e
S=1 AA=0 BB=f O= f f f
S=1 AA=1 BB=f O= f f f
S=1 AA=2 BB=f O= f f f
S=1 AA=3 BB=f O= f f f
S=1 AA=4 BB=f O= f f f
S=1 AA=5 BB=f O= f f f
S=1 AA=6 BB=f O= f f f
S=1 AA=7 BB=f O= f f f
S=1 AA=8 BB=f O= f f f
S=1 AA=9 BB=f O= f f f
S=1 AA=a BB=f O= f f f
S=1 AA=b BB=f O= f f f
S=1 AA=c BB=f O= f f f
S=1 AA=d BB=f O= f f f
S=1 AA=e BB=f O= f f f
S=1 AA=f BB=f O= f f f
i=0 oc= 1 1 1 1 1 1 1
i=1 oc= 2 2 2 2 2 2 2
i=2 oc= 3 3 3 3 3 3 3
i=3 oc= 4 4 4 4 4 4 4
i=4 oc= 5 5 5 5 5 5 5
i=5 oc= 6 6 6 6 6 6 6
i=6 oc= 7 7 7 7 7 7 7
i=7 oc= 8 8 8 8 8 8 8
i=8 oc= 9 9 9 9 9 9 9
i=9 oc= 10 10 10 10 10 10 10
i=10 oc= 11 11 11 11 11 11 11
i=11 oc= 12 12 12 12 12 12 12
i=12 oc= 13 13 13 13 13 13 13
i=13 oc= 14 14 14 14 14 14 14
i=14 oc= 15 15 15 15 15 15 15
i=15 oc= 16 16 16 16 16 16 16
i=16 oc= 17 17 17 17 17 17 17
i=17 oc= 18 18 18 18 18 18 18
i=18 oc= 19 19 19 19 19 19 19
i=19 oc= 20 20 20 20 20 20 20
i=20 oc= 21 21 21 21 21 21 21
i=21 oc= 22 22 22 22 22 22 22
i=22 oc= 23 23 23 23 23 23 23
i=23 oc= 24 24 24 24 24 24 24
i=24 oc= 25 25 25 25 25 25 25
i=25 oc= 26 26 26 26 26 26 26
i=26 oc= 27 27 27 27 27 27 27
i=27 oc= 28 28 28 28 28 28 28
i=28 oc= 29 29 29 29 29 29 29
i=29 oc= 30 30 30 30 30 30 30
i=30 oc= 31 31 31 31 31 31 31
i=31 oc= 32 32 32 32 32 32 32
i=32 oc= 33 33 33 33 33 33 33
i=33 oc= 34 34 34 34 34 34 34
i=34 oc= 35 35 35 35 35 35 35
i=35 oc= 36 36 36 36 36 36 36
i=36 oc= 37 37 37 37 37 37 37
i=37 oc= 38 38 38 38 38 38 38
i=38 oc= 39 39 39 39 39 39 39
i=39 oc= 40 40 40 40 40 40 40
i=40 oc= 41 41 41 41 41 41 41
i=41 oc= 42 42 42 42 42 42 42
i=42 oc= 43 43 43 43 43 43 43
i=43 oc= 44 44 44 44 44 44 44
i=44 oc= 45 45 45 45 45 45 45
i=45 oc= 46 46 46 46 46 46 46
i=46 oc= 47 47 47 47 47 47 47
i=47 oc= 48 48 48 48 48 48 48
i=48 oc= 49 49 49 49 49 49 49
i=49 oc= 50 50 50 50 50 50 50
i=50 oc= 51 51 51 51 51 51 51
i=51 oc= 52 52 52 52 52 52 52
i=52 oc= 53 53 53 53 53 53 53
i=53 oc= 54 54 54 54 54 54 54
i=54 oc= 55 55 55 55 55 55 55
i=55 oc= 56 56 56 56 56 56 56
i=56 oc= 57 57 57 57 57 57 57
i=57 oc= 58 58 58 58 58 58 58
i=58 oc= 59 59 59 59 59 59 59
i=59 oc= 60 60 60 60 60 60 60
i=60 oc= 61 61 61 61 61 61 61
i=61 oc= 62 62 62 62 62 62 62
i=62 oc= 63 63 63 63 63 63 63
i=63 oc= 0 0 0 0 0 0 0
i=64 oc= 1 1 1 1 1 1 1
i=65 oc= 2 2 2 2 2 2 2
i=66 oc= 3 3 3 3 3 3 3
i=67 oc= 4 4 4 4 4 4 4
i=68 oc= 5 5 5 5 5 5 5
i=69 oc= 6 6 6 6 6 6 6
i=70 oc= 7 7 7 7 7 7 7
i=71 oc= 8 8 8 8 8 8 8
i=72 oc= 9 9 9 9 9 9 9
i=73 oc= 10 10 10 10 10 10 10
i=74 oc= 11 11 11 11 11 11 11
i=75 oc= 12 12 12 12 12 12 12
i=76 oc= 13 13 13 13 13 13 13
i=77 oc= 14 14 14 14 14 14 14
i=78 oc= 15 15 15 15 15 15 15
i=79 oc= 16 16 16 16 16 16 16
i=80 oc= 17 17 17 17 17 17 17
i=81 oc= 18 18 18 18 18 18 18
i=82 oc= 19 19 19 19 19 19 19
i=83 oc= 20 20 20 20 20 20 20
i=84 oc= 21 21 21 21 21 21 21
i=85 oc= 22 22 22 22 22 22 22
i=86 oc= 23 23 23 23 23 23 23
i=87 oc= 24 24 24 24 24 24 24
i=88 oc= 25 25 25 25 25 25 25
i=89 oc= 26 26 26 26 26 26 26
i=90 oc= 27 27 27 27 27 27 27
i=91 oc= 28 28 28 28 28 28 28
i=92 oc= 29 29 29 29 29 29 29
i=93 oc= 30 30 30 30 30 30 30
i=94 oc= 31 31 31 31 31 31 31
i=95 oc= 32 32 32 32 32 32 32
i=96 oc= 33 33 33 33 33 33 33
i=97 oc= 34 34 34 34 34 34 34
i=98 oc= 35 35 35 35 35 35 35
i=99 oc= 36 36 36 36 36 36 36
i=0 osr= 000000 000000 000000 000001
i=1 osr= 000000 000000 000000 000010
i=2 osr= 000000 000000 000000 000100
i=3 osr= 000000 000000 000000 001000
i=4 osr= 000000 000000 000000 010000
i=5 osr= 000000 000000 000000 100000
i=6 osr= 000000 000000 000001 000000
i=7 osr= 000000 000000 000010 000000
i=8 osr= 000000 000000 000100 000000
i=9 osr= 000000 000000 001000 000000
i=10 osr= 000000 000000 010000 000000
i=11 osr= 000000 000000 100000 000000
i=12 osr= 000000 000001 000000 000000
i=13 osr= 000000 000010 000000 000000
i=14 osr= 000000 000100 000000 000000
i=15 osr= 000000 001000 000000 000000
i=16 osr= 000000 010000 000000 000000
i=17 osr= 000000 100000 000000 000000
i=18 osr= 000001 000000 000000 000000
i=19 osr= 000010 000000 000000 000000
i=20 osr= 000100 000000 000000 000000
i=21 osr= 001000 000000 000000 000000
i=22 osr= 010000 000000 000000 000000
i=23 osr= 100000 000000 000000 000000
i=24 osr= 000000 000000 000000 000000
i=25 osr= 000000 000000 000000 000001
i=26 osr= 000000 000000 000000 000010
i=27 osr= 000000 000000 000000 000100
i=28 osr= 000000 000000 000000 001000
i=29 osr= 000000 000000 000000 010000
i=30 osr= 000000 000000 000000 100000
i=31 osr= 000000 000000 000001 000000
i=32 osr= 000000 000000 000010 000000
i=33 osr= 000000 000000 000100 000000
i=34 osr= 000000 000000 001000 000000
i=35 osr= 000000 000000 010000 000000
i=36 osr= 000000 000000 100000 000000
i=37 osr= 000000 000001 000000 000000
i=38 osr= 000000 000010 000000 000000
i=39 osr= 000000 000100 000000 000000
i=40 osr= 000000 001000 000000 000000
i=41 osr= 000000 010000 000000 000000
i=42 osr= 000000 100000 000000 000000
i=43 osr= 000001 000000 000000 000000
i=44 osr= 000010 000000 000000 000000
i=45 osr= 000100 000000 000000 000000
i=46 osr= 001000 000000 000000 000000
i=47 osr= 010000 000000 000000 000000
i=48 osr= 100000 000000 000000 000000
i=49 osr= 000000 000000 000000 000000


0: 1000000
  - 
 | |
    
 | |
  - 



1: 1111001
    
   |
    
   |
    



2: 0100100
  - 
   |
  - 
 |  
  - 



3: 0110000
  - 
   |
  - 
   |
  - 



4: 0011001
    
 | |
  - 
   |
    



5: 0010010
  - 
 |  
  - 
   |
  - 



6: 0000010
  - 
 |  
  - 
 | |
  - 



7: 1111000
  - 
   |
    
   |
    



8: 0000000
  - 
 | |
  - 
 | |
  - 



9: 0010000
  - 
 | |
  - 
   |
  - 



a: 0001000
  - 
 | |
  - 
 | |
    



b: 0000011
    
 |  
  - 
 | |
  - 



c: 1000110
  - 
 |  
    
 |  
  - 



d: 0100001
    
   |
  - 
 | |
  - 



e: 0000110
  - 
 |  
  - 
 |  
  - 



f: 0001110
  - 
 |  
  - 
 |  
    


Personal tools