Exemple #1
0
def draw_node_element_rect(x, y, width, height, title_text):
    background_rect = pygame.Rect(x, y, width, height)
    pygame.draw.rect(screen, cpu_rect_background, background_rect)
    pygame.draw.rect(screen, cpu_rect_background, background_rect)
    pygame.draw.rect(screen, cpu_rect_border, background_rect, 4)

    title_rect = pygame.Rect(x, y, width, 30)
    pygame.draw.rect(screen, cpu_rect_border, title_rect)

    title = font_bold.render(title_text, True, cpu_text_color)

    title_width = title.get_width()
    screen.blit(title, (x + abs(width - title_width) / 2, y + 5))
Exemple #2
0
def draw_alert_rect(x, y, alert):
    width = 170
    background_rect = pygame.Rect(x, y, width, 33)
    pygame.draw.rect(screen, cpu_alert_background, background_rect, 0, 10)

    title = font_bold.render(alert, True, cpu_text_color)

    title_width = title.get_width()
    screen.blit(title, (x + abs(width - title_width) / 2, y + 5))
Exemple #3
0
def draw_node(x, y, instr, mem_dir, data, state, alert, node_id):
    background_rect = pygame.Rect(x - 5, y - 5, 181, 272)
    pygame.draw.rect(screen, node_background, background_rect)

    draw_cpu(x, y, node_id, instr)

    draw_cache(x, y + 140, mem_dir, data, state)

    draw_alert_rect(x, y + 280, alert)
Exemple #4
0
def draw_mem_operations(x, y, operations):
    width = 170
    background_rect = pygame.Rect(x, y, width, 132)
    pygame.draw.rect(screen, cpu_alert_background, background_rect, 0, 10)
    for i in range(0, len(operations)):
        font = font_bold.render(operations[i], True, white)
        text_width = font.get_width()
        screen.blit(font, (x + abs(width - text_width) / 2,
                           (y + 10) + space_y * (i)))
def draw_instr_modifier(mode):
    if mode:
        return

    x = 250
    y = 565

    width = 100
    heigh = 130

    # Background
    p_rect = pygame.Rect(x, y, width, heigh)
    pygame.draw.rect(screen, node_background, p_rect, 0, 10)

    # Button
    b_rect = pygame.Rect(360, 615, 75, 35)
    pygame.draw.rect(screen, green, b_rect, 0, 10)
    write_text(370, 620, "Agregar")

    x += 10
    y += 10

    # Nombre del procesador
    write_text(x, y, "P:")
    write_text(x + 40, y, processor_name[instr_modifier[0]])

    # Nombre de la instruccion
    write_text(x, y + space_y, "Instr:")
    write_text(x + 40, y + space_y, instr_type[instr_modifier[1]])

    if instr_modifier[1] < 1:
        return

    # Direccion de memoria
    write_text(x, y + space_y * 2, "Dir:")
    write_text(x + 40, y + space_y * 2, dec_to_bin(instr_modifier[2]))

    if instr_modifier[1] < 2:
        return

    # Dato
    write_text(x, y + space_y * 3, "Dato:")
    write_text(x + 40, y + space_y * 3, dec_to_hex(instr_modifier[3]))
Exemple #6
0
def draw_cpu(x, y, num, cpu_instr):
    max_width = 170
    draw_node_element_rect(x, y, max_width, 125, "Procesador " + str(num))

    x += 10
    y += 5

    for i in range(0, len(cpu_instr)):
        if i == len(cpu_instr) - 1:
            instr_rect = pygame.Rect(x - 3, y + space_y * (i + 1),
                                     max_width - 13, 24)
            pygame.draw.rect(screen, cpu_rect_aux, instr_rect, 0, 10)
            instr = font_bold.render(cpu_instr[i], True, cpu_text_color)
            screen.blit(instr, (x, y + space_y * (i + 1)))
        else:
            instr = font.render(cpu_instr[i], True, cpu_text_color)
            screen.blit(instr, (x, y + space_y * (i + 1)))