Reputation: 313
I try to code floating adder; https://github.com/ElectronNest/FPU/blob/master/FloatAdd.scala This is half way.
The normalization is huge code part, so I would like to use for-loop or some equivalent representation method. Is it possible to use loop or we need strict coding?
Best, S.Takano
Upvotes: 1
Views: 328
Reputation: 6064
Welcome and thank you for your interest in Chisel!
I would like to echo Chick's suggestion to start from something small that compiles and simulates and build up from there. In particular, the linked code above conflates some Scala vs. Chisel constructs (eg. Scala's if
else
, vs. Chisel's when
, .elsewhen
, .otherwise
), as well as some Verilog vs. Chisel concepts (eg. bit indexing with [high:low]
vs. Chisel's (high, low)
)
In case you haven't seen it, I would suggest taking a look at the Chisel Bootcamp which helps explain how to use constructs like for
loops to generate hardware.
I'll also plug my own responses to this question on the chisel-users mailing list where I tried to explain some of the intuition behind writing Chisel generators, including differentiating if
and when
and using for
loops.
Upvotes: 0
Reputation: 4051
This is a very general and large question. The equivalent of a for loop in hardware can be implemented using a number of techniques, pretty much all of them involving registers to hold state information. Looking at your code I would suggest that you start a little smaller and work on syntax, I see many syntax errors currently. I use IntelliJ community edition as an editor because it does a great job with helping to get the code properly structured. I also would strongly recommend starting from the chisel-template repository. It has the proper layout and examples of a working circuit and unit testing harness. Then start with a smaller implementation that does something simple like just pass input to output and runs in a test harness, then slowly build up the circuit to achieve your goals.
Good luck!
Upvotes: 1