Ejemplo n.º 1
0
        /// <summary>
        /// Construct an L1Cache given a cache settings
        /// </summary>
        /// <param name="mb">reference to main memory block</param>
        /// <param name="cs">instruction cache preferences</param>
        public L1Cache(MemoryBlock mb, InstructionCachePreferences cs)
        {
            memBlock = mb;

            //Only if this cache is enabled do we create all these items
            if (cs.Enabled)
            {
                replaceStrategy = cs.ReplaceStrategy;
                wordsPerBlock   = cs.BlockSize / 4;
                uint numberBlocks = cs.NumberBlocks;
                uint blocksPerSet = cs.BlocksPerSet;

                //determine the number of sets in the cache
                uint numSets = numberBlocks / blocksPerSet;

                //and allocate the collection of sets
                Sets = new CacheSet[numSets];

                //create and init each set
                uint blockNumber = 0;
                for (uint ii = 0; ii < numSets; ii++)
                {
                    Sets[ii]     = new CacheSet(mb, wordsPerBlock, blocksPerSet, blockNumber, replaceStrategy);
                    blockNumber += blocksPerSet;
                } //for ii
            }     //if

            ResetStats();
        }//L1Cache ctor
Ejemplo n.º 2
0
        public void SetSettings(CachePreferences cachePreferences)
        {
            InstructionCachePreferences cp = mInstructionCacheSummary ? cachePreferences.InstructionCachePreferences : cachePreferences.DataCachePreferences;

            if (!cp.Enabled)
            {
                gbSummary.Enabled = false;
                return;
            }
            lblCacheSize.Text = (cp.NumberBlocks * cp.BlockSize).ToString() + " Bytes";
            lblBlockSize.Text = cp.BlockSize.ToString() + " Bytes";
            lblNumBlocks.Text = cp.NumberBlocks.ToString();

            if (cp.NumberBlocks == 1)
            {
                lblAssociativity.Text = "Fully Associative";
            }
            else if (cp.NumberBlocks == cp.BlocksPerSet)
            {
                lblAssociativity.Text = "Direct Mapped";
            }
            else
            {
                lblAssociativity.Text = string.Format("{0} way", cp.BlocksPerSet);
            }

            lblReplacement.Text = cp.ReplaceStrategy.ToString();

            if (!mInstructionCacheSummary)
            {
                DataCachePreferences dcp = cachePreferences.DataCachePreferences;
                lblAllocate.Text = dcp.AllocatePolicy.ToString();
                lblWrite.Text    = dcp.WritePolicy.ToString();
            }
        }//SetSettings
Ejemplo n.º 3
0
        public CacheWizard(CachePreferences cachePreferences)
        {
            InitializeComponent();

            mCachePreferences = cachePreferences;

            rbUnifiedYes.Checked = mCachePreferences.UnifiedCache;
            rbUnifiedNo.Checked  = !mCachePreferences.UnifiedCache;

            {
                InstructionCachePreferences icp = mCachePreferences.InstructionCachePreferences;
                rbICacheEnableYes.Checked = icp.Enabled;
                rbICacheEnableNo.Checked  = !icp.Enabled;

                instructionCacheSize.Set(icp.BlockSize, icp.NumberBlocks);
                instructionAssociativity.Set(icp.NumberBlocks, icp.BlocksPerSet);
                instructionReplacementStrategy.ReplaceStrategyType = icp.ReplaceStrategy;
            }

            {
                DataCachePreferences dcp = mCachePreferences.DataCachePreferences;
                rbDCacheEnableYes.Checked = dcp.Enabled;
                rbDCacheEnableNo.Checked  = !dcp.Enabled;

                dataCacheSize.Set(dcp.BlockSize, dcp.NumberBlocks);
                dataAssociativity.Set(dcp.NumberBlocks, dcp.BlocksPerSet);
                dataReplacementStrategy.ReplaceStrategyType = dcp.ReplaceStrategy;

                writePolicy.WritePolicyType       = dcp.WritePolicy;
                allocatePolicy.AllocatePolicyType = dcp.AllocatePolicy;
            }
        }