def word_csr_r(opcode, syntax, xregs, fregs, imms, symbols):
    csr = random.choice(csr_names)
    if ('pmpaddr' in csr):
        tpe = MEM_R
        insts = ['la xreg1, symbol', 'srai xreg1, xreg1, 1', syntax.format(csr)]
        symbols.append('symbol')
    else:
        tpe = CSR
        insts = ['xor xreg1, xreg1, xreg1']
        for i in range(random.randint(0, 3)):
            set_bits = random.choice([1, 3])
            offset = random.randint(0, 31)
            insts = (insts + ['addi xreg{}, zero, {}'.format((i + 2), set_bits), 'slli xreg{}, xreg{}, {}'.format((i + 2), (i + 2), offset), 'add xreg1, xreg1, xreg{}'.format((i + 2))])
            xregs.append('xreg{}'.format((i + 2)))
        insts.append(syntax.format(csr))
    return (tpe, insts)
def word_csr_r(opcode, syntax, xregs, fregs, imms, symbols):
    csr = random.choice(csr_names)
    if ('pmpaddr' in csr):
        tpe = MEM_R
        insts = ['la xreg1, symbol', 'srai xreg1, xreg1, 1', syntax.format(csr)]
        symbols.append('symbol')
    else:
        tpe = CSR
        insts = ['xor xreg1, xreg1, xreg1']
        for i in range(random.randint(0, 3)):
            set_bits = random.choice([1, 3])
            offset = random.randint(0, 31)
            insts = (insts + ['addi xreg{}, zero, {}'.format((i + 2), set_bits), 'slli xreg{}, xreg{}, {}'.format((i + 2), (i + 2), offset), 'add xreg1, xreg1, xreg{}'.format((i + 2))])
            xregs.append('xreg{}'.format((i + 2)))
        insts.append(syntax.format(csr))
    return (tpe, insts)