From a87ad06780261fb40a8b5507aa28561a9075c916 Mon Sep 17 00:00:00 2001 From: Andrew Waterman Date: Mon, 5 Dec 2011 15:45:44 -0800 Subject: [PATCH] Automatically infer rocketCAM address width --- rocket/src/main/scala/dtlb.scala | 4 ++-- rocket/src/main/scala/itlb.scala | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/rocket/src/main/scala/dtlb.scala b/rocket/src/main/scala/dtlb.scala index dabcc02d..23f1563a 100644 --- a/rocket/src/main/scala/dtlb.scala +++ b/rocket/src/main/scala/dtlb.scala @@ -68,7 +68,7 @@ class rocketDTLB(entries: Int) extends Component val lookup_tag = Cat(r_cpu_req_asid, r_cpu_req_vpn); - val tag_cam = new rocketCAM(entries, addr_bits, ASID_BITS+VPN_BITS); + val tag_cam = new rocketCAM(entries, ASID_BITS+VPN_BITS); val tag_ram = Mem(entries, io.ptw.resp_val, r_refill_waddr.toUFix, io.ptw.resp_ppn); tag_cam.io.clear := io.cpu.invalidate; @@ -183,4 +183,4 @@ class rocketDTLB(entries: Int) extends Component } } } -} \ No newline at end of file +} diff --git a/rocket/src/main/scala/itlb.scala b/rocket/src/main/scala/itlb.scala index dcfb0efb..95fde913 100644 --- a/rocket/src/main/scala/itlb.scala +++ b/rocket/src/main/scala/itlb.scala @@ -18,7 +18,8 @@ class ioCAM(entries: Int, addr_bits: Int, tag_bits: Int) extends Bundle { val write_addr = UFix(addr_bits, 'input); } -class rocketCAM(entries: Int, addr_bits: Int, tag_bits: Int) extends Component { +class rocketCAM(entries: Int, tag_bits: Int) extends Component { + val addr_bits = ceil(log(entries)/log(2)).toInt; val io = new ioCAM(entries, addr_bits, tag_bits); val cam_tags = Mem(entries, io.write, io.write_addr, io.write_tag); @@ -112,7 +113,7 @@ class rocketITLB(entries: Int) extends Component val lookup_tag = Cat(r_cpu_req_asid, r_cpu_req_vpn); - val tag_cam = new rocketCAM(entries, addr_bits, ASID_BITS+VPN_BITS); + val tag_cam = new rocketCAM(entries, ASID_BITS+VPN_BITS); val tag_ram = Mem(entries, io.ptw.resp_val, r_refill_waddr.toUFix, io.ptw.resp_ppn); tag_cam.io.clear := io.cpu.invalidate; @@ -204,4 +205,4 @@ class rocketITLB(entries: Int) extends Component } } } -} \ No newline at end of file +}