EDAboard.com | EDAboard.de | EDAboard.co.uk | WTWH Media

[discuss] verilog code to synthesis

Ask a question - edaboard.com

elektroda.net NewsGroups Forum Index - Verilog Language - [discuss] verilog code to synthesis

Yang Luo
Guest

Mon Mar 14, 2016 1:27 pm   



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[i] <= #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[i];
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[i] <= #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[i];
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];

Mark Curry
Guest

Tue Mar 15, 2016 10:22 pm   



In article <983d44ac-903a-4f88-aba2-f5c6f82b3821_at_googlegroups.com>,
Yang Luo <youngluoyang_at_gmail.com> wrote:
Quote:
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[i] <= #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[i];
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[i] <= #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[i];
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)?


For loops must be (in software terms) "unrolled" at elaboration time during
synthesis. So for your second case to work, firstly, "w_buff_length" must be a constant
at elaboration time. Secondly, even if it was a constant at elaboration time, the
tool would have to support this type of "unrolling". I'm doubtful any synthesis
tools would succeed on the second point. I'd think they'd flag an error.

Quote:
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];


All synthesis tools (that I've used) can handle 2-d arrays fine. Are you asking
about a 3-d array? (Your example seems to imply two "unpacked" dimensions.) I'm
unsure on Synthesis support (under verilog-2001) for this. It WOULD work fine
by turning on SystemVerilog support under your tool.

May I also suggest training yourself to NOT use #delays within
synthesizable code. They're entirely unneccesary, and often seen as a
crutch for new users. They're not harmful, and can make viewing waveforums
easier for new users. But are generally avoided by most users.

Regards,

Mark

Yang Luo
Guest

Sun Mar 20, 2016 11:05 am   



在 2016年3月16日星期三 UTC+8上午4:25:27,Mark Curry写道:
Quote:
In article <983d44ac-903a-4f88-aba2-f5c6f82b3821_at_googlegroups.com>,
Yang Luo <youngluoyang_at_gmail.com> wrote:
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[i] <= #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[i];
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[i] <= #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[i];
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)?

For loops must be (in software terms) "unrolled" at elaboration time during
synthesis. So for your second case to work, firstly, "w_buff_length" must be a constant
at elaboration time. Secondly, even if it was a constant at elaboration time, the
tool would have to support this type of "unrolling". I'm doubtful any synthesis
tools would succeed on the second point. I'd think they'd flag an error.

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];

Yes, this 3d array can not synthesis using DC2010. I tested using such example:
integer i,j;
always@(posedge clk or negedge rst_n)
if(!rst_n)begin
for (i=0;i<BUFF_LENGTH;i=i+1)
for (j=0;j<BUFF_LENGTH;j=j+1)
s_data_buff2d [i][j]<=0;
end
....
when synthesis, it will give an error that index i or j over BUFF_LENGTH.
Quote:

All synthesis tools (that I've used) can handle 2-d arrays fine. Are you asking
about a 3-d array? (Your example seems to imply two "unpacked" dimensions..) I'm
unsure on Synthesis support (under verilog-2001) for this. It WOULD work fine
by turning on SystemVerilog support under your tool.

May I also suggest training yourself to NOT use #delays within
synthesizable code. They're entirely unneccesary, and often seen as a
crutch for new users. They're not harmful, and can make viewing waveforums
easier for new users. But are generally avoided by most users.
#delay is not my style.

Regards,

Mark



Guest

Sat Oct 14, 2017 3:57 am   



hello, in my opinion, I think you should try to think how your code will be synthesized to what kind of difital circuits, it is more helpful for you, sometimes the synthesizer maybe not easy to P&R, so the result is not as your thought.


Guest

Sat Oct 14, 2017 4:17 am   



I am not prefer to use for loop in verilog language.

elektroda.net NewsGroups Forum Index - Verilog Language - [discuss] verilog code to synthesis

Ask a question - edaboard.com

Arabic version Bulgarian version Catalan version Czech version Danish version German version Greek version English version Spanish version Finnish version French version Hindi version Croatian version Indonesian version Italian version Hebrew version Japanese version Korean version Lithuanian version Latvian version Dutch version Norwegian version Polish version Portuguese version Romanian version Russian version Slovak version Slovenian version Serbian version Swedish version Tagalog version Ukrainian version Vietnamese version Chinese version Turkish version
EDAboard.com map