def METHOD_NAME(f, modname, width, subs):
    print("module %s (A, B, C, X, Y, Z);" % modname, file=f)
    inbits = list()
    outbits = list()
    for p in "ABC":
        offset = np.random.randint(10) if enable_offset else 0
        if enable_upto and np.random.randint(2):
            print("  input [%d:%d] %s;" % (offset, offset+width-1, p), file=f)
        else:
            print("  input [%d:%d] %s;" % (offset+width-1, offset, p), file=f)
        for i in range(offset, offset+width):
            inbits.append("%s[%d]" % (p, i))
    for p in "XYZ":
        offset = np.random.randint(10) if enable_offset else 0
        if enable_upto and np.random.randint(2):
            print("  output [%d:%d] %s;" % (offset, offset+width-1, p), file=f)
        else:
            print("  output [%d:%d] %s;" % (offset+width-1, offset, p), file=f)
        for i in range(offset, offset+width):
            outbits.append("%s[%d]" % (p, i))
    instidx = 0
    subcandidates = list(subs.keys())
    while len(outbits) > 0:
        submod = None
        if len(subcandidates):
            submod = np.random.choice(subcandidates)
            subcandidates.remove(submod)
        if submod is None or 3*subs[submod] >= len(outbits):
            for bit in outbits:
                if enable_logic:
                    print("  assign %s = %s & ~%s;" % (bit,  np.random.choice(inbits), np.random.choice(inbits)), file=f)
                else:
                    print("  assign %s = %s;" % (bit,  np.random.choice(inbits)), file=f)
            break
        instidx += 1
        print("  %s inst%d (" % (submod, instidx), file=f)
        for p in "ABC":
            print("    .%s({%s})," % (p, ",".join(np.random.choice(inbits, subs[submod]))), file=f)
        for p in "XYZ":
            bits = list(np.random.choice(outbits, subs[submod], False))
            for bit in bits:
                outbits.remove(bit)
            print("    .%s({%s})%s" % (p, ",".join(bits), "," if p != "Z" else ""), file=f)
        print("  );", file=f);
    print("endmodule", file=f)