EmbDev.net

Forum: FPGA, VHDL & Verilog using generate with clk


von stas (Guest)


Rate this post
useful
not useful
Hi,

I'm using generate to create 32 dff's to work as a shift register,
that part works great.
The problem is, that i want to input data only on rising edge of the 
clock,
but the actual insert takes place half clk after that.
Do i need to change the generate itself?

thx !

this is the component that activates the generate:
1
begin 
2
 
3
  dffx: for i in 1 to 31 generate
4
  
5
  lsb: if i=1 generate 
6
    dff1: dff24 port map
7
    (clk,rst,data_in,fir_array((24*i-1) downto (i-1)*24));
8
  end generate lsb;
9
   
10
   msb: if (i>1)and(i<=31) generate 
11
    dffs: dff24 port map
12
    (clk,rst,fir_array((24*(i-1)-1) downto (i-2)*24),fir_array((24*i-1) downto (i-1)*24));
13
  end generate msb;
14
    end process;
15
  end generate dffx;
this is the component that the generate use:
1
architecture beh of dff24 is
2
3
4
  begin
5
  
6
    process (clk, rst)    
7
      
8
      begin
9
        if(rst = '0') then
10
          q <= "000000000000000000000000" ;
11
      
12
        else if (rising_edge(clk)) then
13
           q <= d;
14
         end if;
15
        end if;
16
      end process;
17
      
18
  end beh;

: Edited by Moderator
von Lothar M. (Company: Titel) (lkmiller) (Moderator)


Rate this post
useful
not useful
Try that for posting VHDL code:
1
[vhdl]
2
  VHDL code
3
[/vhdl]

stas wrote:
> The problem is, that i want to input data only on rising edge of the
> clock, but the actual insert takes place half clk after that.
Which insert to what?

stas wrote:
> I'm using generate to create 32 dff's to work as a shift register,
You are using 24*32 dffs for a amazing complex looking shift register...
What do you want to get with that? What is your actual task to do?

von stas (Guest)


Rate this post
useful
not useful
1
 this is the component that activates the generate:
2
begin 
3
 
4
  dffx: for i in 1 to 31 generate
5
  
6
  lsb: if i=1 generate 
7
    dff1: dff24 port map
8
    (clk,rst,data_in,fir_array((24*i-1) downto (i-1)*24));
9
  end generate lsb;
10
   
11
   msb: if (i>1)and(i<=31) generate 
12
    dffs: dff24 port map
13
    (clk,rst,fir_array((24*(i-1)-1) downto (i-2)*24),fir_array((24*i-1) downto (i-1)*24));
14
  end generate msb;
15
    end process;
16
  end generate dffx;
17
18
19
this is the component that the generate use:
20
architecture beh of dff24 is
21
22
23
  begin
24
  
25
    process (clk, rst)    
26
      
27
      begin
28
        if(rst = '0') then
29
          q <= "000000000000000000000000" ;
30
      
31
        else if (rising_edge(clk)) then
32
           q <= d;
33
         end if;
34
        end if;
35
      end process;
36
      
37
  end beh;

the project itself is to build fir filter, this part of the project 
should only store every sample (every sample size is 24 bits and there 
are 32 samples), every rising edge i wish to insert the new sample to 
the first flipflop and move the last sample to the next.
The result would be 32 samples in 32 flipflops as the last one in is in 
the number 1 flip flop.

von Achim S. (Guest)


Rate this post
useful
not useful
So you want to store 32 samples in 32 registers, where each registers 
contains 24 Flipflops, correct?

stas wrote:
> but the actual insert takes place half clk after that.

How do you come to this conclusion? Observed by oscilloscope? Observed 
by behavioral simulation or timing simulation?

Everthing in the shown code works on the rising clk edge. So in 
behavioral simulation you should see the FFs are switching triggered by 
the rising clk edge.

But if you run timing simulation or monitor the FPGAs outputs with an 
osci, you will see the switching after some delay (cause the switching 
takes some time, the routing from the FF to the output causes some 
delay, ...). This delay might look like the switching happens at the 
falling clk edge.

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.