x393_mcntrl.py 4.87 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
from __future__ import division
from __future__ import print_function

'''
# Copyright (C) 2015, Elphel.inc.
# Class to set memory controller channels  
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http:#www.gnu.org/licenses/>.

@author:     Andrey Filippov
@copyright:  2015 Elphel, Inc.
@license:    GPLv3.0+
@contact:    andrey@elphel.coml
@deffield    updated: Updated
'''
__author__ = "Andrey Filippov"
__copyright__ = "Copyright 2015, Elphel, Inc."
__license__ = "GPL"
__version__ = "3.0+"
__maintainer__ = "Andrey Filippov"
__email__ = "andrey@elphel.com"
__status__ = "Development"
#import sys
#import pickle
#from x393_mem                import X393Mem
#import x393_axi_control_status

#import x393_utils

#import time
import vrlg

43 44
def func_encode_mode_scan_tiled   (skip_too_late = False,
                                   disable_need = False,
45 46 47 48 49 50 51 52
                                   repetitive=    True,
                                   single =       False,
                                   reset_frame =  False,
                                   byte32 =       True,
                                   keep_open =    False,
                                   extra_pages =  0,
                                   write_mem =    False,
                                   enable =       True,
53
                                   chn_reset =    False,
54 55
                                   copy_frame =   False,
                                   abort_late =   False):
56 57
    """
    Combines arguments to create a 12-bit encoded data for scanline mode memory R/W
58
    @param skip_too_late - Skip over missed blocks to preserve frame structure (increment pointers),
59 60 61 62 63 64 65 66 67 68
    @param disable_need - disable 'need' generation, only 'want' (compressor channels),
    @param repetitive   - run repetitive frames (add this to older 'master' tests)
    @param single       - run single frame
    @param reset_frame  - reset frame number
    @param byte32 -       32-byte columns (False - 16-byte columns) (not used in scanline mode)
    @param keep_open-     for 8 or less rows - do not close page between accesses (not used in scanline mode)
    @param extra_pages  2-bit number of extra pages that need to stay (not to be overwritten) in the buffer
                    This argument can be used for  read access with horizontal overlapping tiles
    @param write_mem,    write to memory mode (0 - read from memory)
    @param enable,       enable requests from this channel ( 0 will let current to finish, but not raise want/need)
69 70
    @param chn_reset   immediately reset all the internal circuitry
    @param copy_frame  copy frame number from the master channel (non-persistent)
71
    @param abort_late  abort frame r/w at the next frame sync, if not finished. Wait for pending memory transfers
72 73
    """
    rslt = 0;
74 75
    rslt |= (1,0)[chn_reset] <<     vrlg.MCONTR_LINTILE_NRESET # inverted
    rslt |= (0,1)[enable] <<        vrlg.MCONTR_LINTILE_EN
76 77 78 79 80
    rslt |= (0,1)[write_mem] <<     vrlg.MCONTR_LINTILE_WRITE
    rslt |= (extra_pages & ((1 <<   vrlg.MCONTR_LINTILE_EXTRAPG_BITS) - 1)) << vrlg.MCONTR_LINTILE_EXTRAPG
    rslt |= (0,1)[keep_open] <<     vrlg.MCONTR_LINTILE_KEEP_OPEN
    rslt |= (0,1)[byte32] <<        vrlg.MCONTR_LINTILE_BYTE32
    rslt |= (0,1)[reset_frame] <<   vrlg.MCONTR_LINTILE_RST_FRAME
81
    
82 83 84 85
    rslt |= (0,1)[single] <<        vrlg.MCONTR_LINTILE_SINGLE
    rslt |= (0,1)[repetitive] <<    vrlg.MCONTR_LINTILE_REPEAT
    rslt |= (0,1)[disable_need] <<  vrlg.MCONTR_LINTILE_DIS_NEED
    rslt |= (0,1)[skip_too_late] << vrlg.MCONTR_LINTILE_SKIP_LATE
86
    rslt |= (0,1)[copy_frame] <<    vrlg.MCONTR_LINTILE_COPY_FRAME
87
    rslt |= (0,1)[copy_frame] <<    vrlg.MCONTR_LINTILE_ABORT_LATE
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
    return rslt

'''
class X393Mcntrl(object):
    DRY_MODE= True # True
    DEBUG_MODE=1
    x393_mem=None
    x393_axi_tasks=None #x393X393AxiControlStatus
    x393_utils=None
    verbose=1
    def __init__(self, debug_mode=1,dry_mode=True, saveFileName=None):
        self.DEBUG_MODE=  debug_mode
        self.DRY_MODE=    dry_mode
        self.x393_mem=            X393Mem(debug_mode,dry_mode)
        self.x393_axi_tasks=      x393_axi_control_status.X393AxiControlStatus(debug_mode,dry_mode)
        self.x393_utils=          x393_utils.X393Utils(debug_mode,dry_mode, saveFileName) # should not overwrite save file path
        try:
            self.verbose=vrlg.VERBOSE
        except:
            pass
 '''