dsptools
dsptools copied to clipboard
PaperProject Details
Branches
project | branch |
---|---|
firrtl | intervals |
chisel3 | interval-type-2 |
firrtl-interpreter | instrumenting-sizes |
Branches I'm using (based off the above):
Branches
project | branch |
---|---|
firrtl | intervals-oct |
chisel3 | interval-oct |
firrtl-interpreter | ??? |
@chick can you make sure ops like the ones in https://github.com/ucb-bar/dsptools/tree/master/src/main/scala/dsptools/numbers are also supported? i.e. <<, >> not implemented:
scala.NotImplementedError: an implementation is missing [info] at scala.Predef$.$qmark$qmark$qmark(Predef.scala:225) [info] at chisel3.internal.firrtl.IntervalRange.$less$less(IR.scala:359)
Working on it. Is there general agreement on what it means. I would guess for shift that:
- Shifts the point of Closed and Open and BinaryPoint by the shift amount
- UnknownBounds and BinaryPoint remain unchanged.
And what about merge. Not mentioned in Wikipedia Intervals My instinct would be:
- increase the bounds of the interval with the smaller binary point so it matches the binary point of the larger
- min of lows
- max of uppers
- All this when defined.
Or maybe more naively
- Low is min of bounds if defined, unknown otherwise
- Upper is max of bounds if defined, unknown otherwise
- max of binary point
@shunshou , @azidar @grebe Your thoughts?
So two things:
-
We need to look at how Adam's firrtl code does this -- probably would be useful to have Adam document user-facing features; or that might already be in his tests.
-
For dsptools:
a >> n Arithmetic shift right where n is either Int or UInt Note: precision loss will result since the decimal point location is not adjusted
AND
a.div2(n) a/2^n UInt: Consistent with a >> n (i.e. rounds 1/2 to 0) SInt: Round output to nearest SInt via DspContext.trimType FixedPoint: Adjusts decimal point; up to you how much precision to keep via DspContext.trimType and DspContext.binaryPointGrowth (adds more fractional bits on top of the input amount) For both FixedPoint and SInt, again, be aware of overflow behavior when RoundHalfUp is used for the most positive input
^ Both should be eventually supported (but not necessarily in Chisel; can be in dsptools).
What is merge?
It seems like, for example, with multiply, you were intending to have firrtl infer everything if uninferred i.e. maybe the naive approach?
Are we going at this expecting that Chisel basically should have no knowledge of intervals besides the ones that are user assigned and letting firrtl take care of pretty much everything?
Also, fyi, I pushed more changes to aforementioned branches to fix some bugs.
I added the unimplemented shift functions IntervalRange and Interval. I need to add more tests but I wanted to get the implementations out there first. I left merge() in as unimplemented. Not sure what it is intended for.
And yes, I believe @azidar thought the naive approach of anything not simple with intervals should be deferred to Firrtl as best for now.
Ok then beyond that, the ops that should take precedence are clip, wrap, etc. (overflow behavior and truncation/round, etc.). After that, I think we're good for being able to try some more complicated legitimate hardware...
I will also add some tests... (but in my FFT repo for now)
Here are the ops Adam checked in IntervalMathSpec:
+
*
-
>, >=, <, <=, ===, =/=
>> int
<< int
<< uint
>> uint
[]()
arith assign?
cat
Is cat something built into the type in Chisel or an external helper? o_O Otherwise, assuming the dynamic/static shifts work, I think we've covered all of our bases there.
And as far as the rest of Adam's non-math tests, really it's:
Cannot defined unknown BP for interval (Chisel restriction) -- just my note
wrap clip
Is there a setBinaryPoint equivalent for Interval? That might be more necessary for stuff like rounding ops.
I can't find a reference to merge in our doc. @chick, your instinct matches mine, but I'm still trying to think of why it would be useful.
@shunshou @azidar are there any explicit docs on clip, wrap, etc. I am working from what I can see in intervals-oct, but any other materials would be useful
@shunshou I've pushed naive wrap and clip to chisel3 intervals-oct, they don't really figure anything out right now. just make things Unknown so firrtl can figure it all out. I need to talk to Adam to proceed on this.
Also I did not see a problem with running the interpreter's instrumenting-sizes branch with the intervals-oct branches of firrtl and chisel3, if you have an example can you pass it to me
Yeah, so Adam's super busy this week--he asked to reschedule our meeting (will send out an email shortly), but if he has a few minutes to meet with you tomorrow to discuss next steps, that'd be great. The one thing I'd like to see is being able to do clip based off of some other signal's range * # of loops, as an example, to handle: multiply by a constant and accumulate. I'll test firrtl-interpreter again with various branches and copy+paste the error I get in a few minutes.
Also, are you on the same branch of chisel-testers/dsptools as I am? Note: the last working verison of firrtl-interpreter is 5dd2f5b When I switch over to firrtl-interpreter/instrumenting-sizes, and I try to re-publish-local chisel-testers with hash cb82340, I get:
[error] /Users/angie.wang/Chisel3FFAST/Chisel3DSPDependencies/chisel-testers/src/main/scala/chisel3/iotesters/Driver.scala:130: type mismatch;
[error] found : optionsManager.type (with underlying type chisel3.iotesters.ReplOptionsManager)
[error] required: firrtl_interpreter.InterpreterOptionsManager with firrtl_interpreter.HasReplConfig
[error] FirrtlRepl.execute(optionsManager)
[error] ^
[error] /Users/angie.wang/Chisel3FFAST/Chisel3DSPDependencies/chisel-testers/src/main/scala/chisel3/iotesters/Driver.scala:130: type mismatch;
[error] found : optionsManager.type (with underlying type chisel3.iotesters.ReplOptionsManager)
[error] required: firrtl_interpreter.InterpreterOptionsManager with firrtl_interpreter.HasReplConfig
[error] FirrtlRepl.execute(optionsManager)
[error] ^
[error] /Users/angie.wang/Chisel3FFAST/Chisel3DSPDependencies/chisel-testers/src/main/scala/chisel3/iotesters/FirrtlTerpBackend.scala:14: type mismatch;
[error] found : chisel3.iotesters.TesterOptionsManager
[error] required: firrtl_interpreter.HasInterpreterSuite
[error] val interpretiveTester = new InterpretiveTester(firrtlIR, optionsManager)
[error] ^
[error] /Users/angie.wang/Chisel3FFAST/Chisel3DSPDependencies/chisel-testers/src/main/scala/chisel3/iotesters/FirrtlTerpBackend.scala:14: type mismatch;
[error] found : chisel3.iotesters.TesterOptionsManager
[error] required: firrtl_interpreter.HasInterpreterSuite
[error] val interpretiveTester = new InterpretiveTester(firrtlIR, optionsManager)
If you are on a better version of chisel-testers (and corresponding dsptools), please let me know!
@azidar all the wrap cases I did made sense except for
val base = Wire(Interval(range"[-4, 6]"))
val disjointRight = Wire(Interval(range"[7,11]"))
val w6 = base.wrap(disjointRight)
assert(w6 === 10.I()) // FAILS says it should be 6.U
// even though derived interval is disjointRight Closed(7) Closed(11)
Any ideas
Before you delve too deep into this, as a basic use case, I just want to see that val base = Wire(Interval(range"[0, 9]")) val out = base.wrap(range"[0,7]") base := 9.I --> out == 1.I without any mux logic. That's the most common use-case for wrap. Does that work?
@shunshou I'll need to change chisel-testers to fix its publishLocal problems with the instrumenting-sizes branch of firrtl-interpreter. Can there be a intervals-oct branch of chisel-testers that I can make my changes in. I'm not sure what to do with cb82340
yea go for it--make a branch and i'll point my stuff to it. thanks!! :D
@shunshou pushed my latest wrap stuff to intervals-oct. This includes wrap(that: IntervalRange)
which lets you say myInterval.wrap(range"[-4, 11)")
if you are inclined to say such things
Will try to do clip next
@shunshou just pushed intervals-oct branch with interpreter fixes for instrumenting-sizes branch. It's based on the cb82340 (I hope that's ok) this builds for me, hope it works for you
Hmm... I get Can you report latest hashes of everything so I can double check?
] Executing in batch mode.
[warn] For better performance, hit [ENTER] to switch to interactive mode, or
[warn] consider launching sbt without any commands, or explicitly passing 'shell'
[info] Loading project definition from /Users/angie.wang/Chisel3FFAST/Chisel3DSPDependencies/chisel-testers/project
[info] Set current project to Chisel.iotesters (in build file:/Users/angie.wang/Chisel3FFAST/Chisel3DSPDependencies/chisel-testers/)
[info] Packaging /Users/angie.wang/Chisel3FFAST/Chisel3DSPDependencies/chisel-testers/target/scala-2.11/chisel-iotesters_2.11-1.2-SNAPSHOT-sources.jar ...
[info] Done packaging.
[info] Main Scala API documentation to /Users/angie.wang/Chisel3FFAST/Chisel3DSPDependencies/chisel-testers/target/scala-2.11/api...
[info] Wrote /Users/angie.wang/Chisel3FFAST/Chisel3DSPDependencies/chisel-testers/target/scala-2.11/chisel-iotesters_2.11-1.2-SNAPSHOT.pom
[info] :: delivering :: edu.berkeley.cs#chisel-iotesters_2.11;1.2-SNAPSHOT :: 1.2-SNAPSHOT :: integration :: Mon Oct 16 21:58:03 PDT 2017
[info] delivering ivy file to /Users/angie.wang/Chisel3FFAST/Chisel3DSPDependencies/chisel-testers/target/scala-2.11/ivy-1.2-SNAPSHOT.xml
[info] Compiling 20 Scala sources to /Users/angie.wang/Chisel3FFAST/Chisel3DSPDependencies/chisel-testers/target/scala-2.11/classes...
[error] /Users/angie.wang/Chisel3FFAST/Chisel3DSPDependencies/chisel-testers/src/main/scala/chisel3/iotesters/ChiselPokeSpec.scala:15: type mismatch;
[error] found : options.type (with underlying type chisel3.iotesters.TesterOptionsManager)
[error] required: chisel3.iotesters.TesterOptionsManager with firrtl_interpreter.HasInterpreterSuite
[error] setupFirrtlTerpBackend(dutGen, options)
[error] ^
[error] /Users/angie.wang/Chisel3FFAST/Chisel3DSPDependencies/chisel-testers/src/main/scala/chisel3/iotesters/ChiselPokeSpec.scala:15: type mismatch;
[error] found : options.type (with underlying type chisel3.iotesters.TesterOptionsManager)
[error] required: chisel3.iotesters.TesterOptionsManager with firrtl_interpreter.HasInterpreterSuite
[error] setupFirrtlTerpBackend(dutGen, options)
[error] ^
[error] /Users/angie.wang/Chisel3FFAST/Chisel3DSPDependencies/chisel-testers/src/main/scala/chisel3/iotesters/Driver.scala:51: type mismatch;
[error] found : optionsManager.type (with underlying type chisel3.iotesters.TesterOptionsManager)
[error] required: chisel3.iotesters.TesterOptionsManager with firrtl_interpreter.HasInterpreterSuite
[error] setupFirrtlTerpBackend(dutGenerator, optionsManager)
[error] ^
[error] /Users/angie.wang/Chisel3FFAST/Chisel3DSPDependencies/chisel-testers/src/main/scala/chisel3/iotesters/Driver.scala:60: type mismatch;
[error] found : Any
[error] required: chisel3.iotesters.Backend
[error] backendVar.withValue(Some(backend)) {
[error] ^
[error] /Users/angie.wang/Chisel3FFAST/Chisel3DSPDependencies/chisel-testers/src/main/scala/chisel3/iotesters/Driver.scala:62: type mismatch;
[error] found : dut.type (with underlying type Any)
[error] required: T
[error] testerGen(dut).finish
[error] ^
[error] /Users/angie.wang/Chisel3FFAST/Chisel3DSPDependencies/chisel-testers/src/main/scala/chisel3/iotesters/Driver.scala:130: type mismatch;
[error] found : optionsManager.type (with underlying type chisel3.iotesters.ReplOptionsManager)
[error] required: firrtl_interpreter.InterpreterOptionsManager with firrtl_interpreter.HasReplConfig
[error] FirrtlRepl.execute(optionsManager)
[error] ^
[error] /Users/angie.wang/Chisel3FFAST/Chisel3DSPDependencies/chisel-testers/src/main/scala/chisel3/iotesters/Driver.scala:51: type mismatch;
[error] found : optionsManager.type (with underlying type chisel3.iotesters.TesterOptionsManager)
[error] required: chisel3.iotesters.TesterOptionsManager with firrtl_interpreter.HasInterpreterSuite
[error] setupFirrtlTerpBackend(dutGenerator, optionsManager)
[error] ^
[error] /Users/angie.wang/Chisel3FFAST/Chisel3DSPDependencies/chisel-testers/src/main/scala/chisel3/iotesters/Driver.scala:60: type mismatch;
[error] found : Any
[error] required: chisel3.iotesters.Backend
[error] backendVar.withValue(Some(backend)) {
[error] ^
[error] /Users/angie.wang/Chisel3FFAST/Chisel3DSPDependencies/chisel-testers/src/main/scala/chisel3/iotesters/Driver.scala:62: type mismatch;
[error] found : dut.type (with underlying type Any)
[error] required: T
[error] testerGen(dut).finish
[error] ^
[error] /Users/angie.wang/Chisel3FFAST/Chisel3DSPDependencies/chisel-testers/src/main/scala/chisel3/iotesters/Driver.scala:130: type mismatch;
[error] found : optionsManager.type (with underlying type chisel3.iotesters.ReplOptionsManager)
[error] required: firrtl_interpreter.InterpreterOptionsManager with firrtl_interpreter.HasReplConfig
[error] FirrtlRepl.execute(optionsManager)
[error] ^
[error] /Users/angie.wang/Chisel3FFAST/Chisel3DSPDependencies/chisel-testers/src/main/scala/chisel3/iotesters/FirrtlTerpBackend.scala:12: type mismatch;
[error] found : chisel3.iotesters.TesterOptionsManager
[error] required: chisel3.iotesters.TesterOptionsManager with firrtl_interpreter.HasInterpreterSuite
[error] optionsManager: TesterOptionsManager with HasInterpreterSuite = new TesterOptionsManager)
[error] ^
[error] /Users/angie.wang/Chisel3FFAST/Chisel3DSPDependencies/chisel-testers/src/main/scala/chisel3/iotesters/FirrtlTerpBackend.scala:106: type mismatch;
[error] found : chisel3.iotesters.TesterOptionsManager
[error] required: chisel3.iotesters.TesterOptionsManager with firrtl_interpreter.HasInterpreterSuite
[error] optionsManager: TesterOptionsManager with HasInterpreterSuite = new TesterOptionsManager): (T, Backend) = {
[error] ^
[error] /Users/angie.wang/Chisel3FFAST/Chisel3DSPDependencies/chisel-testers/src/main/scala/chisel3/iotesters/FirrtlTerpBackend.scala:12: type mismatch;
[error] found : chisel3.iotesters.TesterOptionsManager
[error] required: chisel3.iotesters.TesterOptionsManager with firrtl_interpreter.HasInterpreterSuite
[error] optionsManager: TesterOptionsManager with HasInterpreterSuite = new TesterOptionsManager)
[error] ^
[error] /Users/angie.wang/Chisel3FFAST/Chisel3DSPDependencies/chisel-testers/src/main/scala/chisel3/iotesters/FirrtlTerpBackend.scala:106: type mismatch;
[error] found : chisel3.iotesters.TesterOptionsManager
[error] required: chisel3.iotesters.TesterOptionsManager with firrtl_interpreter.HasInterpreterSuite
@shunshou just pushed clip (saturate) operator for intervals BTW Aaaargh, on weird errors with testers, I'll try to reproduce
Thx! Finally have a ~10 pg outline of the ~6 pg paper. :P Will look into this after I'm done drafing background + intro hopefully...
Hmnm, I am building with (cd firrtl ; git status | grep 'On branch') On branch intervals-oct (cd firrtl-interpreter ; git status | grep 'On branch') On branch instrumenting-sizes (cd chisel3 ; git status | grep 'On branch') On branch intervals-oct (cd chisel-testers ; git status | grep 'On branch') On branch intervals-oct (cd dsptools ; git status | grep 'On branch') On branch master
@chick, I'm still getting:
error] /Users/angie.wang/Chisel3FFAST/Chisel3DSPDependencies/chisel-testers/src/main/scala/chisel3/iotesters/ChiselPokeSpec.scala:15: type mismatch;
[error] found : options.type (with underlying type chisel3.iotesters.TesterOptionsManager)
[error] required: chisel3.iotesters.TesterOptionsManager with firrtl_interpreter.HasInterpreterSuite
[error] setupFirrtlTerpBackend(dutGen, options)
[error] ^
[error] /Users/angie.wang/Chisel3FFAST/Chisel3DSPDependencies/chisel-testers/src/main/scala/chisel3/iotesters/ChiselPokeSpec.scala:15: type mismatch;
[error] found : options.type (with underlying type chisel3.iotesters.TesterOptionsManager)
[error] required: chisel3.iotesters.TesterOptionsManager with firrtl_interpreter.HasInterpreterSuite
[error] setupFirrtlTerpBackend(dutGen, options)
[error] ^
[error] /Users/angie.wang/Chisel3FFAST/Chisel3DSPDependencies/chisel-testers/src/main/scala/chisel3/iotesters/Driver.scala:51: type mismatch;
[error] found : optionsManager.type (with underlying type chisel3.iotesters.TesterOptionsManager)
[error] required: chisel3.iotesters.TesterOptionsManager with firrtl_interpreter.HasInterpreterSuite
[error] setupFirrtlTerpBackend(dutGenerator, optionsManager)
[error] ^
[error] /Users/angie.wang/Chisel3FFAST/Chisel3DSPDependencies/chisel-testers/src/main/scala/chisel3/iotesters/Driver.scala:60: type mismatch;
[error] found : Any
[error] required: chisel3.iotesters.Backend
[error] backendVar.withValue(Some(backend)) {
[error] ^
[error] /Users/angie.wang/Chisel3FFAST/Chisel3DSPDependencies/chisel-testers/src/main/scala/chisel3/iotesters/Driver.scala:62: type mismatch;
[error] found : dut.type (with underlying type Any)
[error] required: T
[error] testerGen(dut).finish
[error] ^
[error] /Users/angie.wang/Chisel3FFAST/Chisel3DSPDependencies/chisel-testers/src/main/scala/chisel3/iotesters/Driver.scala:130: type mismatch;
[error] found : optionsManager.type (with underlying type chisel3.iotesters.ReplOptionsManager)
[error] required: firrtl_interpreter.InterpreterOptionsManager with firrtl_interpreter.HasReplConfig
[error] FirrtlRepl.execute(optionsManager)
[error] ^
[error] /Users/angie.wang/Chisel3FFAST/Chisel3DSPDependencies/chisel-testers/src/main/scala/chisel3/iotesters/Driver.scala:51: type mismatch;
[error] found : optionsManager.type (with underlying type chisel3.iotesters.TesterOptionsManager)
[error] required: chisel3.iotesters.TesterOptionsManager with firrtl_interpreter.HasInterpreterSuite
[error] setupFirrtlTerpBackend(dutGenerator, optionsManager)
[error] ^
[error] /Users/angie.wang/Chisel3FFAST/Chisel3DSPDependencies/chisel-testers/src/main/scala/chisel3/iotesters/Driver.scala:60: type mismatch;
[error] found : Any
[error] required: chisel3.iotesters.Backend
[error] backendVar.withValue(Some(backend)) {
[error] ^
[error] /Users/angie.wang/Chisel3FFAST/Chisel3DSPDependencies/chisel-testers/src/main/scala/chisel3/iotesters/Driver.scala:62: type mismatch;
[error] found : dut.type (with underlying type Any)
[error] required: T
[error] testerGen(dut).finish
[error] ^
[error] /Users/angie.wang/Chisel3FFAST/Chisel3DSPDependencies/chisel-testers/src/main/scala/chisel3/iotesters/Driver.scala:130: type mismatch;
[error] found : optionsManager.type (with underlying type chisel3.iotesters.ReplOptionsManager)
[error] required: firrtl_interpreter.InterpreterOptionsManager with firrtl_interpreter.HasReplConfig
[error] FirrtlRepl.execute(optionsManager)
with the branches you've pointed me to :(
Still trying to get this Maybe now (had to push to interpreter and testers) firrtl 3abda10e5e82b481f58c73adf26c48678e496574 firrtl-interpreter 4f0c623ad03b1b7f5c484aa99575ea324d8cdfbd chisel3 14cc99a8880ba2ee735f888cec70c7cc99235a4b chisel-testers 496bd86063b9a47a0bb13264068efdf94bd98a66
Yay looks like i was able to sbt publish-local everything this time around, but dsptools still needs editing :( --
(When I run FFT-local tests):
java.lang.NoSuchMethodError: firrtl_interpreter.InterpreterOptions.copy(ZZZZZJLscala/collection/Seq;JZZ)Lfirrtl_interpreter/InterpreterOptions;
at dsptools.Driver$$anonfun$execute$1.apply$mcZ$sp(Driver.scala:27)
at dsptools.Driver$$anonfun$execute$1.apply(Driver.scala:26)
at dsptools.Driver$$anonfun$execute$1.apply(Driver.scala:26)
at scala.util.DynamicVariable.withValue(DynamicVariable.scala:58)
at dsptools.Driver$.execute(Driver.scala:26)
at dsptools.intervals.tests.BasicIASpec$$anonfun$2.apply(BasicIA.scala:134)
at dsptools.intervals.tests.BasicIASpec$$anonfun$2.apply(BasicIA.scala:135)
at org.scalatest.OutcomeOf$class.outcomeOf(OutcomeOf.scala:85)
at org.scalatest.OutcomeOf$.outcomeOf(OutcomeOf.scala:104)
at org.scalatest.Transformer.apply(Transformer.scala:22)
at org.scalatest.Transformer.apply(Transformer.scala:20)
at org.scalatest.FlatSpecLike$$anon$1.apply(FlatSpecLike.scala:1682)
at org.scalatest.TestSuite$class.withFixture(TestSuite.scala:196)
at org.scalatest.FlatSpec.withFixture(FlatSpec.scala:1685)
at org.scalatest.FlatSpecLike$class.invokeWithFixture$1(FlatSpecLike.scala:1679)
at org.scalatest.FlatSpecLike$$anonfun$runTest$1.apply(FlatSpecLike.scala:1692)
at org.scalatest.FlatSpecLike$$anonfun$runTest$1.apply(FlatSpecLike.scala:1692)
at org.scalatest.SuperEngine.runTestImpl(Engine.scala:289)
at org.scalatest.FlatSpecLike$class.runTest(FlatSpecLike.scala:1692)
at org.scalatest.FlatSpec.runTest(FlatSpec.scala:1685)
at org.scalatest.FlatSpecLike$$anonfun$runTests$1.apply(FlatSpecLike.scala:1750)
at org.scalatest.FlatSpecLike$$anonfun$runTests$1.apply(FlatSpecLike.scala:1750)
at org.scalatest.SuperEngine$$anonfun$traverseSubNodes$1$1.apply(Engine.scala:396)
at org.scalatest.SuperEngine$$anonfun$traverseSubNodes$1$1.apply(Engine.scala:384)
at scala.collection.immutable.List.foreach(List.scala:381)
at org.scalatest.SuperEngine.traverseSubNodes$1(Engine.scala:384)
@shunshou What's the branch of dsptools
I assumed you were on master, so I switched to that (but that's probably just not compatible w/ old stuff...).