After using Verilog for a few months, I am curious what the difference is between the following:
reg [31:0] sum;
integer sum;
Since the integer is just a 32-bit value why can't you just use reg to represent it? Why might one be more efficient than the other in terms of memory usage or access time? Please let me know what you think or if you need me to expand on my question.
Example Using Integer:
integer t = 0;
always @(posedge clk) begin
if (t < 9999) t = t + 1;
else t = 0;
end
Example Using Reg:
reg[13:0] t = 14'b0; //Represent up to 16383
always @(posedge clk) begin
if (t < 9999) t = t + 14'b00000000000001;
else t = 14'b0;
end