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.

VHDL equivalent of Verilog code

Status
Not open for further replies.

hareeshP

Member level 3
Joined
Jul 19, 2017
Messages
59
Helped
1
Reputation
2
Reaction score
1
Trophy points
8
Activity points
491
Hi,
please anyone post the vhdl equivalent of the following verilog code,

Code Verilog - [expand]
1
always @(posedge ifc_clk or negedge pon_rst_n or posedge rst_hold_f)

[/syntax]
Thanks
 

TrickyDicky

Advanced Member level 5
Joined
Jun 7, 2010
Messages
7,082
Helped
2,078
Reputation
4,173
Reaction score
2,034
Trophy points
1,393
Activity points
39,298
difficult without the rest of the code, but probably something like this:


Code VHDL - [expand]
1
2
3
4
5
6
7
8
9
10
process(ifc_clk, pon_rst_n, rst_hold_f)
begin
  if pon_rst_n = '0' then
  -- reset 1
  elsif rst_hold_f = '1' then
  --reset 2
  elsif rising_edge(ifc_clk) then
    --synchronous code
 end if;
end process;



Pretty basic stuff...
 

hareeshP

Member level 3
Joined
Jul 19, 2017
Messages
59
Helped
1
Reputation
2
Reaction score
1
Trophy points
8
Activity points
491
the code is given below

Code Verilog - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
always @(posedge ifc_clk or negedge pon_rst_n or posedge rst_hold_f)
begin
    if(!pon_rst_n )
    begin
        x1<= 0;
        x2 <= 0;
        x3<= 0;
        x4 <= 0;
        x5<= 0;
        x6 <= 0;        
        x7 <= 0;
        x8<= 0;
        end



- - - Updated - - -

In this code if anyone of the signal (ifc_clk, pon_rst_n, pon_rst_n) changes, the rest of the code will executes
is that right?
 

TrickyDicky

Advanced Member level 5
Joined
Jun 7, 2010
Messages
7,082
Helped
2,078
Reputation
4,173
Reaction score
2,034
Trophy points
1,393
Activity points
39,298
This cant be the whole code, as this just shows a reset.
Your assertion is partially correct, but it will only trigger on the edges specified in the eventControl statement ( the @ ).
 

dpaul

Advanced Member level 5
Joined
Jan 16, 2008
Messages
1,535
Helped
307
Reputation
614
Reaction score
308
Trophy points
1,373
Location
Germany
Activity points
11,425
In this code if anyone of the signal (ifc_clk, pon_rst_n, pon_rst_n) changes, the rest of the code will executes is that right?

Yes, that's how sensitivity list works.
 

hareeshP

Member level 3
Joined
Jul 19, 2017
Messages
59
Helped
1
Reputation
2
Reaction score
1
Trophy points
8
Activity points
491
This cant be the whole code, as this just shows a reset.
Your assertion is partially correct, but it will only trigger on the edges specified in the eventControl statement ( the @ ).
You are right, this is just a part of the code. and i want the equivalent in vhdl .

- - - Updated - - -

difficult without the rest of the code, but probably something like this:


Code VHDL - [expand]
1
2
3
4
5
6
7
8
9
10
process(ifc_clk, pon_rst_n, rst_hold_f)
begin
  if pon_rst_n = '0' then
 
  elsif rst_hold_f = '1' then
 
  elsif rising_edge(ifc_clk) then
 
 end if;
end process;



Pretty basic stuff...

What happens if i put

Code VHDL - [expand]
1
2
3
4
5
6
7
8
if rising_edge(ifc_clk) then
 
  elsif pon_rst_n = '0' then
 
  elsif  rst_hold_f = '1' then
 
 end if;
end process;

 

TrickyDicky

Advanced Member level 5
Joined
Jun 7, 2010
Messages
7,082
Helped
2,078
Reputation
4,173
Reaction score
2,034
Trophy points
1,393
Activity points
39,298
Then you have made an asynchronous reset from the verilog code into a synchronous one in VHDL.
 

hareeshP

Member level 3
Joined
Jul 19, 2017
Messages
59
Helped
1
Reputation
2
Reaction score
1
Trophy points
8
Activity points
491
Then you have made an asynchronous reset from the verilog code into a synchronous one in VHDL.
That's all i want. but when i simulate the below code it is showing some error

Code VHDL - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity t1024_1 is 
port(clk,pon_rst_n: in std_logic;  
        ifc: out std_logic);
end t1024_1;
architecture behav of t1024_1 is
begin
    process(clk,pon_rst_n )
begin
  if (rising_edge(clk)) then 
    elsif pon_rst_n = '1' then
     ifc<= '1';
     else 
     ifc<= '0';
 end if;
end process;
end behav;



Error (10818): Can't infer register for "ifc" at test4.vhd(12) because it does not hold its value outside the clock edge.
 

FvM

Super Moderator
Staff member
Joined
Jan 22, 2008
Messages
48,938
Helped
14,337
Reputation
28,938
Reaction score
13,084
Trophy points
1,393
Location
Bochum, Germany
Activity points
282,362
I would prefer to see the original Verilog code to check, if it's synthesizable at all. Otherwise, it would be pointless to convert it to VHDL.

Take care that there can be only one truely edge sensitive condition in the always block. It's clear so far that pon_rst is an asynchronous (level sensitive) condition, but because you didn't show the other code, the nature of rst_hold is unclear.

Error (10818): Can't infer register for "ifc" at test4.vhd(12) because it does not hold its value outside the clock edge.
A typical non-synthesizable construct. Try to follow the template suggested by TrickyDicky: Asynchronous conditions first else rising_edge()...
 

hareeshP

Member level 3
Joined
Jul 19, 2017
Messages
59
Helped
1
Reputation
2
Reaction score
1
Trophy points
8
Activity points
491
please anyone give me the vhdl equivalent of above code.
 

CataM

Advanced Member level 4
Joined
Dec 23, 2015
Messages
1,275
Helped
314
Reputation
628
Reaction score
312
Trophy points
83
Location
Madrid, Spain
Activity points
8,417
Take care that there can be only one truely edge sensitive condition in the always block. It's clear so far that pon_rst is an asynchronous (level sensitive) condition
I know that only one truely edge sensitive condition can be implemented in an always block/process, but why ? One can have multiple clocks.. how do you manage a code which needs to handle multiple clocks?
 

TrickyDicky

Advanced Member level 5
Joined
Jun 7, 2010
Messages
7,082
Helped
2,078
Reputation
4,173
Reaction score
2,034
Trophy points
1,393
Activity points
39,298
I know that only one truely edge sensitive condition can be implemented in an always block/process, but why ? One can have multiple clocks.. how do you manage a code which needs to handle multiple clocks?

This is just a limitation of FPGA hardware - Registers only have a single clock input. In Asic, multiple clocks per register may be possible if you're using technology that supports it.
In a design with multiple clock domains, no registers ever need multiple clocks.
 
  • Like
Reactions: CataM

    CataM

    Points: 2
    Helpful Answer Positive Rating

ads-ee

Super Moderator
Staff member
Joined
Sep 10, 2013
Messages
7,848
Helped
1,815
Reputation
3,640
Reaction score
1,778
Trophy points
1,393
Location
USA
Activity points
59,287
please anyone give me the vhdl equivalent of above code.

You mean for this code?
the code is given below

Code Verilog - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
always @(posedge ifc_clk or negedge pon_rst_n or posedge rst_hold_f)
begin
    if(!pon_rst_n )
    begin
        x1<= 0;
        x2 <= 0;
        x3<= 0;
        x4 <= 0;
        x5<= 0;
        x6 <= 0;        
        x7 <= 0;
        x8<= 0;
        end



In this code if anyone of the signal (ifc_clk, pon_rst_n, pon_rst_n) changes, the rest of the code will executes
is that right?


Code VHDL - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
process (ifc_clk, pon_rst_n, rst_hold_f)
begin
  if (pon_rst_n = '0') then
    x1 <= '0';
    x2 <= '0';
    x3 <= '0';
    x4 <= '0';
    x5 <= '0';
    x6 <= '0';
    x7 <= '0';
    x8 <= '0';
-- you didn't specify the rst_hold_f in the above code, so I'm not including it here
-- basically you didn't ask a good question
  elsif rising_edge(ifc_clk) then
    -- synchronous code
  end if;
end process;

 

FvM

Super Moderator
Staff member
Joined
Jan 22, 2008
Messages
48,938
Helped
14,337
Reputation
28,938
Reaction score
13,084
Trophy points
1,393
Location
Bochum, Germany
Activity points
282,362
This is just a limitation of FPGA hardware - Registers only have a single clock input. In Asic, multiple clocks per register may be possible if you're using technology that supports it.
In a design with multiple clock domains, no registers ever need multiple clocks.
There's no commonly agreed syntax to model a register with multiple clocks in Verilog. In the usual Verilog register modeling template, there can be only one final else statement which "specifies the synchronous logic part of the design" (IEEE 1364.1-2002).

Although 1364.1 isn't part of the recent IEEE 1800 System Verilog standard, it hasn't been replaced by a new RTL synthesis specification. Please correct me, if you know a commonly agreed Verilog Syntax for registers with multiple clocks.

In more practical regard, I understand that the thread is about FPGA synthesis, so registers with multiple clocks aren't an option.
 
  • Like
Reactions: CataM

    CataM

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top