From de26108e13acc24f0b411225f6e18cd619a57d8d Mon Sep 17 00:00:00 2001 From: Srivatsa Yogendra Date: Thu, 31 Jan 2019 13:13:27 -0800 Subject: [PATCH 1/5] adding cover points to check if each of pmp access is set --- src/main/scala/rocket/PMP.scala | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/main/scala/rocket/PMP.scala b/src/main/scala/rocket/PMP.scala index 03e1a909..65d8cdbb 100644 --- a/src/main/scala/rocket/PMP.scala +++ b/src/main/scala/rocket/PMP.scala @@ -161,6 +161,25 @@ class PMPChecker(lgMaxSize: Int)(implicit p: Parameters) extends CoreModule()(p) val hit = pmp.hit(io.addr, io.size, lgMaxSize, prevPMP) val ignore = default && !pmp.cfg.l val aligned = pmp.aligned(io.addr, io.size, lgMaxSize, prevPMP) + + cover(!default && pmp.cfg.a === 0x0, "The cfg access is set to no access", "Cover PMP access mode setting") + cover(!default && pmp.cfg.a === 0x1, "The cfg access is set to TOR access", "Cover PMP access mode setting") + cover(!default && pmp.cfg.a === 0x2, "The cfg access is set to NA4 access", "Cover PMP access mode setting") + cover(!default && pmp.cfg.a === 0x3, "The cfg access is set to NAPOT access", "Cover PMP access mode setting") + cover(!default && pmp.cfg.l === 0x1, "The cfg lock is set to high", "Cover PMP lock mode setting") + + // Not including Write and no Read permission as the combination is reserved + cover(!default && (Cat(pmp.cfg.x, pmp.cfg.w, pmp.cfg.r) === 0x0), "The permission is set to no access", "Cover PMP access permission setting") + cover(!default && (Cat(pmp.cfg.x, pmp.cfg.w, pmp.cfg.r) === 0x1), "The permission is set to Read only access", "Cover PMP access permission setting") + cover(!default && (Cat(pmp.cfg.x, pmp.cfg.w, pmp.cfg.r) === 0x3), "The permission is set to Read and Write only access", "Cover PMP access permission setting") + cover(!default && (Cat(pmp.cfg.x, pmp.cfg.w, pmp.cfg.r) === 0x4), "The permission is set to Execution only access", "Cover PMP access permission setting") + cover(!default && (Cat(pmp.cfg.x, pmp.cfg.w, pmp.cfg.r) === 0x5), "The permission is set to Read and Execution only access", "Cover PMP access permission setting") + cover(!default && (Cat(pmp.cfg.x, pmp.cfg.w, pmp.cfg.r) === 0x7), "The permission is set to Read, Write and Execution access", "Cover PMP access permission setting") + + cover(!ignore && hit && aligned && pmp.cfg.a === 0x1, "The access matches TOR mode", "Cover PMP access") + cover(!ignore && hit && aligned && pmp.cfg.a === 0x2, "The access matches NA4 mode", "Cover PMP access") + cover(!ignore && hit && aligned && pmp.cfg.a === 0x3, "The access matches NAPOT mode", "Cover PMP access") + val cur = Wire(init = pmp) cur.cfg.r := (aligned && pmp.cfg.r) || ignore cur.cfg.w := (aligned && pmp.cfg.w) || ignore From b704835189ed3a42ca0ff8dd284c145aa2ad2e7e Mon Sep 17 00:00:00 2001 From: Srivatsa Yogendra Date: Thu, 31 Jan 2019 13:59:32 -0800 Subject: [PATCH 2/5] changes made as suggested by review --- src/main/scala/rocket/PMP.scala | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/src/main/scala/rocket/PMP.scala b/src/main/scala/rocket/PMP.scala index 65d8cdbb..c9275c67 100644 --- a/src/main/scala/rocket/PMP.scala +++ b/src/main/scala/rocket/PMP.scala @@ -162,23 +162,17 @@ class PMPChecker(lgMaxSize: Int)(implicit p: Parameters) extends CoreModule()(p) val ignore = default && !pmp.cfg.l val aligned = pmp.aligned(io.addr, io.size, lgMaxSize, prevPMP) - cover(!default && pmp.cfg.a === 0x0, "The cfg access is set to no access", "Cover PMP access mode setting") - cover(!default && pmp.cfg.a === 0x1, "The cfg access is set to TOR access", "Cover PMP access mode setting") - cover(!default && pmp.cfg.a === 0x2, "The cfg access is set to NA4 access", "Cover PMP access mode setting") - cover(!default && pmp.cfg.a === 0x3, "The cfg access is set to NAPOT access", "Cover PMP access mode setting") - cover(!default && pmp.cfg.l === 0x1, "The cfg lock is set to high", "Cover PMP lock mode setting") - - // Not including Write and no Read permission as the combination is reserved - cover(!default && (Cat(pmp.cfg.x, pmp.cfg.w, pmp.cfg.r) === 0x0), "The permission is set to no access", "Cover PMP access permission setting") - cover(!default && (Cat(pmp.cfg.x, pmp.cfg.w, pmp.cfg.r) === 0x1), "The permission is set to Read only access", "Cover PMP access permission setting") - cover(!default && (Cat(pmp.cfg.x, pmp.cfg.w, pmp.cfg.r) === 0x3), "The permission is set to Read and Write only access", "Cover PMP access permission setting") - cover(!default && (Cat(pmp.cfg.x, pmp.cfg.w, pmp.cfg.r) === 0x4), "The permission is set to Execution only access", "Cover PMP access permission setting") - cover(!default && (Cat(pmp.cfg.x, pmp.cfg.w, pmp.cfg.r) === 0x5), "The permission is set to Read and Execution only access", "Cover PMP access permission setting") - cover(!default && (Cat(pmp.cfg.x, pmp.cfg.w, pmp.cfg.r) === 0x7), "The permission is set to Read, Write and Execution access", "Cover PMP access permission setting") + for ((name, idx) <- Seq("no", "TOR", "NA4", "NAPOT").zipWithIndex) + cover(!default && pmp.cfg.a === idx, "The cfg access is set to $name access ", "Cover PMP access mode setting") - cover(!ignore && hit && aligned && pmp.cfg.a === 0x1, "The access matches TOR mode", "Cover PMP access") - cover(!ignore && hit && aligned && pmp.cfg.a === 0x2, "The access matches NA4 mode", "Cover PMP access") - cover(!ignore && hit && aligned && pmp.cfg.a === 0x3, "The access matches NAPOT mode", "Cover PMP access") + cover(!default && pmp.cfg.l === 0x1, "The cfg lock is set to high ", "Cover PMP lock mode setting") + + // Not including Write and no Read permission as the combination is reserved + for ((name, idx) <- Seq("no", "RO", "", "RW", "X", "RX", "", "RWX").zipWithIndex; if name.nonEmpty) + cover(!default && (Cat(pmp.cfg.x, pmp.cfg.w, pmp.cfg.r) === idx), "The permission is set to $name access ", "Cover PMP access permission setting") + + for ((name, idx) <- Seq("", "TOR", "NA4", "NAPOT").zipWithIndex; if name.nonEmpty) + cover(!ignore && hit && aligned && pmp.cfg.a === idx, "The access matches $name mode ", "Cover PMP access") val cur = Wire(init = pmp) cur.cfg.r := (aligned && pmp.cfg.r) || ignore From 346ba318d14d0556d7ff0b03e61324fd248be328 Mon Sep 17 00:00:00 2001 From: Srivatsa Yogendra Date: Thu, 31 Jan 2019 14:26:57 -0800 Subject: [PATCH 3/5] adding the missing library --- src/main/scala/rocket/PMP.scala | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/scala/rocket/PMP.scala b/src/main/scala/rocket/PMP.scala index c9275c67..a9db1172 100644 --- a/src/main/scala/rocket/PMP.scala +++ b/src/main/scala/rocket/PMP.scala @@ -7,6 +7,7 @@ import Chisel.ImplicitConversions._ import freechips.rocketchip.config._ import freechips.rocketchip.tile._ import freechips.rocketchip.util._ +import freechips.rocketchip.util.property._ class PMPConfig extends Bundle { val l = Bool() From 2b64cbcc1486781fb3d36c74578d02d6bc5cdbe0 Mon Sep 17 00:00:00 2001 From: Srivatsa Yogendra Date: Thu, 31 Jan 2019 15:12:04 -0800 Subject: [PATCH 4/5] correcting the string passing --- src/main/scala/rocket/PMP.scala | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/scala/rocket/PMP.scala b/src/main/scala/rocket/PMP.scala index a9db1172..d85982e2 100644 --- a/src/main/scala/rocket/PMP.scala +++ b/src/main/scala/rocket/PMP.scala @@ -164,16 +164,16 @@ class PMPChecker(lgMaxSize: Int)(implicit p: Parameters) extends CoreModule()(p) val aligned = pmp.aligned(io.addr, io.size, lgMaxSize, prevPMP) for ((name, idx) <- Seq("no", "TOR", "NA4", "NAPOT").zipWithIndex) - cover(!default && pmp.cfg.a === idx, "The cfg access is set to $name access ", "Cover PMP access mode setting") + cover(!default && pmp.cfg.a === idx, s"The cfg access is set to ${name} access ", "Cover PMP access mode setting") - cover(!default && pmp.cfg.l === 0x1, "The cfg lock is set to high ", "Cover PMP lock mode setting") + cover(!default && pmp.cfg.l === 0x1, s"The cfg lock is set to high ", "Cover PMP lock mode setting") // Not including Write and no Read permission as the combination is reserved for ((name, idx) <- Seq("no", "RO", "", "RW", "X", "RX", "", "RWX").zipWithIndex; if name.nonEmpty) - cover(!default && (Cat(pmp.cfg.x, pmp.cfg.w, pmp.cfg.r) === idx), "The permission is set to $name access ", "Cover PMP access permission setting") + cover(!default && (Cat(pmp.cfg.x, pmp.cfg.w, pmp.cfg.r) === idx), s"The permission is set to ${name} access ", "Cover PMP access permission setting") for ((name, idx) <- Seq("", "TOR", "NA4", "NAPOT").zipWithIndex; if name.nonEmpty) - cover(!ignore && hit && aligned && pmp.cfg.a === idx, "The access matches $name mode ", "Cover PMP access") + cover(!ignore && hit && aligned && pmp.cfg.a === idx, s"The access matches ${name} mode ", "Cover PMP access") val cur = Wire(init = pmp) cur.cfg.r := (aligned && pmp.cfg.r) || ignore From 178a93b587e742bd4bab38051016f522fc61d93a Mon Sep 17 00:00:00 2001 From: Srivatsa Yogendra Date: Fri, 1 Feb 2019 16:21:58 -0800 Subject: [PATCH 5/5] Indenting for the loop --- src/main/scala/rocket/PMP.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/scala/rocket/PMP.scala b/src/main/scala/rocket/PMP.scala index d85982e2..c00b0f40 100644 --- a/src/main/scala/rocket/PMP.scala +++ b/src/main/scala/rocket/PMP.scala @@ -164,16 +164,16 @@ class PMPChecker(lgMaxSize: Int)(implicit p: Parameters) extends CoreModule()(p) val aligned = pmp.aligned(io.addr, io.size, lgMaxSize, prevPMP) for ((name, idx) <- Seq("no", "TOR", "NA4", "NAPOT").zipWithIndex) - cover(!default && pmp.cfg.a === idx, s"The cfg access is set to ${name} access ", "Cover PMP access mode setting") + cover(!default && pmp.cfg.a === idx, s"The cfg access is set to ${name} access ", "Cover PMP access mode setting") cover(!default && pmp.cfg.l === 0x1, s"The cfg lock is set to high ", "Cover PMP lock mode setting") // Not including Write and no Read permission as the combination is reserved for ((name, idx) <- Seq("no", "RO", "", "RW", "X", "RX", "", "RWX").zipWithIndex; if name.nonEmpty) - cover(!default && (Cat(pmp.cfg.x, pmp.cfg.w, pmp.cfg.r) === idx), s"The permission is set to ${name} access ", "Cover PMP access permission setting") + cover(!default && (Cat(pmp.cfg.x, pmp.cfg.w, pmp.cfg.r) === idx), s"The permission is set to ${name} access ", "Cover PMP access permission setting") for ((name, idx) <- Seq("", "TOR", "NA4", "NAPOT").zipWithIndex; if name.nonEmpty) - cover(!ignore && hit && aligned && pmp.cfg.a === idx, s"The access matches ${name} mode ", "Cover PMP access") + cover(!ignore && hit && aligned && pmp.cfg.a === idx, s"The access matches ${name} mode ", "Cover PMP access") val cur = Wire(init = pmp) cur.cfg.r := (aligned && pmp.cfg.r) || ignore