Find Jobs
Hire Freelancers

Creating a cache class test code in C#

$10-30 USD

已关闭
已发布大约 6 年前

$10-30 USD

货到付款
. Program 2 builds and tests a Cache class which is used for modeling the two levels of Cache needed for Program 3. The cache is composed of a number of “lines” or “blocks”. A cache line includes a valid flag, a tag and LRU data. In the real world, it would also include a data block, but for this simulation, the data blocks don’t need to be modeled. To simplify code, we’ll leave it out. For the ARM Cortex-A53 processor, there are two levels of cache. Level 1 is 32KB with 64-byte blocks and is organized as 40way set-associative. Level 2 cache is 1MB with 64-byte blocks but is 16-way. The Cache class should have a constructor which is defined as public Cache(int CacheSize, int BlockSize, int Associativity) The cache itself would be an array of structs containing three parameters: a valid variable, a tag variable and an LRU number. The actual data in the cache is not represented because it’s not need for this program to run. The number of entries in the cache array depends on the size of cache and the number of bytes per block. There is a method which is used to obtain information from the cache. The function prototype is public bool Get(uint uAddress, uint uCycle) The method returns true if there was a tag match (data was found in cache), or false if there was a miss. Since we’re not modeling data transfers in cache, just hits and misses, the interaction between cache levels is much simpler. On your first access to L1 Get, you’ll have a compulsory miss. Make the assumption that you’ll eventually get the data from L2 so before you return “false”, update the cache as if you got data from L2. That means set the valid bit, write the tag and the LRU information. Your method returns false (because there wasn’t a tag match) and you then call the L2 Get method. If it’s the first call of the program to L2, it too will miss and return a false, but like L1, you pretend you got the data from a lower-level store (main memory in this case) and set the appropriate valid flag, the LRU info and the tag. Thus, if you go back into L1 again with an address that’s similar to the first address you sent to L1, you’ll get a hit. The L1 Get method returns true, and then you don’t go ask L2 about the data. You will also need a method to print the valid contents of cache. An example from the L1 cache is All blocks in a set are printed on the same line, although only sets with valid entries are printed. A set whose entries are all invalid will not appear. The above image is for the L1 cache which has 4 cache blocks per set. For the L2 cache, the print output would be much wider because there are 16 blocks per set. Here is what the L2 cache print would look like, although the blocks are truncated because of the width of the image:
项目 ID: 16545119

关于此项目

远程项目
活跃6 年前

想赚点钱吗?

在Freelancer上竞价的好处

设定您的预算和时间范围
为您的工作获得报酬
简要概述您的提案
免费注册和竞标工作

关于客户

UNITED STATES的国旗
United States
0.0
0
付款方式已验证
会员自3月 11, 2018起

客户认证

谢谢!我们已通过电子邮件向您发送了索取免费积分的链接。
发送电子邮件时出现问题。请再试一次。
已注册用户 发布工作总数
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
加载预览
授予地理位置权限。
您的登录会话已过期而且您已经登出,请再次登录。