arbiter tree with arbiters, not tested
This commit is contained in:
parent
d0a2fff096
commit
af52c688a3
|
@ -87,13 +87,13 @@ namespace tmpl {
|
||||||
bitval = (i & ( 1 << j )) >> j; // Get binary digit of integer i, column j
|
bitval = (i & ( 1 << j )) >> j; // Get binary digit of integer i, column j
|
||||||
[bitval = 1 ->
|
[bitval = 1 ->
|
||||||
atree_x[i].in[j] = addr_buf.out.d.d[j].t;
|
atree_x[i].in[j] = addr_buf.out.d.d[j].t;
|
||||||
[]bitval = 0 ->
|
[]bitval = 0 ->
|
||||||
atree_x[i].in[j] = addr_buf.out.d.d[j].f;
|
atree_x[i].in[j] = addr_buf.out.d.d[j].f;
|
||||||
[]bitval >= 2 -> {false : "fuck"};
|
[]bitval >= 2 -> {false : "fuck"};
|
||||||
]
|
]
|
||||||
atree_x[i].out = outx[i];
|
atree_x[i].out = outx[i];
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
andtree<NyC> atree_y[Ny];
|
andtree<NyC> atree_y[Ny];
|
||||||
(k:0..Ny-1:atree_y[k].supply = supply;)
|
(k:0..Ny-1:atree_y[k].supply = supply;)
|
||||||
|
@ -102,16 +102,120 @@ namespace tmpl {
|
||||||
bitval = (i & ( 1 << j )) >> j; // Get binary digit of integer i, column j
|
bitval = (i & ( 1 << j )) >> j; // Get binary digit of integer i, column j
|
||||||
[bitval = 1 ->
|
[bitval = 1 ->
|
||||||
atree_y[i].in[j] = addr_buf.out.d.d[j+NxC].t;
|
atree_y[i].in[j] = addr_buf.out.d.d[j+NxC].t;
|
||||||
[]bitval = 0 ->
|
[]bitval = 0 ->
|
||||||
atree_y[i].in[j] = addr_buf.out.d.d[j+NxC].f;
|
atree_y[i].in[j] = addr_buf.out.d.d[j+NxC].f;
|
||||||
]
|
]
|
||||||
atree_y[i].out = outy[i];
|
atree_y[i].out = outy[i];
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Build an arbiter_handshake tree.
|
||||||
|
*/
|
||||||
|
export template<pint N>
|
||||||
|
defproc arbtree (a1of1 in[N]; a1of1 out; power supply)
|
||||||
|
{
|
||||||
|
bool tout;
|
||||||
|
|
||||||
|
{ N > 0 : "What?" };
|
||||||
|
|
||||||
|
pint i, end, j;
|
||||||
|
i = 0;
|
||||||
|
end = N-1;
|
||||||
|
|
||||||
|
pint arbCount;
|
||||||
|
arbCount = 0;
|
||||||
|
/* Pre"calculate" the number of C cells required, look below if confused */
|
||||||
|
*[ i != end ->
|
||||||
|
j = 0;
|
||||||
|
*[ i <= end ->
|
||||||
|
j = j + 1;
|
||||||
|
[i = end ->
|
||||||
|
i = end+1;
|
||||||
|
[] i+1 = end ->
|
||||||
|
i = end+1;
|
||||||
|
arbCount = arbCount +1;
|
||||||
|
[] else ->
|
||||||
|
i = i + 2;
|
||||||
|
arbCount = arbCount +1;
|
||||||
|
]
|
||||||
|
]
|
||||||
|
/*-- update range that has to be combined --*/
|
||||||
|
// i = end+1;
|
||||||
|
end = end+j;
|
||||||
|
]
|
||||||
|
|
||||||
|
/* array that holds ALL the nodes in the completion tree */
|
||||||
|
a1of1 tmp[end+1];
|
||||||
|
|
||||||
|
// Connecting the first nodes to the input
|
||||||
|
(l:N:
|
||||||
|
tmp[l] = in[l];
|
||||||
|
)
|
||||||
|
|
||||||
|
/* array to hold the actual C-elments, either A2C or A3C */
|
||||||
|
[arbCount > 0 ->
|
||||||
|
arbiter_handshake arbs[arbCount];
|
||||||
|
]
|
||||||
|
(h:arbCount:arbs[h].supply = supply;)
|
||||||
|
|
||||||
|
/* Reset the variables we just stole lol */
|
||||||
|
i = 0;
|
||||||
|
end = N-1;
|
||||||
|
j = 0;
|
||||||
|
pint arbIndex = 0;
|
||||||
|
|
||||||
|
/* Invariant: i <= end */
|
||||||
|
|
||||||
|
*[ i != end ->
|
||||||
|
/*
|
||||||
|
* Invariant: tmp[i..end] has the current signals that need to be
|
||||||
|
* combined together, and "isinv" specifies if they are the inverted
|
||||||
|
* sense or not
|
||||||
|
*/
|
||||||
|
j = 0;
|
||||||
|
*[ i <= end ->
|
||||||
|
/*-- there are still signals that need to be combined --*/
|
||||||
|
j = j + 1;
|
||||||
|
[ i = end ->
|
||||||
|
/*-- last piece: pipe input through to next layer --*/
|
||||||
|
tmp[end+j] = tmp[i];
|
||||||
|
i = end+1;
|
||||||
|
[] i+1 = end ->
|
||||||
|
/*-- last piece: use either a 2 input C-element --*/
|
||||||
|
arbs[arbIndex].in1 = tmp[i];
|
||||||
|
arbs[arbIndex].in2 = tmp[i+1];
|
||||||
|
arbs[arbIndex].out = tmp[end+j];
|
||||||
|
arbIndex = arbIndex +1;
|
||||||
|
i = end+1;
|
||||||
|
[] else ->
|
||||||
|
/*-- more to come; so use a two input C-element --*/
|
||||||
|
arbs[arbIndex].in1 = tmp[i];
|
||||||
|
arbs[arbIndex].in2 = tmp[i+1];
|
||||||
|
arbs[arbIndex].out = tmp[end+j];
|
||||||
|
arbIndex = arbIndex +1;
|
||||||
|
i = i + 2;
|
||||||
|
]
|
||||||
|
]
|
||||||
|
/*-- update range that has to be combined --*/
|
||||||
|
i = end+1;
|
||||||
|
end = end+j;
|
||||||
|
j = 0;
|
||||||
|
]
|
||||||
|
|
||||||
|
out = tmp[end];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue