|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.table.AbstractTableModel
mars.tools.BHTableModel
public class BHTableModel
Simulates the actual functionality of a Branch History Table (BHT).
The BHT consists of a number of BHT entries which are used to perform branch prediction. The entries of the BHT are stored as a Vector of BHTEntry objects. The number of entries is configurable but has to be a power of 2. The history kept by each BHT entry is also configurable during run-time. A change of the configuration however causes a complete reset of the BHT.
The typical interaction is as follows:
getIdxForAddress(int)
method.getPredictionAtIdx(int)
method.updatePredictionAtIdx(int, boolean)
method.Additionally it serves as TableModel that can be directly used to render the state of the BHT in a JTable. Feedback provided to the BHT causes a change of the internal state and a repaint of the table(s) associated to this model.
Field Summary |
---|
Fields inherited from class javax.swing.table.AbstractTableModel |
---|
listenerList |
Constructor Summary | |
---|---|
BHTableModel(int numEntries,
int historySize,
boolean initVal)
Constructs a new BHT with given number of entries and history size. |
Method Summary | |
---|---|
Class |
getColumnClass(int i)
Returns the class/type of the i-th column of the table. |
int |
getColumnCount()
Returns the number of columns. |
String |
getColumnName(int i)
Returns the name of the i-th column of the table. |
int |
getIdxForAddress(int address)
Returns the index into the BHT for a given branch instruction address. |
boolean |
getPredictionAtIdx(int index)
Retrieve the prediction for the i-th BHT entry. |
int |
getRowCount()
Returns the number of entries of the BHT. |
Object |
getValueAt(int row,
int col)
Returns the value of the cell at the given row and column Required by the TableModel interface. |
void |
initBHT(int numEntries,
int historySize,
boolean initVal)
Initializes the BHT with the given size and history. |
void |
updatePredictionAtIdx(int index,
boolean branchTaken)
Updates the BHT entry with the outcome of the branch instruction. |
Methods inherited from class javax.swing.table.AbstractTableModel |
---|
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, isCellEditable, removeTableModelListener, setValueAt |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BHTableModel(int numEntries, int historySize, boolean initVal)
numEntries
- number of entries in the BHThistorySize
- size of the history (in bits/number of past branches)Method Detail |
---|
public String getColumnName(int i)
getColumnName
in interface TableModel
getColumnName
in class AbstractTableModel
i
- the index of the column
public Class getColumnClass(int i)
getColumnClass
in interface TableModel
getColumnClass
in class AbstractTableModel
i
- the index of the column
public int getColumnCount()
public int getRowCount()
public Object getValueAt(int row, int col)
row
- the row indexcol
- the column index
public void initBHT(int numEntries, int historySize, boolean initVal)
numEntries
- number of entries in the BHT (has to be a power of 2)historySize
- size of the history to considerinitVal
- initial value for each entry (true means take branch, false do not take branch)public int getIdxForAddress(int address)
address
- the address of the branch instruction
public boolean getPredictionAtIdx(int index)
index
- the index of the entry in the BHT
public void updatePredictionAtIdx(int index, boolean branchTaken)
index
- the index of the entry in the BHTbranchTaken
-
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |