i have a verilog code in which there is a line as follows:
parameter ADDR_WIDTH = 8 ;
parameter RAM_DEPTH = 1 << ADDR_WIDTH;
here what will be stored in RAM_DEPTH
and what does the <<
operator do here.
This question is related to
operator-keyword
verilog
<<
is the left-shift operator, as it is in many other languages.
Here RAM_DEPTH
will be 1
left-shifted by 8 bits
, which is equivalent to 2^8
, or 256
.
1 << ADDR_WIDTH
means 1 will be shifted 8 bits to the left and will be assigned as the value for RAM_DEPTH
.
In addition, 1 << ADDR_WIDTH
also means 2^ADDR_WIDTH.
Given ADDR_WIDTH = 8
, then 2^8 = 256
and that will be the value for RAM_DEPTH
Source: Stackoverflow.com