summaryrefslogtreecommitdiff
path: root/2004/n/fpga/src/pwm/tb_toppwm3.vhd
blob: 5775d18d17dd4007cfb9e54c753f51c366ef0c1e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
--simulation sur 82 ms environ
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_arith.all;
use IEEE.std_logic_unsigned.all;
library work;
library synopsys;
use synopsys.bv_arithmetic.all;

--ENTITY
entity tb_toppwm3 is
end tb_toppwm3;

--ARCHITECTURE
architecture sim1 of tb_toppwm3 is
  component toppwm3
   port(
   	RST	:in std_logic;
	CLK	:in std_logic;
	DATA	:in std_logic_vector (7 downto 0);
	OUTPWM	:out std_logic
   );      
 end component;
-- declaration des signaux
signal RST : std_logic;
signal CLK : std_logic:='0';
signal DATA: std_logic_vector (7 downto 0);

signal OUTPWM: std_logic;

--CONSTANT
--constant ENVLP_PERIOD : time := 20 ms;
--constant DATA_MAX : integer := 15;
--constant CLK_PERIOD : time := (ENVLP_PERIOD/DATA_MAX);
--constant CLK1_FREQ	:integer:= 30E+6;--car freq de 30MHz
--constant tcmax		:integer:= 600E3; 
--constant seconde	:time  	:= 1 sec;
--constant CLK_PERIOD 	:time	:= (seconde/CLK1_FREQ) ;

--constant CLK1US_PERIOD	:time:= 992 ns;
--constant tcmax		:integer:= 20161;  --pour le clk1us
constant CLK_PERIOD 	:time	:= 32 ns ;

  
--MAP
        begin
        U1toppwm3: toppwm3 port map (
          RST=>RST,
          CLK=>CLK,
          DATA=>DATA,
          OUTPWM=>OUTPWM
	);

-- STIMULI
	RST <= '1','0' after(CLK_PERIOD/6);
	clk<= not clk after (CLK_PERIOD/2);

	data<="00000011", "00011001" after 17 ms,  --0 25
         -- "00000000", "00011001" after 17 ms,  --0 25
          "00000000" after 38 ms,       -- 0 
          "11111111" after 58 ms,       -- 255 
          "01111111" after 78 ms;             -- 127

        --"00000000", "00011001" after ((tcmax*CLK1US_PERIOD)-(CLK1US_PERIOD/6)),
        --"00000000" after (2*(tcmax*CLK1US_PERIOD)-(CLK1US_PERIOD/6)),
        --"11111111" after (3*(tcmax*CLK1US_PERIOD)-(CLK1US_PERIOD/6)),
        --"00011100" after (4*(tcmax*CLK1US_PERIOD)-(CLK1US_PERIOD/6));

        --"00000000",--10
             -- "01100101" after 25 ms,--5
             -- "00000000" after 30 ms,--v�rifier que cette donn�e est bien perdue
            --  "11111111" after 38 ms,
            --  "00100000" after 50 ms;
end sim1;

--CONFIGURATION
configuration cfg_tb_toppwm3 of tb_toppwm3 is
  for sim1
 --  for U1toppwm3 : toppwm3 use entity work.toppwm3(RTL);end for;
   for all : toppwm3 use entity work.toppwm3(RTL);end for;
end for;
end cfg_tb_toppwm3;