Below is the always block code.
I need to have same code 11 times, with same functionality but on different variables. So how can I reuse the code?
always @(posedge tconClk or negedge tconRst_n)
begin
if(~tconRst_n)
begin
pulse_cnt <= 0;
pulse_start = 0;
start_written = 0;
pulse_width <= 'h271;
end
else if(~pulse_rst)
begin
pulse_cnt <= 0;
pulse_start = 0;
end
else
begin
if(start_signal)
begin
// start_written = 0;
pulse_width <= (pulse_start) ? pulse_width : START_PW;
pulse_start = 1;
end
pulse_cnt <= (pulse_start) ? (pulse_cnt + 1) : pulse_cnt;
end
end
Naming Pattern -
tconClk,tconRst_nis common,pulse_cnt0,pulse_cnt1upto10,pulse_width0,pulse_width1upto10,pulse_start[0:10](Array),start_written[0:10](Array),pulse_rst[0:10](Array),start_signal[0:10](Array),START_PW(No pattern, different name for each 11 always blocks)
Note -
Defining macro won't work, as this code contains many verilog tokens.
I can't make module of the code, because the signals used in the always block, are also used in other part of the code. So if I make module, then I won't be able to ensure proper reg or wire connections to the module. (Like a module output port must be a wire, but that same signal has been used as a reg in other part of code)
_cnt,_start,_width) and only the prefix (pulse) changes. - Greg