Example #1
0
    ad = int(input("Mem. address (byte)  --------------------> "))
    loadstore = int(input("read (0) - Write (1)  -------------------> "))

    c = Cache(ws, bls, ss, Rpol, ad, loadstore, h, table, access)

    print("")
    print("")
    print("")
    print("Address: " + str(ad) + " / Word: " + str(c.word()) + " / Block: " +
          str(c.block()))
    print("Set: " + str(c.set()) + " / Tag: " + str(c.tag()) + " / Line: " +
          str(c.line()))

    if (Rpol == 1):
        #if replacement policy is LRU
        s = Set(ss, c.line(), c.set(), c.dirty(), c.tag(), c.block(),
                c.hit_miss(), table)
        t = Time(c.rewr, c.hit_miss(), c.dirty(), c.number_words_block(),
                 table)

        print(str(c.hit_miss()))
        print(str(c.hits()))
        print(str(c.dirty()))
        h = c.hits()
        print("Access time: " + str(t.accesstime()))
        print("Hit rate: " + str(round(c.hit_rate(), 2)))

        #fill in the table with the new values
        s.finder()

    if (Rpol == 0):