step time simulation

Guest #3622097
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?
Attached files:
Moderator (Company: Titel)
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?

Reply

A question of your own? This thread is over 12 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [vhdl]VHDL-Code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.