资源简介
实现Cache模拟器.zip
代码片段和文件信息
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.io.*;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import javax.swing.Jframe;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.EtchedBorder;
public class CCacheSim extends Jframe implements ActionListener{
private JPanel panelTop panelLeft panelRight panelBottom;
private JButton execStepBtn execAllBtn fileBotton;
private JComboBox csBox bsBox wayBox replaceBox prefetchBox writeBox allocBox;
private JFileChooser fileChoose;
private JLabel labelToplabelLeftrightLabelbottomLabelfileLabelfileAddrBtn stepLabel1stepLabel2csLabel bsLabel wayLabel replaceLabel prefetchLabel writeLabel allocLabel;
private JLabel results[];
//添加
private JLabel stepLabel[];
private JLabel missCountDisp[];
private JLabel missRateDisp[];
//参数定义
private String cachesize[] = { “2KB“ “8KB“ “32KB“ “128KB“ “512KB“ “2MB“ };
private String blocksize[] = { “16B“ “32B“ “64B“ “128B“ “256B“ };
private String way[] = { “直接映象“ “2路“ “4路“ “8路“ “16路“ “32路“ };
private String replace[] = { “LRU“ “FIFO“ “RAND“ };
private String pref[] = { “不预取“ “不命中预取“ };
private String write[] = { “写回法“ “写直达法“ };
private String alloc[] = { “按写分配“ “不按写分配“ };
private String typename[] = { “读数据“ “写数据“ “读指令“ };
private String hitname[] = {“不命中“ “命中“ };
//右侧结果显示
private String rightLable[]={“访问总次数:““读指令次数:““读数据次数:““写数据次数:“};
//添加不命中信息统计
private String missCountLabel=“不命中次数: “;
private String missRateLabel=“不命中率: “;
//添加单步执行每一步的情况
private String stepLabelMenu[]={“访问类型: ““地址: ““块号:““块内地址:““索引: ““命中情况: “};
private String stepResult[]=new String[6];
//打开文件
private File file;
//分别表示左侧几个下拉框所选择的第几项,索引从 0 开始
private int csIndex bsIndex wayIndex replaceIndex prefetchIndex writeIndex allocIndex;
//其它变量定义
//...
//选择后的cachesize,blocksize,相联度
double selectedCacheSize selectedBlockSize selectedWay;
//选择后的替换策略,写策略
String selectedReplace selectedWrite;
static int step = 0; //单步执行的步数
boolean execAll = false; //执行到底的标记
static double[] accessCount=new double[4]; //保存访存次数 的统计,分别为总访问、读指令、读数据、写数据
static double[] missCount=new double[4]; //保存不命中次数
static double[] missRate=new double[4]; //保存不命中率
//存放地址流的数组
List addrStream = new ArrayList();
public class AddrStream{
String type; //访存类型
String addr; //访存地址
}
//存放cache
Cache[][] caches;
public class Cache{
int tag; //tag 用来与地址的高位比较,判断请求是否在cache中
int time; //用于替换算法 使用时间到达时间记录
int valid; //有效位,用来标
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2019-03-23 21:21 src\
文件 20266 2018-04-13 14:55 src\CCacheSim.java
文件 342 2014-09-04 16:18 src\readme.md
文件 79007 2018-04-14 10:43 实现Cache模拟器.docx
- 上一篇:PSCAD光伏模型
- 下一篇:模拟温度采集监测系统.zip
相关资源
- unity3d插件-脚本-图像识别OpenCVforUnit
- TIA链接密码.txt
- C窗体局域网、广域网斗地主游戏.ra
- js 翻翻乐使用js书写的翻番乐初学js有
- usbviewer.rar
- DropDown.rar
- QmlBarGraphShow.zip
-
Mapob
jects2.4Crack.rar - 模式识别-中科院.txt
- v1.2.txt
- Qt异或实现文件加解密.rar
- EncryptQtDemo.rar
- smallpdf1.20.0无限时间版.rar
- 383C开发大全(提高卷)源码.rar
- IsoHeightCtrl.zip
- 0145、低成本可调数显稳压电源(1.3
- refined_Lee_fliter.rar
- shadowsocks-libev_2.5.5-1_amd64_Ubuntu14.04.de
- 普林斯顿微积分读本视频列表.txt
- WannaCry勒索病毒一键加固脚本v1.05by叉
- WINDOWS聊天课程设计报告
- sccm.txt序列号.txt
- 8taesy.rar
- luke1215_10971614.txt
- MyTest.zip
- FFMpeg_SDK_详细中文指南开发手册.pdf
- NMSPublishSubscribe.zip
- 序列号吗.txt
- 完美DDOS破解版.rar
- 智慧树刷课.txt
评论
共有 条评论