def mkMultiplier(index, lwidth=32, rwidth=32, lsigned=True, rsigned=True, depth=6):
    if lwidth < 0: raise ValueError("data width must be greater than 0.")
    if rwidth < 0: raise ValueError("data width must be greater than 0.")
    if depth < 2: raise ValueError("depth must be greater than 2.")
    
    retwidth = lwidth + rwidth
    
    mult = mkMultiplierCore(index, lwidth, rwidth, lsigned, rsigned, depth)
    
    m = module.Module('multiplier_%d' % index)
    
    clk = m.Input('CLK')
    rst = m.Input('RST')
    
    update = m.Input('update')
    enable = m.Input('enable')
    valid = m.Output('valid')
    
    a = m.Input('a', lwidth)
    b = m.Input('b', rwidth)
    c = m.Output('c', retwidth)

    valid_reg = [ m.Reg('valid_reg%d' % i) for i in range(depth) ]

    m.Assign( valid(valid_reg[depth-1]) )

    m.Always(vtypes.Posedge(clk))(
        vtypes.If(rst)(
            [ valid_reg[i](0) for i in range(depth) ]
        ).Else(
            vtypes.If(update)(
                valid_reg[0](enable),
                [ valid_reg[i](valid_reg[i-1]) for i in range(1, depth) ]
            )
        ))
    
    ports = [ ('CLK', clk), ('update', update), ('a', a), ('b', b), ('c', c) ]
    m.Instance(mult, 'mult', ports=ports)
    
    return m

# global multiplier count
dataset/ETHPy150Open PyHDI/veriloggen/veriloggen/dataflow/mul.py/mkMultiplier/original