Hi,
First, thanks for sharing these useful learning materials so much!
I notice some typos and hope you can double check them:
1 For the "Bit#(2) d = x[i:i-1]; // OK, fixed-size and fixed-value slice",
should the "x[i:i-1]" be "x[fixed_i:fixed_i-1]"?
2 In the section "Concatenating Bits",
"Bit#(2) a = 2'b11; Bit#(3) b = 3'b001;" are defined, but then "x" and "y" are used. So I guess the definitions should be "Bit#(2) x = 2'b11; Bit#(3) y = 3'b001;", right?
3 In the section "Case",
should "x = xval3 if (switch!=val1) && (switch!=val2)" be "x = xval3 if (switch!=val1) && (switch!=val2) && (switch!=val3)"?
4 In the section "Note on Calling Functions",
For the statement "to be explained in the next function", should it be "to be explained in the next section"?
5 In the section "Module",
should the statement "and the some new values" be "and then some new values"?
I also have several questions and will appreciate it if you are willing to answer them.
1 According to the section "Tuples", it seems that it is not allowed to update/modify a field of a tuple, right? In other words, "tuple's field assignment" is not allowed. If we want to do so, we have to use struct instead, right?
2 Is it true that the numeric type must be constant value (or fixed value)?
For example, for the "n" in the "Bit#(n)", it must be predefined (say "typedef 3 n") or passed as a module/interface parameter as a constant.
I tried the following code with "n" being a variable and they can be compiled successfully.
"Bit#(3) n = 10; Bit#(n) x = 0;"
"Bit#(3) n = r; Bit#(n) x = 0;" (here r is a Reg#(Bit#(8)) variable and its value is known in the runtime)
3 Can a function accept a Reg#(type) argument and/or return a Reg#(type)? I guess not?
4 In the section "For loops", by saying "it just becomes a hard-coded constant for each iteration of the loop.", I guess here the "hard-coded constant" should be 4 according to the above example, right?
5 According to the section "Note on Calling Functions", using many functions calls will definitely occupy too much hardware resource. So doing so may not be a good coding habit ?
6 In the section "Instantiating Internal State",
For the statement "For registers that store data, we often can just not specify an initial value (as this results in less hardware).", why does doing so result in less hardware? Could you please explain more about this? I'm interested in it! Thanks!
7 In the section "Vectors",
If we want to initialize the "Vector#(5, Reg#(Bit#(n))) myVec1" with "0, 1, 2, 3, 4", how can we do so?
Some other comments:
Thanks to this document, I know so many bitwise operation functions in the section "Other Bit Functions", which I think are really useful in some areas (like compression/decompression).
Finally, I thank this document again and look forward to your kind reply and advice!
Hi,
First, thanks for sharing these useful learning materials so much!
I notice some typos and hope you can double check them:
1 For the "Bit#(2) d = x[i:i-1]; // OK, fixed-size and fixed-value slice",
should the "x[i:i-1]" be "x[fixed_i:fixed_i-1]"?
2 In the section "Concatenating Bits",
"Bit#(2) a = 2'b11; Bit#(3) b = 3'b001;" are defined, but then "x" and "y" are used. So I guess the definitions should be "Bit#(2) x = 2'b11; Bit#(3) y = 3'b001;", right?
3 In the section "Case",
should "x = xval3 if (switch!=val1) && (switch!=val2)" be "x = xval3 if (switch!=val1) && (switch!=val2) && (switch!=val3)"?
4 In the section "Note on Calling Functions",
For the statement "to be explained in the next function", should it be "to be explained in the next section"?
5 In the section "Module",
should the statement "and the some new values" be "and then some new values"?
I also have several questions and will appreciate it if you are willing to answer them.
1 According to the section "Tuples", it seems that it is not allowed to update/modify a field of a tuple, right? In other words, "tuple's field assignment" is not allowed. If we want to do so, we have to use struct instead, right?
2 Is it true that the numeric type must be constant value (or fixed value)?
For example, for the "n" in the "Bit#(n)", it must be predefined (say "typedef 3 n") or passed as a module/interface parameter as a constant.
I tried the following code with "n" being a variable and they can be compiled successfully.
"Bit#(3) n = 10; Bit#(n) x = 0;"
"Bit#(3) n = r; Bit#(n) x = 0;" (here r is a Reg#(Bit#(8)) variable and its value is known in the runtime)
3 Can a function accept a Reg#(type) argument and/or return a Reg#(type)? I guess not?
4 In the section "For loops", by saying "it just becomes a hard-coded constant for each iteration of the loop.", I guess here the "hard-coded constant" should be 4 according to the above example, right?
5 According to the section "Note on Calling Functions", using many functions calls will definitely occupy too much hardware resource. So doing so may not be a good coding habit ?
6 In the section "Instantiating Internal State",
For the statement "For registers that store data, we often can just not specify an initial value (as this results in less hardware).", why does doing so result in less hardware? Could you please explain more about this? I'm interested in it! Thanks!
7 In the section "Vectors",
If we want to initialize the "Vector#(5, Reg#(Bit#(n))) myVec1" with "0, 1, 2, 3, 4", how can we do so?
Some other comments:
Thanks to this document, I know so many bitwise operation functions in the section "Other Bit Functions", which I think are really useful in some areas (like compression/decompression).
Finally, I thank this document again and look forward to your kind reply and advice!