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 C. PLACED COMBINATOR LIBRARIES 260 by auto end C.5 H-Tree block htree (int n, block R (‘a, ‘a) ∼ ‘a) (‘a i [m]) ∼ (‘a o) { const m = 2 ∗∗ n. ‘a st1 in[m/2], st2 in[m/2], st1 out, st2 out. if n == 0 { o = i[0] . } else { i ; half (m/2) ; (st1 in, st2 in) at (0,0). if (n mod 2 == 0) { // Vertical sub−tree arrangement st1 in ; htree (n−1, R) ; st1 out at (0,0). (st1 out, st2 out) ; R ; o at (0, height(st1 in ; htree (n−1, R) ; st1 out)). st2 in ; htree (n−1, R) ; st2 out at (0, height(st1 in;htree (n−1, R);st1 out) + height ((st1 out, st2 out);R;o )). } else { // Horizontal sub−tree arrangement st1 in ; htree (n−1, R) ; st1 out at (0,0). (st1 out, st2 out) ; R ; o at (width(st1 in ;htree (n−1, R) ; st1 out), 0). st2 in ; htree (n−1, R) ; st2 out at (width(st1 in;htree (n−1, R);st1 out) + width ((st1 out, st2 out);R;o), 0) . } . } . } theory htree = half: section {* Function definitions *} consts struct:: "nat=>(((’t20*’t20)=>’t20=>bool,(’t20*’t20)=>’t20=>int)block)=>(’t20) vector=>’t20=>bool" height:: "nat=>(((’t20*’t20)=>’t20=>bool,(’t20*’t20)=>’t20=>int)block)=>(’t20) vector=>’t20=>int" width:: "nat=>(((’t20*’t20)=>’t20=>bool,(’t20*’t20)=>’t20=>int)block)=>(’t20) vector=>’t20=>int" htree:: "((int*(((’t20*’t20)=>’t20=>bool,(’t20*’t20)=>’t20=>int)block))=>(’t20) vector=>’t20=>bool, (int*(((’t20*’t20)=>’t20=>bool,(’t20*’t20)=>’t20=>int) block))=>(’t20)vector=>’t20=>int)block" defs htree_def: "htree == (| Def = % (n, R) i o_. struct (int2nat n) R i o_, Height = % (n, R) i o_. height (int2nat n) R i o_, Width = % (n, R) i o_. width ( int2nat n) R i o_|)"

APPENDIX C. PLACED COMBINATOR LIBRARIES 261 primrec "struct 0 R i o_ = (o_ = i)" "struct (Suc n) R i o_ = (let m = (2 pwr (int (Suc n))) in EX (st1_in::(’t20)vector) (st2_in::(’t20)vector) (st1_out::’t20) (st2_out::’t20). Def (i ;;; half $ (m div 2) ;;; (st1_in, st2_in)) & (if ((Suc n) mod 2) = 0 then (struct n R st1_in st1_out) & Def ((st1_out, st2_out ) ;;; R ;;; o_) & (struct n R st2_in st2_out) else (struct n R st1_in st1_out) & Def ((st1_out, st2_out) ;;; R ;;; o_) & ( struct n R st2_in st2_out)))" primrec "height 0 R i o_ = 0" "height (Suc n) R i o_ = (let m = (2 pwr (int (Suc n))) in let st1_in = (THE (st1_in::(’t20)vector). EX (st2_in::(’t20)vector) (st1_out::’ t20) (st2_out::’t20). Def (i ;;; half $ (m div 2) ;;; (st1_in, st2_in)) & (if ((Suc n) mod 2) = 0 then (struct n R st1_in st1_out) & Def ((st1_out, st2_out) ;;; R ;;; o_) & (struct n R st2_in st2_out) else (struct n R st1_in st1_out) & Def ((st1_out, st2_out) ;;; R ;;; o_) & ( struct n R st2_in st2_out)) ) in let st2_in = (THE (st2_in::(’t20)vector). EX (st1_in::(’t20)vector) (st1_out::’ t20) (st2_out::’t20). Def (i ;;; half $ (m div 2) ;;; (st1_in, st2_in)) & (if ((Suc n) mod 2) = 0 then (struct n R st1_in st1_out) & Def ((st1_out, st2_out) ;;; R ;;; o_) & (struct n R st2_in st2_out) else (struct n R st1_in st1_out) & Def ((st1_out, st2_out) ;;; R ;;; o_) & ( struct n R st2_in st2_out)) ) in let st1_out = (THE (st1_out::’t20). EX (st1_in::(’t20)vector) (st2_in::(’t20) vector) (st2_out::’t20). Def (i ;;; half $ (m div 2) ;;; (st1_in, st2_in)) & (if ((Suc n) mod 2) = 0 then (struct n R st1_in st1_out) & Def ((st1_out, st2_out) ;;; R ;;; o_) & (struct n R st2_in st2_out) else (struct n R st1_in st1_out) & Def ((st1_out, st2_out) ;;; R ;;; o_) & ( struct n R st2_in st2_out)) ) in let st2_out = (THE (st2_out::’t20). EX (st1_in::(’t20)vector) (st2_in::(’t20) vector) (st1_out::’t20). Def (i ;;; half $ (m div 2) ;;; (st1_in, st2_in)) & (if ((Suc n) mod 2) = 0 then (struct n R st1_in st1_out) & Def ((st1_out, st2_out) ;;; R ;;; o_) & (struct n R st2_in st2_out) else (struct n R st1_in st1_out) & Def ((st1_out, st2_out) ;;; R ;;; o_) & ( struct n R st2_in st2_out)) ) in max (Height (i ;;; half $ (m div 2) ;;; (st1_in, st2_in))) (if ((Suc n) mod 2) = 0 then max ((height n R st1_in st1_out) + (Height ((st1_out, st2_out) ;;; R ;;; o_)) + (height n R st2_in st2_out)) ((max ((height n R st1_in st1_out) + (Height ((st1_out, st2_out) ;;; R ;;; o_))) (height n R st1_in st1_out))) else max (height n R st2_in st2_out) ((max (Height ((st1_out, st2_out) ;;; R ;;; o_)) (height n R st1_in st1_out)))) )" primrec "width 0 R i o_ = 0" "width (Suc n) R i o_ = (let m = (2 pwr (int (Suc n))) in

APPENDIX C. PLACED COMBINATOR LIBRARIES 260<br />

by auto<br />

end<br />

C.5 H-Tree<br />

block htree (int n, block R (‘a, ‘a) ∼ ‘a) (‘a i [m]) ∼ (‘a o)<br />

{<br />

const m = 2 ∗∗ n.<br />

‘a st1 in[m/2], st2 in[m/2], st1 out, st2 out.<br />

if n == 0 {<br />

o = i[0] .<br />

} else {<br />

i ; half (m/2) ; (st1 in, st2 in)<br />

at (0,0).<br />

if (n mod 2 == 0) {<br />

// Vertical sub−tree arrangement<br />

st1 in ; htree (n−1, R) ; st1 out<br />

at (0,0).<br />

(st1 out, st2 out) ; R ; o<br />

at (0, height(st1 in ; htree (n−1, R) ; st1 out)).<br />

st2 in ; htree (n−1, R) ; st2 out<br />

at (0, height(st1 in;htree (n−1, R);st1 out) + height ((st1 out, st2 out);R;o<br />

)).<br />

} else {<br />

// Horizontal sub−tree arrangement<br />

st1 in ; htree (n−1, R) ; st1 out<br />

at (0,0).<br />

(st1 out, st2 out) ; R ; o<br />

at (width(st1 in ;htree (n−1, R) ; st1 out), 0).<br />

st2 in ; htree (n−1, R) ; st2 out<br />

at (width(st1 in;htree (n−1, R);st1 out) + width ((st1 out, st2 out);R;o), 0)<br />

.<br />

} .<br />

} .<br />

}<br />

theory htree = half:<br />

section {* Function definitions *}<br />

consts<br />

struct:: "nat=>(((’t20*’t20)=>’t20=>bool,(’t20*’t20)=>’t20=>int)block)=>(’t20)<br />

vector=>’t20=>bool"<br />

height:: "nat=>(((’t20*’t20)=>’t20=>bool,(’t20*’t20)=>’t20=>int)block)=>(’t20)<br />

vector=>’t20=>int"<br />

width:: "nat=>(((’t20*’t20)=>’t20=>bool,(’t20*’t20)=>’t20=>int)block)=>(’t20)<br />

vector=>’t20=>int"<br />

htree:: "((int*(((’t20*’t20)=>’t20=>bool,(’t20*’t20)=>’t20=>int)block))=>(’t20)<br />

vector=>’t20=>bool, (int*(((’t20*’t20)=>’t20=>bool,(’t20*’t20)=>’t20=>int)<br />

block))=>(’t20)vector=>’t20=>int)block"<br />

defs<br />

htree_def: "htree == (| Def = % (n, R) i o_. struct (int2nat n) R i o_, Height =<br />

% (n, R) i o_. height (int2nat n) R i o_, Width = % (n, R) i o_. width (<br />

int2nat n) R i o_|)"

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

Saved successfully!

Ooh no, something went wrong!