Code Monkey home page Code Monkey logo

cache-based-on-freearm7's Introduction

Cache based on FreeARM7

描述

  本科二年级《计算机组成原理》上完成的一个课程项目,使用的开发环境是 Xilinx ISE 12.3 。基于 FreeARM7 开源项目提供的ARM内核构建32位处理器。通过ISE软件进行I-Cache和D-Cache的设计、实现、软件仿真与调试。并采用不同的 Cache映射规则Cache替换策略D-Cache写策略进行优化。
  本仓库仅用作代码保存与共享目的,想要了解本项目更多细节可以通过上述实验报告[PDF]获取。

目录介绍

. 
├── arm_clear		基于FreeARM7内核搭建的处理器(无Cache)ISE工程完整源代码  
├── arm_clear_cache		基于FreeARM7内核搭建的处理器(加入简单I-Cache)ISE工程完整源代码
├── Cache_v0 ………………………………………………………………………… 未进行优化的实现
|   ├── D_Cache.v ……………………………………………………… D_Cache 模块.v 文件
|   ├── dram_ctrl_sim.v ………………………………………………… dram controller 模块.v 文件
|   ├── I_Cache.v ………………………………………………………… I_Cache 模块.v 文件
|   ├── stimulus.v ………………………………………………………… 仿真测试文件
├── Cache_v1 ……………………………………………………………………… 进行优化的实现
|   ├── D_Cache.v ……………………………………………………… D_Cache 模块.v 文件
|   ├── dram_ctrl_sim.v ………………………………………………… dram controller 模块.v 文件
|   ├── I_Cache.v ………………………………………………………… I_Cache 模块.v 文件
|   ├── stimulus.v ………………………………………………………… 仿真测试文件
├── Test ……………………………………………………………………… 用于测试的测试用例
|   ├── cache_test_512 …………………………………………………… 512 个随机数生成与排序(包括.c/.s/.mif文件)
|   ├── cache_test_8096 ………………………………………………… 长度 8096 的数组简单赋值(包括.c/.s/.mif文件)
|   ├── cache_test_high …………………………………………………… 8096 个随机数生成与排序(包括.c/.s/.mif文件) 
├── 【SoCVista】FreeARM7_文档.pdf		FreeARM7开源项目说明文档
└── 12353022_陈胜杰_Cache.pdf		详细的试验实验报告

内容

FreeARM7系统结构

编译器工作流程简图

代码流图

Cache映射规则

  • 直接映射规则,即对于内存中的任何一个数据,在 Cache 中有且只有一个块与之对应。实现中即是,对于一个内存地址,只对应于一个 Cache 索引。

  • 全相联,对于内存中的一个地址,对应于 Cache 中的任何一个位置,类似于将内存中的数据直接搬入 Cache,而 Cache 作为一个中转站。

  • 组相联映射,结合了上述两种映射规则,一个内存地址索引到 Cache 的一个组,这里是直接映射;而具体到一个组的哪一个块则采用全相联的方式。

  • 直接映射规则能够高效进行内存与 Cache 间数据的转移以及地址的转换, 而全相联则能提供一个较高的命中率。组相联映射,折中了二者的优点。

Cache替换策略

 当 Cache 缺失,而缺失所在块(组)存在数据,我们需要一定策略选择一个替换块来存放我们从主存中载入的数据,以使我们在未来的指令操作中,竟可能减 Cache 缺失的可能。

  • FIFO,先到先置换算法,在一开始我们实现的直接相连映射下的覆盖方式类似于这种方法;
  • 随机算法,即随机置换一个块;
  • 最近最少使用算法(LRU),这一算法运用了程序时间局部性的原理,在置换的时候,选择组中最近不怎么使用的块,将其置换,可以竟可能达到满意的命中率。

D-Cache写策略

 对于 D_Cache 的写操作,有两种比较常见的策略:

  • 写直达法,即向 D-Cache 写入数据时,直接将数据写入主存, 同时采用写不分配法, 写数据的时候不将写缺失块载入 Cache, 等到读缺失时再将其载入;
  • 写回法,向 D-Cache 写入数据时,采用写分配法,为其在 Cache 中分配空间,直接在 Cache 中写入数据,当其需要被置换时,再将其写入主存;
  • 这两种方法都能保持 Cache 与主存的一致性。

使用说明

  • 使用ISE软件打开 arm_clear_cache 工程
  • 使用 Cache_v? 文件夹下文件替换工程中相应文件
  • Test 文件夹下各测试用例对应的 .mif 文件内容写入 arm_clear_cache 工程下的 program.mif 文件,对个测试用例进行测试

cache-based-on-freearm7's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.