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 IR_WIDTH: integer := 2;
154 -- The default MANUFACTURING ID is not representing a valid
155 -- manufacturer according to the JTAG standard
156 MANUFACTURER: std_logic_vector(10 downto 0) := "10001111111";
157 PART_NUMBER: std_logic_vector(15 downto 0) := "0000000000000001";
158 VERSION: std_logic_vector(3 downto 0) := "0000"
166 TRST_N: in std_logic;
168 -- The FSM state indicators
169 RESET: out std_logic; -- In reset state
170 DRCAPTURE: out std_logic; -- In DR_Capture state
171 DRSHIFT: out std_logic; -- In DR_Shift state
172 DRUPDATE: out std_logic; -- In DR_Update state
174 -- The Instruction Register
175 IR: out std_logic_vector(IR_WIDTH-1 downto 0);
177 -- The I/O access ports
178 CORE_IN: out std_logic_vector(IOS-1 downto 0);
179 CORE_EN: in std_logic_vector(IOS-1 downto 0);
180 CORE_OUT: in std_logic_vector(IOS-1 downto 0);
182 -- The pad connections
183 PAD_IN: in std_logic_vector(IOS-1 downto 0);
184 PAD_EN: out std_logic_vector(IOS-1 downto 0);
185 PAD_OUT: out std_logic_vector(IOS-1 downto 0)
187 end component c4m_jtag_tap_controller;
189 function c4m_jtag_cmd_idcode(width: integer) return std_logic_vector;
190 function c4m_jtag_cmd_bypass(width: integer) return std_logic_vector;
191 function c4m_jtag_cmd_samplepreload(width: integer) return std_logic_vector;
192 function c4m_jtag_cmd_extest(width: integer) return std_logic_vector;
195 package body c4m_jtag is
196 function c4m_jtag_cmd_bypass(width: integer) return std_logic_vector is
197 variable return_vector: std_logic_vector(width-1 downto 0);
199 return_vector := (others => '1');
200 return return_vector;
203 function c4m_jtag_cmd_idcode(width: integer) return std_logic_vector is
204 variable return_vector: std_logic_vector(width-1 downto 0);
206 return_vector := (0 => '1', others => '0');
207 return return_vector;
210 function c4m_jtag_cmd_samplepreload(width: integer) return std_logic_vector is
211 variable return_vector: std_logic_vector(width-1 downto 0);
213 return_vector := (1 => '1', others => '0');
214 return return_vector;
217 function c4m_jtag_cmd_extest(width: integer) return std_logic_vector is
218 variable return_vector: std_logic_vector(width-1 downto 0);
220 return_vector := (others => '0');
221 return return_vector;