# Utility for the Single AXI4 memory mapped (MM) user interface of the The Xilinx DMA/Bridge Subsystem for PCI Express (pg195)
# Author: Ton Damen, tond@nikhef.nl
# Date: 3/9/2020
#
importos
importsys
importargparse
parser=argparse.ArgumentParser(description='Spec7 tool to access the memory mapped area',epilog='A number with prefix "0x" is interpreted as hex value')
parser.add_argument('--device','-d',default='/dev/xdma0_user',help='device path name, default is /dev/xdma0_user')
parser.add_argument('--address','-a',default='0',help='address to access (0x prefix for hex)')
parser.add_argument('--is-pipe','-p',dest='is_pipe',action="store_true",help='register is a pipe')
parser.add_argument('--count','-n',dest='count',help='number of reads/writes')
action_args=parser.add_mutually_exclusive_group()
action_args.add_argument('--write','-w',metavar='value',nargs='+',help='write value(s) to address (0x prefix for hex)')
action_args.add_argument('--write-from-file','-f',dest='write_file',help='write file to memory from address');
action_args.add_argument('--copy-to-file',dest='read_file',help='copy memory to file from address')