Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Synthesizability of a code

Status
Not open for further replies.

fragnen

Full Member level 3
Full Member level 3
Joined
Apr 3, 2019
Messages
168
Helped
0
Reputation
0
Reaction score
1
Trophy points
18
Activity points
1,229
Is the following code synthesizable? If not, why? Here f(sig_a) if a logical function of sig_a and g(sig_b) is another logical function of sig_b. Here sig_a and sig_b are either wire or reg.

always (posedge sig_a or sig_b or negedge reset)
if (!reset)
out<=1'b0;
else if (enable1)
out<=f(sig_a);
else if (enable2)
out<=g(sig_b);
 

barry

Advanced Member level 7
Advanced Member level 7
Joined
Mar 31, 2005
Messages
6,062
Helped
1,178
Reputation
2,368
Reaction score
1,339
Trophy points
1,393
Location
California, USA
Activity points
32,974
Not synthesizable because you’re missing an “@“.

but why dont you just try and synthesize it; that would be more educational than somebody just telling you.
 
Last edited:

danadakk

Advanced Member level 5
Advanced Member level 5
Joined
Mar 26, 2018
Messages
2,372
Helped
358
Reputation
734
Reaction score
538
Trophy points
113
Activity points
10,372
Being a newbee I would be fishing around for where the "@" goes....something like this

always @(posedge Clk or negedge Reset) or

always @(posedge Clk or negedge Reset) begin
.
.
.
end


Regards, Dana
 

barry

Advanced Member level 7
Advanced Member level 7
Joined
Mar 31, 2005
Messages
6,062
Helped
1,178
Reputation
2,368
Reaction score
1,339
Trophy points
1,393
Location
California, USA
Activity points
32,974
Being a newbee I would be fishing around for where the "@" goes....something like this

always @(posedge Clk or negedge Reset) or

always @(posedge Clk or negedge Reset) begin
.
.
.
end


Regards, Dana
There’s no ”fishing around“ required. There are tons and tons and tons and tons and tons and tons of information on the internet and in bookstores and in libraries about verilog. If you don’t even know the most absolutely fundamental aspects of it, I suggest you start by reading something.
 

danadakk

Advanced Member level 5
Advanced Member level 5
Joined
Mar 26, 2018
Messages
2,372
Helped
358
Reputation
734
Reaction score
538
Trophy points
113
Activity points
10,372
There’s no ”fishing around“ required. There are tons and tons and tons and tons and tons and tons of information on the internet and in bookstores and in libraries about verilog. If you don’t even know the most absolutely fundamental aspects of it, I suggest you start by reading something.
Thanks, quite aware of that, been doing youtube videos and some basic Verilog. I have
been programming since 1970 and have many languages rattling around in my head so
always classify myself as a newbee.

My comment to OP was more in case he was newcomer and thought an answer
to his question with example might help.

Regards, Dana.
 

FvM

Super Moderator
Staff member
Advanced Member level 7
Joined
Jan 22, 2008
Messages
51,209
Helped
14,651
Reputation
29,580
Reaction score
13,795
Trophy points
1,393
Location
Bochum, Germany
Activity points
292,720
The Verilog language specification doesn't enclose specific synthesis rules. Synthesizability of a Verilog description depends on hardware properties. Respectively you'd ask if the code is synthesizable for a specific FPGA family or ASIC library.

To understand, if the post#1 code snippet can be meaningful Verilog, we need to see the definition of included functions. The already mentioned syntax error has to be corrected of course.

At first sight, I don't recognize meaningful Verilog.
 

ads-ee

Super Moderator
Staff member
Advanced Member level 7
Joined
Sep 10, 2013
Messages
7,941
Helped
1,822
Reputation
3,654
Reaction score
1,807
Trophy points
1,393
Location
USA
Activity points
60,176
Is the following code synthesizable? If not, why? Here f(sig_a) if a logical function of sig_a and g(sig_b) is another logical function of sig_b. Here sig_a and sig_b are either wire or reg.

always (posedge sig_a or sig_b or negedge reset)
if (!reset)
out<=1'b0;
else if (enable1)
out<=f(sig_a);
else if (enable2)
out<=g(sig_b);
I don't think this code is synthesizable as the code does not match any kind of synchronous or asynchronous coding template that a synthesizer would recognize.

always @(posedge sig_a or sig_b or negedge reset)

an always block that contains posedge xxxx is used to describe a FF the additional negedge/posedge signal that follows will implement an asynchronous set/reset when used in an if statement. The additional sig_b does not match any description of a FF and will probably cause the synthesis to fail.

Besides this the sig_a is used as a combinational input to a function, which is not going to synthesize a FF.


Code Verilog - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// FF
always @(posedge clk)
 
// FF with async reset
always @(posedge clk or negedge reset)
  if (!reset)
  else
 
// FF with sync reset
always @(posedge clk)
  if (!reset)
  else
 
// combitnational logic
always @(*)

 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top