encoder init
This commit is contained in:
parent
382714d11e
commit
f55322bc7c
@ -34,6 +34,14 @@ import "../../dataflow_neuro/primitives.act";
|
||||
import std::channel;
|
||||
open std::channel;
|
||||
|
||||
import std::data;
|
||||
open std::data;
|
||||
|
||||
|
||||
// import dev::channel;
|
||||
// open dev::channel;
|
||||
|
||||
|
||||
namespace tmpl {
|
||||
namespace dataflow_neuro {
|
||||
|
||||
@ -226,38 +234,96 @@ namespace tmpl {
|
||||
}
|
||||
|
||||
|
||||
template<pint N, pint M, pint ACK_STRENGTH>
|
||||
defproc encoder2D(a1of1 x[N]; a1of1 y[M] ;avMx1of2<X> addr; bool! out_a; power supply)
|
||||
{
|
||||
// Arbiters
|
||||
a1of1 _out_arb_x,_out_arb_y;
|
||||
a1of1 _x_temp[N];
|
||||
(i:N:
|
||||
_x_temp[i].r = x[i].r;
|
||||
)
|
||||
(i:M:
|
||||
_y_temp[i].r = y[i].r;
|
||||
)
|
||||
arbtree<N> Xarb(.in = _x_temp,.out = _out_arb_X,.supply = supply);
|
||||
arbtree<M> Yarb(.in = _y_temp,.out = _out_arb_Y,.supply = supply);
|
||||
|
||||
sigbuf<ACK_STRENGTH> x_ack_arb[N];
|
||||
sigbuf<ACK_STRENGTH> y_ack_arb[M];
|
||||
(i:N:
|
||||
x_ack_arb[i].in = _x_temp[i].a;
|
||||
x_ack_arb[i].out[0] = x[i].a;
|
||||
x_ack_arb[i].supply = supply;
|
||||
)
|
||||
(i:M:
|
||||
y_ack_arb[i].in = _y_temp[i].a;
|
||||
y_ack_arb[i].out[0] = y[i].a;
|
||||
y_ack_arb[i].supply = supply;
|
||||
)
|
||||
// Generates the OR-trees required to go from
|
||||
// N one-hot inputs to Nc dual rail binary encoding.
|
||||
export template<pint Nc, N>
|
||||
defproc encoder(bool? in[N]; Mx1of2<Nc> out; power supply) {
|
||||
{N <= 1<<Nc : "Num inputs too wide for encoding channel!"};
|
||||
|
||||
// For each output line, need to precalculate how big of an OR tree it needs
|
||||
// since can't presume that N = 2**Nc
|
||||
// First version however, just be hella lazy and presume N=2**Nc,
|
||||
// connect extra nodes to ground (sorry)
|
||||
pint _N; // N rounded up to a power of 2
|
||||
_N = (1<<Nc);
|
||||
ortree<_N/2> ors_t[Nc];
|
||||
ortree<_N/2> ors_f[Nc];
|
||||
(i:Nc:ors_t[i].supply = supply; ors_t[i].out = out.d[i].t;)
|
||||
(i:Nc:ors_f[i].supply = supply; ors_f[i].out = out.d[i].f;)
|
||||
|
||||
pint num_connected_t; // Number of guys already connected to the current OR tree
|
||||
pint num_connected_f;
|
||||
|
||||
TIELO_X1 tielo(.vdd = supply.vdd, .vss = supply.vss); // I'm sorry
|
||||
pint bitval;
|
||||
(i:0..Nc-1: // For each output line
|
||||
num_connected_t = 0;
|
||||
num_connected_f = 0;
|
||||
(j:0.. _N-1:
|
||||
bitval = (j & ( 1 << i )) >> i; // Get binary digit of integer j, column i
|
||||
[bitval = 1 & j <= N-1->
|
||||
ors_t[i].in[num_connected_t] = in[j];
|
||||
num_connected_t = num_connected_t + 1;
|
||||
[] bitval = 0 & j <= N-1->
|
||||
ors_f[i].in[num_connected_f] = in[j];
|
||||
num_connected_f = num_connected_f + 1;
|
||||
[] bitval = 1 & j > N-1->
|
||||
ors_t[i].in[num_connected_t] = tielo.y;
|
||||
num_connected_t = num_connected_t + 1;
|
||||
[] bitval = 0 & j > N-1->
|
||||
ors_f[i].in[num_connected_f] = tielo.y;
|
||||
num_connected_f = num_connected_f + 1;
|
||||
]
|
||||
|
||||
)
|
||||
|
||||
|
||||
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// template<pint N, pint M, ACK_STRENGTH>
|
||||
// defproc encoder2D(a1of1 x[N]; a1of1 y[M] ;avMx1of2<X> addr; bool! out_a; power supply)
|
||||
// {
|
||||
// // Arbiters
|
||||
// a1of1 _out_arb_x,_out_arb_y;
|
||||
// a1of1 _x_temp[N];
|
||||
// (i:N:
|
||||
// _x_temp[i].r = x[i].r;
|
||||
// )
|
||||
// (i:M:
|
||||
// _y_temp[i].r = y[i].r;
|
||||
// )
|
||||
// arbtree<N> Xarb(.in = _x_temp,.out = _out_arb_X,.supply = supply);
|
||||
// arbtree<M> Yarb(.in = _y_temp,.out = _out_arb_Y,.supply = supply);
|
||||
|
||||
// sigbuf<ACK_STRENGTH> x_ack_arb[N];
|
||||
// sigbuf<ACK_STRENGTH> y_ack_arb[M];
|
||||
// (i:N:
|
||||
// x_ack_arb[i].in = _x_temp[i].a;
|
||||
// x_ack_arb[i].out[0] = x[i].a;
|
||||
// x_ack_arb[i].supply = supply;
|
||||
// )
|
||||
// (i:M:
|
||||
// y_ack_arb[i].in = _y_temp[i].a;
|
||||
// y_ack_arb[i].out[0] = y[i].a;
|
||||
// y_ack_arb[i].supply = supply;
|
||||
// )
|
||||
|
||||
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user