renamed encoder to dualrail_encoder

This commit is contained in:
alexmadison 2022-03-04 14:53:14 +01:00
parent 2882bc0f24
commit a53110dda4
3 changed files with 117 additions and 117 deletions

View File

@ -237,7 +237,7 @@ namespace tmpl {
// Generates the OR-trees required to go from // Generates the OR-trees required to go from
// N one-hot inputs to Nc dual rail binary encoding. // N one-hot inputs to Nc dual rail binary encoding.
export template<pint Nc, N> export template<pint Nc, N>
defproc encoder(bool? in[N]; Mx1of2<Nc> out; power supply) { defproc dualrail_encoder(bool? in[N]; Mx1of2<Nc> out; power supply) {
{N <= 1<<Nc : "Num inputs too wide for encoding channel!"}; {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 // For each output line, need to precalculate how big of an OR tree it needs
@ -284,133 +284,133 @@ namespace tmpl {
} }
template<pint N, pint M,pint address_size, pint ACK_STRENGTH> // template<pint N, pint M,pint address_size, pint ACK_STRENGTH>
defproc encoder2D(a1of1 x[N]; a1of1 y[M] ;avMx1of2<address_size> addr; power supply; bool reset_B) { // defproc encoder2D(a1of1 x[N]; a1of1 y[M] ;avMx1of2<address_size> addr; power supply; bool reset_B) {
// Reset buffers // // Reset buffers
bool _reset_BX,_reset_BXX[H]; // bool _reset_BX,_reset_BXX[H];
BUF_X1 reset_buf(.a=reset_B, .y=_reset_BX,.vdd=supply.vdd,.vss=supply.vss); // 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,.vdd=supply.vdd,.vss=supply.vss); // sigbuf<2*address_size+3> reset_bufarray(.in=_reset_BX, .out=_reset_BXX,.vdd=supply.vdd,.vss=supply.vss);
// Arbiters // // Arbiters
a1of1 _out_arb_x,_out_arb_y; // a1of1 _out_arb_x,_out_arb_y;
a1of1 _x_temp[N]; // a1of1 _x_temp[N];
(i:N: // (i:N:
_x_temp[i].r = x[i].r; // _x_temp[i].r = x[i].r;
) // )
(i:M: // (i:M:
_y_temp[i].r = y[i].r; // _y_temp[i].r = y[i].r;
) // )
arbtree<N> Xarb(.in = _x_temp,.out = _out_arb_X,.supply = supply); // 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<M> Yarb(.in = _y_temp,.out = _out_arb_Y,.supply = supply);
// Sigbufs for strong ackowledge signals // // Sigbufs for strong ackowledge signals
sigbuf_1output<ACK_STRENGTH> x_ack_arb[N]; // sigbuf_1output<ACK_STRENGTH> x_ack_arb[N];
sigbuf_1output<ACK_STRENGTH> y_ack_arb[M]; // sigbuf_1output<ACK_STRENGTH> y_ack_arb[M];
(i:N: // (i:N:
x_ack_arb[i].in = _x_temp[i].a; // x_ack_arb[i].in = _x_temp[i].a;
x_ack_arb[i].out[0] = x[i].a; // x_ack_arb[i].out[0] = x[i].a;
x_ack_arb[i].supply = supply; // x_ack_arb[i].supply = supply;
) // )
(i:M: // (i:M:
y_ack_arb[i].in = _y_temp[i].a; // y_ack_arb[i].in = _y_temp[i].a;
y_ack_arb[i].out[0] = y[i].a; // y_ack_arb[i].out[0] = y[i].a;
y_ack_arb[i].supply = supply; // y_ack_arb[i].supply = supply;
) // )
// This block checks that the input is valid and that the arbiter made a choice // // This block checks that the input is valid and that the arbiter made a choice
// Then activates the ack of the arbiter // // Then activates the ack of the arbiter
bool _x_v,_in_x_v; // bool _x_v,_in_x_v;
A_2C2P_RB_X1 Y_ack_confirm(); // A_2C2P_RB_X1 Y_ack_confirm();
Y_ack_confirm.p1 = _x_v; // Y_ack_confirm.p1 = _x_v;
Y_ack_confirm.p2 =_in_x_v; // Y_ack_confirm.p2 =_in_x_v;
Y_ack_confirm.c1 = _out_arb_Y.r; // Y_ack_confirm.c1 = _out_arb_Y.r;
Y_ack_confirm.c2 = _x_a_B; // Y_ack_confirm.c2 = _x_a_B;
Y_ack_confirm.y = _out_arb_Y.a; // Y_ack_confirm.y = _out_arb_Y.a;
Y_ack_confirm.vdd = supply.vdd; // Y_ack_confirm.vdd = supply.vdd;
Y_ack_confirm.vss = supply.vss; // Y_ack_confirm.vss = supply.vss;
Y_ack_confirm.reset_B = _reset_BXX[0]; // Y_ack_confirm.reset_B = _reset_BXX[0];
// This block checks that the input is valid and that the arbiter made a choice // // This block checks that the input is valid and that the arbiter made a choice
// Then activates the ack of the arbiter // // Then activates the ack of the arbiter
A_2C_RB X_ack_confirm(); // A_2C_RB X_ack_confirm();
X_ack_confirm.c1 = _out_arb_X.r; // X_ack_confirm.c1 = _out_arb_X.r;
X_ack_confirm.c2 = _x_a_B; // X_ack_confirm.c2 = _x_a_B;
X_ack_confirm.vdd = supply.vdd; // X_ack_confirm.vdd = supply.vdd;
X_ack_confirm.vss = supply.vss; // X_ack_confirm.vss = supply.vss;
X_ack_confirm.reset_B = _reset_BXX[1]; // X_ack_confirm.reset_B = _reset_BXX[1];
//X_REQ validation // //X_REQ validation
bool _x_req_array[N],_x_v,_x_v_B; // bool _x_req_array[N],_x_v,_x_v_B;
(i:N:_x_req_array[i] = x[i].r;) // (i:N:_x_req_array[i] = x[i].r;)
ortree x_req_ortree(.in = _x_req_array,.out = _x_v,.supply = supply); // ortree x_req_ortree(.in = _x_req_array,.out = _x_v,.supply = supply);
INV_X1 not_x_req_ortree(.in = _x_v,.out = _x_v_B); // INV_X1 not_x_req_ortree(.in = _x_v,.out = _x_v_B);
// // //
A_2P3P1C2N_RB_X4 x_ack(); // A_2P3P1C2N_RB_X4 x_ack();
//branch1 // //branch1
x_ack.p1 = _in_x_v; // x_ack.p1 = _in_x_v;
x_ack.p2 = _x_v_B; // x_ack.p2 = _x_v_B;
//branch2 // //branch2
x_ack.p3 = _in_x_v; // x_ack.p3 = _in_x_v;
x_ack.p4 = _in_y_v; // x_ack.p4 = _in_y_v;
x_ack.p5 = _x_v; // x_ack.p5 = _x_v;
// // //
x_ack.c1 = _en // x_ack.c1 = _en
x_ack.n1 = addr.v // x_ack.n1 = addr.v
x_ack.n2 = _in_x_v; // x_ack.n2 = _in_x_v;
// // //
x_ack.y = _x_a; // x_ack.y = _x_a;
// // //
x_ack.vdd = supply.vdd; // x_ack.vdd = supply.vdd;
x_ack.vss = supply.vss; // x_ack.vss = supply.vss;
x_ack.reset_B = _reset_BXX[2]; // x_ack.reset_B = _reset_BXX[2];
INV_X1 not_x_ack(.in = _x_a,.out = _x_a_B); // INV_X1 not_x_ack(.in = _x_a,.out = _x_a_B);
A_1C2P enabling(.p1 = addr.a, .p2 = addr.v, .c1 = _x_a, .y = _en, .vdd = supply.vdd, .vss = supply.vss) // A_1C2P enabling(.p1 = addr.a, .p2 = addr.v, .c1 = _x_a, .y = _en, .vdd = supply.vdd, .vss = supply.vss)
avMx1of2<N> _in_x; // avMx1of2<N> _in_x;
dualrail<N> _in; // dualrail<N> _in;
_in_x.d = _in.d; // _in_x.d = _in.d;
_in_x.v = _in_x_v; // _in_x.v = _in_x_v;
//buffer_func_s // //buffer_func_s
A_2C2N_RB buffer_func_s_f[address_size]; // A_2C2N_RB buffer_func_s_f[address_size];
A_2C2N_RB buffer_func_s_t[address_size]; // A_2C2N_RB 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_t(.in=_en, .out=_en_X_t, .supply=supply);
sigbuf<address_size> en_buf_f(.in=_en, .out=_en_X_f, .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); // 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_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); // sigbuf<address_size> out_a_B_buf_t(.in=_out_a_B,.out=_out_a_BX_f, .supply=supply);
(i:address_size: // (i:address_size:
buffer_func_s_f[i].c1 = _en_X_f[i]; // 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].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.d.d[i].f;
buffer_func_s_f[i].n1 = _in_x.v; // buffer_func_s_f[i].n1 = _in_x.v;
buffer_func_s_f[i].vdd=supply.vdd; // buffer_func_s_f[i].vdd=supply.vdd;
buffer_func_s_f[i].vss=supply.vss; // buffer_func_s_f[i].vss=supply.vss;
buffer_func_s_f[i].pr_B = _reset_BXX[i+3]; // 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].sr_B = _reset_BXX[i+3];
buffer_func_s_f[i].y = addr.d.d[i].f; // buffer_func_s_f[i].y = addr.d.d[i].f;
buffer_func_s_t[i].c1 = _en_X_r[i]; // buffer_func_s_t[i].c1 = _en_X_r[i];
buffer_func_s_t[i].c2 = _out_a_BX_t[i]; // buffer_func_s_t[i].c2 = _out_a_BX_t[i];
buffer_func_s_t[i].n1 = _in_x.d.d[i].r; // buffer_func_s_t[i].n1 = _in_x.d.d[i].r;
buffer_func_s_t[i].n1 = _in_x.v; // buffer_func_s_t[i].n1 = _in_x.v;
buffer_func_s_t[i].vdd=supply.vdd; // buffer_func_s_t[i].vdd=supply.vdd;
buffer_func_s_t[i].vss=supply.vss; // 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].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].sr_B = _reset_BXX[i+3+address_size];
buffer_func_s_t[i].y = addr.d.d[i].t; // buffer_func_s_t[i].y = addr.d.d[i].t;
) // )
bool _addr_v // bool _addr_v
vtree addr_validity(.in = addr,.out = _addr_v); // vtree addr_validity(.in = addr,.out = _addr_v);
sigbuf_1output<4> addr_validity_x(.in = _addr_v,.out = addr.v); // sigbuf_1output<4> addr_validity_x(.in = _addr_v,.out = addr.v);
addr_validity.supply = supply; // addr_validity.supply = supply;
addr_validity_x.supply = supply; // addr_validity_x.supply = supply;
} // }

View File

@ -35,7 +35,7 @@ open std::data;
open tmpl::dataflow_neuro; open tmpl::dataflow_neuro;
defproc encoder_7 (bool? in[7]; Mx1of2<3> out){ defproc encoder_7 (bool? in[7]; Mx1of2<3> out){
encoder<3,7> e(.in=in, .out=out); dualrail_encoder<3,7> e(.in=in, .out=out);
e.supply.vss = GND; e.supply.vss = GND;
e.supply.vdd = Vdd; e.supply.vdd = Vdd;

View File

@ -13,7 +13,7 @@ set e.in[6] 0
# set-bool-array "e.in" 7 0 # set-bool-array "e.in" 7 0
cycle cycle
# mode run mode run
# assert t.out 0 # assert t.out 0