refactored decoder into decoder dualrail
This commit is contained in:
		| @@ -48,6 +48,45 @@ open std::data; | |||||||
| namespace tmpl { | namespace tmpl { | ||||||
| 	namespace dataflow_neuro { | 	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<pint Nc, N> | ||||||
|  | 		defproc decoder_dualrail (Mx1of2<Nc> in; bool? out[N]; power supply) { | ||||||
|  | 			// signal buffers | ||||||
|  | 			sigbuf<N> in_tX[Nc]; | ||||||
|  | 			sigbuf<N> 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<Nc> 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. | 		 * 2D decoder which uses a configurable delay from the VCtrees to buffer ack. | ||||||
| 		 *	Nx is the x size of the decoder array | 		 *	Nx is the x size of the decoder array | ||||||
| @@ -63,9 +102,6 @@ namespace tmpl { | |||||||
|  |  | ||||||
| 			// Buffer to recieve concat(x,y) address packet | 			// Buffer to recieve concat(x,y) address packet | ||||||
| 			buffer<NxC+NyC> addr_buf(.in = in, .reset_B = reset_B, .supply = supply); | 			buffer<NxC+NyC> addr_buf(.in = in, .reset_B = reset_B, .supply = supply); | ||||||
| 			// NEED TO BUFFER OUTPUTS FROM BUFFER I RECKON |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
| 			// Validity trees | 			// Validity trees | ||||||
| 			vtree<NxC> vtree_x (.supply = supply); | 			vtree<NxC> vtree_x (.supply = supply); | ||||||
| @@ -91,36 +127,13 @@ namespace tmpl { | |||||||
| 			// FOR TESTING PURPOSES | 			// FOR TESTING PURPOSES | ||||||
| 			// !!!!!!!!!!!!!!!! | 			// !!!!!!!!!!!!!!!! | ||||||
|  |  | ||||||
| 			// AND trees |  | ||||||
| 			pint bitval; |  | ||||||
| 			andtree<NxC> 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<NyC> atree_y[Ny]; | 			// Decoder X/Y And trees | ||||||
| 			(k:0..Ny-1:atree_y[k].supply = supply;) | 			decoder_dualrail<NxC,Nx> d_dr_x(.out = outx, .supply = supply); | ||||||
| 			(i:0..Ny-1: | 			(i:0..NxC-1:d_dr_x.in.d[i] = addr_buf.out.d.d[i];) | ||||||
| 				(j:0..NyC-1: |  | ||||||
| 					bitval = (i & ( 1 << j )) >> j; // Get binary digit of integer i, column j | 			decoder_dualrail<NyC,Ny> d_dr_y(.out = outy, .supply = supply); | ||||||
| 					[bitval = 1 ->  | 			(i:0..NyC-1:d_dr_y.in.d[i] = addr_buf.out.d.d[i+NxC];) | ||||||
| 						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]; |  | ||||||
| 					) |  | ||||||
| 				) |  | ||||||
| 			 | 			 | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user