- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
1130310126_李明远_Cache的实现摘要
第四章‐实验2基本Cache的实现班级:1303101姓名:李明远学号:1130310126实验要求:在实现存储芯片的基础上,按照P112,图4.50实现cache的基本功能,其中替换机构和地址映射的方式可以自定。实验原理P112,图4.50 Cache基本结构如下:三、实验设计主存采用长度为256的向量数组实现(向量长度为4,表示字长为4);Cache采用长度为16的向量数组实现。Cache-主存地址映射采用直接映射方式:设置act变量表示读或写操作,hit变量表示cpu进行读操作时是否命中,并设置大小和Cache一致的标记数组表示标记块。进行读操作时,通过主存高位地址和标记数组进行比较判断是否命中,若命中则直接读取;否则将字块调入Cache。进行写操作时,将数据写入Cache,标记为存入高位地址,然后将字块调入主存。程序设计框图程序代码library IEEE;USE IEEE.STD_LOGIC_1164.ALL;USE IEEE.STD_LOGIC_ARITH.ALL;USE IEEE.STD_LOGIC_UNSIGNED.ALL;-- Uncomment the following library declaration if using-- arithmetic functions with Signed or Unsigned values--use IEEE.NUMERIC_STD.ALL;-- Uncomment the following library declaration if instantiating-- any Xilinx primitives in this code.--library UNISIM;--use UNISIM.VComponents.all;entity code isPort (clk : in STD_LOGIC;Initial : in STD_LOGIC;act : in STD_LOGIC;hit : out STD_LOGIC;high_order : in STD_LOGIC_VECTOR (3 downto 0);low_order : in STD_LOGIC_VECTOR (3 downto 0);input : in STD_LOGIC_VECTOR (3 downto 0);output : out STD_LOGIC_VECTOR (3 downto 0););end code;architecture Behavioral of code istype M_mem is array(255 downto 0) of std_logic_vector(3 downto 0);type Cache is array(15 downto 0) of std_logic_vector(3 downto 0);shared variable MainMem: M_mem;shared variable CacheMem: Cache;shared variable Mark: Cache;signal flag: std_logic;signal data_show:std_logic_vector(3 downto 0);beginhit=flag;output=data_show;process(Initial)beginfor i in 0 to 225 loopMainMem(i):=0000;if i16 thenCacheMem(i):=0000;Mark(i):=0000;end if;end loop;end process;process(clk)beginif rising_edge(clk) thenif act=0 thenif Mark(conv_integer(low_order))=high_order thenflag=1;elseflag=0;CacheMem(conv_integer(low_order)):=MainMem(cont_integer(high_order)*16+conv_integer(low_order));Mark(conv_integer(low_order)):=high_order;end if;data_show=CacheMem(conv_integer(low_order));elseif Mark(conv_integer(low_order))=high_order thenflag=1;elseflag=0;end if;CacheMem(conv_integer(low_order)):=input;Mark(conv_integer(low_order)):=
您可能关注的文档
最近下载
- 瓷砖胶品牌、瓷砖胶缺点、瓷砖胶禁忌.doc VIP
- 《杜邦分析法下公司盈利能力分析—以海澜之家为例》7500字.docx VIP
- 2025年高中数学奥林匹克竞赛试卷试题及答案解析.docx VIP
- 住房公积金政策知识竞赛题库附答案(150题).docx VIP
- EN 50618-2014 光伏系统用电缆.pdf VIP
- 边坡治理工程(抗滑桩、锚杆、锚索、挡板、冠梁)专项施工组织设计.doc VIP
- 畜牧兽医法律法规和职业道德(第二版)PPT课件(全).pptx VIP
- 人教版(新教材)七年级上册音乐第一单元《生活中的音乐》全单元教学课件课件.pptx
- 苏教版五年级上册《科学》全套教学课件(共486页PPT).pptx
- 欧洲知识点PPT课件.pptx
文档评论(0)