import ariane_pkg::*;
"""
-from nmigen import Const, Signal
+from nmigen import Const, Signal, Cat
from math import log
DCACHE_SET_ASSOC = 8
data_rvalid = Signal()
data_rdata = Signal(64)
-ASID_WIDTH = 1
+ASID_WIDTH = 8
class PTE: #(RecordObject):
def __init__(self):
self.r = Signal()
self.v = Signal()
+ def flatten(self):
+ return Cat(*self.ports())
+
def eq(self, x):
- return [self.reserved.eq(x.reserved),
- self.ppn.eq(x.ppn), self.rsw.eq(x.rsw),
- self.d.eq(x.d), self.a.eq(x.a), self.g.eq(x.g),
- self.u.eq(x.u), self.x.eq(x.x), self.w.eq(x.w),
- self.r.eq(x.r), self.v.eq(x.v)]
+ return self.flatten().eq(x.flatten())
def ports(self):
return [self.reserved, self.ppn, self.rsw, self.d, self.a, self.g,
from nmigen import Signal, Module, Cat, Const, Array
from nmigen.cli import verilog, rtlil
+from ptw import TLBUpdate, PTE, ASID_WIDTH
# SV39 defines three levels of page tables
class TLBEntry:
self.valid = Signal()
TLB_ENTRIES = 4
-ASID_WIDTH = 1
-
-from ptw import TLBUpdate, PTE
class TLB:
# lvl0 <=> MSB, lvl1 <=> MSB-1, ...
shift = LOG_TLB - lvl;
new_idx = Const(~((i >> (shift-1)) & 1), 1)
- print ("plru", i, lvl, hex(idx_base), shift, new_idx)
+ print ("plru", i, lvl, hex(idx_base),
+ idx_base + (i >> shift), shift, new_idx)
m.d.sync += plru_tree[idx_base + (i >> shift)].eq(new_idx)
# Decode tree to write enable signals
m.d.comb += plru.eq(plru_tree[idx_base + (i>>shift)])
# en &= plru_tree_q[idx_base + (i>>shift)] == new_idx;
if new_idx:
- en[lvl].eq(~plru) # yes inverted (using bool())
+ m.d.comb += en[lvl].eq(~plru) # yes inverted (using bool())
else:
- en[lvl].eq(plru) # yes inverted (using bool())
+ m.d.comb += en[lvl].eq(plru) # yes inverted (using bool())
print ("plru", i, en)
# boolean logic manipluation:
# plur0 & plru1 & plur2 == ~(~plru0 | ~plru1 | ~plru2)