added data slice primitive
This commit is contained in:
parent
55ed8bb839
commit
560ae9c5f0
|
@ -33,6 +33,9 @@ import "../../dataflow_neuro/treegates.act";
|
|||
import std::channel;
|
||||
open std::channel;
|
||||
|
||||
// import std::func;
|
||||
|
||||
|
||||
namespace tmpl {
|
||||
namespace dataflow_neuro {
|
||||
|
||||
|
@ -829,7 +832,32 @@ namespace tmpl {
|
|||
)
|
||||
|
||||
}
|
||||
/**
|
||||
* Drops bits. Slices lines. Crop in. Enhance.
|
||||
* Useful if say, have an 8 bit packet coming in, but
|
||||
* receiver only needs 3 of them.
|
||||
* KEEPS all bits between the two bounds.
|
||||
* e.g. drop_lines(8, 0, 3) would keep lines [0,1,2]
|
||||
**/
|
||||
export template<pint N, N0, N1>
|
||||
defproc slice_data(avMx1of2<N> in; avMx1of2<std::min(N1,N)-std::max(N0,0)> out; power supply) {
|
||||
// {N0 >= 0 : "N0 can be minimum 0!"};
|
||||
// {N1 <= N : "N1 can be maximum N"};
|
||||
|
||||
pint _N1, _N0;
|
||||
|
||||
_N1 = std::min(N1,N);
|
||||
_N0 = std::max(N0,0);
|
||||
|
||||
BUF_X1 ack_buf(.a = out.a, .y = in.a, .vss = supply.vss, .vdd = supply.vdd);
|
||||
|
||||
vtree<N> in_vt(.in = in.d, .out = in.v, .supply = supply);
|
||||
(i:_N1-_N0:
|
||||
in.d.d[i + _N0] = out.d.d[i];
|
||||
)
|
||||
|
||||
in.a = out.a;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue