Skip to content

Commit

Permalink
Criando classe barramento.
Browse files Browse the repository at this point in the history
  • Loading branch information
Italo Valcy committed Jun 11, 2008
1 parent 207086b commit dae9bac
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 74 deletions.
29 changes: 29 additions & 0 deletions lib/barramento.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
require 'gui'
require 'memoria'

class Barramento
def initialize
end

# Solicita do barramento a leitura do dado
# no endereço address.
# Entrada:
# type - Tipo de barramento: mem (memoria), io (I/O)
# address - Endereço que deseja-se ler
# Retorno:
# Valor contido em address
def read(type,address)
Simulador.set_value_bus(type,"con","1")
Simulador.set_value_bus(type,"end",address)
value = Memoria.get_value(address,1)
Simulador.set_value_bus(type,"data",value)
return value
end

def write(type,address,value)
Simulador.set_value_bus(type,"con","2")
Simulador.set_value_bus(type,"end",address)
Simulador.set_value_bus(type,"data",value)
Memoria.set_value(address,value)
end
end
29 changes: 15 additions & 14 deletions lib/gui.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,17 @@ def carregar_arq(file_dialog, view)
return true
end

def get_value_memoria(address,qtd)
b = []
for i in 0..qtd-1
iter = @@glade['gridview_mem'].get_iter("#{address + i}")
b.push iter[1]
end
return b
end

def get_value_cache(address,)

# Insere valores numa treeview
# Entrada:
# view - a treeview onde deseja-se inserir os valores
Expand Down Expand Up @@ -167,22 +178,12 @@ def Simulador.get_value_rg(reg)
return @@glade["rg_#{reg}"].text
end


def Simulador.set_value_bus_mem(bus,value)
@@glade["bus_#{bus}_p_mem"].text = value
end

def Simulador.get_value_bus_mem(bus)
return @@glade["bus_#{bus}_p_mem"].text
end


def Simulador.set_value_bus_io(bus,value)
@@glade["bus_#{bus}_p_io"].text = value
def Simulador.set_value_bus(type,bus,value)
@@glade["bus_#{bus}_p_#{type}"].text = value
end

def Simulador.get_value_bus_io(bus)
return @@glade["bus_#{bus}_p_io"].text
def Simulador.get_value_bus(type,bus)
return @@glade["bus_#{bus}_p_#{type}"].text
end

def Simulador.wait_clock
Expand Down
120 changes: 60 additions & 60 deletions lib/layout.glade
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--Generated with glade3 3.4.5 on Tue Jun 10 11:27:25 2008 -->
<!--Generated with glade3 3.4.5 on Wed Jun 11 17:20:42 2008 -->
<glade-interface>
<widget class="GtkWindow" id="simulador_window">
<property name="width_request">800</property>
Expand Down Expand Up @@ -292,27 +292,53 @@ Feito automaticamente ao iniciar a simulação.</property>
<property name="n_rows">7</property>
<property name="n_columns">2</property>
<child>
<widget class="GtkLabel" id="label8">
<widget class="GtkLabel" id="label10">
<property name="visible">True</property>
<property name="label" translatable="yes">Flags</property>
<property name="label" translatable="yes">Ax</property>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label11">
<property name="visible">True</property>
<property name="label" translatable="yes">Bx</property>
</widget>
<packing>
<property name="top_attach">6</property>
<property name="bottom_attach">7</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label9">
<widget class="GtkLabel" id="label12">
<property name="visible">True</property>
<property name="label" translatable="yes">RI</property>
<property name="label" translatable="yes">Cx</property>
</widget>
<packing>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="rg_flags">
<widget class="GtkLabel" id="label13">
<property name="visible">True</property>
<property name="label" translatable="yes">Dx</property>
</widget>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label14">
<property name="visible">True</property>
<property name="label" translatable="yes">IP</property>
</widget>
<packing>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="rg_ax">
<property name="width_request">70</property>
<property name="height_request">25</property>
<property name="visible">True</property>
Expand All @@ -322,12 +348,10 @@ Feito automaticamente ao iniciar a simulação.</property>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">6</property>
<property name="bottom_attach">7</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="rg_ri">
<widget class="GtkEntry" id="rg_bx">
<property name="width_request">70</property>
<property name="height_request">0</property>
<property name="visible">True</property>
Expand All @@ -337,12 +361,12 @@ Feito automaticamente ao iniciar a simulação.</property>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="rg_ip">
<widget class="GtkEntry" id="rg_cx">
<property name="width_request">70</property>
<property name="height_request">0</property>
<property name="visible">True</property>
Expand All @@ -352,8 +376,8 @@ Feito automaticamente ao iniciar a simulação.</property>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
</packing>
</child>
<child>
Expand All @@ -372,7 +396,7 @@ Feito automaticamente ao iniciar a simulação.</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="rg_cx">
<widget class="GtkEntry" id="rg_ip">
<property name="width_request">70</property>
<property name="height_request">0</property>
<property name="visible">True</property>
Expand All @@ -382,12 +406,12 @@ Feito automaticamente ao iniciar a simulação.</property>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="rg_bx">
<widget class="GtkEntry" id="rg_ri">
<property name="width_request">70</property>
<property name="height_request">0</property>
<property name="visible">True</property>
Expand All @@ -397,12 +421,12 @@ Feito automaticamente ao iniciar a simulação.</property>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="rg_ax">
<widget class="GtkEntry" id="rg_flags">
<property name="width_request">70</property>
<property name="height_request">25</property>
<property name="visible">True</property>
Expand All @@ -412,54 +436,30 @@ Feito automaticamente ao iniciar a simulação.</property>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">6</property>
<property name="bottom_attach">7</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label14">
<property name="visible">True</property>
<property name="label" translatable="yes">IP</property>
</widget>
<packing>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label13">
<property name="visible">True</property>
<property name="label" translatable="yes">Dx</property>
</widget>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label12">
<widget class="GtkLabel" id="label9">
<property name="visible">True</property>
<property name="label" translatable="yes">Cx</property>
<property name="label" translatable="yes">RI</property>
</widget>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label11">
<widget class="GtkLabel" id="label8">
<property name="visible">True</property>
<property name="label" translatable="yes">Bx</property>
<property name="label" translatable="yes">Flags</property>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="top_attach">6</property>
<property name="bottom_attach">7</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label10">
<property name="visible">True</property>
<property name="label" translatable="yes">Ax</property>
</widget>
</child>
</widget>
<packing>
<property name="x">5</property>
Expand Down Expand Up @@ -1092,7 +1092,7 @@ Manual</property>
<property name="height_request">25</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="adjustment">64 63 511 1 10 10</property>
<property name="adjustment">64 64 512 1 10 10</property>
</widget>
<packing>
<property name="x">75</property>
Expand Down

0 comments on commit dae9bac

Please sign in to comment.