Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
M. Mastella 2022-03-07 16:36:05 +01:00
commit 0d3502bf00
2 changed files with 123 additions and 70 deletions

View File

@ -34,6 +34,9 @@ import "../../dataflow_neuro/primitives.act";
import std::channel;
open std::channel;
// import std::func;
open std;
import std::data;
open std::data;
@ -62,6 +65,8 @@ namespace tmpl {
buffer<NxC+NyC> addr_buf(.in = in, .reset_B = reset_B, .supply = supply);
// NEED TO BUFFER OUTPUTS FROM BUFFER I RECKON
// Validity trees
vtree<NxC> vtree_x (.supply = supply);
vtree<NyC> vtree_y (.supply = supply);
@ -284,36 +289,93 @@ namespace tmpl {
}
export template<pint N, M, address_size, ACK_STRENGTH>
defproc encoder2D(a1of1 x[N]; a1of1 y[M] ;avMx1of2<address_size> addr; power supply; bool reset_B) {
/**
* Buffer function code.
* Is the function block ripped from the buffer_s.
* Used in the encoder2d.
*/
export template<pint N>
defproc buffer_s_func (Mx1of2<N> in; avMx1of2<N> out; bool? in_v, en, reset_B; power supply) {
//function
bool _out_a_BX_t[N],_out_a_BX_f[N],_out_a_B,_en_X_t[N],_en_X_f[N], _in_vX, _in_vXX_t[N],_in_vXX_f[N];
A_2C2N_RB_X4 f_buf_func[N];
A_2C2N_RB_X4 t_buf_func[N];
// reset buffers
bool _reset_BX,_reset_BXX[N];
BUF_X1 reset_buf(.a=reset_B, .y=_reset_BX,.vdd=supply.vdd,.vss=supply.vss);
sigbuf<N> reset_bufarray(.in=_reset_BX, .out=_reset_BXX, .supply=supply);
// Enable signal buffers
sigbuf<N> en_buf_t(.in=en, .out=_en_X_t, .supply=supply);
sigbuf<N> en_buf_f(.in=en, .out=_en_X_f, .supply=supply);
// out ack signal buffers
INV_X1 out_a_inv(.a=out.a,.y=_out_a_B, .vss = supply.vss, .vdd = supply.vdd);
sigbuf<N> out_a_B_buf_f(.in=_out_a_B,.out=_out_a_BX_t, .supply=supply);
sigbuf<N> out_a_B_buf_t(.in=_out_a_B,.out=_out_a_BX_f, .supply=supply);
// in val signal buffers
BUF_X4 in_v_prebuf(.a = in_v, .y = _in_vX, .vss = supply.vss, .vdd = supply.vdd);
sigbuf<N> in_v_buf_t(.in=_in_vX, .out=_in_vXX_t, .supply=supply);
sigbuf<N> in_v_buf_f(.in=_in_vX, .out=_in_vXX_f, .supply=supply);
(i:N:
f_buf_func[i].y=out.d.d[i].f;
t_buf_func[i].y=out.d.d[i].t;
f_buf_func[i].c1=_en_X_f[i];
t_buf_func[i].c1=_en_X_t[i];
f_buf_func[i].c2=_out_a_BX_f[i];
t_buf_func[i].c2=_out_a_BX_t[i];
f_buf_func[i].n1=in.d[i].f;
t_buf_func[i].n1=in.d[i].t;
f_buf_func[i].n2=_in_vXX_f[i];
t_buf_func[i].n2=_in_vXX_t[i];
f_buf_func[i].vdd=supply.vdd;
t_buf_func[i].vdd=supply.vdd;
f_buf_func[i].vss=supply.vss;
t_buf_func[i].vss=supply.vss;
t_buf_func[i].pr_B = _reset_BXX[i];
t_buf_func[i].sr_B = _reset_BXX[i];
f_buf_func[i].pr_B = _reset_BXX[i];
f_buf_func[i].sr_B = _reset_BXX[i];
)
}
export template<pint NxC, NyC, Nx, Ny, ACK_STRENGTH>
defproc encoder2D(a1of1 x[Nx]; a1of1 y[Ny]; avMx1of2<(NxC + NyC)> out; power supply; bool reset_B) {
// Reset buffers
pint H = 10; //Reset strength? to be investigated
bool _reset_BX,_reset_BXX[H];
BUF_X1 reset_buf(.a=reset_B, .y=_reset_BX,.vdd=supply.vdd,.vss=supply.vss);
sigbuf<2*address_size+3> reset_bufarray(.in=_reset_BX, .out=_reset_BXX,.supply=supply);
BUF_X1 reset_buf(.a=reset_B, .y=_reset_BX,.vdd=supply.vdd,.vss=supply.vss);
sigbuf<2*(NxC + NyC)+3> reset_bufarray(.in=_reset_BX, .out=_reset_BXX,.supply=supply);
// Arbiters
a1of1 _out_arb_x,_out_arb_y;
a1of1 _x_temp[N],_y_temp[M];
(i:N:
a1of1 _arb_out_x, _arb_out_y;
a1of1 _x_temp[Nx],_y_temp[Ny]; // For wiring the reqs to the arbtrees
(i:Nx:
_x_temp[i].r = x[i].r;
)
(i:M:
(i:Ny:
_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);
arbtree<Nx> Xarb(.in = _x_temp,.out = _arb_out_x,.supply = supply);
arbtree<Ny> Yarb(.in = _y_temp,.out = _arb_out_y,.supply = supply);
// Sigbufs for strong ackowledge signals
sigbuf_1output<ACK_STRENGTH> x_ack_arb[N];
sigbuf_1output<ACK_STRENGTH> y_ack_arb[M];
(i:N:
// Sigbufs for strong ackowledge signals from arb_in's
sigbuf_1output<ACK_STRENGTH> x_ack_arb[Nx];
sigbuf_1output<ACK_STRENGTH> y_ack_arb[Ny];
(i:Nx:
x_ack_arb[i].in = _x_temp[i].a;
x_ack_arb[i].out = x[i].a;
x_ack_arb[i].supply = supply;
)
(i:M:
(i:Ny:
y_ack_arb[i].in = _y_temp[i].a;
y_ack_arb[i].out = y[i].a;
y_ack_arb[i].supply = supply;
@ -325,9 +387,9 @@ namespace tmpl {
A_2C2P_RB_X1 Y_ack_confirm();
Y_ack_confirm.p1 = _x_v;
Y_ack_confirm.p2 =_in_x_v;
Y_ack_confirm.c1 = _out_arb_y.r;
Y_ack_confirm.c1 = _arb_out_y.r;
Y_ack_confirm.c2 = _x_a_B;
Y_ack_confirm.y = _out_arb_y.a;
Y_ack_confirm.y = _arb_out_y.a;
Y_ack_confirm.vdd = supply.vdd;
Y_ack_confirm.vss = supply.vss;
Y_ack_confirm.reset_B = _reset_BX;
@ -335,20 +397,29 @@ namespace tmpl {
// This block checks that the input is valid and that the arbiter made a choice
// Then activates the ack of the arbiter
A_2C_RB_X1 X_ack_confirm();
X_ack_confirm.c1 = _out_arb_x.r;
X_ack_confirm.c1 = _arb_out_x.r;
X_ack_confirm.c2 = _x_a_B;
X_ack_confirm.vdd = supply.vdd;
X_ack_confirm.vss = supply.vss;
X_ack_confirm.pr_B = _reset_BX;
X_ack_confirm.sr_B = _reset_BX;
X_ack_confirm.y = _arb_out_x.a;
//X_REQ validation
bool _x_req_array[N],_x_v_B, _en;
(i:N:_x_req_array[i] = x[i].r;)
ortree x_req_ortree(.in = _x_req_array,.out = _x_v,.supply = supply);
// X_req ORtree
bool _x_req_array[Nx], _x_v_B;
(i:Nx:_x_req_array[i] = x[i].r;)
ortree<Nx> x_req_ortree(.in = _x_req_array,.out = _x_v,.supply = supply); //todo BUFF
INV_X1 not_x_req_ortree(.a = _x_v,.y = _x_v_B);
//
//X_REQ validation
// bool _x_req_array[Nx],_x_v_B, _en;
// (i:Nx:_x_req_array[i] = x[i].r;)
// ortree x_req_ortree(.in = _x_req_array,.out = _x_v,.supply = supply);
// INV_X1 not_x_req_ortree(.a = _x_v,.y = _x_v_B);
bool _en;
A_1C3P2P2N_R_X1 x_ack(); // NEEDS BUFFERING TO X4
//branch1
x_ack.p1 = _in_x_v;
@ -359,7 +430,7 @@ namespace tmpl {
x_ack.p5 = _x_v;
//
x_ack.c1 = _en;
x_ack.n1 = addr.v;
x_ack.n1 = out.v;
x_ack.n2 = _in_x_v;
//
x_ack.y = _x_a_B;
@ -369,54 +440,36 @@ namespace tmpl {
x_ack.pr_B = _reset_BX;
x_ack.sr_B = _reset_BX;
INV_X1 not_x_ack(.y = _x_a,.a = _x_a_B,.vdd = supply.vdd, .vss = supply.vss);
INV_X1 not_x_ack(.a = _x_a_B, .y = _x_a, .vdd = supply.vdd, .vss = supply.vss);
A_1C2P_X1 enabling(.p1 = addr.a, .p2 = addr.v, .c1 = _x_a, .y = _en, .vdd = supply.vdd, .vss = supply.vss);
avMx1of2<address_size> _in_x;
dualrail _in[N];
(i:N:_in_x.d.d[i] = _in[i];)
_in_x.v = _in_x_v;
A_1C2P_X1 enabling(.p1 = out.a, .p2 = out.v, .c1 = _x_a, .y = _en, .vdd = supply.vdd, .vss = supply.vss);
//buffer_func_s
bool _en_X_t[address_size],_en_X_f[address_size],_out_a_BX_f[address_size],_out_a_BX_t[address_size];
bool _out_a_B;
A_2C2N_RB_X1 buffer_func_s_f[address_size];
A_2C2N_RB_X1 buffer_func_s_t[address_size];
sigbuf<address_size> en_buf_t(.in=_en, .out=_en_X_t, .supply=supply);
sigbuf<address_size> en_buf_f(.in=_en, .out=_en_X_f, .supply=supply);
INV_X1 out_a_inv(.a=addr.a,.y=_out_a_B);
sigbuf<address_size> out_a_B_buf_f(.in=_out_a_B,.out=_out_a_BX_t, .supply=supply);
sigbuf<address_size> out_a_B_buf_t(.in=_out_a_B,.out=_out_a_BX_f, .supply=supply);
avMx1of2<(NxC + NyC)> _in_x;
(i:address_size:
buffer_func_s_f[i].c1 = _en_X_f[i];
buffer_func_s_f[i].c2 = _out_a_BX_f[i];
buffer_func_s_f[i].n1 = _in_x.d.d[i].f;
buffer_func_s_f[i].n1 = _in_x.v;
buffer_func_s_f[i].vdd=supply.vdd;
buffer_func_s_f[i].vss=supply.vss;
buffer_func_s_f[i].pr_B = _reset_BXX[i+3];
buffer_func_s_f[i].sr_B = _reset_BXX[i+3];
buffer_func_s_f[i].y = addr.d.d[i].f;
// Encoders
bool x_acks[Nx];
Mx1of2<NxC> x_enc_out;
(i:Nx:x_acks[i] = x[i].a;)
dualrail_encoder<NxC, Nx> x_encoder(.in = x_acks, .out = x_enc_out, .supply = supply);
bool y_acks[Nx];
Mx1of2<NyC> y_enc_out;
(i:Ny:y_acks[i] = y[i].a;)
dualrail_encoder<NyC, Ny> y_encoder(.in = y_acks, .out = y_enc_out, .supply = supply);
// Valid trees
vtree<NxC> vtree_x(.in = x_enc_out, .out = _in_x_v, .supply = supply);
vtree<NxC> vtree_y(.in = y_enc_out, .out = _in_y_v, .supply = supply);
// Buffer func thing
Mx1of2<NxC + NyC> into_buffer;
(i:0..NxC-1:into_buffer.d[i] = x_enc_out.d[i];)
(i:0..NyC-1:into_buffer.d[i+NxC] = y_enc_out.d[i];)
AND2_X1 _in_xy_v(.a = _in_x_v, .b = _in_y_v, .vss = supply.vss, .vdd = supply.vdd);
buffer_s_func<NxC + NyC> buf_s_func(.in = into_buffer, .out = out,
.en = _en, .in_v = _in_xy_v.y, .supply = supply, .reset_B = reset_B);
buffer_func_s_t[i].c1 = _en_X_t[i];
buffer_func_s_t[i].c2 = _out_a_BX_t[i];
buffer_func_s_t[i].n1 = _in_x.d.d[i].t;
buffer_func_s_t[i].n1 = _in_x.v;
buffer_func_s_t[i].vdd=supply.vdd;
buffer_func_s_t[i].vss=supply.vss;
buffer_func_s_t[i].pr_B = _reset_BXX[i+3+address_size];
buffer_func_s_t[i].sr_B = _reset_BXX[i+3+address_size];
buffer_func_s_t[i].y = addr.d.d[i].t;
)
bool _addr_v;
Mx1of2<address_size> addr_temp;
(i:address_size:addr_temp.d[i] = addr.d.d[i];)
vtree<address_size> addr_validity(.in = addr_temp,.out = _addr_v);
sigbuf_1output<4> addr_validity_x(.in = _addr_v,.out = addr.v);
addr_validity.supply = supply;
addr_validity_x.supply = supply;
}

View File

@ -127,7 +127,7 @@ namespace tmpl {
A_2C1N_RB_X4 t_buf_func[N];
sigbuf<N> en_buf_t(.in=_en, .out=_en_X_t, .supply=supply);
sigbuf<N> en_buf_f(.in=_en, .out=_en_X_f, .supply=supply);
INV_X1 out_a_inv(.a=out.a,.y=_out_a_B);
INV_X1 out_a_inv(.a=out.a,.y=_out_a_B, .vss = supply.vss, .vdd = supply.vdd);
sigbuf<N> out_a_B_buf_f(.in=_out_a_B,.out=_out_a_BX_t);
sigbuf<N> out_a_B_buf_t(.in=_out_a_B,.out=_out_a_BX_f);
// check if you can also do single var to array connect a=b[N]
@ -204,7 +204,7 @@ namespace tmpl {
A_2C2N_RB_X4 t_buf_func[N];
sigbuf<N> en_buf_t(.in=_en, .out=_en_X_t, .supply=supply);
sigbuf<N> en_buf_f(.in=_en, .out=_en_X_f, .supply=supply);
INV_X1 out_a_inv(.a=out.a,.y=_out_a_B);
INV_X1 out_a_inv(.a=out.a,.y=_out_a_B, .vss = supply.vss, .vdd = supply.vdd);
sigbuf<N> out_a_B_buf_f(.in=_out_a_B,.out=_out_a_BX_t, .supply=supply);
sigbuf<N> out_a_B_buf_t(.in=_out_a_B,.out=_out_a_BX_f, .supply=supply);
// check if you can also do single var to array connect a=b[N]