actlib_dataflow_neuro/dataflow_neuro/chips.act

131 lines
5.1 KiB
Plaintext
Raw Normal View History

2022-04-04 17:14:08 +02:00
/*************************************************************************
*
* This file is part of ACT dataflow neuro library
*
* Copyright (c) 2022 University of Groningen - Ole Richter
* Copyright (c) 2022 University of Groningen - Michele Mastella
* Copyright (c) 2022 University of Groningen - Hugh Greatorex
* Copyright (c) 2022 University of Groningen - Madison Cotteret
*
*
* This source describes Open Hardware and is licensed under the CERN-OHL-W v2 or later
*
* You may redistribute and modify this documentation and make products
* using it under the terms of the CERN-OHL-W v2 (https:/cern.ch/cern-ohl).
* This documentation is distributed WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTY, INCLUDING OF MERCHANTABILITY, SATISFACTORY QUALITY
* AND FITNESS FOR A PARTICULAR PURPOSE. Please see the CERN-OHL-W v2
* for applicable conditions.
*
* Source location: https://git.web.rug.nl/bics/actlib_dataflow_neuro
*
* As per CERN-OHL-W v2 section 4.1, should You produce hardware based on
* these sources, You must maintain the Source Location visible in its
* documentation.
*
**************************************************************************
*/
import "../../dataflow_neuro/cell_lib_async.act";
import "../../dataflow_neuro/cell_lib_std.act";
import "../../dataflow_neuro/treegates.act";
import "../../dataflow_neuro/primitives.act";
import "../../dataflow_neuro/registers.act";
import "../../dataflow_neuro/coders.act";
2022-04-04 19:32:30 +02:00
import "../../dataflow_neuro/interfaces.act";
2022-04-04 17:14:08 +02:00
// import tmpl::dataflow_neuro;
// import tmpl::dataflow_neuro;
import std::channel;
open std::channel;
namespace tmpl {
namespace dataflow_neuro {
2022-04-04 19:32:30 +02:00
export template<pint N_IN, // Size of input data from outside world
2022-04-04 17:14:08 +02:00
N_NRN_X, N_NRN_Y, N_SYN_X, N_SYN_Y, // Number of neurons / synapses
NC_NRN_X, NC_NRN_Y, NC_SYN_X, NC_SYN_Y,
N_SYN_DLY_CFG,
N_NRN_MON_X, N_NRN_MON_Y, N_SYN_MON_X, N_SYN_MON_Y,
N_BUFFERS,
2022-04-04 17:35:34 +02:00
N_LINE_PD_DLY, // Number of dummy delays to add line pull down
2022-04-05 19:17:54 +02:00
N_BD_DLY_CFG, N_BD_DLY_CFG2,
2022-04-04 17:14:08 +02:00
REG_NCA, REG_NCW, REG_M>
defproc chip_texel (bd<N_IN> in, out;
Mx1of2<REG_NCW> reg_data[REG_M];
a1of1 synapses[N_SYN_X * N_SYN_Y];
a1of1 neurons[N_NRN_X * N_NRN_Y];
2022-04-05 19:17:54 +02:00
bool? bd_dly_cfg[N_BD_DLY_CFG], bd_dly_cfg2[N_BD_DLY_CFG2];
2022-04-04 17:14:08 +02:00
bool? loopback_en;
power supply;
bool? reset_B){
2022-04-05 19:17:54 +02:00
bd2qdi<N_IN, N_BD_DLY_CFG, N_BD_DLY_CFG2> _bd2qdi(.in = in, .dly_cfg = bd_dly_cfg, .dly_cfg2 = bd_dly_cfg2,
2022-04-04 19:32:30 +02:00
.reset_B = reset_B, .supply = supply);
2022-04-04 17:14:08 +02:00
fifo<N_IN,N_BUFFERS> fifo_in2fork(.in = _bd2qdi.out, .reset_B = reset_B, .supply = supply);
fork<N_IN> _fork(.in = fifo_in2fork.out, .reset_B = reset_B, .supply = supply);
// Loopback
fifo<N_IN,N_BUFFERS> fifo_fork2drop(.in = _fork.out1, .reset_B = reset_B, .supply = supply);
dropper_static<N_IN, false> _loopback_dropper(.in = fifo_fork2drop.out, .cond = loopback_en,
.supply = supply);
// Onwards
fifo<N_IN,N_BUFFERS> fifo_fork2dmx(.in = _fork.out2, .reset_B = reset_B, .supply = supply);
2022-04-04 19:32:30 +02:00
demux_bit_msb<N_IN-1> _demux(.in = fifo_fork2dmx.out, .reset_B = reset_B, .supply = supply);
2022-04-04 17:14:08 +02:00
// Register
fifo<N_IN-1,N_BUFFERS> fifo_dmx2reg(.in = _demux.out2, .reset_B = reset_B, .supply = supply);
2022-04-08 12:13:43 +02:00
register_wr_array<REG_NCA, REG_NCW, REG_M> register(.in = fifo_dmx2reg.out, .data = reg_data,
2022-04-04 17:14:08 +02:00
.supply = supply, .reset_B = reset_B);
2022-04-04 17:48:20 +02:00
fifo<N_IN-2,N_BUFFERS> fifo_reg2mrg(.in = register.out, .reset_B = reset_B, .supply = supply);
2022-04-04 17:14:08 +02:00
// TO ADD: nrn/syn mon decoders
// Decoder
2022-04-04 19:32:30 +02:00
pint NC_SYN;
NC_SYN = NC_SYN_X + NC_SYN_Y;
slice_data<N_IN-1, 0, NC_SYN> slice_pre_dec(.in = _demux.out1, .supply = supply);
fifo<NC_SYN,N_BUFFERS> fifo_dmx2dec(.in = slice_pre_dec.out, .reset_B = reset_B, .supply = supply);
2022-04-04 20:23:56 +02:00
decoder_2d_hybrid<NC_SYN_X, NC_SYN_Y, N_SYN_X, N_SYN_Y, N_SYN_DLY_CFG> decoder(.in = fifo_dmx2dec.out,
2022-04-04 17:14:08 +02:00
.out = synapses,
.hs_en = register.data[0].d[0].f, // Defaults to handshake disable
2022-04-04 17:35:34 +02:00
.supply = supply, .reset_B = reset_B);
2022-04-04 19:32:30 +02:00
(i:N_SYN_DLY_CFG: decoder.dly_cfg[i] = register.data[0].d[1 + i].t;) // Defaults to max delay
2022-04-04 17:14:08 +02:00
2022-04-04 17:35:34 +02:00
// Neurons + encoder
2022-04-04 19:32:30 +02:00
pint NC_NRN;
2022-04-04 17:48:20 +02:00
NC_NRN = NC_NRN_X + NC_NRN_Y;
2022-04-08 12:13:43 +02:00
nrn_hs_2d_array<N_NRN_X,N_NRN_Y,N_LINE_PD_DLY> nrn_grid(.in = neurons,
2022-04-04 17:35:34 +02:00
.supply = supply, .reset_B = reset_B);
2022-04-08 12:13:43 +02:00
encoder2d<NC_NRN_X, NC_NRN_Y, N_NRN_X, N_NRN_Y, 16> encoder(
2022-04-04 17:35:34 +02:00
.inx = nrn_grid.outx,
.iny = nrn_grid.outy,
.reset_B = reset_B, .supply = supply
2022-04-04 19:32:30 +02:00
);
2022-04-04 17:48:20 +02:00
fifo<NC_NRN, N_BUFFERS> fifo_enc2mrg(.in = encoder.out,
2022-04-04 17:35:34 +02:00
.reset_B = reset_B, .supply = supply);
2022-04-04 17:14:08 +02:00
2022-04-04 17:48:20 +02:00
// Merge
2022-04-04 19:32:30 +02:00
append<NC_NRN, N_IN-NC_NRN, 0> append_enc(.in = fifo_enc2mrg.out, .supply = supply);
append<N_IN-2, 2, 0> append_reg(.in = fifo_reg2mrg.out, .supply = supply);
merge<N_IN> merge_enc8reg(.in1 = append_enc.out, .in2 = append_reg.out,
.supply = supply, .reset_B = reset_B);
merge<N_IN> merge_loop8mrg(.in1 = merge_enc8reg.out, .in2 = _loopback_dropper.out,
.reset_B = reset_B, .supply = supply);
// qdi2bd
fifo<N_IN, N_BUFFERS> fifo_mrg2bd(.in = merge_loop8mrg.out,
.reset_B = reset_B, .supply = supply);
2022-04-04 20:23:56 +02:00
qdi2bd<N_IN, N_BD_DLY_CFG> _qdi2bd(.in = fifo_mrg2bd.out, .out = out, .dly_cfg = bd_dly_cfg,
2022-04-04 19:32:30 +02:00
.reset_B = reset_B, .supply = supply);
2022-04-04 17:14:08 +02:00
}
}
}