コード例 #1
0
ファイル: Slicer.cs プロジェクト: cephdon/systemsharp
        /// <summary>
        /// Constructs a new instance.
        /// </summary>
        /// <param name="inputWidth">bit-width of operand</param>
        /// <param name="hiOffset">high slice offset</param>
        /// <param name="loOffset">low slice offset</param>
        /// <param name="signed">whether operand is signed</param>
        public Slicer(int inputWidth, int hiOffset, int loOffset, bool signed)
        {
            Contract.Requires <ArgumentOutOfRangeException>(hiOffset - loOffset >= -1);

            InputWidth = inputWidth;
            HiOffset   = hiOffset;
            LoOffset   = loOffset;
            IsSigned   = signed;
            TASite     = new SlicerTransactionSite(this);

            int msb        = signed ? inputWidth - 2 : inputWidth - 1;
            int hiPadWidth = Math.Max(hiOffset, msb) - Math.Max(loOffset, msb + 1) + 1;
            int loPadWidth = Math.Min(hiOffset, -1) - Math.Min(loOffset, 0) + 1;

            _hiSlice = Math.Min(msb, hiOffset);
            _loSlice = Math.Max(0, loOffset);

            if (_loSlice > _hiSlice)
            {
                // degenerate case: actually no portion of input word is used
                _hiSlice = -1;
                _loSlice = 0;
            }

            _hiPad0 = StdLogicVector._0s(hiPadWidth);
            _hiPad1 = StdLogicVector._1s(hiPadWidth);
            _loPad  = StdLogicVector._0s(loPadWidth);

            Debug.Assert(hiPadWidth + loPadWidth + _hiSlice - _loSlice == hiOffset - loOffset);
        }
コード例 #2
0
ファイル: Slicer.cs プロジェクト: venusdharan/systemsharp
        /// <summary>
        /// Constructs a new instance.
        /// </summary>
        /// <param name="inputWidth">bit-width of operand</param>
        /// <param name="hiOffset">high slice offset</param>
        /// <param name="loOffset">low slice offset</param>
        /// <param name="signed">whether operand is signed</param>
        public Slicer(int inputWidth, int hiOffset, int loOffset, bool signed)
        {
            Contract.Requires<ArgumentOutOfRangeException>(hiOffset - loOffset >= -1);

            InputWidth = inputWidth;
            HiOffset = hiOffset;
            LoOffset = loOffset;
            IsSigned = signed;
            TASite = new SlicerTransactionSite(this);

            int msb = signed ? inputWidth - 2 : inputWidth - 1;
            int hiPadWidth = Math.Max(hiOffset, msb) - Math.Max(loOffset, msb + 1) + 1;
            int loPadWidth = Math.Min(hiOffset, -1) - Math.Min(loOffset, 0) + 1;
            _hiSlice = Math.Min(msb, hiOffset);
            _loSlice = Math.Max(0, loOffset);
            
            if (_loSlice > _hiSlice)
            {
                // degenerate case: actually no portion of input word is used
                _hiSlice = -1;
                _loSlice = 0;
            }            

            _hiPad0 = StdLogicVector._0s(hiPadWidth);
            _hiPad1 = StdLogicVector._1s(hiPadWidth);
            _loPad = StdLogicVector._0s(loPadWidth);

            Debug.Assert(hiPadWidth + loPadWidth + _hiSlice - _loSlice == hiOffset - loOffset);
        }