Boletín No. 47
1o. de Marzo de 2015
SIMULADOR DE POLÍTICAS DE UBICACIÓN, SUSTITUCIÓN Y ESCRITURA
DE MEMORIA CACHÉ
Anexo 2
Private Sub INICIO_Click()
If FIFO.Value = True Then
If TASK.Text <> “” Then
datoout = Val(TASK.Text)
odest = datoout Mod noset
TASK.Text = “”
For j = 0 To (fila – 1)
For k = 0 To (colu – 1)
If TABLA.TextMatrix(j, k) = Str(datoout) Then
TABLA.Row = j
TABLA.Col = k
TABLA.CellBackColor = &H80EF6B ‘verde
hitx = j
hity = k
hit = hit + 1
cm = cm – 1
hitup = True
End If
Next
Next
For I = 1 To noset
If dato(1, i) = (odest + 1) Then
cont = dato(2, i)
ncolu = dato(2, i)
If hitup = False Then
If TABLA.TextMatrix((odest * filaset) + (ncolu \ colu), ncolu Mod colu) <> “” Then
cm = cm – 1
odestt = odestt + 1
TABLA.Row = (odest * filaset) + (ncolu \ colu)
TABLA.Col = ncolu Mod colu
TABLA.CellBackColor = &H10A0FF ‘naranja
Else
TABLA.Row = (odest * filaset) + (ncolu \ colu)
TABLA.Col = ncolu Mod colu
TABLA.CellBackColor = &HFF8080 ‘violeta
End If
TABLA.TextMatrix((odest * filaset) + (ncolu \ colu), ncolu Mod colu) = Str(datoout)
End If
If hitup = True And TABLA.TextMatrix(hitj, hitk) <> TABLA.TextMatrix((odest * filaset) + (ncolu \ colu), ncolu Mod colu) Then
cont = cont – 1
End If
cont = cont + 1
If cont > (celda – 1) Then
cont = 0
dato(2, i) = cont
nfila = 0
ncolu = 0
Else
dato(2, i) = cont
End If
End If
Next
consultas = consultas + 1
MAXCON.Text = Str(consultas)
If cm < memc Then
cm = cm + 1
PO.Text = Str(cm)
Else
cm = 0
End If
PC.Text = Str(odestt)
HC.Text = Str(hit)
hitup = False
End If
End If
‘--------------------------------------------------------------
If LRU.Value = True Then
If TASK.Text <> “” Then
datoout = Val(TASK.Text)
odest = datoout Mod noset
TASK.Text = “”
For j = 0 To (fila – 1)
For k = 0 To (colu – 1)
If TABLA.TextMatrix(j, k) = Str(datoout) Then
TABLA.Row = j
TABLA.Col = k
TABLA.CellBackColor = &H80EF6B ‘verde
hitx = j
hity = k
hit = hit + 1
cm = cm – 1
hitup = True
End If
Next
Next
If hitup = True Then
menor = datoLRU(((hitx \ 2) + 1), ((((hitx Mod filaset) * 4) + hity)) + 1)
datoLRU(((hitx \ 2) + 1), ((((hitx Mod filaset) * 4) + hity)) + 1) = menor + 1
End If
If hitup = False Then
For I = 1 To noset
If datoLRU(I, 0) = (odest + 1) Then
menor = 1000
For j = 1 To celda
If datoLRU(I, j) < menor Then
menor = datoLRU(i, j)
LRUcolu = j
LRUset = i
End If
Next
End If
Next
datoLRU(LRUset, LRUcolu) = menor + 1
ncolu = LRUcolu – 1
If TABLA.TextMatrix((odest * filaset) + (ncolu \ colu), ncolu Mod colu) <> “” Then
cm = cm – 1
odestt = odestt + 1
TABLA.Row = (odest * filaset) + (ncolu \ colu)
TABLA.Col = ncolu Mod colu
TABLA.CellBackColor = &H10A0FF ‘naranja
Else
TABLA.Row = (odest * filaset) + (ncolu \ colu)
TABLA.Col = ncolu Mod colu
TABLA.CellBackColor = &HFF8080 ‘violeta
End If
TABLA.TextMatrix((odest * filaset) + (ncolu \ colu), ncolu Mod colu) = Str(datoout)
End If
consultas = consultas + 1
MAXCON.Text = Str(consultas)
If cm < memc Then
cm = cm + 1
PO.Text = Str(cm)
Else
cm = 0
End If
hitup = False
End If
End If
End Sub