def build(ports): m = NDArray((10), dtype=types.i32, name='m1') for i in range(9): m[i] = ports.in1 # CHECK: ValueError: Unassigned sub-matrices: # CHECK: {{[[]}}{{[[]}}9{{[]]}}{{[]]}} m.to_circt()
def build(ports): # a 32xi32 ndarray. m = NDArray((32, ), dtype=types.i32, name='m2') for i in range(16): m[i] = ports.in1 m[16:32] = ports.in0 m = m.reshape((4, 8)) ports.c = m.to_circt()
def build(ports): # a 32x32xi1 ndarray. # A dtype of i32 is fairly expensive wrt. the size of the output IR, but # but allows for assigning indiviudal bits. m = NDArray((32, 32), dtype=types.i1, name='m1') # Assign individual bits to the first 32 bits. for i in range(32): m[0, i] = hw.ConstantOp(types.i1, 1) # Fill the next 15 values with an i32. The ndarray knows how to convert # from i32 to <32xi1> to comply with the ndarray dtype. for i in range(1, 16): m[i] = ports.in1 # Fill the upportmost 16 rows with the input array of in0 : 16xi32 m[16:32] = ports.in0 # We don't provide a method of reshaping the ndarray wrt. its dtype. # that is: 32x32xi1 => 32xi32 # This has massive overhead in the generated IR, and can be easily # achieved by a bitcast. ports.c = hw.BitcastOp(M5.t_c, m.to_circt())
def build(ports): m = NDArray((32, 32), dtype=types.i1, name='m1') # CHECK: ValueError: Width mismatch between provided BitVectorValue (i31) and target shape ([32]i1). m[0] = ports.in1
def build(ports): # CHECK: ValueError: Must specify either shape and dtype, or initialize from a value, but not both. NDArray((10, 32), from_value=ports.in1, dtype=types.i1, name='m1')
def build(ports): m = NDArray((3, 3), dtype=types.i32) for i in range(3): for j in range(3): m[i][j] = types.i32(i * 3 + j) ports.out = m.to_circt()
def build(ports): # Explicit ndarray. m = NDArray(from_value=ports.in1, name='m1') # Here we could do a sequence of transformations on 'm'... # Finally, concatenate [in2, m, in3] ports.out = ports.in2.concatenate((m, ports.in3))
def build(ports): m = NDArray(from_value=ports.in1, name='m1') ports.out = m.to_circt(create_wire=False)
def build(ports): m = NDArray(from_value=ports.in1, name='m1') ports.out = m.to_circt()