2 ----------------------------------------
3 --- d-flipflop with set/reset
4 ----------------------------------------
7 use ieee.std_logic_1164.all;
18 d : in std_logic_vector (dsize - 1 downto 0);
19 q : out std_logic_vector (dsize - 1 downto 0)
23 architecture rtl of d_flip_flop is
26 process (clk, res_n, set_n)
30 elsif (clk'event and clk = '1' and set_n = '0') then
32 elsif (clk'event and clk = '1') then
40 ----------------------------------------
41 --- data latch declaration
42 ----------------------------------------
45 use ieee.std_logic_1164.all;
53 d : in std_logic_vector (dsize - 1 downto 0);
54 q : out std_logic_vector (dsize - 1 downto 0)
58 architecture rtl of latch is
64 --latch only when clock is high
70 ----------------------------------------
72 ----------------------------------------
75 use ieee.std_logic_1164.all;
77 entity tri_state_buffer is
83 d : in std_logic_vector (dsize - 1 downto 0);
84 q : out std_logic_vector (dsize - 1 downto 0)
88 architecture rtl of tri_state_buffer is
90 q <= d when oe_n = '0' else
95 ----------------------------------------
96 --- dual port d flip flop w/ tri-state buffer
97 ----------------------------------------
100 use ieee.std_logic_1164.all;
108 res_n : in std_logic;
109 set_n : in std_logic;
110 gate_cmd : in std_logic_vector (3 downto 0);
111 front_port : inout std_logic_vector (dsize - 1 downto 0);
112 back_in_port : in std_logic_vector (dsize - 1 downto 0);
113 back_out_port : out std_logic_vector (dsize - 1 downto 0)
117 architecture rtl of dual_dff is
119 component d_flip_flop
125 res_n : in std_logic;
126 set_n : in std_logic;
128 d : in std_logic_vector (dsize - 1 downto 0);
129 q : out std_logic_vector (dsize - 1 downto 0)
133 component tri_state_buffer
139 d : in std_logic_vector (dsize - 1 downto 0);
140 q : out std_logic_vector (dsize - 1 downto 0)
144 signal we_n : std_logic;
145 signal q : std_logic_vector (dsize - 1 downto 0);
146 signal d : std_logic_vector (dsize - 1 downto 0);
149 ----------gate_cmd format
150 ------3 : front port oe_n
151 ------2 : front port we_n
152 ------1 : back port oe_n
153 ------0 : back port we_n
154 we_n <= (gate_cmd(2) and gate_cmd(0));
156 d <= front_port when gate_cmd(2) = '0' else
157 back_in_port when gate_cmd(0) = '0' else
160 dff_inst : d_flip_flop generic map (dsize)
161 port map(clk, res_n, set_n, we_n, d, q);
163 front_tsb : tri_state_buffer generic map (dsize)
164 port map(gate_cmd(3), q, front_port);
166 back_tsb : tri_state_buffer generic map (dsize)
167 port map(gate_cmd(1), q, back_out_port);
173 ----------------------------------------
175 ----------------------------------------
178 use ieee.std_logic_1164.all;
180 entity data_bus_buffer is
187 int_oe_n : in std_logic;
188 int_dbus : inout std_logic_vector (dsize - 1 downto 0);
189 ext_dbus : inout std_logic_vector (dsize - 1 downto 0)
193 architecture rtl of data_bus_buffer is
200 d : in std_logic_vector (dsize - 1 downto 0);
201 q : out std_logic_vector (dsize - 1 downto 0)
205 component tri_state_buffer
211 d : in std_logic_vector (dsize - 1 downto 0);
212 q : out std_logic_vector (dsize - 1 downto 0)
216 signal rd_clk : std_logic;
217 signal wr_clk : std_logic;
218 signal read_buf : std_logic_vector (dsize - 1 downto 0);
219 signal write_buf : std_logic_vector (dsize - 1 downto 0);
221 rd_clk <= r_nw and clk;
222 wr_clk <= (not r_nw) and clk;
224 --read from i/o to cpu
225 latch_r : latch generic map (dsize)
226 port map(rd_clk, ext_dbus, read_buf);
227 read_tsb : tri_state_buffer generic map (dsize)
228 port map(int_oe_n, read_buf, int_dbus);
229 --write from cpu to io
230 latch_w : latch generic map (dsize)
231 port map(wr_clk, int_dbus, write_buf);
232 write_tsb : tri_state_buffer generic map (dsize)
233 port map(r_nw, write_buf, ext_dbus);
236 ------------------------------------------
237 ----- input data latch register
238 ------------------------------------------
241 use ieee.std_logic_1164.all;
243 entity input_data_latch is
251 int_dbus : in std_logic_vector (dsize - 1 downto 0);
252 alu_bus : out std_logic_vector (dsize - 1 downto 0)
254 end input_data_latch;
256 architecture rtl of input_data_latch is
264 d : in std_logic_vector (dsize - 1 downto 0);
265 q : out std_logic_vector (dsize - 1 downto 0)
269 component tri_state_buffer
275 d : in std_logic_vector (dsize - 1 downto 0);
276 q : out std_logic_vector (dsize - 1 downto 0)
280 signal latch_clk : std_logic;
281 signal latch_buf : std_logic_vector (dsize - 1 downto 0);
284 latch_clk <= (not we_n) and clk;
285 latch_inst : latch generic map (dsize)
286 port map(latch_clk, int_dbus, latch_buf);
287 iput_data_tsb : tri_state_buffer generic map (dsize)
288 port map(oe_n, latch_buf, alu_bus);