EmbDev.net

Forum: FPGA, VHDL & Verilog delay not wanted vhdl


von angelo (Guest)


Rate this post
useful
not useful
Hi every one,

I'm writing a code for a dac in vhdl and I have some troubles during 
simulation: a delay appears on two signals what is not what I want...

My code:
1
library IEEE;
2
use IEEE.std_logic_1164.all;
3
use ieee.numeric_std.all;
4
5
entity dac is
6
7
  generic (data_width : integer;
8
     SDI_width  : integer;
9
     REF        : real);
10
     
11
  port(  SDI   : in  std_logic_vector (SDI_width - 1 downto 0);
12
    SDO   : out std_logic_vector(SDI_width - 1 downto 0);
13
    SCK   : in  std_logic;
14
    CLR   : in  std_logic;  -- low level active
15
    CS_LD : in  std_logic;   -- '0': CS / '1': LD
16
    LDAC  : in  std_logic;  -- low level active
17
    Vout  : out real
18
      );
19
    
20
end dac;
21
22
architecture archi of dac is  
23
24
signal data      : std_logic_vector(11 downto 0);
25
signal data_real : real;
26
27
begin
28
29
  data <= SDI(15) & SDI(14) & SDI(13) & SDI(12) & SDI(11) & SDI(10) &
30
    SDI(9) & SDI(8) & SDI(7) & SDI(6) & SDI(5) & SDI(4);    
31
  
32
  P1: process(SCK)
33
  begin
34
    
35
    data_real <= (real(to_integer(signed(data))));
36
37
    if (CLR = '0' or CS_LD = '0') then
38
    
39
      Vout <= 0.0;
40
      
41
    elsif (SCK'event and SCK = '1') then
42
      
43
      Vout <= data_real/(2.0**data_width) * REF;
44
      
45
    end if;
46
    
47
  end process;
48
  
49
      
50
end archi;

In simulation this is a delay of 5 ns on the "data_real" signal and 15 
ns on the signal "Vout".

Do you know what is wrong in my code and how to fix it please ?

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


Rate this post
useful
not useful
angelo wrote:
> In simulation this is a delay of 5 ns on the "data_real" signal and 15
> ns on the signal "Vout".
Your problem ist the wrong sensitivity list...

Try this and think about it:
1
  P1: process(SCK,data,CLR,CS_LD) ...

THis line can be shortened:
1
data <= SDI(15) & SDI(14) & SDI(13) & SDI(12) & SDI(11) & SDI(10) &
2
    SDI(9) & SDI(8) & SDI(7) & SDI(6) & SDI(5) & SDI(4);
Try it this way:
1
data <= SDI(15 downto 4);

von angelo (Guest)


Rate this post
useful
not useful
Hi,

Thank you for your answer, with all your advices the issue is 
fixed...partially.

No more delay on data_real signal, but still on Vout signal. Now it's a 
5 ns delay instead 15 ns.

Did I miss something ?

von angelo (Guest)


Rate this post
useful
not useful
Never mind, I'm just silly!

It's all good! Cheers

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


Rate this post
useful
not useful
angelo wrote:
> It's all good!
To all the others: there must be a "delay" due to the clock, obviously.

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.