1 -- Package of jtag support code from the Chips4Makers project
3 use ieee.std_logic_1164.ALL;
6 type TAPSTATE_TYPE is (
18 type SRIOMODE_TYPE is (
19 SR_Through, -- Connect core signal to pad signals
20 SR_2Pad, -- Connect BD to pad
21 SR_2Core, -- Connect BD to core
22 SR_Z -- pad is high impedance
24 type SRSAMPLEMODE_TYPE is (
25 SR_Normal, -- No sampling or shifting
26 SR_Sample, -- Sample IO state in BD SR on rising edge of TCK
27 SR_Update, -- Update BD from SR on falling edge of TCK
28 SR_Shift -- Shift the BD SR
31 component c4m_jtag_tap_fsm is
39 STATE: out TAPSTATE_TYPE;
40 NEXT_STATE: out TAPSTATE_TYPE;
41 DRSTATE: out std_logic;
42 IRSTATE: out std_logic
44 end component c4m_jtag_tap_fsm;
46 component c4m_jtag_irblock is
48 IR_WIDTH: integer := 2
55 TDO_EN: out std_logic;
58 STATE: in TAPSTATE_TYPE;
59 NEXT_STATE: in TAPSTATE_TYPE;
60 IRSTATE: in std_logic;
62 -- instruction register
63 IR: out std_logic_vector(IR_WIDTH-1 downto 0)
65 end component c4m_jtag_irblock;
67 component c4m_jtag_idblock is
69 IR_WIDTH: integer := 2;
71 -- The default MANUFACTURING ID is not representing a valid
72 -- manufacturer according to the JTAG standard
73 MANUFACTURER: std_logic_vector(10 downto 0) := "10001111111";
74 PART_NUMBER: std_logic_vector(15 downto 0) := "0000000000000001";
75 VERSION: std_logic_vector(3 downto 0) := "0000"
82 TDO_EN: out std_logic;
85 STATE: in TAPSTATE_TYPE;
86 NEXT_STATE: in TAPSTATE_TYPE;
87 DRSTATE: in std_logic;
90 IR: in std_logic_vector(IR_WIDTH-1 downto 0)
92 end component c4m_jtag_idblock;
94 component c4m_jtag_iocell is
97 CORE_IN: out std_logic;
98 CORE_OUT: in std_logic;
99 CORE_EN: in std_logic;
102 PAD_IN: in std_logic;
103 PAD_OUT: out std_logic;
104 PAD_EN: out std_logic;
107 BDSR_IN: in std_logic;
108 BDSR_OUT: out std_logic;
111 IOMODE: in SRIOMODE_TYPE;
112 SAMPLEMODE: in SRSAMPLEMODE_TYPE;
115 end component c4m_jtag_iocell;
117 component c4m_jtag_ioblock is
119 IR_WIDTH: integer := 2;
123 -- needed TAP signals
127 TDO_EN: out std_logic;
130 STATE: in TAPSTATE_TYPE;
131 NEXT_STATE: in TAPSTATE_TYPE;
132 DRSTATE: in std_logic;
135 IR: in std_logic_vector(IR_WIDTH-1 downto 0);
137 -- The I/O access ports
138 CORE_OUT: in std_logic_vector(IOS-1 downto 0);
139 CORE_IN: out std_logic_vector(IOS-1 downto 0);
140 CORE_EN: in std_logic_vector(IOS-1 downto 0);
142 -- The pad connections
143 PAD_OUT: out std_logic_vector(IOS-1 downto 0);
144 PAD_IN: in std_logic_vector(IOS-1 downto 0);
145 PAD_EN: out std_logic_vector(IOS-1 downto 0)
147 end component c4m_jtag_ioblock;
149 component c4m_jtag_tap_controller is
151 DEBUG: boolean := false;
153 IR_WIDTH: integer := 2;
156 -- The default MANUFACTURING ID is not representing a valid
157 -- manufacturer according to the JTAG standard
158 MANUFACTURER: std_logic_vector(10 downto 0) := "10001111111";
159 PART_NUMBER: std_logic_vector(15 downto 0) := "0000000000000001";
160 VERSION: std_logic_vector(3 downto 0) := "0000"
168 TRST_N: in std_logic;
170 -- The FSM state indicators
171 RESET: out std_logic; -- In reset state
172 DRCAPTURE: out std_logic; -- In DR_Capture state
173 DRSHIFT: out std_logic; -- In DR_Shift state
174 DRUPDATE: out std_logic; -- In DR_Update state
176 -- The Instruction Register
177 IR: out std_logic_vector(IR_WIDTH-1 downto 0);
179 -- The I/O access ports
180 CORE_IN: out std_logic_vector(IOS-1 downto 0);
181 CORE_EN: in std_logic_vector(IOS-1 downto 0);
182 CORE_OUT: in std_logic_vector(IOS-1 downto 0);
184 -- The pad connections
185 PAD_IN: in std_logic_vector(IOS-1 downto 0);
186 PAD_EN: out std_logic_vector(IOS-1 downto 0);
187 PAD_OUT: out std_logic_vector(IOS-1 downto 0)
189 end component c4m_jtag_tap_controller;
191 function c4m_jtag_cmd_idcode(width: integer) return std_logic_vector;
192 function c4m_jtag_cmd_bypass(width: integer) return std_logic_vector;
193 function c4m_jtag_cmd_samplepreload(width: integer) return std_logic_vector;
194 function c4m_jtag_cmd_extest(width: integer) return std_logic_vector;
197 package body c4m_jtag is
198 function c4m_jtag_cmd_bypass(width: integer) return std_logic_vector is
199 variable return_vector: std_logic_vector(width-1 downto 0);
201 return_vector := (others => '1');
202 return return_vector;
205 function c4m_jtag_cmd_idcode(width: integer) return std_logic_vector is
206 variable return_vector: std_logic_vector(width-1 downto 0);
208 return_vector := (0 => '1', others => '0');
209 return return_vector;
212 function c4m_jtag_cmd_samplepreload(width: integer) return std_logic_vector is
213 variable return_vector: std_logic_vector(width-1 downto 0);
215 return_vector := (1 => '1', others => '0');
216 return return_vector;
219 function c4m_jtag_cmd_extest(width: integer) return std_logic_vector is
220 variable return_vector: std_logic_vector(width-1 downto 0);
222 return_vector := (others => '0');
223 return return_vector;