Comments (14)
@shunshou Thanks I'll work my way through these
from dsptools.
@shunshou seems to me that UInt ring stuff should error on subtraction. Firrtl Spec says that UInt - UInt => SInt
but Ring says minus returns UInt. So following, where io.a and io.b are UInts
val regSubWrap = RegNext(DspContext.withOverflowType(Wrap) { io.a - io.b })
gives
firrtl.passes.CheckTypes$InvalidConnect: @[Reg.scala 14:44:@23.4]: [module OverflowTypeCircuit] Type mismatch. Cannot connect regSubGrow to _T_16.
Seems like a better error up front, saying to cast to SInt would be more reasonable
from dsptools.
This is maybe where @grebe states his opinion. Inside the Ring (so the user doesn't have to do it), we can do an explicit cast back to UInt. I think the types should frankly stay consistent w/ their input types (no surprises!).
from dsptools.
@shunshou @grebe Something like this then?
override def minus(f: UInt, g: UInt): UInt = {
val diff = context.overflowType match {
case Grow => f.asSInt -& g.asSInt
case Wrap => f.asSInt -% g.asSInt
case _ => throw DspException("Saturating subtractor hasn't been implemented")
}
ShiftRegister(diff.asUInt, context.numAddPipes)
}
from dsptools.
I'm fine with that. @grebe?
from dsptools.
@shunshou @grebe So with above logic subtracting 4-bit UInts from each other gives
15 - 1 => 30
Is that ok?
from dsptools.
Oh for wrap it should be trimmed back to 4 bits. I thought that that was the whole point of -% ?
from dsptools.
Is there no -% on UInt that returns a 4 bit UInt (or SInt that should then be cast as UInt)? b/c if so, IMO, that functionality isn't "Wrap"
from dsptools.
Also, re -&, what should be the behavior? That's one of those weird cases where, to always be mathematically correct, you should convert to an SInt... Or in that case, should you only make guarantees on outputs when they're >=0? @grebe ?
from dsptools.
Sorry, I fell very behind on my github mentions. I think we agreed to throw an exception for -&
from dsptools.
@shunshou So what is
io.sAbsWrap := DspContext.withOverflowType(Wrap) { io.sIn.abs() }
Supposed to do for an SInt(4.W) with value -8
from dsptools.
I believe it'll be -8, right? Wrap has 0 guarantees on mathematical correctness, and is just intended to do whatever the standard bit operation does. You'd have a separate function that might pull it to 7 or something. Or maybe Wrap is a bad descriptor? @grebe, opinions?
from dsptools.
from dsptools.
Reiterating what I said in the new issue -- test that a sequence of typeclass ops handles dspcontext correctly (i.e. does some op, b/c of the way it's implemented, make you lose the Real/Ring, etc. context).
from dsptools.
Related Issues (20)
- dsptools/blob/master/rocket/README.md links not working
- DspComplex[T].zero not initialized HOT 1
- Instantiating constants of type DspComplex[DspReal] HOT 7
- Compilation fails in scala 2.12.8 HOT 2
- Pokeable Typeclasses for Testers HOT 1
- Remove updateDependencies script
- Document Width Relationships for Operations
- Add -D flag for rocket source dependency
- Is there any plan to update the SAM module? HOT 1
- Issue with TileLink ready-valid logic in TLMasterModel HOT 2
- Run-time failures for DspComplex isLit()
- Read the docs
- rocket-dsptools DmaSpec test failure with current rocket-chip
- Working with large FixedPoint and Intervals should use BigDecimal not Double
- Set precision in div2 fixedpoint and interval may have provblems
- Update the link to numeric classes description HOT 2
- Failing Tests on 3.4.1 HOT 1
- example code not working
- Library conflict HOT 1
- Arithmetic between types
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dsptools.