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
57 STATE: in TAPSTATE_TYPE;
58 NEXT_STATE: in TAPSTATE_TYPE;
59 IRSTATE: in std_logic;
61 -- instruction register
62 IR: out std_logic_vector(IR_WIDTH-1 downto 0)
64 end component c4m_jtag_irblock;
66 component c4m_jtag_idblock is
68 IR_WIDTH: integer := 2;
70 PART_NUMBER: std_logic_vector(15 downto 0);
71 VERSION: std_logic_vector(3 downto 0) := "0000";
72 MANUFACTURER: std_logic_vector(10 downto 0)
81 STATE: in TAPSTATE_TYPE;
82 NEXT_STATE: in TAPSTATE_TYPE;
83 DRSTATE: in std_logic;
86 IR: in std_logic_vector(IR_WIDTH-1 downto 0)
88 end component c4m_jtag_idblock;
90 component c4m_jtag_iocell is
93 CORE_IN: out std_logic;
94 CORE_OUT: in std_logic;
95 CORE_EN: in std_logic;
99 PAD_OUT: out std_logic;
100 PAD_EN: out std_logic;
103 BDSR_IN: in std_logic;
104 BDSR_OUT: out std_logic;
107 IOMODE: in SRIOMODE_TYPE;
108 SAMPLEMODE: in SRSAMPLEMODE_TYPE;
111 end component c4m_jtag_iocell;
113 component c4m_jtag_ioblock is
115 IR_WIDTH: integer := 2;
119 -- needed TAP signals
125 STATE: in TAPSTATE_TYPE;
126 NEXT_STATE: in TAPSTATE_TYPE;
127 DRSTATE: in std_logic;
130 IR: in std_logic_vector(IR_WIDTH-1 downto 0);
132 -- The I/O access ports
133 CORE_OUT: in std_logic_vector(IOS-1 downto 0);
134 CORE_IN: out std_logic_vector(IOS-1 downto 0);
135 CORE_EN: in std_logic_vector(IOS-1 downto 0);
137 -- The pad connections
138 PAD_OUT: out std_logic_vector(IOS-1 downto 0);
139 PAD_IN: in std_logic_vector(IOS-1 downto 0);
140 PAD_EN: out std_logic_vector(IOS-1 downto 0)
142 end component c4m_jtag_ioblock;
144 component c4m_jtag_tap_controller is
146 IR_WIDTH: integer := 2;
149 VERSION: std_logic_vector(3 downto 0) := "0000"
157 TRST_N: in std_logic;
159 -- The FSM state indicators
160 STATE: out TAPSTATE_TYPE;
161 NEXT_STATE: out TAPSTATE_TYPE;
162 DRSTATE: out std_logic;
164 -- The Instruction Register
165 IR: out std_logic_vector(IR_WIDTH-1 downto 0);
167 -- The I/O access ports
168 CORE_IN: out std_logic_vector(IOS-1 downto 0);
169 CORE_EN: in std_logic_vector(IOS-1 downto 0);
170 CORE_OUT: in std_logic_vector(IOS-1 downto 0);
172 -- The pad connections
173 PAD_IN: in std_logic_vector(IOS-1 downto 0);
174 PAD_EN: out std_logic_vector(IOS-1 downto 0);
175 PAD_OUT: out std_logic_vector(IOS-1 downto 0)
177 end component c4m_jtag_tap_controller;
179 function c4m_jtag_cmd_idcode(width: integer) return std_logic_vector;
180 function c4m_jtag_cmd_bypass(width: integer) return std_logic_vector;
181 function c4m_jtag_cmd_samplepreload(width: integer) return std_logic_vector;
182 function c4m_jtag_cmd_extest(width: integer) return std_logic_vector;
185 package body c4m_jtag is
186 function c4m_jtag_cmd_bypass(width: integer) return std_logic_vector is
187 variable return_vector: std_logic_vector(width-1 downto 0);
189 return_vector := (others => '1');
190 return return_vector;
193 function c4m_jtag_cmd_idcode(width: integer) return std_logic_vector is
194 variable return_vector: std_logic_vector(width-1 downto 0);
196 return_vector := (0 => '1', others => '0');
197 return return_vector;
200 function c4m_jtag_cmd_samplepreload(width: integer) return std_logic_vector is
201 variable return_vector: std_logic_vector(width-1 downto 0);
203 return_vector := (1 => '1', others => '0');
204 return return_vector;
207 function c4m_jtag_cmd_extest(width: integer) return std_logic_vector is
208 variable return_vector: std_logic_vector(width-1 downto 0);
210 return_vector := (others => '0');
211 return return_vector;