chisel-tutorial
chisel-tutorial copied to clipboard
Incorrect description of shift operators in Chisel Tutorial
trafficstars
Section 5.1 of tutorial describes Fill(), >> and << using undefined functions maxNum(n) and minNum(n)
Chisel CheatSheet for Chisel 2.2 described this operations as one would expect:
z = x << n ; wz = wx + n
z = x >> n ; wz = wx - n
z = Fill(n, x) ; wz = wx*n
Then there are dynamic shifts, which take variable as argument.
z = x << y ; wz = wx + maxVal(y)
z = x >> y ; wz = wx - minVal(y)
They are also correctly described in Chisel CheatSheet for Chisel 2.2 (with definition of maxVal(y) and minVal(y)) But strangely dynamic shifts got omitted in Chisel Tutorial 3.0
Because of all above it is unclear from tutorial how >> and << work.
And if you go to chisel3.core.Bits you will find that >> and << return same width as left side argument. So correct description is none above, but:
z = x << y ; wz = wx
z = x >> y ; wz = wx