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.

use rising edge and falling edge of the clock in vhdl

Status
Not open for further replies.

matin-kh

Member level 3
Joined
Nov 9, 2013
Messages
67
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
iran
Activity points
1,955
hi every one,
I want to use both edge of the clock but I have problem to develop it.
I write a simple code for the process like below to check it:

Code VHDL - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
process(x(3),res)
    begin
    if(res='1') then
        a<='0';
        b<='0';
    elsif (x(3)'event and x(3)='1') then
            a<='1';
            b<='0';
    elsif (x(3)'event and x(3)='0') then
            a<='0';
            b<='1';
    end if;
end process;


it has error, so I changed it to:

Code VHDL - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
process(x(3),res)
    begin
    if(res='1') then
        a<='0';
        b<='0';
    elsif (x(3)'event) then
                if(x(3)='1')then
            a<='1';
            b<='0';
            elsif (x(3)='0') then
            a<='0';
            b<='1';
                end if;
    end if;
end process;



i have error in that code too! I write like below:

Code VHDL - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
process(x(3),res)
    begin
    if(res='1') then
        a<='0';
        b<='0';
    elsif (x(3)'event and x(3)='1') then
        a<='1';
        b<='0';
    end if;
end process;
process(x(3),res)
    begin
    if(res='1') then
        a<='0';
        b<='0';
    elsif (x(3)'event and x(3)='0') then
        a<='0';
        b<='1';
    end if;
end process;


I have error in thatcode too!
just a process with an edge is without any error. so what should I do?
Regards
Matin
 
Last edited by a moderator:

FPGAs have very few DDR registers. They are only used for IO pins.

FPGAs have clock synthesizers (PLLs and similar) that can generate the desired 2x rate clock signals. This makes internal DDR registers and emulation of DDR registers less important in FPGA designs. It is easier to just generate the normal clock signal of 2x frequency than to deal with rising/falling edge registers and with any duty-cycle issues.

In the end, the only use for DDR registers is for IO pins. Keep in mind that for FPGA designs, the hardware already exists. A good design will be one that makes use of the FPGA resources that actually exist vs any theoretically better design that doesn't actually fit the existing tech.

I suspect the tools just flag this as an error instead of emulating it using multiple registers and a mux.
 
FPGAs have very few DDR registers. They are only used for IO pins.
The dedicated DDR input and DDR output registers aren't flip-flops clocked by both edges. They are combinations of two DFF and a mux to either split a DDR input signal into two SDR signals or combine two SDR output signals into a DDR output signal.

It's possible under circumstances to emulate a dual edge sensitive DFF by a combination of two DFF and additional logic, including latches. It's not done automatically by the synthesis tools and timing closure will difficult. So the general suggestion is: don't do it.
 
Your first two code samples do not match any flip-flop that exists and therefore won't synthesize.
The first sample responds to both edges of the clock, there is no such FF.

The second version of code responds to an edge then decides the level of that edge with a mux, that doesn't exist in the real world either, so can't be synthesized.

Finally the last one is attempting to describe a DDR FF that can only be done if the signals a and b are on an output pin of the design. If wanted an internal node with a DDR output (not recommeneded, use a 2X clock as suggested by others), then you would have to have different output signal names for a and b rising and falling outputs (e.g. a_rise, b_rise, a_fall, b_fall). Finally you use a multiplxer with the clock as the select to generate the a and b outputs.
 
  • Like
Reactions: matin-kh

    matin-kh

    Points: 2
    Helpful Answer Positive Rating
    V

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

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top