diff --git a/dataflow_neuro/coders.act b/dataflow_neuro/coders.act index 3b2f20e..94ab938 100644 --- a/dataflow_neuro/coders.act +++ b/dataflow_neuro/coders.act @@ -48,6 +48,45 @@ open std::data; namespace tmpl { namespace dataflow_neuro { + /** + * Dualrail decoder. + * Nc is the number of dualrail input channels. + * Then builds N output AND gates, connecting to the right input wires. + */ + export template + defproc decoder_dualrail (Mx1of2 in; bool? out[N]; power supply) { + // signal buffers + sigbuf in_tX[Nc]; + sigbuf in_fX[Nc]; + (i:Nc: + in_tX[i].supply = supply; + in_tX[i].in = in.d[i].t; + + in_fX[i].supply = supply; + in_fX[i].in = in.d[i].f; + ) + + // AND trees + pint bitval; + andtree atree[N]; + (k:0..N-1:atree[k].supply = supply;) + (i:0..N-1: + (j:0..Nc-1: + bitval = (i & ( 1 << j )) >> j; // Get binary digit of integer i, column j + [bitval = 1 -> + atree[i].in[j] = in_tX[j].out[i]; + // atree[i].in[j] = addr_buf.out.d.d[j].t; + []bitval = 0 -> + atree[i].in[j] = in_fX[j].out[i]; + // atree[i].in[j] = addr_buf.out.d.d[j].f; + []bitval >= 2 -> {false : "fuck"}; + ] + atree[i].out = out[i]; + ) + ) + } + + /** * 2D decoder which uses a configurable delay from the VCtrees to buffer ack. * Nx is the x size of the decoder array @@ -63,9 +102,6 @@ namespace tmpl { // Buffer to recieve concat(x,y) address packet buffer addr_buf(.in = in, .reset_B = reset_B, .supply = supply); - // NEED TO BUFFER OUTPUTS FROM BUFFER I RECKON - - // Validity trees vtree vtree_x (.supply = supply); @@ -91,37 +127,14 @@ namespace tmpl { // FOR TESTING PURPOSES // !!!!!!!!!!!!!!!! - // AND trees - pint bitval; - andtree atree_x[Nx]; - (k:0..Nx-1:atree_x[k].supply = supply;) - (i:0..Nx-1: - (j:0..NxC-1: - bitval = (i & ( 1 << j )) >> j; // Get binary digit of integer i, column j - [bitval = 1 -> - atree_x[i].in[j] = addr_buf.out.d.d[j].t; - []bitval = 0 -> - atree_x[i].in[j] = addr_buf.out.d.d[j].f; - []bitval >= 2 -> {false : "fuck"}; - ] - atree_x[i].out = outx[i]; - ) - ) - andtree atree_y[Ny]; - (k:0..Ny-1:atree_y[k].supply = supply;) - (i:0..Ny-1: - (j:0..NyC-1: - bitval = (i & ( 1 << j )) >> j; // Get binary digit of integer i, column j - [bitval = 1 -> - atree_y[i].in[j] = addr_buf.out.d.d[j+NxC].t; - []bitval = 0 -> - atree_y[i].in[j] = addr_buf.out.d.d[j+NxC].f; - ] - atree_y[i].out = outy[i]; - ) - ) + // Decoder X/Y And trees + decoder_dualrail d_dr_x(.out = outx, .supply = supply); + (i:0..NxC-1:d_dr_x.in.d[i] = addr_buf.out.d.d[i];) + decoder_dualrail d_dr_y(.out = outy, .supply = supply); + (i:0..NyC-1:d_dr_y.in.d[i] = addr_buf.out.d.d[i+NxC];) + }