91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 29KB
    文件類型: .zip
    金幣: 2
    下載: 1 次
    發布日期: 2021-05-16
  • 語言: Java
  • 標簽: cache??java??緩存技術??

資源簡介

java開發的cache模擬器,帶有界面,能夠設置 Cache、 Cache 塊的大小,能夠設置Cache 的映射機制:直接映射、n-路組相聯,能夠設置 Cache 的替換策略:LRU、FIFO,能夠設置 Cache 的寫策略:寫回法、寫直達法

資源截圖

代碼片段和文件信息

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.util.ArrayList;
import?java.util.List;

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?stepLabel1?stepLabel2
????csLabel?bsLabel?wayLabel?replaceLabel?prefetchLabel?writeLabel?allocLabel;
private?JLabel?results[];
//添加
private?JLabel?hitCount[];
private?JLabel?hitRate[];
private?JLabel?stepLabel[];


????//參數定義
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?ShitCount=“不命中次數:?“;
private?String?ShitRate=“不命中率:?“;
private?String?SstepLabel[]={“訪問類型:?““地址:?““塊號:““塊內地址:““索引:?““命中情況:?“};

//打開文件
private?File?file;

//分別表示左側幾個下拉框所選擇的第幾項,索引從?0?開始
private?int?csIndex?bsIndex?wayIndex?replaceIndex?prefetchIndex?writeIndex?allocIndex;

//其它變量定義
//...
static?int?[]?InstCount=new?int[4];
static?int?readData;??????//讀數據指令條數
static?int?writeData; ???//寫數據指令條數
static?int?readInst; //讀指令條數
static?int?count;?????????//指令總條數
int?offset;? //字節偏移量

List??instruction=new?ArrayList();??//存放指令的數組
public?class?Instruction{
String?type;????//指令類型
String?addr;????//指令地址
}

/*
?*?構造函數,繪制模擬器面板
?*/
public?CCacheSim(){
super(“Cache?Simulator“);
draw();
}


//響應事件,共有三種事件:
//???1.?執行到底事件
//???2.?單步執行事件
//???3.?文件選擇事件
public?void?actionPerformed(ActionEvent?e){

if?(e.getSource()?==?execAllBtn)?{
simExecAll();
}
if?(e.getSource()?==?execStepBtn)?{
simExecStep();
}
if?(e.getSource()?==?fileBotton){
fileChoose=new?JFileChooser();
int?fileOver?=?fileChoose.showOpenDialog(null);
//System.out.println(“fileOver:?“+fileOver);
if?(fileOver?==?0)?{

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2014-11-25?23:35??cache\
?????目錄???????????0??2014-11-25?23:35??cache\mycache\
?????文件?????????232??2014-11-20?18:32??cache\mycache\.classpath
?????文件?????????383??2014-11-20?18:32??cache\mycache\.project
?????目錄???????????0??2014-11-25?23:35??cache\mycache\bin\
?????文件?????????777??2014-11-25?23:33??cache\mycache\bin\CCacheSim$1.class
?????文件?????????777??2014-11-25?23:33??cache\mycache\bin\CCacheSim$2.class
?????文件?????????777??2014-11-25?23:33??cache\mycache\bin\CCacheSim$3.class
?????文件?????????777??2014-11-25?23:33??cache\mycache\bin\CCacheSim$4.class
?????文件?????????777??2014-11-25?23:33??cache\mycache\bin\CCacheSim$5.class
?????文件?????????779??2014-11-25?23:33??cache\mycache\bin\CCacheSim$6.class
?????文件?????????779??2014-11-25?23:33??cache\mycache\bin\CCacheSim$7.class
?????文件?????????446??2014-11-25?23:33??cache\mycache\bin\CCacheSim$Cache.class
?????文件?????????450??2014-11-25?23:33??cache\mycache\bin\CCacheSim$Instruction.class
?????文件???????20527??2014-11-25?23:33??cache\mycache\bin\CCacheSim.class
?????文件???????14615??2014-11-21?19:17??cache\mycache\CCacheSim.java
?????目錄???????????0??2014-11-25?23:35??cache\mycache\src\
?????文件???????28974??2014-11-25?23:33??cache\mycache\src\CCacheSim.java

評論

共有 條評論