Skip to content

Commit cd015bb

Browse files
committed
feat: Add global settings and custom pprint method; update tests to use new pprint
1 parent ec99a32 commit cd015bb

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/main/scala/dependentChisel/global.scala

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package dependentChisel
22

3-
/* global vars */
3+
/** global and package-wide settings
4+
*
5+
* same as package object in scala 2
6+
*/
47
object global {
58
val enableWidthCheck = true
69
// val enableWidthCheck = false
@@ -12,4 +15,10 @@ object global {
1215
counter += 1
1316
counter
1417
}
18+
19+
/** my pprint, not show field names
20+
*
21+
* @param x
22+
*/
23+
def mPPrint[T](x: T) = { pprint.pprintln(x, showFieldNames = false) }
1524
}

src/test/scala/dependentChisel/astTransformSuite.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import dependentChisel.codegen.sequentialCommands.WeakStmt
2525
import dependentChisel.codegen.sequentialCommands.VarDecls
2626
import dependentChisel.codegen.sequentialCommands.Skip
2727
import dependentChisel.codegen.sequentialCommands.BoolProp
28+
import dependentChisel.global.mPPrint
2829

2930
/* more tests for parameterized mod*/
3031
class astTransformSuite extends AnyFunSuite {
@@ -33,7 +34,7 @@ class astTransformSuite extends AnyFunSuite {
3334
new adder.Adder1prop
3435
})
3536

36-
pprint.pprintln(m.moduleData.commandAsTree())
37+
mPPrint(m.moduleData.commandAsTree())
3738
val newAst =
3839
m.moduleData.transformTree { (ast: TreeNode[Ctrl | Cmds]) =>
3940
val predicate: Ctrl | Cmds => Boolean = {
@@ -44,7 +45,8 @@ class astTransformSuite extends AnyFunSuite {
4445
treeTraverse.filterTop(predicate, ast)
4546
}
4647

47-
pprint.pprintln(newAst)
48+
mPPrint(newAst)
49+
assert(newAst.children.length == 1, "filtered AST should have only 1 assertion")
4850
}
4951

5052
}

0 commit comments

Comments
 (0)