a8c4ac995da3a787e3a75d10e94bf47018defa81
[c4m-jtag.git] / c4m / vhdl / jtag / c4m_jtag_idblock.vhdl
1 -- The JTAG id and bypass handling block
2
3 library ieee;
4 use ieee.std_logic_1164.ALL;
5
6 use work.c4m_jtag.ALL;
7
8 entity c4m_jtag_idblock is
9 generic (
10 IR_WIDTH: integer := 2;
11
12 MANUFACTURER: std_logic_vector(10 downto 0) := "10001111111";
13 PART_NUMBER: std_logic_vector(15 downto 0) := "0000000000000001";
14 VERSION: std_logic_vector(3 downto 0) := "0000"
15 );
16 port (
17 -- needed TAP signals
18 TCK: in std_logic;
19 TDI: in std_logic;
20 TDO: out std_logic;
21 TDO_EN: out std_logic := '0';
22
23 -- The instruction
24 IR: in std_logic_vector(IR_WIDTH-1 downto 0);
25
26 -- actions
27 CAPTURE: in std_logic;
28 SHIFT: in std_logic;
29 UPDATE: in std_logic
30 );
31 end c4m_jtag_idblock;
32
33 architecture rtl of c4m_jtag_idblock is
34 constant IDCODE: std_logic_vector(31 downto 0) := VERSION & PART_NUMBER & MANUFACTURER & "1";
35
36 signal SR_ID: std_logic_vector(31 downto 0);
37 signal EN_TDO: boolean;
38
39 constant CMD_IDCODE: std_logic_vector(IR_WIDTH-1 downto 0) := c4m_jtag_cmd_idcode(IR_WIDTH);
40 constant CMD_BYPASS: std_logic_vector(IR_WIDTH-1 downto 0) := c4m_jtag_cmd_bypass(IR_WIDTH);
41 begin
42 process (TCK)
43 begin
44 if rising_edge(TCK) then
45 if CAPTURE = '1' then
46 SR_ID <= IDCODE;
47 elsif SHIFT = '1' then
48 if IR = CMD_IDCODE then
49 SR_ID(30 downto 0) <= SR_ID(31 downto 1);
50 SR_ID(31) <= TDI;
51 elsif IR = CMD_BYPASS then
52 SR_ID(0) <= TDI;
53 end if;
54 end if;
55 end if;
56 end process;
57
58 TDO <= SR_ID(0) when EN_TDO else
59 '0';
60 EN_TDO <= SHIFT = '1' and (IR = CMD_IDCODE or IR = CMD_BYPASS);
61 TDO_EN <= '1' when EN_TDO else
62 '0';
63 end rtl;