aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite/gna/issue1655/endat_tb.vhdl
blob: ecf4a1932b41723ca7663c1f7a16c36cca0fd9fc (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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.all;

library work;


entity ENDAT_TB is
end ENDAT_TB;


architecture BEHAVIORAL of ENDAT_TB is

  -- Component declaration
  component master
    port (	 -- local clock
 		clk: in std_logic;
 		rst: in std_logic;

 		-- generated clock for slave
		 -- fdiv divides CLK_FREQ
		 ma_fdiv: in unsigned;
		 ma_clk: out std_logic;

		 -- master out, slave in
		 mosi: out std_logic;
		 miso: in std_logic;

		 -- gate to drive output (1 to drive it)
		 gate: out std_logic;

		 -- data from slave, and data length
		 data: out std_logic_vector;
		 len: in unsigned;

		 -- encoder type
		 enc_type: in integer;

		 -- ssi specific control registers
		 ssi_flags: in std_logic_vector;
		 ssi_delay_fdiv: in unsigned
	); end component;

-- Configuration
for u_master: master use entity work.master(absenc_master_rtl);

-- Clock period
constant period: time := 10 ns;

-- Signals
signal clk, rst, ma_clk, mosi, miso, gate, down, up: std_logic;
signal cnt_out: std_logic_vector (3 downto 0);
signal ma_fdiv, ssi_delay_fdiv, len: unsigned(31 downto 0);
signal enc_type: integer;
signal data, ssi_flags: std_logic_vector(31 downto 0);

begin

  -- Instantiate counter...
  u_master : master port map (
	clk => clk,
	rst => rst,

	ma_fdiv => ma_fdiv,
	ma_clk => ma_clk,

	mosi => mosi,
	miso => miso,
	
	gate => gate,

	data => data,
	len => len,

	enc_type => enc_type,

	ssi_flags => ssi_flags,
	ssi_delay_fdiv => ssi_delay_fdiv	
    
  );

  -- Process for applying patterns
  process

    -- Helper to perform one clock cycle...
    procedure run_cycle is
    begin
      clk <= '0';
      wait for period / 2;
      clk <= '1';
      wait for period / 2;
    end procedure;

  begin
	
    -- Reset counter...
    --down <= '1'; up <= '1';
    --run_cycle;
    --assert cnt_out = "0000" report "Reset does not work";

    -- Count up and keep state...
   -- for n in 1 to 20 loop
     -- down <= '0'; up <= '1';
    --  run_cycle;
    --  assert cnt_out = std_logic_vector (to_unsigned (n mod 16, 4)) report "Counting up does not work";
    --  down <= '0'; up <= '0';
    --  run_cycle;
     -- assert cnt_out = std_logic_vector (to_unsigned (n mod 16, 4)) report "Keeping the state does not work";
   -- end loop;

    -- Count down and keep state...
   -- down <= '1'; up <= '1';
   -- run_cycle;
   -- for n in 15 downto integer(-5) loop
    --  down <= '1'; up <= '0';
     -- run_cycle;
     -- assert cnt_out = std_logic_vector (to_unsigned (n mod 16, 4)) report "Counting down does not work";
     -- down <= '0'; up <= '0';
    --  run_cycle;
    --  assert cnt_out = std_logic_vector (to_unsigned (n mod 16, 4)) report "Keeping the state does not work";
   -- end loop;

    -- Print a note & finish simulation...
   -- assert false report "Simulation finished" severity note;
   -- wait;

  end process;

end BEHAVIORAL;