Y
Yang Luo
Guest
Now I'm writing some rtl code, there are some written styles puzzle me. Can you give me some advise?
I'm translating an algorithm into atl and making an ASIC. I'm very worry about whether the code I written can be sythesised using EDA tools.
There are some code block like this:
2.parameter BIT_WIDTH = 8;
parameter BUFF_LENGTH = 16;
input [BIT_WIDTH-1:0] i_data;
reg [BIT_WIDTH-1:0] s_data_buff [BUFF_LENGTH-1:0];
integer i;
2.1
always @(posedge clk or negedge rst_n)
if (!rst_n) begin
for(i=0; i< BUFF_LENGTH; i=i+1)s_data_buff <= #1 {BIT_WIDTH{1'd0}};
end
else begin
s_data_buff[0] <= #1 i_data;
for(i=0; i< BUFF_LENGTH-1;i=i+1)s_data_buff[i+1] <= #1 s_data_buff;
end
2.2
wire [3:0] w_buff_length;//0--15
always @(posedge clk or negedge rst_n)
if (!rst_n) begin
for(i=0; i< w_buff_length; i=i+1)s_data_buff <= #1 {BIT_WIDTH{1'd0}};
end
else begin
s_data_buff[0] <= #1 i_data;
for(i=0; i< w_buff_length-1;i=i+1)s_data_buff[i+1] <= #1 s_data_buff;
end
Are the two styles both good? I know that DC can synthesis the first style, because the array index is a const number. Can EDA tools synthesis the second style(I used a wire variable as index)?
3.Can the 2d array be synthesised using EDA tools in verilog? like this:
reg [BIT_WIDTH-1:0] s_data_buff2d [BUFF_LENGTH-1:0]BUFF_LENGTH-1:0];
I'm translating an algorithm into atl and making an ASIC. I'm very worry about whether the code I written can be sythesised using EDA tools.
There are some code block like this:
2.parameter BIT_WIDTH = 8;
parameter BUFF_LENGTH = 16;
input [BIT_WIDTH-1:0] i_data;
reg [BIT_WIDTH-1:0] s_data_buff [BUFF_LENGTH-1:0];
integer i;
2.1
always @(posedge clk or negedge rst_n)
if (!rst_n) begin
for(i=0; i< BUFF_LENGTH; i=i+1)s_data_buff <= #1 {BIT_WIDTH{1'd0}};
end
else begin
s_data_buff[0] <= #1 i_data;
for(i=0; i< BUFF_LENGTH-1;i=i+1)s_data_buff[i+1] <= #1 s_data_buff;
end
2.2
wire [3:0] w_buff_length;//0--15
always @(posedge clk or negedge rst_n)
if (!rst_n) begin
for(i=0; i< w_buff_length; i=i+1)s_data_buff <= #1 {BIT_WIDTH{1'd0}};
end
else begin
s_data_buff[0] <= #1 i_data;
for(i=0; i< w_buff_length-1;i=i+1)s_data_buff[i+1] <= #1 s_data_buff;
end
Are the two styles both good? I know that DC can synthesis the first style, because the array index is a const number. Can EDA tools synthesis the second style(I used a wire variable as index)?
3.Can the 2d array be synthesised using EDA tools in verilog? like this:
reg [BIT_WIDTH-1:0] s_data_buff2d [BUFF_LENGTH-1:0]BUFF_LENGTH-1:0];