2 use ieee.std_logic_1164.all;
3 use ieee.std_logic_arith.conv_std_logic_vector;
4 use ieee.std_logic_unsigned.conv_integer;
7 generic (dsize : integer := 8);
8 port ( set_clk : in std_logic;
9 trig_clk : in std_logic;
14 instruction : in std_logic_vector (dsize - 1 downto 0);
15 exec_cycle : in std_logic_vector (5 downto 0);
16 next_cycle : out std_logic_vector (5 downto 0);
17 status_reg : inout std_logic_vector (dsize - 1 downto 0);
18 inst_we_n : out std_logic;
19 ad_oe_n : out std_logic;
20 dbuf_int_oe_n : out std_logic;
21 dl_al_we_n : out std_logic;
22 dl_ah_we_n : out std_logic;
23 dl_al_oe_n : out std_logic;
24 dl_ah_oe_n : out std_logic;
25 dl_dh_oe_n : out std_logic;
26 pcl_inc_n : out std_logic;
27 pch_inc_n : out std_logic;
28 pcl_cmd : out std_logic_vector(3 downto 0);
29 pch_cmd : out std_logic_vector(3 downto 0);
30 sp_cmd : out std_logic_vector(3 downto 0);
31 sp_oe_n : out std_logic;
32 sp_push_n : out std_logic;
33 sp_pop_n : out std_logic;
34 acc_cmd : out std_logic_vector(3 downto 0);
35 x_cmd : out std_logic_vector(3 downto 0);
36 y_cmd : out std_logic_vector(3 downto 0);
37 abs_xy_n : out std_logic;
38 ea_carry : in std_logic;
39 pg_next_n : out std_logic;
41 zp_xy_n : out std_logic;
42 rel_calc_n : out std_logic;
43 indir_n : out std_logic;
44 indir_x_n : out std_logic;
45 indir_y_n : out std_logic;
46 arith_en_n : out std_logic;
47 stat_dec_oe_n : out std_logic;
48 stat_bus_oe_n : out std_logic;
49 stat_set_flg_n : out std_logic;
50 stat_flg : out std_logic;
51 stat_bus_all_n : out std_logic;
52 stat_bus_nz_n : out std_logic;
53 stat_alu_we_n : out std_logic;
54 r_vec_oe_n : out std_logic;
55 n_vec_oe_n : out std_logic;
56 i_vec_oe_n : out std_logic;
58 ;---for parameter check purpose!!!
59 check_bit : out std_logic_vector(1 to 5)
63 architecture rtl of decoder is
65 component d_flip_flop_bit
76 procedure d_print(msg : string) is
78 --use ieee.std_logic_textio.all;
79 variable out_l : line;
82 -- writeline(output, out_l);
85 ---ival : 0x0000 - 0xffff
86 function conv_hex8(ival : integer) return string is
87 variable tmp1, tmp2 : integer;
88 variable hex_chr: string (1 to 16) := "0123456789abcdef";
90 tmp2 := (ival mod 16 ** 2) / 16 ** 1;
91 tmp1 := ival mod 16 ** 1;
92 return hex_chr(tmp2 + 1) & hex_chr(tmp1 + 1);
96 -- bit 5 : pcl increment carry flag
97 -- bit 4,3 : cycle type: 00 normal, 01 reset , 10 nmi, 11 irq
100 --00xxx : exec cycle : T0 > T1 > T2 > T3 > T4 > T5 > T6 > T0
101 constant T0 : std_logic_vector (5 downto 0) := "000000";
102 constant T1 : std_logic_vector (5 downto 0) := "000001";
103 constant T2 : std_logic_vector (5 downto 0) := "000010";
104 constant T3 : std_logic_vector (5 downto 0) := "000011";
105 constant T4 : std_logic_vector (5 downto 0) := "000100";
106 constant T5 : std_logic_vector (5 downto 0) := "000101";
107 constant T6 : std_logic_vector (5 downto 0) := "000110";
109 --01xxx : reset cycle : R0 > R1 > R2 > R3 > R4 > R5 > T0
110 constant R0 : std_logic_vector (5 downto 0) := "001000";
111 constant R1 : std_logic_vector (5 downto 0) := "001001";
112 constant R2 : std_logic_vector (5 downto 0) := "001010";
113 constant R3 : std_logic_vector (5 downto 0) := "001011";
114 constant R4 : std_logic_vector (5 downto 0) := "001100";
115 constant R5 : std_logic_vector (5 downto 0) := "001101";
117 --10xxx : nmi cycle : T0 > N1 > N2 > N3 > N4 > N5 > T0
118 constant N1 : std_logic_vector (5 downto 0) := "010001";
119 constant N2 : std_logic_vector (5 downto 0) := "010010";
120 constant N3 : std_logic_vector (5 downto 0) := "010011";
121 constant N4 : std_logic_vector (5 downto 0) := "010100";
122 constant N5 : std_logic_vector (5 downto 0) := "010101";
124 --11xxx : irq cycle : T0 > I1 > I2 > I3 > I4 > I5 > T0
125 constant I1 : std_logic_vector (5 downto 0) := "011001";
126 constant I2 : std_logic_vector (5 downto 0) := "011010";
127 constant I3 : std_logic_vector (5 downto 0) := "011011";
128 constant I4 : std_logic_vector (5 downto 0) := "011100";
129 constant I5 : std_logic_vector (5 downto 0) := "011101";
131 constant ERROR_CYCLE : std_logic_vector (5 downto 0) := "111111";
133 -- SR Flags (bit 7 to bit 0):
138 -- 3 D .... Decimal (use BCD for arithmetics)
139 -- 2 I .... Interrupt (IRQ disable)
142 constant st_N : integer := 7;
143 constant st_V : integer := 6;
144 constant st_B : integer := 4;
145 constant st_D : integer := 3;
146 constant st_I : integer := 2;
147 constant st_Z : integer := 1;
148 constant st_C : integer := 0;
151 signal pch_inc_input : std_logic;
153 -- page boundary handling
154 signal a2_abs_xy_next_cycle : std_logic_vector (5 downto 0);
155 signal a2_indir_y_next_cycle : std_logic_vector (5 downto 0);
156 signal a58_branch_next_cycle : std_logic_vector (5 downto 0);
157 signal wait_a2_abs_xy_next : std_logic;
158 signal wait_a2_indir_y_next : std_logic;
159 signal wait_a58_branch_next : std_logic;
163 ---pc page next is connected to top bit of exec_cycle
164 pch_inc_input <= not exec_cycle(5);
165 pch_inc_reg : d_flip_flop_bit
166 port map(set_clk, '1', '1', '0', pch_inc_input, pch_inc_n);
168 a2_abs_xy_next_cycle <= T4 when ea_carry = '1' else
170 a2_indir_y_next_cycle <= T5 when ea_carry = '1' else
172 a58_branch_next_cycle <= T3 when ea_carry = '1' else
175 main_p : process (set_clk, res_n, nmi_n,
176 a2_abs_xy_next_cycle, a2_indir_y_next_cycle, a58_branch_next_cycle)
178 ---for nmi handling
\r
179 variable nmi_handled_n : std_logic;
\r
182 -------------------------------------------------------------
183 -------------------------------------------------------------
184 ----------------------- comon routines ----------------------
185 -------------------------------------------------------------
186 -------------------------------------------------------------
188 ----------gate_cmd format
189 ------3 : front port oe_n
190 ------2 : front port we_n
191 ------1 : back port oe_n
192 ------0 : back port we_n
193 procedure front_oe (signal cmd : out std_logic_vector(3 downto 0);
194 val : in std_logic) is
198 procedure front_we (signal cmd : out std_logic_vector(3 downto 0);
199 val : in std_logic) is
203 procedure back_oe (signal cmd : out std_logic_vector(3 downto 0);
204 val : in std_logic) is
208 procedure back_we (signal cmd : out std_logic_vector(3 downto 0);
209 val : in std_logic) is
214 procedure fetch_next is
217 back_oe(pcl_cmd, '0');
218 back_oe(pch_cmd, '0');
219 back_we(pcl_cmd, '0');
220 back_we(pch_cmd, '1');
223 procedure fetch_stop is
226 back_oe(pcl_cmd, '1');
227 back_oe(pch_cmd, '1');
228 back_we(pcl_cmd, '1');
231 procedure read_status is
233 status_reg <= (others => 'Z');
234 stat_dec_oe_n <= '0';
237 procedure disable_pins is
239 --disable the last opration pins.
240 dbuf_int_oe_n <= '1';
264 stat_bus_oe_n <= '1';
265 stat_set_flg_n <= '1';
267 stat_bus_all_n <= '1';
268 stat_bus_nz_n <= '1';
269 stat_alu_we_n <= '1';
275 wait_a2_abs_xy_next <= '0';
276 wait_a2_indir_y_next <= '0';
277 wait_a58_branch_next <= '0';
280 procedure fetch_inst (inc_pcl : in std_logic) is
282 if instruction = conv_std_logic_vector(16#4c#, dsize) then
283 --if prior cycle is jump instruction,
284 --fetch opcode from where the latch is pointing to.
290 --fetch opcode and pcl increment.
298 pcl_inc_n <= inc_pcl;
301 d_print(string'("fetch 1"));
305 ---(along with the page boundary condition, the last
306 ---cycle is bypassed and slided to T0.)
307 procedure t0_cycle is
310 if (nmi_n = '0' and nmi_handled_n = '1') then
311 --start nmi handling...
320 ---common routine for single byte instruction.
321 procedure single_inst is
327 procedure fetch_imm is
329 d_print("immediate");
331 --send data from data bus buffer.
332 --receiver is instruction dependent.
333 dbuf_int_oe_n <= '0';
337 procedure set_nz_from_bus is
339 --status register n/z bit update.
340 stat_bus_nz_n <= '0';
343 procedure set_zc_from_alu is
345 --status register n/z bit update.
346 stat_alu_we_n <= '0';
347 stat_dec_oe_n <= '1';
348 status_reg <= "00000011";
351 procedure set_nz_from_alu is
353 --status register n/z/c bit update.
354 stat_alu_we_n <= '0';
355 stat_dec_oe_n <= '1';
356 status_reg <= "10000010";
359 procedure set_nzc_from_alu is
361 --status register n/z/c bit update.
362 stat_alu_we_n <= '0';
363 stat_dec_oe_n <= '1';
364 status_reg <= "10000011";
367 procedure set_nvz_from_alu is
369 --status register n/z/v bit update.
370 stat_alu_we_n <= '0';
371 stat_dec_oe_n <= '1';
372 status_reg <= "11000010";
375 procedure set_nvzc_from_alu is
377 stat_alu_we_n <= '0';
378 stat_dec_oe_n <= '1';
379 status_reg <= "11000011";
382 --flag on/off instruction
383 procedure set_flag (int_flg : in integer; val : in std_logic) is
385 stat_dec_oe_n <= '1';
386 stat_set_flg_n <= '0';
387 --specify which to set.
388 status_reg(7 downto int_flg + 1)
390 status_reg(int_flg - 1 downto 0)
392 status_reg(int_flg) <= '1';
397 procedure set_flag0 (val : in std_logic) is
399 stat_dec_oe_n <= '1';
400 stat_set_flg_n <= '0';
401 status_reg <= "00000001";
405 procedure fetch_low is
407 d_print("fetch low 2");
408 --fetch next opcode (abs low).
410 --latch abs low data.
411 dbuf_int_oe_n <= '0';
416 procedure abs_fetch_high is
418 d_print("abs (xy) 3");
423 dbuf_int_oe_n <= '0';
428 procedure abs_latch_out is
439 procedure ea_x_out is
441 -----calucurate and output effective addr
446 procedure ea_y_out is
452 --A.2. internal execution on memory data
456 if exec_cycle = T1 then
458 elsif exec_cycle = T2 then
460 dbuf_int_oe_n <= '0';
472 if exec_cycle = T1 then
474 elsif exec_cycle = T2 then
476 elsif exec_cycle = T3 then
478 dbuf_int_oe_n <= '0';
483 procedure a2_page_next is
485 --close open gate if page boundary crossed.
486 back_we(acc_cmd, '1');
487 front_we(acc_cmd, '1');
488 front_we(x_cmd, '1');
489 front_we(y_cmd, '1');
490 stat_alu_we_n <= '1';
493 procedure a2_abs_xy (is_x : in boolean) is
495 if exec_cycle = T1 then
497 elsif exec_cycle = T2 then
499 elsif exec_cycle = T3 then
503 if (is_x = true) then
508 dbuf_int_oe_n <= '0';
510 wait_a2_abs_xy_next <= '1';
511 next_cycle <= a2_abs_xy_next_cycle;
512 d_print("absx step 1");
513 elsif exec_cycle = T4 then
514 --case page boundary crossed.
516 d_print("absx 5 (page boudary crossed.)");
518 pg_next_n <= not ea_carry;
523 procedure a2_zp_xy (is_x : in boolean) is
525 if exec_cycle = T1 then
527 elsif exec_cycle = T2 then
530 dbuf_int_oe_n <= '0';
537 elsif exec_cycle = T3 then
540 if (is_x = true) then
549 procedure a2_indir_y is
551 if exec_cycle = T1 then
556 elsif exec_cycle = T2 then
564 dbuf_int_oe_n <= '0';
567 elsif exec_cycle = T3 then
571 dbuf_int_oe_n <= '0';
574 elsif exec_cycle = T4 then
576 dbuf_int_oe_n <= '1';
582 dbuf_int_oe_n <= '0';
584 wait_a2_indir_y_next <= '1';
585 next_cycle <= a2_indir_y_next_cycle;
586 elsif exec_cycle = T5 then
587 --case page boundary crossed.
589 d_print("(indir), y (page boudary crossed.)");
591 pg_next_n <= not ea_carry;
596 --A.3. store operation.
600 if exec_cycle = T1 then
602 elsif exec_cycle = T2 then
604 dbuf_int_oe_n <= '1';
615 procedure a3_zp_xy (is_x : in boolean) is
617 if exec_cycle = T1 then
619 elsif exec_cycle = T2 then
621 dbuf_int_oe_n <= '1';
628 elsif exec_cycle = T3 then
633 if (is_x = true) then
647 if exec_cycle = T1 then
649 elsif exec_cycle = T2 then
651 elsif exec_cycle = T3 then
653 dbuf_int_oe_n <= '1';
659 procedure a3_abs_xy (is_x : in boolean) is
661 if exec_cycle = T1 then
663 elsif exec_cycle = T2 then
665 elsif exec_cycle = T3 then
669 dbuf_int_oe_n <= '1';
670 if (is_x = true) then
676 elsif exec_cycle = T4 then
677 pg_next_n <= not ea_carry;
679 if (is_x = true) then
690 procedure a3_indir_y is
692 if exec_cycle = T1 then
697 elsif exec_cycle = T2 then
705 dbuf_int_oe_n <= '0';
708 elsif exec_cycle = T3 then
712 dbuf_int_oe_n <= '0';
715 elsif exec_cycle = T4 then
717 dbuf_int_oe_n <= '1';
725 elsif exec_cycle = T5 then
729 pg_next_n <= not ea_carry;
736 ---A.4. read-modify-write operation
740 if exec_cycle = T1 then
742 elsif exec_cycle = T2 then
744 dbuf_int_oe_n <= '1';
751 elsif exec_cycle = T3 then
754 --keep data in the alu reg.
756 dbuf_int_oe_n <= '0';
758 elsif exec_cycle = T4 then
759 dbuf_int_oe_n <= '1';
761 --t5 cycle writes modified value.
772 if exec_cycle = T1 then
774 elsif exec_cycle = T2 then
776 dbuf_int_oe_n <= '1';
779 --t2 cycle read bal only.
783 elsif exec_cycle = T3 then
784 --t3 cycle read bal + x
790 elsif exec_cycle = T4 then
796 --keep data in the alu reg.
798 dbuf_int_oe_n <= '0';
800 elsif exec_cycle = T5 then
801 dbuf_int_oe_n <= '1';
803 --t5 cycle writes modified value.
817 if exec_cycle = T1 then
819 elsif exec_cycle = T2 then
821 elsif exec_cycle = T3 then
822 --T3 cycle do nothing.
825 elsif exec_cycle = T4 then
828 --t4 cycle save data in the alu register only.
829 --hardware maunual says write original data,
830 --but this implementation doesn't write because bus shortage....
833 elsif exec_cycle = T5 then
834 dbuf_int_oe_n <= '1';
836 --t5 cycle writes modified value.
843 procedure a4_abs_x is
845 if exec_cycle = T1 then
847 elsif exec_cycle = T2 then
849 elsif exec_cycle = T3 then
850 --T3 cycle discarded.
854 dbuf_int_oe_n <= '0';
857 elsif exec_cycle = T4 then
858 --t4 cycle fetch only.
861 pg_next_n <= not ea_carry;
864 elsif exec_cycle = T5 then
865 --t4 cycle redo fetch and save data in the alu register only.
869 elsif exec_cycle = T6 then
870 --t5 cycle writes modified value.
873 dbuf_int_oe_n <= '1';
881 procedure a51_push is
883 if exec_cycle = T1 then
886 elsif exec_cycle = T2 then
887 back_oe(sp_cmd, '0');
888 back_we(sp_cmd, '0');
897 procedure a52_pull is
899 if exec_cycle = T1 then
903 elsif exec_cycle = T2 then
904 --stack decrement first.
905 back_oe(sp_cmd, '0');
906 back_we(sp_cmd, '0');
911 elsif exec_cycle = T3 then
913 back_we(sp_cmd, '1');
915 ---pop data from stack.
916 back_oe(sp_cmd, '0');
918 dbuf_int_oe_n <= '0';
924 -- A.5.8 branch operations
926 procedure a58_branch (int_flg : in integer; br_cond : in std_logic) is
928 if exec_cycle = T1 then
930 if status_reg(int_flg) = br_cond then
934 dbuf_int_oe_n <= '0';
938 d_print("no branch");
941 elsif exec_cycle = T2 then
944 dbuf_int_oe_n <= '1';
947 --calc relative addr.
951 back_oe(pcl_cmd, '0');
952 back_oe(pch_cmd, '0');
953 back_we(pcl_cmd, '0');
955 wait_a58_branch_next <= '1';
956 next_cycle <= a58_branch_next_cycle;
957 elsif exec_cycle = T3 then
958 d_print("page crossed.");
959 --page crossed. adh calc.
960 back_we(pcl_cmd, '1');
961 back_oe(pcl_cmd, '0');
962 back_oe(pch_cmd, '0');
963 back_we(pch_cmd, '0');
972 -------------------------------------------------------------
973 -------------------------------------------------------------
974 ---------------- main state machine start.... ---------------
975 -------------------------------------------------------------
976 -------------------------------------------------------------
980 -- if (res_n = '0') then
981 -- --pc l/h is reset vector.
982 -- pcl_cmd <= "1110";
983 -- pch_cmd <= "1110";
985 -- elsif (res_n'event and res_n = '1') then
986 -- pcl_cmd <= "1111";
987 -- pch_cmd <= "1111";
990 -- if (nmi_n'event and nmi_n = '1') then
991 -- --reset nmi handle status
992 -- nmi_handled_n := '1';
996 -- if (a2_abs_xy_next_cycle'event) then
997 -- if (wait_a2_abs_xy_next = '1') then
998 -- d_print("absx step 2");
999 -- next_cycle <= a2_abs_xy_next_cycle;
1000 -- if (ea_carry = '1') then
1006 -- if (a2_indir_y_next_cycle'event) then
1007 -- if (wait_a2_indir_y_next = '1') then
1008 -- d_print("indir step 2");
1009 -- next_cycle <= a2_indir_y_next_cycle;
1010 -- if (ea_carry = '1') then
1016 -- if (a58_branch_next_cycle'event) then
1017 -- if (wait_a58_branch_next = '1') then
1018 -- d_print("branch step 2");
1019 -- next_cycle <= a58_branch_next_cycle;
1020 -- if (ea_carry = '1') then
1026 --if (set_clk'event and set_clk = '1' and res_n = '1') then
\r
1027 if (res_n = '0') then
\r
1028 --pc l/h is reset vector.
\r
1029 pcl_cmd <= "1110";
\r
1030 pch_cmd <= "1110";
\r
1032 elsif (rising_edge(set_clk)) then
\r
1033 d_print(string'("-"));
1035 if exec_cycle = T0 then
1039 elsif exec_cycle = T1 or exec_cycle = T2 or exec_cycle = T3 or
1040 exec_cycle = T4 or exec_cycle = T5 or exec_cycle = T6 then
1043 ---asyncronous page change might happen.
1044 back_we(pch_cmd, '1');
1046 if exec_cycle = T1 then
1047 d_print("decode and execute inst: "
1048 & conv_hex8(conv_integer(instruction)));
1049 --disable pin for jmp instruction
1051 back_we(pcl_cmd, '1');
1052 front_we(pch_cmd, '1');
1054 --grab instruction register data.
1058 --imelementation is wriiten in the order of hardware manual
1061 ----------------------------------------
1062 --A.1. Single byte instruction.
1063 ----------------------------------------
1064 if instruction = conv_std_logic_vector(16#0a#, dsize) then
1068 back_oe(acc_cmd, '0');
1069 front_we(acc_cmd, '0');
1073 elsif instruction = conv_std_logic_vector(16#18#, dsize) then
1078 elsif instruction = conv_std_logic_vector(16#d8#, dsize) then
1080 set_flag (st_D, '0');
1083 elsif instruction = conv_std_logic_vector(16#58#, dsize) then
1085 set_flag (st_I, '0');
1088 elsif instruction = conv_std_logic_vector(16#b8#, dsize) then
1090 set_flag (st_V, '0');
1093 elsif instruction = conv_std_logic_vector(16#ca#, dsize) then
1096 back_oe(x_cmd, '0');
1097 front_we(x_cmd, '0');
1102 elsif instruction = conv_std_logic_vector(16#88#, dsize) then
1105 back_oe(y_cmd, '0');
1106 front_we(y_cmd, '0');
1111 elsif instruction = conv_std_logic_vector(16#e8#, dsize) then
1114 back_oe(x_cmd, '0');
1115 front_we(x_cmd, '0');
1120 elsif instruction = conv_std_logic_vector(16#c8#, dsize) then
1123 back_oe(y_cmd, '0');
1124 front_we(y_cmd, '0');
1128 elsif instruction = conv_std_logic_vector(16#4a#, dsize) then
1132 back_oe(acc_cmd, '0');
1133 front_we(acc_cmd, '0');
1137 elsif instruction = conv_std_logic_vector(16#ea#, dsize) then
1141 elsif instruction = conv_std_logic_vector(16#2a#, dsize) then
1145 back_oe(acc_cmd, '0');
1146 front_we(acc_cmd, '0');
1150 elsif instruction = conv_std_logic_vector(16#6a#, dsize) then
1154 back_oe(acc_cmd, '0');
1155 front_we(acc_cmd, '0');
1159 elsif instruction = conv_std_logic_vector(16#38#, dsize) then
1164 elsif instruction = conv_std_logic_vector(16#f8#, dsize) then
1166 set_flag (st_D, '1');
1169 elsif instruction = conv_std_logic_vector(16#78#, dsize) then
1171 set_flag (st_I, '1');
1174 elsif instruction = conv_std_logic_vector(16#aa#, dsize) then
1178 front_oe(acc_cmd, '0');
1179 front_we(x_cmd, '0');
1181 elsif instruction = conv_std_logic_vector(16#a8#, dsize) then
1185 front_oe(acc_cmd, '0');
1186 front_we(y_cmd, '0');
1188 elsif instruction = conv_std_logic_vector(16#ba#, dsize) then
1192 elsif instruction = conv_std_logic_vector(16#8a#, dsize) then
1196 front_oe(x_cmd, '0');
1197 front_we(acc_cmd, '0');
1199 elsif instruction = conv_std_logic_vector(16#9a#, dsize) then
1203 front_oe(x_cmd, '0');
1204 front_we(sp_cmd, '0');
1206 elsif instruction = conv_std_logic_vector(16#98#, dsize) then
1210 front_oe(y_cmd, '0');
1211 front_we(acc_cmd, '0');
1215 ----------------------------------------
1216 --A.2. internal execution on memory data
1217 ----------------------------------------
1218 elsif instruction = conv_std_logic_vector(16#69#, dsize) then
1223 back_oe(acc_cmd, '0');
1224 back_we(acc_cmd, '0');
1227 elsif instruction = conv_std_logic_vector(16#65#, dsize) then
1231 if exec_cycle = T2 then
1233 back_oe(acc_cmd, '0');
1234 back_we(acc_cmd, '0');
1238 elsif instruction = conv_std_logic_vector(16#75#, dsize) then
1242 if exec_cycle = T3 then
1244 back_oe(acc_cmd, '0');
1245 back_we(acc_cmd, '0');
1249 elsif instruction = conv_std_logic_vector(16#6d#, dsize) then
1253 if exec_cycle = T3 then
1255 back_oe(acc_cmd, '0');
1256 back_we(acc_cmd, '0');
1260 elsif instruction = conv_std_logic_vector(16#7d#, dsize) then
1264 if exec_cycle = T3 or exec_cycle = T4 then
1266 back_oe(acc_cmd, '0');
1267 back_we(acc_cmd, '0');
1271 elsif instruction = conv_std_logic_vector(16#79#, dsize) then
1275 if exec_cycle = T3 or exec_cycle = T4 then
1277 back_oe(acc_cmd, '0');
1278 back_we(acc_cmd, '0');
1282 elsif instruction = conv_std_logic_vector(16#61#, dsize) then
1286 elsif instruction = conv_std_logic_vector(16#71#, dsize) then
1290 if exec_cycle = T4 or exec_cycle = T5 then
1292 back_oe(acc_cmd, '0');
1293 back_we(acc_cmd, '0');
1297 elsif instruction = conv_std_logic_vector(16#29#, dsize) then
1302 back_oe(acc_cmd, '0');
1303 back_we(acc_cmd, '0');
1306 elsif instruction = conv_std_logic_vector(16#25#, dsize) then
1310 if exec_cycle = T2 then
1312 back_oe(acc_cmd, '0');
1313 back_we(acc_cmd, '0');
1317 elsif instruction = conv_std_logic_vector(16#35#, dsize) then
1321 if exec_cycle = T3 then
1323 back_oe(acc_cmd, '0');
1324 back_we(acc_cmd, '0');
1328 elsif instruction = conv_std_logic_vector(16#2d#, dsize) then
1332 if exec_cycle = T3 then
1334 back_oe(acc_cmd, '0');
1335 back_we(acc_cmd, '0');
1339 elsif instruction = conv_std_logic_vector(16#3d#, dsize) then
1343 if exec_cycle = T3 or exec_cycle = T4 then
1345 back_oe(acc_cmd, '0');
1346 back_we(acc_cmd, '0');
1350 elsif instruction = conv_std_logic_vector(16#39#, dsize) then
1354 if exec_cycle = T3 or exec_cycle = T4 then
1356 back_oe(acc_cmd, '0');
1357 back_we(acc_cmd, '0');
1361 elsif instruction = conv_std_logic_vector(16#21#, dsize) then
1365 elsif instruction = conv_std_logic_vector(16#31#, dsize) then
1369 if exec_cycle = T4 or exec_cycle = T5 then
1371 back_oe(acc_cmd, '0');
1372 back_we(acc_cmd, '0');
1376 elsif instruction = conv_std_logic_vector(16#24#, dsize) then
1380 if exec_cycle = T2 then
1382 back_oe(acc_cmd, '0');
1386 elsif instruction = conv_std_logic_vector(16#2c#, dsize) then
1390 if exec_cycle = T3 then
1392 back_oe(acc_cmd, '0');
1396 elsif instruction = conv_std_logic_vector(16#c9#, dsize) then
1401 back_oe(acc_cmd, '0');
1404 elsif instruction = conv_std_logic_vector(16#c5#, dsize) then
1408 if exec_cycle = T2 then
1410 back_oe(acc_cmd, '0');
1414 elsif instruction = conv_std_logic_vector(16#d5#, dsize) then
1418 if exec_cycle = T3 then
1420 back_oe(acc_cmd, '0');
1424 elsif instruction = conv_std_logic_vector(16#cd#, dsize) then
1428 if exec_cycle = T3 then
1430 back_oe(acc_cmd, '0');
1434 elsif instruction = conv_std_logic_vector(16#dd#, dsize) then
1438 if exec_cycle = T3 or exec_cycle = T4 then
1440 back_oe(acc_cmd, '0');
1444 elsif instruction = conv_std_logic_vector(16#d9#, dsize) then
1448 if exec_cycle = T3 or exec_cycle = T4 then
1450 back_oe(acc_cmd, '0');
1454 elsif instruction = conv_std_logic_vector(16#c1#, dsize) then
1458 elsif instruction = conv_std_logic_vector(16#d1#, dsize) then
1462 if exec_cycle = T4 or exec_cycle = T5 then
1464 back_oe(acc_cmd, '0');
1468 elsif instruction = conv_std_logic_vector(16#e0#, dsize) then
1473 back_oe(x_cmd, '0');
1476 elsif instruction = conv_std_logic_vector(16#e4#, dsize) then
1480 if exec_cycle = T2 then
1482 back_oe(x_cmd, '0');
1486 elsif instruction = conv_std_logic_vector(16#ec#, dsize) then
1490 if exec_cycle = T3 then
1492 back_oe(x_cmd, '0');
1496 elsif instruction = conv_std_logic_vector(16#c0#, dsize) then
1501 back_oe(y_cmd, '0');
1504 elsif instruction = conv_std_logic_vector(16#c4#, dsize) then
1508 if exec_cycle = T2 then
1510 back_oe(y_cmd, '0');
1514 elsif instruction = conv_std_logic_vector(16#cc#, dsize) then
1518 if exec_cycle = T3 then
1520 back_oe(y_cmd, '0');
1524 elsif instruction = conv_std_logic_vector(16#49#, dsize) then
1529 back_oe(acc_cmd, '0');
1530 back_we(acc_cmd, '0');
1533 elsif instruction = conv_std_logic_vector(16#45#, dsize) then
1537 if exec_cycle = T2 then
1539 back_oe(acc_cmd, '0');
1540 back_we(acc_cmd, '0');
1544 elsif instruction = conv_std_logic_vector(16#55#, dsize) then
1548 if exec_cycle = T3 then
1550 back_oe(acc_cmd, '0');
1551 back_we(acc_cmd, '0');
1555 elsif instruction = conv_std_logic_vector(16#4d#, dsize) then
1559 if exec_cycle = T3 then
1561 back_oe(acc_cmd, '0');
1562 back_we(acc_cmd, '0');
1566 elsif instruction = conv_std_logic_vector(16#5d#, dsize) then
1570 if exec_cycle = T3 or exec_cycle = T4 then
1572 back_oe(acc_cmd, '0');
1573 back_we(acc_cmd, '0');
1577 elsif instruction = conv_std_logic_vector(16#59#, dsize) then
1581 if exec_cycle = T3 or exec_cycle = T4 then
1583 back_oe(acc_cmd, '0');
1584 back_we(acc_cmd, '0');
1588 elsif instruction = conv_std_logic_vector(16#41#, dsize) then
1592 elsif instruction = conv_std_logic_vector(16#51#, dsize) then
1596 if exec_cycle = T4 or exec_cycle = T5 then
1598 back_oe(acc_cmd, '0');
1599 back_we(acc_cmd, '0');
1603 elsif instruction = conv_std_logic_vector(16#a9#, dsize) then
1607 front_we(acc_cmd, '0');
1610 elsif instruction = conv_std_logic_vector(16#a5#, dsize) then
1614 if exec_cycle = T2 then
1615 front_we(acc_cmd, '0');
1619 elsif instruction = conv_std_logic_vector(16#b5#, dsize) then
1623 if exec_cycle = T3 then
1624 front_we(acc_cmd, '0');
1628 elsif instruction = conv_std_logic_vector(16#ad#, dsize) then
1632 if exec_cycle = T3 then
1634 front_we(acc_cmd, '0');
1637 elsif instruction = conv_std_logic_vector(16#bd#, dsize) then
1641 if exec_cycle = T3 or exec_cycle = T4 then
1643 front_we(acc_cmd, '0');
1647 elsif instruction = conv_std_logic_vector(16#b9#, dsize) then
1651 if exec_cycle = T3 or exec_cycle = T4 then
1653 front_we(acc_cmd, '0');
1657 elsif instruction = conv_std_logic_vector(16#a1#, dsize) then
1661 elsif instruction = conv_std_logic_vector(16#b1#, dsize) then
1665 if exec_cycle = T4 or exec_cycle = T5 then
1667 front_we(acc_cmd, '0');
1671 elsif instruction = conv_std_logic_vector(16#a2#, dsize) then
1676 front_we(x_cmd, '0');
1678 elsif instruction = conv_std_logic_vector(16#a6#, dsize) then
1682 if exec_cycle = T2 then
1683 front_we(x_cmd, '0');
1687 elsif instruction = conv_std_logic_vector(16#b6#, dsize) then
1691 if exec_cycle = T3 then
1692 front_we(x_cmd, '0');
1696 elsif instruction = conv_std_logic_vector(16#ae#, dsize) then
1700 if exec_cycle = T3 then
1702 front_we(x_cmd, '0');
1705 elsif instruction = conv_std_logic_vector(16#be#, dsize) then
1709 if exec_cycle = T3 or exec_cycle = T4 then
1710 front_we(x_cmd, '0');
1714 elsif instruction = conv_std_logic_vector(16#a0#, dsize) then
1719 front_we(y_cmd, '0');
1721 elsif instruction = conv_std_logic_vector(16#a4#, dsize) then
1725 if exec_cycle = T2 then
1726 front_we(y_cmd, '0');
1730 elsif instruction = conv_std_logic_vector(16#b4#, dsize) then
1734 if exec_cycle = T3 then
1735 front_we(y_cmd, '0');
1739 elsif instruction = conv_std_logic_vector(16#ac#, dsize) then
1743 if exec_cycle = T3 then
1745 front_we(y_cmd, '0');
1748 elsif instruction = conv_std_logic_vector(16#bc#, dsize) then
1752 if exec_cycle = T3 or exec_cycle = T4 then
1754 front_we(y_cmd, '0');
1757 elsif instruction = conv_std_logic_vector(16#09#, dsize) then
1762 back_oe(acc_cmd, '0');
1763 back_we(acc_cmd, '0');
1766 elsif instruction = conv_std_logic_vector(16#05#, dsize) then
1770 if exec_cycle = T2 then
1772 back_oe(acc_cmd, '0');
1773 back_we(acc_cmd, '0');
1777 elsif instruction = conv_std_logic_vector(16#15#, dsize) then
1781 if exec_cycle = T3 then
1783 back_oe(acc_cmd, '0');
1784 back_we(acc_cmd, '0');
1788 elsif instruction = conv_std_logic_vector(16#0d#, dsize) then
1792 if exec_cycle = T3 then
1794 back_oe(acc_cmd, '0');
1795 back_we(acc_cmd, '0');
1799 elsif instruction = conv_std_logic_vector(16#1d#, dsize) then
1803 if exec_cycle = T3 or exec_cycle = T4 then
1805 back_oe(acc_cmd, '0');
1806 back_we(acc_cmd, '0');
1810 elsif instruction = conv_std_logic_vector(16#19#, dsize) then
1814 if exec_cycle = T3 or exec_cycle = T4 then
1816 back_oe(acc_cmd, '0');
1817 back_we(acc_cmd, '0');
1821 elsif instruction = conv_std_logic_vector(16#01#, dsize) then
1825 elsif instruction = conv_std_logic_vector(16#11#, dsize) then
1829 if exec_cycle = T4 or exec_cycle = T5 then
1831 back_oe(acc_cmd, '0');
1832 back_we(acc_cmd, '0');
1836 elsif instruction = conv_std_logic_vector(16#e9#, dsize) then
1841 back_oe(acc_cmd, '0');
1842 back_we(acc_cmd, '0');
1845 elsif instruction = conv_std_logic_vector(16#e5#, dsize) then
1849 if exec_cycle = T2 then
1851 back_oe(acc_cmd, '0');
1852 back_we(acc_cmd, '0');
1856 elsif instruction = conv_std_logic_vector(16#f5#, dsize) then
1860 if exec_cycle = T3 then
1862 back_oe(acc_cmd, '0');
1863 back_we(acc_cmd, '0');
1867 elsif instruction = conv_std_logic_vector(16#ed#, dsize) then
1871 if exec_cycle = T3 then
1873 back_oe(acc_cmd, '0');
1874 back_we(acc_cmd, '0');
1878 elsif instruction = conv_std_logic_vector(16#fd#, dsize) then
1882 if exec_cycle = T3 or exec_cycle = T4 then
1884 back_oe(acc_cmd, '0');
1885 back_we(acc_cmd, '0');
1889 elsif instruction = conv_std_logic_vector(16#f9#, dsize) then
1893 if exec_cycle = T3 or exec_cycle = T4 then
1895 back_oe(acc_cmd, '0');
1896 back_we(acc_cmd, '0');
1900 elsif instruction = conv_std_logic_vector(16#e1#, dsize) then
1904 elsif instruction = conv_std_logic_vector(16#f1#, dsize) then
1908 if exec_cycle = T4 or exec_cycle = T5 then
1910 back_oe(acc_cmd, '0');
1911 back_we(acc_cmd, '0');
1917 ----------------------------------------
1918 ---A.3. store operation.
1919 ----------------------------------------
1920 elsif instruction = conv_std_logic_vector(16#85#, dsize) then
1924 if exec_cycle = T2 then
1925 front_oe(acc_cmd, '0');
1928 elsif instruction = conv_std_logic_vector(16#95#, dsize) then
1932 if exec_cycle = T2 then
1933 front_oe(acc_cmd, '0');
1936 elsif instruction = conv_std_logic_vector(16#8d#, dsize) then
1940 if exec_cycle = T3 then
1941 front_oe(acc_cmd, '0');
1944 elsif instruction = conv_std_logic_vector(16#9d#, dsize) then
1948 if exec_cycle = T4 then
1949 front_oe(acc_cmd, '0');
1952 elsif instruction = conv_std_logic_vector(16#99#, dsize) then
1956 if exec_cycle = T4 then
1957 front_oe(acc_cmd, '0');
1960 elsif instruction = conv_std_logic_vector(16#81#, dsize) then
1964 elsif instruction = conv_std_logic_vector(16#91#, dsize) then
1968 if exec_cycle = T5 then
1969 front_oe(acc_cmd, '0');
1972 elsif instruction = conv_std_logic_vector(16#86#, dsize) then
1976 if exec_cycle = T2 then
1977 front_oe(x_cmd, '0');
1980 elsif instruction = conv_std_logic_vector(16#96#, dsize) then
1984 if exec_cycle = T2 then
1985 front_oe(x_cmd, '0');
1988 elsif instruction = conv_std_logic_vector(16#8e#, dsize) then
1992 if exec_cycle = T3 then
1993 front_oe(x_cmd, '0');
1996 elsif instruction = conv_std_logic_vector(16#84#, dsize) then
2000 if exec_cycle = T2 then
2001 front_oe(y_cmd, '0');
2004 elsif instruction = conv_std_logic_vector(16#94#, dsize) then
2008 if exec_cycle = T2 then
2009 front_oe(y_cmd, '0');
2012 elsif instruction = conv_std_logic_vector(16#8c#, dsize) then
2016 if exec_cycle = T3 then
2017 front_oe(y_cmd, '0');
2021 ----------------------------------------
2022 ---A.4. read-modify-write operation
2023 ----------------------------------------
2024 elsif instruction = conv_std_logic_vector(16#06#, dsize) then
2028 if exec_cycle = T4 then
2032 elsif instruction = conv_std_logic_vector(16#16#, dsize) then
2036 if exec_cycle = T5 then
2040 elsif instruction = conv_std_logic_vector(16#0e#, dsize) then
2044 if exec_cycle = T5 then
2048 elsif instruction = conv_std_logic_vector(16#1e#, dsize) then
2052 if exec_cycle = T6 then
2056 elsif instruction = conv_std_logic_vector(16#c6#, dsize) then
2060 if exec_cycle = T4 then
2064 elsif instruction = conv_std_logic_vector(16#d6#, dsize) then
2068 if exec_cycle = T5 then
2072 elsif instruction = conv_std_logic_vector(16#ce#, dsize) then
2076 if exec_cycle = T5 then
2080 elsif instruction = conv_std_logic_vector(16#de#, dsize) then
2084 if exec_cycle = T6 then
2088 elsif instruction = conv_std_logic_vector(16#e6#, dsize) then
2092 if exec_cycle = T4 then
2096 elsif instruction = conv_std_logic_vector(16#f6#, dsize) then
2100 if exec_cycle = T5 then
2104 elsif instruction = conv_std_logic_vector(16#ee#, dsize) then
2108 if exec_cycle = T5 then
2112 elsif instruction = conv_std_logic_vector(16#fe#, dsize) then
2116 if exec_cycle = T6 then
2120 elsif instruction = conv_std_logic_vector(16#46#, dsize) then
2124 if exec_cycle = T4 then
2128 elsif instruction = conv_std_logic_vector(16#56#, dsize) then
2132 if exec_cycle = T5 then
2136 elsif instruction = conv_std_logic_vector(16#4e#, dsize) then
2140 if exec_cycle = T5 then
2144 elsif instruction = conv_std_logic_vector(16#5e#, dsize) then
2148 if exec_cycle = T6 then
2152 elsif instruction = conv_std_logic_vector(16#26#, dsize) then
2156 if exec_cycle = T4 then
2160 elsif instruction = conv_std_logic_vector(16#36#, dsize) then
2164 if exec_cycle = T5 then
2168 elsif instruction = conv_std_logic_vector(16#2e#, dsize) then
2172 if exec_cycle = T5 then
2176 elsif instruction = conv_std_logic_vector(16#3e#, dsize) then
2180 if exec_cycle = T6 then
2184 elsif instruction = conv_std_logic_vector(16#66#, dsize) then
2188 if exec_cycle = T4 then
2192 elsif instruction = conv_std_logic_vector(16#76#, dsize) then
2196 if exec_cycle = T5 then
2200 elsif instruction = conv_std_logic_vector(16#6e#, dsize) then
2204 if exec_cycle = T5 then
2208 elsif instruction = conv_std_logic_vector(16#7e#, dsize) then
2212 if exec_cycle = T6 then
2217 ----------------------------------------
2218 --A.5. miscellaneous oprations.
2219 ----------------------------------------
2222 elsif instruction = conv_std_logic_vector(16#08#, dsize) then
2225 if exec_cycle = T2 then
2226 stat_bus_oe_n <= '0';
2229 elsif instruction = conv_std_logic_vector(16#48#, dsize) then
2232 if exec_cycle = T2 then
2233 front_oe(acc_cmd, '0');
2236 elsif instruction = conv_std_logic_vector(16#28#, dsize) then
2239 if exec_cycle = T3 then
2240 stat_dec_oe_n <= '1';
2241 stat_bus_all_n <= '0';
2244 elsif instruction = conv_std_logic_vector(16#68#, dsize) then
2247 if exec_cycle = T3 then
2248 front_we(acc_cmd, '0');
2253 ----------------------------------------
2255 ----------------------------------------
2256 elsif instruction = conv_std_logic_vector(16#20#, dsize) then
2257 if exec_cycle = T1 then
2258 d_print("jsr abs 2");
2261 dbuf_int_oe_n <= '0';
2265 elsif exec_cycle = T2 then
2268 dbuf_int_oe_n <= '1';
2271 --push return addr high into stack.
2274 front_oe(pch_cmd, '0');
2275 back_oe(sp_cmd, '0');
2276 back_we(sp_cmd, '0');
2279 elsif exec_cycle = T3 then
2281 front_oe(pch_cmd, '1');
2283 --push return addr low into stack.
2286 front_oe(pcl_cmd, '0');
2287 back_oe(sp_cmd, '0');
2288 back_we(sp_cmd, '0');
2292 elsif exec_cycle = T4 then
2296 front_oe(pcl_cmd, '1');
2297 back_oe(sp_cmd, '1');
2298 back_we(sp_cmd, '1');
2302 back_oe(pch_cmd, '0');
2303 back_oe(pcl_cmd, '0');
2304 dbuf_int_oe_n <= '0';
2308 elsif exec_cycle = T5 then
2311 back_oe(pch_cmd, '1');
2312 back_oe(pcl_cmd, '1');
2313 dbuf_int_oe_n <= '1';
2319 front_we(pch_cmd, '0');
2323 back_we(pcl_cmd, '0');
2326 end if; --if exec_cycle = T1 then
2329 elsif instruction = conv_std_logic_vector(16#00#, dsize) then
2331 ----------------------------------------
2332 -- A.5.5 return from interrupt
2333 ----------------------------------------
2334 elsif instruction = conv_std_logic_vector(16#40#, dsize) then
2335 if exec_cycle = T1 then
2339 --pop stack (decrement only)
2340 back_oe(sp_cmd, '0');
2341 back_we(sp_cmd, '0');
2346 elsif exec_cycle = T2 then
2350 back_oe(sp_cmd, '0');
2351 back_we(sp_cmd, '0');
2356 stat_dec_oe_n <= '1';
2357 dbuf_int_oe_n <= '0';
2358 stat_bus_all_n <= '0';
2361 elsif exec_cycle = T3 then
2363 stat_bus_all_n <= '1';
2366 back_oe(sp_cmd, '0');
2367 back_we(sp_cmd, '0');
2372 dbuf_int_oe_n <= '0';
2373 front_we(pcl_cmd, '0');
2376 elsif exec_cycle = T4 then
2378 --stack decrement stop.
2379 back_we(sp_cmd, '1');
2381 front_we(pcl_cmd, '1');
2384 back_oe(sp_cmd, '0');
2387 dbuf_int_oe_n <= '0';
2388 front_we(pch_cmd, '0');
2391 elsif exec_cycle = T5 then
2393 back_oe(sp_cmd, '1');
2396 dbuf_int_oe_n <= '1';
2397 front_we(pch_cmd, '1');
2401 end if; --if exec_cycle = T1 then
2403 ----------------------------------------
2405 ----------------------------------------
2406 elsif instruction = conv_std_logic_vector(16#4c#, dsize) then
2408 if exec_cycle = T1 then
2410 --fetch next opcode (abs low).
2413 --latch abs low data.
2414 dbuf_int_oe_n <= '0';
2417 elsif exec_cycle = T2 then
2425 dbuf_int_oe_n <= '0';
2428 front_we(pch_cmd, '0');
2433 elsif instruction = conv_std_logic_vector(16#6c#, dsize) then
2435 if exec_cycle = T1 then
2437 --fetch next opcode (abs low).
2440 --latch abs low data.
2441 dbuf_int_oe_n <= '0';
2444 elsif exec_cycle = T2 then
2452 dbuf_int_oe_n <= '0';
2456 elsif exec_cycle = T3 then
2463 front_we(pcl_cmd, '0');
2466 elsif exec_cycle = T4 then
2469 front_we(pcl_cmd, '1');
2472 front_we(pch_cmd, '0');
2480 ----------------------------------------
2481 -- A.5.7 return from soubroutine
2482 ----------------------------------------
2483 elsif instruction = conv_std_logic_vector(16#60#, dsize) then
2484 if exec_cycle = T1 then
2488 --pop stack (decrement only)
2489 back_oe(sp_cmd, '0');
2490 back_we(sp_cmd, '0');
2495 elsif exec_cycle = T2 then
2499 back_oe(sp_cmd, '0');
2500 back_we(sp_cmd, '0');
2505 dbuf_int_oe_n <= '0';
2506 front_we(pcl_cmd, '0');
2509 elsif exec_cycle = T3 then
2511 --stack decrement stop.
2512 back_we(sp_cmd, '1');
2514 front_we(pcl_cmd, '1');
2517 back_oe(sp_cmd, '0');
2520 dbuf_int_oe_n <= '0';
2521 front_we(pch_cmd, '0');
2524 elsif exec_cycle = T4 then
2526 back_oe(sp_cmd, '1');
2529 dbuf_int_oe_n <= '1';
2530 front_we(pch_cmd, '1');
2532 --complying h/w manual...
2534 elsif exec_cycle = T5 then
2540 end if; --if exec_cycle = T1 then
2542 ----------------------------------------
2543 -- A.5.8 branch operations
2544 ----------------------------------------
2545 elsif instruction = conv_std_logic_vector(16#90#, dsize) then
2547 a58_branch (st_C, '0');
2549 elsif instruction = conv_std_logic_vector(16#b0#, dsize) then
2551 a58_branch (st_C, '1');
2553 elsif instruction = conv_std_logic_vector(16#f0#, dsize) then
2555 a58_branch (st_Z, '1');
2557 elsif instruction = conv_std_logic_vector(16#30#, dsize) then
2559 a58_branch (st_N, '1');
2561 elsif instruction = conv_std_logic_vector(16#d0#, dsize) then
2563 a58_branch (st_Z, '0');
2565 elsif instruction = conv_std_logic_vector(16#10#, dsize) then
2567 a58_branch (st_N, '0');
2569 elsif instruction = conv_std_logic_vector(16#50#, dsize) then
2571 a58_branch (st_V, '0');
2573 elsif instruction = conv_std_logic_vector(16#70#, dsize) then
2575 a58_branch (st_V, '1');
2578 ---unknown instruction!!!!
2580 report "======== unknow instruction "
2581 & conv_hex8(conv_integer(instruction))
2583 end if; --if instruction = conv_std_logic_vector(16#0a#, dsize)
2585 elsif exec_cycle = R0 then
2586 d_print(string'("reset"));
2588 front_we(pch_cmd, '1');
2589 back_we(pcl_cmd, '1');
2591 --initialize port...
2594 dbuf_int_oe_n <= '1';
2621 stat_dec_oe_n <= '1';
2622 stat_bus_oe_n <= '1';
2623 stat_set_flg_n <= '1';
2625 stat_bus_all_n <= '1';
2626 stat_bus_nz_n <= '1';
2627 stat_alu_we_n <= '1';
2632 nmi_handled_n := '1';
2636 elsif exec_cycle = R1 or exec_cycle = N1 then
2648 --front_oe(pch_cmd, '0');
2649 back_oe(sp_cmd, '0');
2650 back_we(sp_cmd, '0');
2653 if exec_cycle = R1 then
2655 elsif exec_cycle = N1 then
2659 elsif exec_cycle = R2 or exec_cycle = N2 then
2660 front_oe(pch_cmd, '1');
2665 front_oe(pcl_cmd, '0');
2666 back_oe(sp_cmd, '0');
2667 back_we(sp_cmd, '0');
2670 if exec_cycle = R2 then
2672 elsif exec_cycle = N2 then
2676 elsif exec_cycle = R3 or exec_cycle = N3 then
2677 front_oe(pcl_cmd, '1');
2682 stat_bus_oe_n <= '0';
2683 back_oe(sp_cmd, '0');
2684 back_we(sp_cmd, '0');
2687 if exec_cycle = R3 then
2689 elsif exec_cycle = N3 then
2693 elsif exec_cycle = R4 or exec_cycle = N4 then
2694 stat_bus_oe_n <= '1';
2697 front_oe(pcl_cmd, '1');
2698 back_oe(sp_cmd, '1');
2699 back_we(sp_cmd, '1');
2701 --fetch reset vector low
2703 dbuf_int_oe_n <= '0';
2704 front_we(pcl_cmd, '0');
2706 if exec_cycle = R4 then
2709 elsif exec_cycle = N4 then
2714 elsif exec_cycle = R5 or exec_cycle = N5 then
2715 front_we(pcl_cmd, '1');
2717 --fetch reset vector hi
2718 front_we(pch_cmd, '0');
2721 if exec_cycle = N5 then
2722 nmi_handled_n := '0';
2724 --start execute cycle.
2727 elsif exec_cycle(5) = '1' then
2728 ---pc increment and next page.
2729 d_print(string'("pch next page..."));
2730 --pcl stop increment
2732 back_we(pcl_cmd, '1');
2734 back_we(pch_cmd, '0');
2735 back_oe(pch_cmd, '0');
2737 if ('0' & exec_cycle(4 downto 0) = T0) then
2738 --do the t0 identical routine.
2743 elsif ('0' & exec_cycle(4 downto 0) = T1) then
2744 --if fetch cycle, preserve instrution register
2747 --TODO: must handle for jmp case???
2748 elsif ('0' & exec_cycle(4 downto 0) = T2) then
2749 --disable previous we_n gate.
2750 --t1 cycle is fetch low oprand.
2752 elsif ('0' & exec_cycle(4 downto 0) = T3) then
2753 --t2 cycle is fetch high oprand.
2757 end if; --if exec_cycle = T0 then
2759 end if; --if (set_clk'event and set_clk = '1')