Example #1
0
        /// <summary>
        /// Construction Function
        /// </summary>
        public Cache(bool pim)
        {
            replace_policy = (new LRU() as CacheReplacePolicy);

            cycle = 0;
            int set_size = 0;

            if (!pim)
            {
                assoc    = Config.l1cache_assoc;
                set_size = Config.block_size * assoc;
                max_set  = Config.l1cache_size / set_size;
                assoc    = Config.l1cache_assoc;
            }
            else
            {
                assoc    = PIMConfigs.l1cache_assoc;
                set_size = Config.block_size * assoc;
                max_set  = PIMConfigs.l1cache_size / set_size;
                assoc    = PIMConfigs.l1cache_assoc;
            }

            cache = new CacheEntity[assoc, max_set];


            for (int i = 0; i < assoc; i++)
            {
                for (int j = 0; j < max_set; j++)
                {
                    cache[i, j] = new CacheEntity(NULL, 0, false, 0, false);
                }
            }
        }
Example #2
0
        public UInt64 miss = 0;     //number of cache misses

        #endregion

        #region Public Methods

        /// <summary>
        /// Construction Functions
        /// </summary>
        public Shared_Cache()
        {
            replace_policy = (new LRU() as CacheReplacePolicy);

            cycle = 0;
            int set_size = 0;

            assoc    = Config.shared_cache_assoc;
            set_size = Config.block_size * assoc;
            max_set  = Config.shared_cache_size / set_size;
            assoc    = Config.shared_cache_assoc;
            cache    = new CacheEntity[assoc, max_set];
            for (int i = 0; i < assoc; i++)
            {
                for (int j = 0; j < max_set; j++)
                {
                    cache[i, j] = new CacheEntity(NULL, 0, false, 0, false);
                }
            }
        }