Chisel does not generate error if size argument is not .W in RegInit
See original GitHub issueType of issue: bug report Impact: no functional change Development Phase: request
What is the current behavior? If I instantiate a register this way :
val sizeFrame = 30
val writeFrame = RegInit(0.U(sizeFrame))
Chisel compile without problem. But the size of writeFrame register will be 1.
I think it’s a chisel bug, because width parameter must be suffixed by ‘.W’.
What is the expected behavior? In my opinion, the correct way to instantiate my register is :
val sizeFrame = 30
val writeFrame = RegInit(0.U(sizeFrame.W))
And the declaration given at the begining should generate an error.
Please tell us about your environment:
- version: 3.1.8
- OS: Linux Debian 4.9.0-9-amd64 #1 SMP Debian 4.9.168-1+deb9u5 (2019-08-11) x86_64 GNU/Linux
Issue Analytics
- State:
- Created 4 years ago
- Comments:20 (20 by maintainers)
Top Results From Across the Web
Remove implicit width truncation / Don't repeat Verilog's ...
This is one of the worst issues in Verilog and modern synthesize tools should ... Chisel does not generate error if size argument...
Read more >freechipsproject/chisel3 - Gitter
I was generating random inputs based on the bit width of the input rin . The port is defined as UInt(12.W) and it's...
Read more >How to init a register with a parametrized value - Stack Overflow
When I tried the above, I got 3 errors: [error] /Users/jack/work/chisel3-raw/src/main/scala/RegInit.scala:10:13: inferred type arguments ...
Read more >Advanced Chisel Topics
PriorityEncoder – returns the bit position of the trailing 1 in the input vector with the assumption that multiple bits of the input...
Read more >RegInit - chisel3
The single argument form uses the argument to specify both the type and reset value. For non-literal Bits, the width of the Reg...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
8.U(3)
is a huge wart that merits fixing. Removing indexing withInt
would fix it but is a pretty draconian change that would require updating a lot of code (indexing Wires, Regs and the like). There are a couple of other approaches we could do:From the example in #871
Basically, from a Scala operations point of view, it looks like a literal chained with a bit extract, which is legal and apparently in use - and which is why it’s so hard to fix.
One solution might be the use of macros (or a linter) to detect and warn on style-based anti-patterns like this. Or we might define a
.U(int)
function that is deprecated / errors and requires users to introduce parens to make chained literal - bit extract operations explicit.