Verification of Parameterised FPGA Circuit Descriptions with Layout ...

Verification of Parameterised FPGA Circuit Descriptions with Layout ... Verification of Parameterised FPGA Circuit Descriptions with Layout ...

24.04.2013 Views

APPENDIX D. CIRCUIT LAYOUT CASE STUDIES 306 } cin = false. (a, b) ; zip 2 ; converse (pi1) ; col (n, fadd clk) ; (cin, ans) at (0,0). /∗ Repeating cell for cubical matrix multiplier ∗/ block matmultcell (int n) (wire clk) (wire x in[n], wire y in[n], wire z in[n]) ∼ (wire z out[n], wire y out[n], wire x out[n]) { x out = x in. y out = y in. ((x in, y in), z in) ; fst (mult n) ; add n clk; z out at (0,0). } /∗∗ Transpose a matrix ∗/ block word transpose (int bits) (int n, int m) (‘a v1[n][m][bits ]) ∼ (‘a v2[m][n][ bits ]) { int i , j. for i = 0..n−1 { for j = 0..m−1 { v2[j ][ i ] = v1[i ][ j]. } . } . } /∗∗ Matrix multiplier ∗/ block matmult (wire clk) (int bits) (int x, int y, int z) (wire mat1[y][z ][ bits ], wire mat2[z][x][ bits ]) ∼ (wire mat3[y][x][ bits ]) { wire emptymat[y][x][bits]. wire mat trans[z][y][ bits ]. int i , j, k. for i = 0..y−1 { for j = 0..x−1 { for k = 0..bits−1 { emptymat[i][j][ k] = false. } . } . } . mat1 ; word transpose bits (y, z) ; mat trans at (0,0). (mat trans, mat2, emptymat) ; cube (x, y, z, matmultcell bits clk) ; converse (tplapl 2) ; pi1 ; mat3 at (0,0). } D.3.2 Theory cube cell theory cube_cell = apr + lsh + swap + fst + rsh + apl + converse + snd: section {* Temporary definitions to support tplapl in Isabelle *} constdefs tplapr2_struct :: "((’a*’b)*’c)=>(’a*’b*’c)=>bool" "tplapr2_struct == (% ((a, b), c) (d, e, f). a = d & b = e & f = c)" tplapr2 :: "(((’a*’b)*’c)=>(’a*’b*’c)=>bool,((’a*’b)*’c)=>(’a*’b*’c)=>int)block" "tplapr2 == (| Def = tplapr2_struct, Height = % a b. (0::int), Width = % a b. (0::int) |)" tplapl2_struct :: "(’a*(’b*’c))=>(’a*’b*’c)=>bool" "tplapl2_struct == (% (a, (b, c)) (d, e, f). a = d & b = e & c = f)" tplapl2 :: "((’a*(’b*’c))=>(’a*’b*’c)=>bool,(’a*(’b*’c))=>(’a*’b*’c)=>int)block" "tplapl2 == (| Def = tplapl2_struct, Height = % a b. (0::int), Width = % a b. (0::int) |)" section {* Function definitions *} consts

APPENDIX D. CIRCUIT LAYOUT CASE STUDIES 307 struct:: "(int*(((’t697*’t698*’t772)=>(’t772*’t698*’t697)=>bool,(’t697*’t698*’ t772)=>(’t772*’t698*’t697)=>int)block))=>(((’t772)vector*’t697)*’t698)=>(’ t698*((’t772)vector*’t697))=>bool" height:: "(int*(((’t697*’t698*’t772)=>(’t772*’t698*’t697)=>bool,(’t697*’t698*’ t772)=>(’t772*’t698*’t697)=>int)block))=>(((’t772)vector*’t697)*’t698)=>(’ t698*((’t772)vector*’t697))=>int" width:: "(int*(((’t697*’t698*’t772)=>(’t772*’t698*’t697)=>bool,(’t697*’t698*’t772 )=>(’t772*’t698*’t697)=>int)block))=>(((’t772)vector*’t697)*’t698)=>(’t698 *((’t772)vector*’t697))=>int" cube_cell:: "((int*(((’t697*’t698*’t772)=>(’t772*’t698*’t697)=>bool,(’t697*’t698 *’t772)=>(’t772*’t698*’t697)=>int)block))=>(((’t772)vector*’t697)*’t698)=>(’ t698*((’t772)vector*’t697))=>bool, (int*(((’t697*’t698*’t772)=>(’t772*’t698*’ t697)=>bool,(’t697*’t698*’t772)=>(’t772*’t698*’t697)=>int)block))=>(((’t772) vector*’t697)*’t698)=>(’t698*((’t772)vector*’t697))=>int)block" defs struct_def: "struct == % (n, R) ((z, x), y) (y2, (z2, x2)). Def (((x, y), z) ;;; snd $ (converse $ (apl $ (n - 1))) ;; rsh ;; fst $ (tplapr2 ;; R ;; converse $ (tplapl2) ;; swap) ;; lsh ;; snd $ (swap ;; apr $ (n - 1)) ;;; ((y2, x2), z2))" height_def: "height == % (n, R) ((z, x), y) (y2, (z2, x2)). Height (((x, y), z) ;;; snd $ (converse $ (apl $ (n - 1))) ;; rsh ;; fst $ (tplapr2 ;; R ;; converse $ (tplapl2) ;; swap) ;; lsh ;; snd $ (swap ;; apr $ (n - 1)) ;;; (( y2, x2), z2))" width_def: "width == % (n, R) ((z, x), y) (y2, (z2, x2)). Width (((x, y), z) ;;; snd $ (converse $ (apl $ (n - 1))) ;; rsh ;; fst $ (tplapr2 ;; R ;; converse $ (tplapl2) ;; swap) ;; lsh ;; snd $ (swap ;; apr $ (n - 1)) ;;; ((y2, x2), z2))" cube_cell_def: "cube_cell == (| Def = struct, Height = height, Width = width |)" declare width_def [simp] declare height_def [simp] declare struct_def [simp] section {* Validity of width and height functions *} theorem height_ge0_int : "!! (n::int) (R::(((’t697*’t698*’t772)=>(’t772*’t698*’t697) =>bool,(’t697*’t698*’t772)=>(’t772*’t698*’t697)=>int)block)) (z::(’t772)vector) (x::’t697) (y::’t698) (y2::’t698) (z2::(’t772)vector) (x2::’t697). [| ALL ( qs1101::(’t697*’t698*’t772)) (qs1102::(’t772*’t698*’t697)). 0

APPENDIX D. CIRCUIT LAYOUT CASE STUDIES 307<br />

struct:: "(int*(((’t697*’t698*’t772)=>(’t772*’t698*’t697)=>bool,(’t697*’t698*’<br />

t772)=>(’t772*’t698*’t697)=>int)block))=>(((’t772)vector*’t697)*’t698)=>(’<br />

t698*((’t772)vector*’t697))=>bool"<br />

height:: "(int*(((’t697*’t698*’t772)=>(’t772*’t698*’t697)=>bool,(’t697*’t698*’<br />

t772)=>(’t772*’t698*’t697)=>int)block))=>(((’t772)vector*’t697)*’t698)=>(’<br />

t698*((’t772)vector*’t697))=>int"<br />

width:: "(int*(((’t697*’t698*’t772)=>(’t772*’t698*’t697)=>bool,(’t697*’t698*’t772<br />

)=>(’t772*’t698*’t697)=>int)block))=>(((’t772)vector*’t697)*’t698)=>(’t698<br />

*((’t772)vector*’t697))=>int"<br />

cube_cell:: "((int*(((’t697*’t698*’t772)=>(’t772*’t698*’t697)=>bool,(’t697*’t698<br />

*’t772)=>(’t772*’t698*’t697)=>int)block))=>(((’t772)vector*’t697)*’t698)=>(’<br />

t698*((’t772)vector*’t697))=>bool, (int*(((’t697*’t698*’t772)=>(’t772*’t698*’<br />

t697)=>bool,(’t697*’t698*’t772)=>(’t772*’t698*’t697)=>int)block))=>(((’t772)<br />

vector*’t697)*’t698)=>(’t698*((’t772)vector*’t697))=>int)block"<br />

defs<br />

struct_def: "struct == % (n, R) ((z, x), y) (y2, (z2, x2)). Def (((x, y), z) ;;;<br />

snd $ (converse $ (apl $ (n - 1))) ;; rsh ;; fst $ (tplapr2 ;; R ;; converse<br />

$ (tplapl2) ;; swap) ;; lsh ;; snd $ (swap ;; apr $ (n - 1)) ;;; ((y2, x2),<br />

z2))"<br />

height_def: "height == % (n, R) ((z, x), y) (y2, (z2, x2)). Height (((x, y), z)<br />

;;; snd $ (converse $ (apl $ (n - 1))) ;; rsh ;; fst $ (tplapr2 ;; R ;;<br />

converse $ (tplapl2) ;; swap) ;; lsh ;; snd $ (swap ;; apr $ (n - 1)) ;;; ((<br />

y2, x2), z2))"<br />

width_def: "width == % (n, R) ((z, x), y) (y2, (z2, x2)). Width (((x, y), z) ;;;<br />

snd $ (converse $ (apl $ (n - 1))) ;; rsh ;; fst $ (tplapr2 ;; R ;; converse<br />

$ (tplapl2) ;; swap) ;; lsh ;; snd $ (swap ;; apr $ (n - 1)) ;;; ((y2, x2),<br />

z2))"<br />

cube_cell_def: "cube_cell == (| Def = struct, Height = height, Width = width |)"<br />

declare width_def [simp]<br />

declare height_def [simp]<br />

declare struct_def [simp]<br />

section {* Validity <strong>of</strong> width and height functions *}<br />

theorem height_ge0_int : "!! (n::int) (R::(((’t697*’t698*’t772)=>(’t772*’t698*’t697)<br />

=>bool,(’t697*’t698*’t772)=>(’t772*’t698*’t697)=>int)block)) (z::(’t772)vector)<br />

(x::’t697) (y::’t698) (y2::’t698) (z2::(’t772)vector) (x2::’t697). [| ALL (<br />

qs1101::(’t697*’t698*’t772)) (qs1102::(’t772*’t698*’t697)). 0

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!