Comments (6)
Hi,
Why should it be 1 bits ? the value zero is "nothing" "non" "nada", it doesn't need any space to be encoded. B(0) mean a binary value loaded with the integer value zero.
If you want to exprime a single bit literal value you have multiple choose :
B"0" which explicitly exprime a binary value (ex : B"10101010")
Else there True and False to Bool.
Basicaly SpinalHDL integrate a compilation phase which is able to remove all zero wire signals. So having a zero bits value isn't realy a problem.
from spinalhdl.
Ahhh yeah i think this is it,
B(0) isn't the same than B"0", as the first is to give an Bits literal loaded with an integer, while the second one is to get a Bits literal loaded with an explicit binary value
Seem ok ?
from spinalhdl.
Hi Dolu,
sorry for the delayed response.
"nothing" "non" "nada" doesn't need any space to be encoded -> agreed
Zero is none of them, it is a number which represents "nothing" as a quantity.
Zero, IMHO, has the same dignity and rights of other numbers and carries the "zero" information, that's why I would expect B(0) to return a 1-bit bit vector; 0-bits do not carry any information.
Anyway, now I think I understand your point: the width of B(n) is the smallest width sufficient to host all the 1 present in the binary representation of n. Since the binary representation of 0 doesn't contain any bit at 1, B(0) returns a bit vector of 0 bits. Is this what you mean?
I think it is a matter of taste. I'm not saying that B(0) returning bit vector of 0 bits is wrong. Personally, I would expect it returning at least 1 bit, since 0 bits can't carry any information.
Seeing B(0) returning a bit vector of 0 bits was looking strange to me, that's the reason why I opened this ticket.
from spinalhdl.
The thing is that there is many case where via components parameters, you endup with unecessary logic if you aren't doing it that way. For instance a burst counter could be to count from zero to parameterX, and when this parameterX is zero, then you don't need any bit for the counter and the U(parameterX)
Zero width wire support is realy something that can be usefull to avoid defining useless logic.
Then if you want to explicitly define a Bits value of 1 bit set to zero, you can use :
B"0"
B(0, 1 bits)
Does that make sense ?
from spinalhdl.
Anyway, now I think I understand your point: the width of B(n) is the smallest width sufficient to host all the 1 present in the binary representation of n. Since the binary representation of 0 doesn't contain any bit at 1, B(0) returns a bit vector of 0 bits. Is this what you mean?
Yes kind of, it is also the beaviour of the log2up function, which return how many bits i need to encode N states. Very often in VHDL/Verilog, this function is implemented to have a bias and return 1 bits for both 0 and 1 values.
Imagine you have an array of signals, but this array only contain one element, then how many bit you need to access it => zero bits, => myArray(U(0)) is fine, because currently U(0) return zero bits.
from spinalhdl.
It makes sense, thanks for the clarification.
Furthermore I agree that in many cases you want to express the width of a bit vector explicitly.
Also, it is good that log2up(0) returns 0.
I don't have any further comment from my side. I think the ticket can be closed if you also don't have any additional comment/observation.
Cheers
from spinalhdl.
Related Issues (20)
- The signals in the toplevel port of a Verilog module should be explicitly given a net-type. HOT 4
- Expected HW when doing `/=` assign to Reg HOT 2
- the issues of tester's sim HOT 7
- tester version conflict in scala 2.12 but not 2.11. HOT 12
- how to drive inout IO ?for example i2c HOT 2
- XSim on Windows : getting it to work as expected through cmd or MSYS2(MINGW64) HOT 33
- 『Requirement And Idea』SpinalHDL generated verilog code parameterization and generate block simplification requirements. HOT 13
- Ability to specify path to make binary HOT 6
- Bad interaction between Bits.aliasAs and Data.as HOT 2
- How to understand the Simulated behavior in SpinalHDL? HOT 4
- spinal.lib.misc.pipeline refractoring
- SpinalConfig.generate does not work as expected When define two modules with implicit parameter in "generate" func HOT 7
- Axi4Stream: userWidth tied to dataWidth HOT 5
- Implicit parity signal in Bundle, freeze, and signalCache HOT 7
- Arbitrary data bundle type for Axi4Stream HOT 8
- Blackbox Verilog sources are not included in formal verification
- Vec as packed array in io HOT 9
- Issues with verilator 5 HOT 2
- Documentation / example usage for `Axi4ReadOnlyMasterAgent` and `Axi4WriteOnlyMasterAgent` HOT 5
- Signals in simulation pruned HOT 2
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 spinalhdl.