diff --git a/dataflow_neuro/coders.act b/dataflow_neuro/coders.act index 7ad3757..b4b2bfa 100644 --- a/dataflow_neuro/coders.act +++ b/dataflow_neuro/coders.act @@ -237,7 +237,7 @@ namespace tmpl { // Generates the OR-trees required to go from // N one-hot inputs to Nc dual rail binary encoding. export template - defproc encoder(bool? in[N]; Mx1of2 out; power supply) { + defproc dualrail_encoder(bool? in[N]; Mx1of2 out; power supply) { {N <= 1< - defproc encoder2D(a1of1 x[N]; a1of1 y[M] ;avMx1of2 addr; power supply; bool reset_B) { - // Reset buffers - 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,.vdd=supply.vdd,.vss=supply.vss); + // template + // defproc encoder2D(a1of1 x[N]; a1of1 y[M] ;avMx1of2 addr; power supply; bool reset_B) { + // // Reset buffers + // 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,.vdd=supply.vdd,.vss=supply.vss); - // 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 Xarb(.in = _x_temp,.out = _out_arb_X,.supply = supply); - arbtree Yarb(.in = _y_temp,.out = _out_arb_Y,.supply = 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 Xarb(.in = _x_temp,.out = _out_arb_X,.supply = supply); + // arbtree Yarb(.in = _y_temp,.out = _out_arb_Y,.supply = supply); - // Sigbufs for strong ackowledge signals - sigbuf_1output x_ack_arb[N]; - sigbuf_1output 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; - ) + // // Sigbufs for strong ackowledge signals + // sigbuf_1output x_ack_arb[N]; + // sigbuf_1output 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; + // ) - // This block checks that the input is valid and that the arbiter made a choice - // Then activates the ack of the arbiter - bool _x_v,_in_x_v; - 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.c2 = _x_a_B; - Y_ack_confirm.y = _out_arb_Y.a; - Y_ack_confirm.vdd = supply.vdd; - Y_ack_confirm.vss = supply.vss; - Y_ack_confirm.reset_B = _reset_BXX[0]; + // // This block checks that the input is valid and that the arbiter made a choice + // // Then activates the ack of the arbiter + // bool _x_v,_in_x_v; + // 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.c2 = _x_a_B; + // Y_ack_confirm.y = _out_arb_Y.a; + // Y_ack_confirm.vdd = supply.vdd; + // Y_ack_confirm.vss = supply.vss; + // Y_ack_confirm.reset_B = _reset_BXX[0]; - // 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 X_ack_confirm(); - X_ack_confirm.c1 = _out_arb_X.r; - X_ack_confirm.c2 = _x_a_B; - X_ack_confirm.vdd = supply.vdd; - X_ack_confirm.vss = supply.vss; - X_ack_confirm.reset_B = _reset_BXX[1]; + // // 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 X_ack_confirm(); + // X_ack_confirm.c1 = _out_arb_X.r; + // X_ack_confirm.c2 = _x_a_B; + // X_ack_confirm.vdd = supply.vdd; + // X_ack_confirm.vss = supply.vss; + // X_ack_confirm.reset_B = _reset_BXX[1]; - //X_REQ validation - bool _x_req_array[N],_x_v,_x_v_B; - (i:N:_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(.in = _x_v,.out = _x_v_B); + // //X_REQ validation + // bool _x_req_array[N],_x_v,_x_v_B; + // (i:N:_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(.in = _x_v,.out = _x_v_B); - // - A_2P3P1C2N_RB_X4 x_ack(); - //branch1 - x_ack.p1 = _in_x_v; - x_ack.p2 = _x_v_B; - //branch2 - x_ack.p3 = _in_x_v; - x_ack.p4 = _in_y_v; - x_ack.p5 = _x_v; - // - x_ack.c1 = _en - x_ack.n1 = addr.v - x_ack.n2 = _in_x_v; - // - x_ack.y = _x_a; - // - x_ack.vdd = supply.vdd; - x_ack.vss = supply.vss; - x_ack.reset_B = _reset_BXX[2]; + // // + // A_2P3P1C2N_RB_X4 x_ack(); + // //branch1 + // x_ack.p1 = _in_x_v; + // x_ack.p2 = _x_v_B; + // //branch2 + // x_ack.p3 = _in_x_v; + // x_ack.p4 = _in_y_v; + // x_ack.p5 = _x_v; + // // + // x_ack.c1 = _en + // x_ack.n1 = addr.v + // x_ack.n2 = _in_x_v; + // // + // x_ack.y = _x_a; + // // + // x_ack.vdd = supply.vdd; + // x_ack.vss = supply.vss; + // 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 _in_x; - dualrail _in; - _in_x.d = _in.d; - _in_x.v = _in_x_v; + // avMx1of2 _in_x; + // dualrail _in; + // _in_x.d = _in.d; + // _in_x.v = _in_x_v; - //buffer_func_s - A_2C2N_RB buffer_func_s_f[address_size]; - A_2C2N_RB buffer_func_s_t[address_size]; - sigbuf en_buf_t(.in=_en, .out=_en_X_t, .supply=supply); - sigbuf en_buf_f(.in=_en, .out=_en_X_f, .supply=supply); - INV_X1 out_a_inv(.a=addr.a,.y=_out_a_B); - sigbuf out_a_B_buf_f(.in=_out_a_B,.out=_out_a_BX_t, .supply=supply); - sigbuf out_a_B_buf_t(.in=_out_a_B,.out=_out_a_BX_f, .supply=supply); + // //buffer_func_s + // A_2C2N_RB buffer_func_s_f[address_size]; + // A_2C2N_RB buffer_func_s_t[address_size]; + // sigbuf en_buf_t(.in=_en, .out=_en_X_t, .supply=supply); + // sigbuf en_buf_f(.in=_en, .out=_en_X_f, .supply=supply); + // INV_X1 out_a_inv(.a=addr.a,.y=_out_a_B); + // sigbuf out_a_B_buf_f(.in=_out_a_B,.out=_out_a_BX_t, .supply=supply); + // sigbuf out_a_B_buf_t(.in=_out_a_B,.out=_out_a_BX_f, .supply=supply); - (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; + // (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; - 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].n1 = _in_x.d.d[i].r; - 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 - vtree addr_validity(.in = addr,.out = _addr_v); - sigbuf_1output<4> addr_validity_x(.in = _addr_v,.out = addr.v); - addr_validity.supply = supply; - addr_validity_x.supply = supply; - } + // 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].n1 = _in_x.d.d[i].r; + // 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 + // vtree addr_validity(.in = addr,.out = _addr_v); + // sigbuf_1output<4> addr_validity_x(.in = _addr_v,.out = addr.v); + // addr_validity.supply = supply; + // addr_validity_x.supply = supply; + // } diff --git a/test/unit_tests/encoder_7/test.act b/test/unit_tests/encoder_7/test.act index b4c3f9d..2aab2ac 100644 --- a/test/unit_tests/encoder_7/test.act +++ b/test/unit_tests/encoder_7/test.act @@ -35,7 +35,7 @@ open std::data; open tmpl::dataflow_neuro; 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.vdd = Vdd; diff --git a/test/unit_tests/encoder_7/test.prsim b/test/unit_tests/encoder_7/test.prsim index b66a30a..467b3bb 100644 --- a/test/unit_tests/encoder_7/test.prsim +++ b/test/unit_tests/encoder_7/test.prsim @@ -13,7 +13,7 @@ set e.in[6] 0 # set-bool-array "e.in" 7 0 cycle -# mode run +mode run # assert t.out 0