EmbDev.net

Forum: FPGA, VHDL & Verilog step time simulation


von angelo (Guest)


Attached files:

Rate this post
useful
not useful
Hi all,

I'm stuck on a simple issue but can't get out of it: I would like to 
generate severals waveform signals for my future testbench but the 
frequency of my signals are not correct.

Below is the code I want to simulate:
1
library ieee;
2
use ieee.std_logic_1164 .all;
3
use ieee.std_logic_arith.all;
4
use ieee.std_logic_unsigned.all;
5
use ieee.math_real.all;
6
7
entity triangle_generator is
8
9
 generic(AMP: real;
10
  OFFSET: real;
11
  FREQ: real;
12
  PHASE :real);
13
 
14
 port(wave1: out real);
15
       
16
end triangle_generator;
17
18
architecture archi of triangle_generator is
19
20
signal tmp1 : real := 0.0;
21
22
23
begin
24
25
 P1:process
26
 
27
 constant delta   : real := 1000.0e-12;
28
 constant fin  : time := 1000 ps;
29
 
30
 variable angle   : real := 0.0;
31
 variable t    : real := 0.0;
32
 variable PHASE_RAD : real := 0.0;
33
 
34
 begin
35
 
36
   PHASE_RAD := (math_2_pi * PHASE)/360.0;
37
38
  loop
39
   angle   := math_2_pi * FREQ * t;
40
   t := t + delta;
41
   
42
   tmp1 <= OFFSET+(AMP/2.0)*(2.0/math_pi)*arcsin(sin(angle));
43
44
   wait for fin;
45
  
46
  end loop;
47
  
48
  wait;
49
  
50
 end process P1;
51
 
52
 wave1 <= tmp1;
53
 
54
end archi;

When I simule this code with FREQ=100 000 000 Hz I get the waveform in 
attachment, not really what I wanted. So I was thinking, if I write 
delta = 1000.0e-15 maybe it will be right, but absolutly not. When I 
change the value of delta, the frequency of the waveform is wrong.

So can you help me to get through this please?

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


Rate this post
useful
not useful
angelo wrote:
> When I change the value of delta, the frequency of the waveform is
> wrong.
You are turning the wrong screw...

Think about this:
1
 constant fin  : time := 1000 ps;
2
 :
3
     wait for fin;
What is the cycle time of 100MHz?
How many 1ns steps will fit in 10ns?
Do you find any coincidence with your screenshot?

von angelo (Guest)


Rate this post
useful
not useful
Hi! Thanks! Your advices help me a lot.

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.