cc7d167852ab062340e6f51ee96b7886d7982251
[c4m-jtag.git] / test / vhdl / ghdl / idcode / idcode.vhdl
1 -- reset JTAG interface and then IDCODE should be shifted out
2
3 library ieee;
4 use ieee.std_logic_1164.ALL;
5
6 use work.c4m_jtag.ALL;
7
8 entity bench_idcode is
9 end bench_idcode;
10
11 architecture rtl of bench_idcode is
12 signal TCK: std_logic;
13 signal TMS: std_logic;
14 signal TDI: std_logic;
15 signal TDO: std_logic;
16 signal TRST_N: std_logic;
17
18 constant CLK_PERIOD: time := 10 ns;
19
20 procedure ClkCycle(
21 signal CLK: out std_logic;
22 CLK_PERIOD: time
23 ) is
24 begin
25 CLK <= '0';
26 wait for CLK_PERIOD/4;
27 CLK <= '1';
28 wait for CLK_PERIOD/2;
29 CLK <= '0';
30 wait for CLK_PERIOD/4;
31 end ClkCycle;
32
33 procedure ClkCycles(
34 N: integer;
35 signal CLK: out std_logic;
36 CLK_PERIOD: time
37 ) is
38 begin
39 for i in 1 to N loop
40 ClkCycle(CLK, CLK_PERIOD);
41 end loop;
42 end ClkCycles;
43 begin
44 JTAG_BLOCK: c4m_jtag_tap_controller
45 -- Use default values
46 port map (
47 TCK => TCK,
48 TMS => TMS,
49 TDI => TDI,
50 TDO => TDO,
51 TRST_N => TRST_N,
52 RESET => open,
53 CAPTURE => open,
54 SHIFT => open,
55 UPDATE => open,
56 IR => open,
57 CORE_OUT => "0",
58 CORE_IN => open,
59 CORE_EN => "0",
60 PAD_OUT => open,
61 PAD_IN => "0",
62 PAD_EN => open
63 );
64
65 SIM: process
66 begin
67 -- Reset
68 TCK <= '0';
69 TMS <= '1';
70 TDI <= '0';
71 TRST_N <= '0';
72 wait for 10*CLK_PERIOD;
73
74 TRST_N <= '1';
75 wait for CLK_PERIOD;
76
77 -- Enter RunTestIdle
78 TMS <= '0';
79 ClkCycle(TCK, CLK_PERIOD);
80 -- Enter SelectDRScan
81 TMS <= '1';
82 ClkCycle(TCK, CLK_PERIOD);
83 -- Enter Capture
84 TMS <= '0';
85 ClkCycle(TCK, CLK_PERIOD);
86 -- Enter Shift, run for 35 CLK cycles
87 TMS <= '0';
88 ClkCycles(35, TCK, CLK_PERIOD);
89 -- Enter Exit1
90 TMS <= '1';
91 ClkCycle(TCK, CLK_PERIOD);
92 -- Enter Update
93 TMS <= '1';
94 ClkCycle(TCK, CLK_PERIOD);
95 -- To TestLogicReset
96 TMS <= '1';
97 ClkCycles(4, TCK, CLK_PERIOD);
98
99 -- end simulation
100 wait;
101 end process;
102 end rtl;