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;
5 use work.motonesfpga_common.all;
8 generic (dsize : integer := 8);
11 cpu_clk : in std_logic;
12 dl_cpu_clk : in std_logic;
17 instruction : in std_logic_vector (dsize - 1 downto 0);
18 exec_cycle : in std_logic_vector (5 downto 0);
19 next_cycle : out std_logic_vector (5 downto 0);
20 ea_carry : in std_logic;
21 status_reg : inout std_logic_vector (dsize - 1 downto 0);
24 inst_we_n : out std_logic;
25 ad_oe_n : out std_logic;
26 dbuf_int_oe_n : out std_logic;
29 ----control line for dual port registers.
30 idl_l_cmd : out std_logic_vector(3 downto 0);
31 idl_h_cmd : out std_logic_vector(3 downto 0);
32 pcl_cmd : out std_logic_vector(3 downto 0);
33 pch_cmd : out std_logic_vector(3 downto 0);
34 sp_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 acc_cmd : out std_logic_vector(3 downto 0);
40 pcl_inc_n : out std_logic;
41 sp_oe_n : out std_logic;
42 sp_push_n : out std_logic;
43 sp_pop_n : out std_logic;
44 abs_xy_n : out std_logic;
45 pg_next_n : out std_logic;
47 zp_xy_n : out std_logic;
48 rel_calc_n : out std_logic;
49 indir_n : out std_logic;
50 indir_x_n : out std_logic;
51 indir_y_n : out std_logic;
52 addr_cycle : out std_logic_vector(2 downto 0);
55 stat_dec_oe_n : out std_logic;
56 stat_bus_oe_n : out std_logic;
57 stat_set_flg_n : out std_logic;
58 stat_flg : out std_logic;
59 stat_bus_all_n : out std_logic;
60 stat_bus_nz_n : out std_logic;
61 stat_alu_we_n : out std_logic;
64 arith_en_n : out std_logic;
65 alu_cycle : out std_logic_vector(1 downto 0);
68 r_vec_oe_n : out std_logic;
69 n_vec_oe_n : out std_logic;
70 i_vec_oe_n : out std_logic
72 ;---for parameter check purpose!!!
73 check_bit : out std_logic_vector(1 to 5)
77 architecture rtl of decoder is
79 component d_flip_flop_bit
91 -- bit 5 : special cycle
92 -- bit 4,3 : cycle type: 00 normal, 01 reset , 10 nmi, 11 irq
95 --00xxx : exec cycle : T0 > T1 > T2 > T3 > T4 > T5 > T6 > T0
96 constant T0 : std_logic_vector (5 downto 0) := "000000";
97 constant T1 : std_logic_vector (5 downto 0) := "000001";
98 constant T2 : std_logic_vector (5 downto 0) := "000010";
99 constant T3 : std_logic_vector (5 downto 0) := "000011";
100 constant T4 : std_logic_vector (5 downto 0) := "000100";
101 constant T5 : std_logic_vector (5 downto 0) := "000101";
102 constant T6 : std_logic_vector (5 downto 0) := "000110";
110 --R5: fetch vector low
111 --R6: fetch vector high
114 --01xxx : reset cycle : R0 > R1 > R2 > R3 > R4 > R5 > R6 > T0
115 constant R0 : std_logic_vector (5 downto 0) := "001000";
116 constant R1 : std_logic_vector (5 downto 0) := "001001";
117 constant R2 : std_logic_vector (5 downto 0) := "001010";
118 constant R3 : std_logic_vector (5 downto 0) := "001011";
119 constant R4 : std_logic_vector (5 downto 0) := "001100";
120 constant R5 : std_logic_vector (5 downto 0) := "001101";
121 constant R6 : std_logic_vector (5 downto 0) := "001110";
123 --10xxx : nmi cycle : T0 > N1 > N2 > N3 > N4 > N5 > N6 > T0
124 constant N1 : std_logic_vector (5 downto 0) := "010001";
125 constant N2 : std_logic_vector (5 downto 0) := "010010";
126 constant N3 : std_logic_vector (5 downto 0) := "010011";
127 constant N4 : std_logic_vector (5 downto 0) := "010100";
128 constant N5 : std_logic_vector (5 downto 0) := "010101";
129 constant N6 : std_logic_vector (5 downto 0) := "010110";
131 --11xxx : irq cycle : T0 > I1 > I2 > I3 > I4 > I5 > I6 > T0
132 constant I1 : std_logic_vector (5 downto 0) := "011001";
133 constant I2 : std_logic_vector (5 downto 0) := "011010";
134 constant I3 : std_logic_vector (5 downto 0) := "011011";
135 constant I4 : std_logic_vector (5 downto 0) := "011100";
136 constant I5 : std_logic_vector (5 downto 0) := "011101";
137 constant I6 : std_logic_vector (5 downto 0) := "011110";
139 constant ERROR_CYCLE : std_logic_vector (5 downto 0) := "111111";
141 -- SR Flags (bit 7 to bit 0):
146 -- 3 D .... Decimal (use BCD for arithmetics)
147 -- 2 I .... Interrupt (IRQ disable)
150 constant st_N : integer := 7;
151 constant st_V : integer := 6;
152 constant st_B : integer := 4;
153 constant st_D : integer := 3;
154 constant st_I : integer := 2;
155 constant st_Z : integer := 1;
156 constant st_C : integer := 0;
158 --Address calcuration (indirect addressing) has several stages
159 constant ADDR_Z : std_logic_vector (2 downto 0) := "000";
160 constant ADDR_T2 : std_logic_vector (2 downto 0) := "001";
161 constant ADDR_T3 : std_logic_vector (2 downto 0) := "010";
162 constant ADDR_T4 : std_logic_vector (2 downto 0) := "011";
163 constant ADDR_T5 : std_logic_vector (2 downto 0) := "100";
165 --ALU cycle (memory to memory operation) has several stages
166 constant MEM_Z : std_logic_vector (1 downto 0) := "00";
167 constant MEM_T1 : std_logic_vector (1 downto 0) := "01";
168 constant MEM_T2 : std_logic_vector (1 downto 0) := "10";
169 constant MEM_T3 : std_logic_vector (1 downto 0) := "11";
172 signal nmi_handled_n : std_logic;
173 signal ea_carry_reg : std_logic;
177 ea_carry_inst: d_flip_flop_bit
178 port map(dl_cpu_clk, '1', '1', '0', ea_carry, ea_carry_reg);
180 main_p : process (cpu_clk, res_n, nmi_n)
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, '0');
221 if exec_cycle = T1 then
222 front_we(idl_l_cmd, '0');
223 elsif exec_cycle = T2 then
224 front_we(idl_l_cmd, '1');
225 front_we(idl_h_cmd, '0');
229 procedure fetch_stop is
232 back_oe(pcl_cmd, '1');
233 back_oe(pch_cmd, '1');
234 back_we(pcl_cmd, '1');
235 back_we(pch_cmd, '1');
236 front_we(idl_l_cmd, '1');
237 front_we(idl_h_cmd, '1');
240 procedure read_status is
242 status_reg <= (others => 'Z');
243 stat_dec_oe_n <= '0';
246 procedure init_all_pins is
251 dbuf_int_oe_n <= '1';
275 addr_cycle <= ADDR_Z;
278 stat_bus_oe_n <= '1';
279 stat_set_flg_n <= '1';
281 stat_bus_all_n <= '1';
282 stat_bus_nz_n <= '1';
283 stat_alu_we_n <= '1';
286 addr_cycle <= ADDR_Z;
292 nmi_handled_n <= '1';
296 procedure disable_pins is
298 --following pins are not set in this function.
299 -- inst_we_n : out std_logic;
300 -- ad_oe_n : out std_logic;
301 -- pcl_inc_n : out std_logic;
302 -- r_nw : out std_logic
304 --disable the last opration pins.
305 dbuf_int_oe_n <= '1';
327 addr_cycle <= ADDR_Z;
330 stat_bus_oe_n <= '1';
331 stat_set_flg_n <= '1';
333 stat_bus_all_n <= '1';
334 stat_bus_nz_n <= '1';
335 stat_alu_we_n <= '1';
346 procedure fetch_inst (pm_pcl_inc_n : in std_logic) is
348 if (instruction = conv_std_logic_vector(16#4c#, dsize) or
349 instruction = conv_std_logic_vector(16#20#, dsize)) then
350 --if prior cycle is jump/jsr instruction,
351 --fetch opcode from where the latch is pointing to.
354 back_oe(idl_l_cmd, '0');
357 --fetch opcode and pcl increment.
365 pcl_inc_n <= pm_pcl_inc_n;
368 d_print(string'("fetch 1"));
372 ---(along with the page boundary condition, the last
373 ---cycle is bypassed and slided to T0.)
374 procedure t0_cycle is
377 if (nmi_n = '0' and nmi_handled_n = '1') then
378 --start nmi handling...
387 ---common routine for single byte instruction.
388 procedure single_inst is
394 procedure fetch_imm is
396 d_print("immediate");
398 --send data from data bus buffer.
399 --receiver is instruction dependent.
400 dbuf_int_oe_n <= '0';
404 procedure set_nz_from_bus is
406 --status register n/z bit update.
407 stat_bus_nz_n <= '0';
410 procedure set_zc_from_alu is
412 --status register n/z bit update.
413 stat_alu_we_n <= '0';
414 stat_dec_oe_n <= '1';
415 status_reg <= "00000011";
418 procedure set_nz_from_alu is
420 --status register n/z/c bit update.
421 stat_alu_we_n <= '0';
422 stat_dec_oe_n <= '1';
423 status_reg <= "10000010";
426 procedure set_nzc_from_alu is
428 --status register n/z/c bit update.
429 stat_alu_we_n <= '0';
430 stat_dec_oe_n <= '1';
431 status_reg <= "10000011";
434 procedure set_nvz_from_alu is
436 --status register n/z/v bit update.
437 stat_alu_we_n <= '0';
438 stat_dec_oe_n <= '1';
439 status_reg <= "11000010";
442 procedure set_nvzc_from_alu is
444 stat_alu_we_n <= '0';
445 stat_dec_oe_n <= '1';
446 status_reg <= "11000011";
449 --flag on/off instruction
450 procedure set_flag (int_flg : in integer; val : in std_logic) is
452 stat_dec_oe_n <= '1';
453 stat_set_flg_n <= '0';
454 --specify which to set.
455 status_reg(7 downto int_flg + 1)
457 status_reg(int_flg - 1 downto 0)
459 status_reg(int_flg) <= '1';
464 procedure set_flag0 (val : in std_logic) is
466 stat_dec_oe_n <= '1';
467 stat_set_flg_n <= '0';
468 status_reg <= "00000001";
472 procedure fetch_low is
474 d_print("fetch low 2");
475 --fetch next opcode (abs low).
477 --latch abs low data.
478 dbuf_int_oe_n <= '0';
482 procedure abs_fetch_high is
484 d_print("abs (xy) 3");
488 dbuf_int_oe_n <= '0';
492 procedure abs_latch_out is
498 back_oe(idl_l_cmd, '0');
499 back_oe(idl_h_cmd, '0');
502 procedure ea_x_out is
504 -----calucurate and output effective addr
509 procedure ea_y_out is
515 --A.2. internal execution on memory data
519 if exec_cycle = T1 then
521 elsif exec_cycle = T2 then
523 dbuf_int_oe_n <= '0';
526 back_oe(idl_l_cmd, '0');
534 if exec_cycle = T1 then
536 elsif exec_cycle = T2 then
538 elsif exec_cycle = T3 then
540 dbuf_int_oe_n <= '0';
545 procedure a2_abs_xy (is_x : in boolean) is
547 if exec_cycle = T1 then
549 elsif exec_cycle = T2 then
551 elsif exec_cycle = T3 then
555 if (is_x = true) then
560 dbuf_int_oe_n <= '0';
563 d_print("absx step 1");
564 elsif (exec_cycle = T0 and ea_carry_reg = '1') then
565 --case page boundary crossed.
567 d_print("absx 5 (page boudary crossed.)");
574 procedure a2_zp_xy (is_x : in boolean) is
576 if exec_cycle = T1 then
578 elsif exec_cycle = T2 then
581 dbuf_int_oe_n <= '0';
584 back_oe(idl_l_cmd, '0');
587 elsif exec_cycle = T3 then
590 if (is_x = true) then
599 procedure a2_indir_y is
601 if exec_cycle = T1 then
605 elsif exec_cycle = T2 then
611 addr_cycle <= ADDR_T2;
612 back_oe(idl_l_cmd, '0');
613 dbuf_int_oe_n <= '0';
616 elsif exec_cycle = T3 then
618 addr_cycle <= ADDR_T3;
619 back_oe(idl_l_cmd, '0');
621 dbuf_int_oe_n <= '0';
624 elsif exec_cycle = T4 then
625 back_oe(idl_l_cmd, '1');
626 dbuf_int_oe_n <= '1';
632 addr_cycle <= ADDR_T4;
633 dbuf_int_oe_n <= '0';
636 elsif (exec_cycle = T0) then
637 --case page boundary crossed.
639 d_print("(indir), y (page boudary crossed.)");
643 addr_cycle <= ADDR_T5;
648 procedure a2_indir_x is
650 if exec_cycle = T1 then
654 elsif exec_cycle = T2 then
658 --output BAL @IAL, but cycle #2 is discarded
660 addr_cycle <= ADDR_T2;
661 back_oe(idl_l_cmd, '0');
664 elsif exec_cycle = T3 then
666 addr_cycle <= ADDR_T3;
667 back_oe(idl_l_cmd, '1');
670 dbuf_int_oe_n <= '0';
674 elsif exec_cycle = T4 then
676 addr_cycle <= ADDR_T4;
678 --output BAH @IAL+x+1
679 dbuf_int_oe_n <= '0';
683 elsif (exec_cycle = T5) then
685 addr_cycle <= ADDR_T5;
690 --A.3. store operation.
694 if exec_cycle = T1 then
696 elsif exec_cycle = T2 then
698 dbuf_int_oe_n <= '1';
701 back_oe(idl_l_cmd, '0');
708 procedure a3_zp_xy (is_x : in boolean) is
710 if exec_cycle = T1 then
712 elsif exec_cycle = T2 then
714 dbuf_int_oe_n <= '1';
717 back_oe(idl_l_cmd, '0');
720 elsif exec_cycle = T3 then
722 back_oe(idl_l_cmd, '0');
725 if (is_x = true) then
739 if exec_cycle = T1 then
741 elsif exec_cycle = T2 then
743 elsif exec_cycle = T3 then
745 dbuf_int_oe_n <= '1';
751 procedure a3_abs_xy (is_x : in boolean) is
753 if exec_cycle = T1 then
755 elsif exec_cycle = T2 then
757 elsif exec_cycle = T3 then
761 dbuf_int_oe_n <= '1';
762 if (is_x = true) then
768 elsif exec_cycle = T4 then
769 if (ea_carry_reg = '1') then
775 if (is_x = true) then
786 procedure a3_indir_y is
788 if exec_cycle = T1 then
792 elsif exec_cycle = T2 then
798 addr_cycle <= ADDR_T2;
799 back_oe(idl_l_cmd, '0');
800 dbuf_int_oe_n <= '0';
803 elsif exec_cycle = T3 then
805 addr_cycle <= ADDR_T3;
806 back_oe(idl_l_cmd, '0');
808 dbuf_int_oe_n <= '0';
811 elsif exec_cycle = T4 then
812 back_oe(idl_l_cmd, '1');
813 dbuf_int_oe_n <= '1';
819 addr_cycle <= ADDR_T4;
822 elsif exec_cycle = T5 then
826 addr_cycle <= ADDR_T5;
828 if (ea_carry_reg = '1') then
838 procedure a3_indir_x is
840 if exec_cycle = T1 then
844 elsif exec_cycle = T2 then
848 --output BAL @IAL, but cycle #2 is discarded
850 addr_cycle <= ADDR_T2;
851 back_oe(idl_l_cmd, '0');
854 elsif exec_cycle = T3 then
856 addr_cycle <= ADDR_T3;
857 back_oe(idl_l_cmd, '1');
860 dbuf_int_oe_n <= '0';
864 elsif exec_cycle = T4 then
866 addr_cycle <= ADDR_T4;
868 --output BAH @IAL+x+1
869 dbuf_int_oe_n <= '0';
873 elsif (exec_cycle = T5) then
875 addr_cycle <= ADDR_T5;
876 dbuf_int_oe_n <= '1';
882 ---A.4. read-modify-write operation
886 if exec_cycle = T1 then
888 elsif exec_cycle = T2 then
892 back_oe(idl_l_cmd, '0');
894 --keep data in the alu reg.
897 dbuf_int_oe_n <= '0';
899 elsif exec_cycle = T3 then
900 --t3 fix alu internal register.
901 back_oe(idl_l_cmd, '0');
905 dbuf_int_oe_n <= '1';
907 elsif exec_cycle = T4 then
908 --t5 cycle writes modified value.
909 back_oe(idl_l_cmd, '0');
920 if exec_cycle = T1 then
922 elsif exec_cycle = T2 then
924 dbuf_int_oe_n <= '1';
926 --t2 cycle read bal only.
927 back_oe(idl_l_cmd, '0');
930 elsif exec_cycle = T3 then
931 --t3 cycle read bal + x
932 back_oe(idl_l_cmd, '0');
937 --keep data in the alu reg.
940 dbuf_int_oe_n <= '0';
943 elsif exec_cycle = T4 then
944 back_oe(idl_l_cmd, '0');
949 --fix alu internal register.
952 dbuf_int_oe_n <= '1';
954 elsif exec_cycle = T5 then
955 dbuf_int_oe_n <= '1';
957 --t5 cycle writes modified value.
958 back_oe(idl_l_cmd, '0');
972 if exec_cycle = T1 then
974 elsif exec_cycle = T2 then
976 elsif exec_cycle = T3 then
979 --keep data in the alu reg.
982 dbuf_int_oe_n <= '0';
984 elsif exec_cycle = T4 then
987 --fix alu internal register.
990 dbuf_int_oe_n <= '1';
992 elsif exec_cycle = T5 then
993 dbuf_int_oe_n <= '1';
995 --t5 cycle writes modified value.
1003 procedure a4_abs_x is
1005 if exec_cycle = T1 then
1007 elsif exec_cycle = T2 then
1009 elsif exec_cycle = T3 then
1010 --T3 cycle discarded.
1014 dbuf_int_oe_n <= '0';
1017 elsif exec_cycle = T4 then
1020 if (ea_carry_reg = '1') then
1026 --keep data in the alu reg.
1028 alu_cycle <= MEM_T1;
1029 dbuf_int_oe_n <= '0';
1032 elsif exec_cycle = T5 then
1033 --fix alu internal register.
1035 alu_cycle <= MEM_T2;
1036 dbuf_int_oe_n <= '1';
1039 elsif exec_cycle = T6 then
1040 --t5 cycle writes modified value.
1043 alu_cycle <= MEM_T3;
1051 procedure a51_push is
1053 if exec_cycle = T1 then
1056 elsif exec_cycle = T2 then
1057 back_oe(sp_cmd, '0');
1058 back_we(sp_cmd, '0');
1067 procedure a52_pull is
1069 if exec_cycle = T1 then
1073 elsif exec_cycle = T2 then
1074 --stack decrement first.
1075 back_oe(sp_cmd, '0');
1076 back_we(sp_cmd, '0');
1081 elsif exec_cycle = T3 then
1083 back_we(sp_cmd, '1');
1085 ---pop data from stack.
1086 back_oe(sp_cmd, '0');
1088 dbuf_int_oe_n <= '0';
1094 -- A.5.8 branch operations
1096 procedure a58_branch (int_flg : in integer; br_cond : in std_logic) is
1098 if exec_cycle = T1 then
1100 if status_reg(int_flg) = br_cond then
1104 dbuf_int_oe_n <= '0';
1105 front_we(idl_h_cmd, '0');
1108 d_print("no branch");
1111 elsif exec_cycle = T2 then
1114 dbuf_int_oe_n <= '1';
1115 front_we(idl_h_cmd, '1');
1117 --calc relative addr.
1120 front_oe(idl_h_cmd, '0');
1121 back_oe(pcl_cmd, '0');
1122 back_oe(pch_cmd, '0');
1123 back_we(pcl_cmd, '0');
1126 elsif (exec_cycle = T0 and ea_carry = '1') then
1127 d_print("page crossed.");
1128 --page crossed. adh calc.
1129 back_we(pcl_cmd, '1');
1130 back_oe(pcl_cmd, '0');
1131 back_oe(pch_cmd, '0');
1132 back_we(pch_cmd, '0');
1133 front_oe(idl_h_cmd, '0');
1141 -------------------------------------------------------------
1142 -------------------------------------------------------------
1143 ---------------- main state machine start.... ---------------
1144 -------------------------------------------------------------
1145 -------------------------------------------------------------
1148 if (res_n = '0') then
1149 --prevent status revister from broken.
1150 stat_dec_oe_n <= '0';
1151 stat_bus_oe_n <= '1';
1152 stat_set_flg_n <= '1';
1154 stat_bus_all_n <= '1';
1155 stat_bus_nz_n <= '1';
1156 stat_alu_we_n <= '1';
1158 --pc l/h is reset vector.
1163 elsif (rising_edge(cpu_clk)) then
1164 d_print(string'("-"));
1166 if (nmi_n = '1') then
1167 --nmi handle flag reset.
1168 nmi_handled_n <= '1';
1172 --case dma is runnting.
1176 back_oe(idl_l_cmd, '1');
1182 elsif (exec_cycle = T0 and ea_carry = '0') then
1186 elsif exec_cycle = T1 or exec_cycle = T2 or exec_cycle = T3 or
1187 exec_cycle = T4 or exec_cycle = T5 or exec_cycle = T6 or
1188 (exec_cycle = T0 and ea_carry = '1') then
1191 ---asyncronous page change might happen.
1192 back_we(pch_cmd, '1');
1194 if exec_cycle = T1 then
1195 d_print("decode and execute inst: "
1196 & conv_hex8(conv_integer(instruction)));
1197 --disable pin for jmp instruction
1198 back_oe(idl_l_cmd, '1');
1199 back_we(pcl_cmd, '1');
1200 front_we(pch_cmd, '1');
1202 --grab instruction register data.
1206 --imelementation is wriiten in the order of hardware manual
1209 ----------------------------------------
1210 --A.1. Single byte instruction.
1211 ----------------------------------------
1212 if instruction = conv_std_logic_vector(16#0a#, dsize) then
1216 back_oe(acc_cmd, '0');
1217 front_we(acc_cmd, '0');
1221 elsif instruction = conv_std_logic_vector(16#18#, dsize) then
1226 elsif instruction = conv_std_logic_vector(16#d8#, dsize) then
1228 set_flag (st_D, '0');
1231 elsif instruction = conv_std_logic_vector(16#58#, dsize) then
1233 set_flag (st_I, '0');
1236 elsif instruction = conv_std_logic_vector(16#b8#, dsize) then
1238 set_flag (st_V, '0');
1241 elsif instruction = conv_std_logic_vector(16#ca#, dsize) then
1244 back_oe(x_cmd, '0');
1245 front_we(x_cmd, '0');
1250 elsif instruction = conv_std_logic_vector(16#88#, dsize) then
1253 back_oe(y_cmd, '0');
1254 front_we(y_cmd, '0');
1259 elsif instruction = conv_std_logic_vector(16#e8#, dsize) then
1262 back_oe(x_cmd, '0');
1263 front_we(x_cmd, '0');
1268 elsif instruction = conv_std_logic_vector(16#c8#, dsize) then
1271 back_oe(y_cmd, '0');
1272 front_we(y_cmd, '0');
1276 elsif instruction = conv_std_logic_vector(16#4a#, dsize) then
1280 back_oe(acc_cmd, '0');
1281 front_we(acc_cmd, '0');
1285 elsif instruction = conv_std_logic_vector(16#ea#, dsize) then
1289 elsif instruction = conv_std_logic_vector(16#2a#, dsize) then
1293 back_oe(acc_cmd, '0');
1294 front_we(acc_cmd, '0');
1298 elsif instruction = conv_std_logic_vector(16#6a#, dsize) then
1302 back_oe(acc_cmd, '0');
1303 front_we(acc_cmd, '0');
1307 elsif instruction = conv_std_logic_vector(16#38#, dsize) then
1312 elsif instruction = conv_std_logic_vector(16#f8#, dsize) then
1314 set_flag (st_D, '1');
1317 elsif instruction = conv_std_logic_vector(16#78#, dsize) then
1319 set_flag (st_I, '1');
1322 elsif instruction = conv_std_logic_vector(16#aa#, dsize) then
1326 front_oe(acc_cmd, '0');
1327 front_we(x_cmd, '0');
1329 elsif instruction = conv_std_logic_vector(16#a8#, dsize) then
1333 front_oe(acc_cmd, '0');
1334 front_we(y_cmd, '0');
1336 elsif instruction = conv_std_logic_vector(16#ba#, dsize) then
1340 front_oe(sp_cmd, '0');
1341 front_we(x_cmd, '0');
1343 elsif instruction = conv_std_logic_vector(16#8a#, dsize) then
1347 front_oe(x_cmd, '0');
1348 front_we(acc_cmd, '0');
1350 elsif instruction = conv_std_logic_vector(16#9a#, dsize) then
1354 front_oe(x_cmd, '0');
1355 front_we(sp_cmd, '0');
1357 elsif instruction = conv_std_logic_vector(16#98#, dsize) then
1361 front_oe(y_cmd, '0');
1362 front_we(acc_cmd, '0');
1366 ----------------------------------------
1367 --A.2. internal execution on memory data
1368 ----------------------------------------
1369 elsif instruction = conv_std_logic_vector(16#69#, dsize) then
1374 back_oe(acc_cmd, '0');
1375 back_we(acc_cmd, '0');
1378 elsif instruction = conv_std_logic_vector(16#65#, dsize) then
1382 if exec_cycle = T2 then
1384 back_oe(acc_cmd, '0');
1385 back_we(acc_cmd, '0');
1389 elsif instruction = conv_std_logic_vector(16#75#, dsize) then
1393 if exec_cycle = T3 then
1395 back_oe(acc_cmd, '0');
1396 back_we(acc_cmd, '0');
1400 elsif instruction = conv_std_logic_vector(16#6d#, dsize) then
1404 if exec_cycle = T3 then
1406 back_oe(acc_cmd, '0');
1407 back_we(acc_cmd, '0');
1411 elsif instruction = conv_std_logic_vector(16#7d#, dsize) then
1415 if exec_cycle = T3 or exec_cycle = T0 then
1417 back_oe(acc_cmd, '0');
1418 back_we(acc_cmd, '0');
1422 elsif instruction = conv_std_logic_vector(16#79#, dsize) then
1426 if exec_cycle = T3 or exec_cycle = T0 then
1428 back_oe(acc_cmd, '0');
1429 back_we(acc_cmd, '0');
1433 elsif instruction = conv_std_logic_vector(16#61#, dsize) then
1437 if exec_cycle = T5 then
1439 back_oe(acc_cmd, '0');
1440 back_we(acc_cmd, '0');
1444 elsif instruction = conv_std_logic_vector(16#71#, dsize) then
1448 if exec_cycle = T4 or exec_cycle = T0 then
1450 back_oe(acc_cmd, '0');
1451 back_we(acc_cmd, '0');
1455 elsif instruction = conv_std_logic_vector(16#29#, dsize) then
1460 back_oe(acc_cmd, '0');
1461 back_we(acc_cmd, '0');
1464 elsif instruction = conv_std_logic_vector(16#25#, dsize) then
1468 if exec_cycle = T2 then
1470 back_oe(acc_cmd, '0');
1471 back_we(acc_cmd, '0');
1475 elsif instruction = conv_std_logic_vector(16#35#, dsize) then
1479 if exec_cycle = T3 then
1481 back_oe(acc_cmd, '0');
1482 back_we(acc_cmd, '0');
1486 elsif instruction = conv_std_logic_vector(16#2d#, dsize) then
1490 if exec_cycle = T3 then
1492 back_oe(acc_cmd, '0');
1493 back_we(acc_cmd, '0');
1497 elsif instruction = conv_std_logic_vector(16#3d#, dsize) then
1501 if exec_cycle = T3 or exec_cycle = T0 then
1503 back_oe(acc_cmd, '0');
1504 back_we(acc_cmd, '0');
1508 elsif instruction = conv_std_logic_vector(16#39#, dsize) then
1512 if exec_cycle = T3 or exec_cycle = T0 then
1514 back_oe(acc_cmd, '0');
1515 back_we(acc_cmd, '0');
1519 elsif instruction = conv_std_logic_vector(16#21#, dsize) then
1523 if exec_cycle = T5 then
1525 back_oe(acc_cmd, '0');
1526 back_we(acc_cmd, '0');
1530 elsif instruction = conv_std_logic_vector(16#31#, dsize) then
1534 if exec_cycle = T4 or exec_cycle = T0 then
1536 back_oe(acc_cmd, '0');
1537 back_we(acc_cmd, '0');
1541 elsif instruction = conv_std_logic_vector(16#24#, dsize) then
1545 if exec_cycle = T2 then
1547 back_oe(acc_cmd, '0');
1551 elsif instruction = conv_std_logic_vector(16#2c#, dsize) then
1555 if exec_cycle = T3 then
1557 back_oe(acc_cmd, '0');
1561 elsif instruction = conv_std_logic_vector(16#c9#, dsize) then
1566 back_oe(acc_cmd, '0');
1569 elsif instruction = conv_std_logic_vector(16#c5#, dsize) then
1573 if exec_cycle = T2 then
1575 back_oe(acc_cmd, '0');
1579 elsif instruction = conv_std_logic_vector(16#d5#, dsize) then
1583 if exec_cycle = T3 then
1585 back_oe(acc_cmd, '0');
1589 elsif instruction = conv_std_logic_vector(16#cd#, dsize) then
1593 if exec_cycle = T3 then
1595 back_oe(acc_cmd, '0');
1599 elsif instruction = conv_std_logic_vector(16#dd#, dsize) then
1603 if exec_cycle = T3 or exec_cycle = T0 then
1605 back_oe(acc_cmd, '0');
1609 elsif instruction = conv_std_logic_vector(16#d9#, dsize) then
1613 if exec_cycle = T3 or exec_cycle = T0 then
1615 back_oe(acc_cmd, '0');
1619 elsif instruction = conv_std_logic_vector(16#c1#, dsize) then
1623 if exec_cycle = T5 then
1625 back_oe(acc_cmd, '0');
1629 elsif instruction = conv_std_logic_vector(16#d1#, dsize) then
1633 if exec_cycle = T4 or exec_cycle = T0 then
1635 back_oe(acc_cmd, '0');
1639 elsif instruction = conv_std_logic_vector(16#e0#, dsize) then
1644 back_oe(x_cmd, '0');
1647 elsif instruction = conv_std_logic_vector(16#e4#, dsize) then
1651 if exec_cycle = T2 then
1653 back_oe(x_cmd, '0');
1657 elsif instruction = conv_std_logic_vector(16#ec#, dsize) then
1661 if exec_cycle = T3 then
1663 back_oe(x_cmd, '0');
1667 elsif instruction = conv_std_logic_vector(16#c0#, dsize) then
1672 back_oe(y_cmd, '0');
1675 elsif instruction = conv_std_logic_vector(16#c4#, dsize) then
1679 if exec_cycle = T2 then
1681 back_oe(y_cmd, '0');
1685 elsif instruction = conv_std_logic_vector(16#cc#, dsize) then
1689 if exec_cycle = T3 then
1691 back_oe(y_cmd, '0');
1695 elsif instruction = conv_std_logic_vector(16#49#, dsize) then
1700 back_oe(acc_cmd, '0');
1701 back_we(acc_cmd, '0');
1704 elsif instruction = conv_std_logic_vector(16#45#, dsize) then
1708 if exec_cycle = T2 then
1710 back_oe(acc_cmd, '0');
1711 back_we(acc_cmd, '0');
1715 elsif instruction = conv_std_logic_vector(16#55#, dsize) then
1719 if exec_cycle = T3 then
1721 back_oe(acc_cmd, '0');
1722 back_we(acc_cmd, '0');
1726 elsif instruction = conv_std_logic_vector(16#4d#, dsize) then
1730 if exec_cycle = T3 then
1732 back_oe(acc_cmd, '0');
1733 back_we(acc_cmd, '0');
1737 elsif instruction = conv_std_logic_vector(16#5d#, dsize) then
1741 if exec_cycle = T3 or exec_cycle = T0 then
1743 back_oe(acc_cmd, '0');
1744 back_we(acc_cmd, '0');
1748 elsif instruction = conv_std_logic_vector(16#59#, dsize) then
1752 if exec_cycle = T3 or exec_cycle = T0 then
1754 back_oe(acc_cmd, '0');
1755 back_we(acc_cmd, '0');
1759 elsif instruction = conv_std_logic_vector(16#41#, dsize) then
1763 if exec_cycle = T5 then
1765 back_oe(acc_cmd, '0');
1766 back_we(acc_cmd, '0');
1770 elsif instruction = conv_std_logic_vector(16#51#, dsize) then
1774 if exec_cycle = T4 or exec_cycle = T0 then
1776 back_oe(acc_cmd, '0');
1777 back_we(acc_cmd, '0');
1781 elsif instruction = conv_std_logic_vector(16#a9#, dsize) then
1785 front_we(acc_cmd, '0');
1788 elsif instruction = conv_std_logic_vector(16#a5#, dsize) then
1792 if exec_cycle = T2 then
1793 front_we(acc_cmd, '0');
1797 elsif instruction = conv_std_logic_vector(16#b5#, dsize) then
1801 if exec_cycle = T3 then
1802 front_we(acc_cmd, '0');
1806 elsif instruction = conv_std_logic_vector(16#ad#, dsize) then
1810 if exec_cycle = T3 then
1812 front_we(acc_cmd, '0');
1815 elsif instruction = conv_std_logic_vector(16#bd#, dsize) then
1819 if exec_cycle = T3 or exec_cycle = T0 then
1821 front_we(acc_cmd, '0');
1825 elsif instruction = conv_std_logic_vector(16#b9#, dsize) then
1829 if exec_cycle = T3 or exec_cycle = T0 then
1831 front_we(acc_cmd, '0');
1835 elsif instruction = conv_std_logic_vector(16#a1#, dsize) then
1839 if exec_cycle = T5 then
1840 front_we(acc_cmd, '0');
1844 elsif instruction = conv_std_logic_vector(16#b1#, dsize) then
1848 if exec_cycle = T4 or exec_cycle = T0 then
1850 front_we(acc_cmd, '0');
1854 elsif instruction = conv_std_logic_vector(16#a2#, dsize) then
1859 front_we(x_cmd, '0');
1861 elsif instruction = conv_std_logic_vector(16#a6#, dsize) then
1865 if exec_cycle = T2 then
1866 front_we(x_cmd, '0');
1870 elsif instruction = conv_std_logic_vector(16#b6#, dsize) then
1874 if exec_cycle = T3 then
1875 front_we(x_cmd, '0');
1879 elsif instruction = conv_std_logic_vector(16#ae#, dsize) then
1883 if exec_cycle = T3 then
1885 front_we(x_cmd, '0');
1888 elsif instruction = conv_std_logic_vector(16#be#, dsize) then
1892 if exec_cycle = T3 or exec_cycle = T0 then
1893 front_we(x_cmd, '0');
1897 elsif instruction = conv_std_logic_vector(16#a0#, dsize) then
1902 front_we(y_cmd, '0');
1904 elsif instruction = conv_std_logic_vector(16#a4#, dsize) then
1908 if exec_cycle = T2 then
1909 front_we(y_cmd, '0');
1913 elsif instruction = conv_std_logic_vector(16#b4#, dsize) then
1917 if exec_cycle = T3 then
1918 front_we(y_cmd, '0');
1922 elsif instruction = conv_std_logic_vector(16#ac#, dsize) then
1926 if exec_cycle = T3 then
1928 front_we(y_cmd, '0');
1931 elsif instruction = conv_std_logic_vector(16#bc#, dsize) then
1935 if exec_cycle = T3 or exec_cycle = T0 then
1937 front_we(y_cmd, '0');
1940 elsif instruction = conv_std_logic_vector(16#09#, dsize) then
1945 back_oe(acc_cmd, '0');
1946 back_we(acc_cmd, '0');
1949 elsif instruction = conv_std_logic_vector(16#05#, dsize) then
1953 if exec_cycle = T2 then
1955 back_oe(acc_cmd, '0');
1956 back_we(acc_cmd, '0');
1960 elsif instruction = conv_std_logic_vector(16#15#, dsize) then
1964 if exec_cycle = T3 then
1966 back_oe(acc_cmd, '0');
1967 back_we(acc_cmd, '0');
1971 elsif instruction = conv_std_logic_vector(16#0d#, dsize) then
1975 if exec_cycle = T3 then
1977 back_oe(acc_cmd, '0');
1978 back_we(acc_cmd, '0');
1982 elsif instruction = conv_std_logic_vector(16#1d#, dsize) then
1986 if exec_cycle = T3 or exec_cycle = T0 then
1988 back_oe(acc_cmd, '0');
1989 back_we(acc_cmd, '0');
1993 elsif instruction = conv_std_logic_vector(16#19#, dsize) then
1997 if exec_cycle = T3 or exec_cycle = T0 then
1999 back_oe(acc_cmd, '0');
2000 back_we(acc_cmd, '0');
2004 elsif instruction = conv_std_logic_vector(16#01#, dsize) then
2008 if exec_cycle = T5 then
2010 back_oe(acc_cmd, '0');
2011 back_we(acc_cmd, '0');
2015 elsif instruction = conv_std_logic_vector(16#11#, dsize) then
2019 if exec_cycle = T4 or exec_cycle = T0 then
2021 back_oe(acc_cmd, '0');
2022 back_we(acc_cmd, '0');
2026 elsif instruction = conv_std_logic_vector(16#e9#, dsize) then
2031 back_oe(acc_cmd, '0');
2032 back_we(acc_cmd, '0');
2035 elsif instruction = conv_std_logic_vector(16#e5#, dsize) then
2039 if exec_cycle = T2 then
2041 back_oe(acc_cmd, '0');
2042 back_we(acc_cmd, '0');
2046 elsif instruction = conv_std_logic_vector(16#f5#, dsize) then
2050 if exec_cycle = T3 then
2052 back_oe(acc_cmd, '0');
2053 back_we(acc_cmd, '0');
2057 elsif instruction = conv_std_logic_vector(16#ed#, dsize) then
2061 if exec_cycle = T3 then
2063 back_oe(acc_cmd, '0');
2064 back_we(acc_cmd, '0');
2068 elsif instruction = conv_std_logic_vector(16#fd#, dsize) then
2072 if exec_cycle = T3 or exec_cycle = T0 then
2074 back_oe(acc_cmd, '0');
2075 back_we(acc_cmd, '0');
2079 elsif instruction = conv_std_logic_vector(16#f9#, dsize) then
2083 if exec_cycle = T3 or exec_cycle = T0 then
2085 back_oe(acc_cmd, '0');
2086 back_we(acc_cmd, '0');
2090 elsif instruction = conv_std_logic_vector(16#e1#, dsize) then
2094 if exec_cycle = T5 then
2096 back_oe(acc_cmd, '0');
2097 back_we(acc_cmd, '0');
2101 elsif instruction = conv_std_logic_vector(16#f1#, dsize) then
2105 if exec_cycle = T4 or exec_cycle = T0 then
2107 back_oe(acc_cmd, '0');
2108 back_we(acc_cmd, '0');
2114 ----------------------------------------
2115 ---A.3. store operation.
2116 ----------------------------------------
2117 elsif instruction = conv_std_logic_vector(16#85#, dsize) then
2121 if exec_cycle = T2 then
2122 front_oe(acc_cmd, '0');
2125 elsif instruction = conv_std_logic_vector(16#95#, dsize) then
2129 if exec_cycle = T2 then
2130 front_oe(acc_cmd, '0');
2133 elsif instruction = conv_std_logic_vector(16#8d#, dsize) then
2137 if exec_cycle = T3 then
2138 front_oe(acc_cmd, '0');
2141 elsif instruction = conv_std_logic_vector(16#9d#, dsize) then
2145 if exec_cycle = T4 then
2146 front_oe(acc_cmd, '0');
2149 elsif instruction = conv_std_logic_vector(16#99#, dsize) then
2153 if exec_cycle = T4 then
2154 front_oe(acc_cmd, '0');
2157 elsif instruction = conv_std_logic_vector(16#81#, dsize) then
2161 if exec_cycle = T5 then
2162 front_oe(acc_cmd, '0');
2165 elsif instruction = conv_std_logic_vector(16#91#, dsize) then
2169 if exec_cycle = T5 then
2170 front_oe(acc_cmd, '0');
2173 elsif instruction = conv_std_logic_vector(16#86#, dsize) then
2177 if exec_cycle = T2 then
2178 front_oe(x_cmd, '0');
2181 elsif instruction = conv_std_logic_vector(16#96#, dsize) then
2185 if exec_cycle = T2 then
2186 front_oe(x_cmd, '0');
2189 elsif instruction = conv_std_logic_vector(16#8e#, dsize) then
2193 if exec_cycle = T3 then
2194 front_oe(x_cmd, '0');
2197 elsif instruction = conv_std_logic_vector(16#84#, dsize) then
2201 if exec_cycle = T2 then
2202 front_oe(y_cmd, '0');
2205 elsif instruction = conv_std_logic_vector(16#94#, dsize) then
2209 if exec_cycle = T2 then
2210 front_oe(y_cmd, '0');
2213 elsif instruction = conv_std_logic_vector(16#8c#, dsize) then
2217 if exec_cycle = T3 then
2218 front_oe(y_cmd, '0');
2222 ----------------------------------------
2223 ---A.4. read-modify-write operation
2224 ----------------------------------------
2225 elsif instruction = conv_std_logic_vector(16#06#, dsize) then
2229 if exec_cycle = T4 then
2233 elsif instruction = conv_std_logic_vector(16#16#, dsize) then
2237 if exec_cycle = T5 then
2241 elsif instruction = conv_std_logic_vector(16#0e#, dsize) then
2245 if exec_cycle = T5 then
2249 elsif instruction = conv_std_logic_vector(16#1e#, dsize) then
2253 if exec_cycle = T6 then
2257 elsif instruction = conv_std_logic_vector(16#c6#, dsize) then
2261 if exec_cycle = T4 then
2265 elsif instruction = conv_std_logic_vector(16#d6#, dsize) then
2269 if exec_cycle = T5 then
2273 elsif instruction = conv_std_logic_vector(16#ce#, dsize) then
2277 if exec_cycle = T5 then
2281 elsif instruction = conv_std_logic_vector(16#de#, dsize) then
2285 if exec_cycle = T6 then
2289 elsif instruction = conv_std_logic_vector(16#e6#, dsize) then
2293 if exec_cycle = T4 then
2297 elsif instruction = conv_std_logic_vector(16#f6#, dsize) then
2301 if exec_cycle = T5 then
2305 elsif instruction = conv_std_logic_vector(16#ee#, dsize) then
2309 if exec_cycle = T5 then
2313 elsif instruction = conv_std_logic_vector(16#fe#, dsize) then
2317 if exec_cycle = T6 then
2321 elsif instruction = conv_std_logic_vector(16#46#, dsize) then
2325 if exec_cycle = T4 then
2329 elsif instruction = conv_std_logic_vector(16#56#, dsize) then
2333 if exec_cycle = T5 then
2337 elsif instruction = conv_std_logic_vector(16#4e#, dsize) then
2341 if exec_cycle = T5 then
2345 elsif instruction = conv_std_logic_vector(16#5e#, dsize) then
2349 if exec_cycle = T6 then
2353 elsif instruction = conv_std_logic_vector(16#26#, dsize) then
2357 if exec_cycle = T4 then
2361 elsif instruction = conv_std_logic_vector(16#36#, dsize) then
2365 if exec_cycle = T5 then
2369 elsif instruction = conv_std_logic_vector(16#2e#, dsize) then
2373 if exec_cycle = T5 then
2377 elsif instruction = conv_std_logic_vector(16#3e#, dsize) then
2381 if exec_cycle = T6 then
2385 elsif instruction = conv_std_logic_vector(16#66#, dsize) then
2389 if exec_cycle = T4 then
2393 elsif instruction = conv_std_logic_vector(16#76#, dsize) then
2397 if exec_cycle = T5 then
2401 elsif instruction = conv_std_logic_vector(16#6e#, dsize) then
2405 if exec_cycle = T5 then
2409 elsif instruction = conv_std_logic_vector(16#7e#, dsize) then
2413 if exec_cycle = T6 then
2418 ----------------------------------------
2419 --A.5. miscellaneous oprations.
2420 ----------------------------------------
2423 elsif instruction = conv_std_logic_vector(16#08#, dsize) then
2426 if exec_cycle = T2 then
2427 stat_bus_oe_n <= '0';
2430 elsif instruction = conv_std_logic_vector(16#48#, dsize) then
2433 if exec_cycle = T2 then
2434 front_oe(acc_cmd, '0');
2437 elsif instruction = conv_std_logic_vector(16#28#, dsize) then
2440 if exec_cycle = T3 then
2441 stat_dec_oe_n <= '1';
2442 stat_bus_all_n <= '0';
2445 elsif instruction = conv_std_logic_vector(16#68#, dsize) then
2448 if exec_cycle = T3 then
2449 front_we(acc_cmd, '0');
2454 ----------------------------------------
2456 ----------------------------------------
2457 elsif instruction = conv_std_logic_vector(16#20#, dsize) then
2458 if exec_cycle = T1 then
2459 d_print("jsr abs 2");
2462 dbuf_int_oe_n <= '0';
2465 elsif exec_cycle = T2 then
2468 dbuf_int_oe_n <= '1';
2470 --read sp (discarded).
2472 back_oe(sp_cmd, '0');
2475 elsif exec_cycle = T3 then
2477 front_oe(pch_cmd, '1');
2479 --push return addr high into stack.
2482 front_oe(pch_cmd, '0');
2483 back_oe(sp_cmd, '0');
2484 back_we(sp_cmd, '0');
2488 elsif exec_cycle = T4 then
2490 front_oe(pch_cmd, '1');
2492 --push return addr low into stack.
2495 front_oe(pcl_cmd, '0');
2496 back_oe(sp_cmd, '0');
2497 back_we(sp_cmd, '0');
2501 elsif exec_cycle = T5 then
2505 front_oe(pcl_cmd, '1');
2506 back_oe(sp_cmd, '1');
2507 back_we(sp_cmd, '1');
2511 dbuf_int_oe_n <= '0';
2512 back_oe(pch_cmd, '0');
2513 back_oe(pcl_cmd, '0');
2514 front_we(pch_cmd, '0');
2517 end if; --if exec_cycle = T1 then
2520 elsif instruction = conv_std_logic_vector(16#00#, dsize) then
2522 ----------------------------------------
2523 -- A.5.5 return from interrupt
2524 ----------------------------------------
2525 elsif instruction = conv_std_logic_vector(16#40#, dsize) then
2526 if exec_cycle = T1 then
2530 --pop stack (decrement only)
2531 back_oe(sp_cmd, '0');
2532 back_we(sp_cmd, '0');
2537 elsif exec_cycle = T2 then
2541 back_oe(sp_cmd, '0');
2542 back_we(sp_cmd, '0');
2547 stat_dec_oe_n <= '1';
2548 dbuf_int_oe_n <= '0';
2549 stat_bus_all_n <= '0';
2552 elsif exec_cycle = T3 then
2554 stat_bus_all_n <= '1';
2557 back_oe(sp_cmd, '0');
2558 back_we(sp_cmd, '0');
2563 dbuf_int_oe_n <= '0';
2564 front_we(pcl_cmd, '0');
2567 elsif exec_cycle = T4 then
2569 --stack decrement stop.
2570 back_we(sp_cmd, '1');
2572 front_we(pcl_cmd, '1');
2575 back_oe(sp_cmd, '0');
2578 dbuf_int_oe_n <= '0';
2579 front_we(pch_cmd, '0');
2582 elsif exec_cycle = T5 then
2584 back_oe(sp_cmd, '1');
2587 dbuf_int_oe_n <= '1';
2588 front_we(pch_cmd, '1');
2592 end if; --if exec_cycle = T1 then
2594 ----------------------------------------
2596 ----------------------------------------
2597 elsif instruction = conv_std_logic_vector(16#4c#, dsize) then
2599 if exec_cycle = T1 then
2601 --fetch next opcode (abs low).
2604 --latch abs low data.
2605 dbuf_int_oe_n <= '0';
2607 elsif exec_cycle = T2 then
2614 dbuf_int_oe_n <= '0';
2616 front_we(pch_cmd, '0');
2621 elsif instruction = conv_std_logic_vector(16#6c#, dsize) then
2623 if exec_cycle = T1 then
2625 --fetch next opcode (abs low).
2628 --latch abs low data.
2629 dbuf_int_oe_n <= '0';
2631 elsif exec_cycle = T2 then
2638 dbuf_int_oe_n <= '0';
2641 elsif exec_cycle = T3 then
2645 back_oe(idl_h_cmd, '0');
2646 back_oe(idl_l_cmd, '0');
2647 front_we(pcl_cmd, '0');
2650 elsif exec_cycle = T4 then
2651 back_oe(idl_h_cmd, '0');
2652 back_oe(idl_l_cmd, '0');
2653 front_we(pcl_cmd, '1');
2656 front_we(pch_cmd, '0');
2664 ----------------------------------------
2665 -- A.5.7 return from soubroutine
2666 ----------------------------------------
2667 elsif instruction = conv_std_logic_vector(16#60#, dsize) then
2668 if exec_cycle = T1 then
2672 --pop stack (decrement only)
2673 back_oe(sp_cmd, '0');
2674 back_we(sp_cmd, '0');
2679 elsif exec_cycle = T2 then
2683 back_oe(sp_cmd, '0');
2684 back_we(sp_cmd, '0');
2689 dbuf_int_oe_n <= '0';
2690 front_we(pcl_cmd, '0');
2693 elsif exec_cycle = T3 then
2695 --stack decrement stop.
2696 back_we(sp_cmd, '1');
2698 front_we(pcl_cmd, '1');
2701 back_oe(sp_cmd, '0');
2704 dbuf_int_oe_n <= '0';
2705 front_we(pch_cmd, '0');
2708 elsif exec_cycle = T4 then
2710 back_oe(sp_cmd, '1');
2713 dbuf_int_oe_n <= '1';
2714 front_we(pch_cmd, '1');
2716 --complying h/w manual...
2718 elsif exec_cycle = T5 then
2724 end if; --if exec_cycle = T1 then
2726 ----------------------------------------
2727 -- A.5.8 branch operations
2728 ----------------------------------------
2729 elsif instruction = conv_std_logic_vector(16#90#, dsize) then
2731 a58_branch (st_C, '0');
2733 elsif instruction = conv_std_logic_vector(16#b0#, dsize) then
2735 a58_branch (st_C, '1');
2737 elsif instruction = conv_std_logic_vector(16#f0#, dsize) then
2739 a58_branch (st_Z, '1');
2741 elsif instruction = conv_std_logic_vector(16#30#, dsize) then
2743 a58_branch (st_N, '1');
2745 elsif instruction = conv_std_logic_vector(16#d0#, dsize) then
2747 a58_branch (st_Z, '0');
2749 elsif instruction = conv_std_logic_vector(16#10#, dsize) then
2751 a58_branch (st_N, '0');
2753 elsif instruction = conv_std_logic_vector(16#50#, dsize) then
2755 a58_branch (st_V, '0');
2757 elsif instruction = conv_std_logic_vector(16#70#, dsize) then
2759 a58_branch (st_V, '1');
2762 ---unknown instruction!!!!
2764 report "======== unknow instruction "
2765 & conv_hex8(conv_integer(instruction))
2767 end if; --if instruction = conv_std_logic_vector(16#0a#, dsize)
2769 elsif exec_cycle = R0 then
2770 d_print(string'("reset"));
2774 elsif exec_cycle = R1 or exec_cycle = N1 then
2777 if exec_cycle = R1 then
2779 elsif exec_cycle = N1 then
2782 elsif exec_cycle = R2 or exec_cycle = N2 then
2786 back_oe(idl_l_cmd, '1');
2794 --front_oe(pch_cmd, '0');
2795 back_oe(sp_cmd, '0');
2796 back_we(sp_cmd, '0');
2799 if exec_cycle = R2 then
2801 elsif exec_cycle = N2 then
2805 elsif exec_cycle = R3 or exec_cycle = N3 then
2806 front_oe(pch_cmd, '1');
2811 front_oe(pcl_cmd, '0');
2812 back_oe(sp_cmd, '0');
2813 back_we(sp_cmd, '0');
2816 if exec_cycle = R3 then
2818 elsif exec_cycle = N3 then
2822 elsif exec_cycle = R4 or exec_cycle = N4 then
2823 front_oe(pcl_cmd, '1');
2828 stat_bus_oe_n <= '0';
2829 back_oe(sp_cmd, '0');
2830 back_we(sp_cmd, '0');
2833 if exec_cycle = R4 then
2835 elsif exec_cycle = N4 then
2839 elsif exec_cycle = R5 or exec_cycle = N5 then
2840 stat_bus_oe_n <= '1';
2843 front_oe(pcl_cmd, '1');
2844 back_oe(sp_cmd, '1');
2845 back_we(sp_cmd, '1');
2847 --fetch reset vector low
2849 dbuf_int_oe_n <= '0';
2850 front_we(pcl_cmd, '0');
2851 back_oe(idl_l_cmd, '1');
2852 back_oe(idl_h_cmd, '1');
2854 if exec_cycle = R5 then
2858 elsif exec_cycle = N5 then
2864 elsif exec_cycle = R6 or exec_cycle = N6 then
2865 front_we(pcl_cmd, '1');
2867 --fetch reset vector hi
2869 dbuf_int_oe_n <= '0';
2870 front_we(pch_cmd, '0');
2871 addr_cycle <= ADDR_T2;
2873 if exec_cycle = N6 then
2874 nmi_handled_n <= '0';
2876 --start execute cycle.
2879 end if; --if rdy = '0' then
2881 end if; -- if (res_n = '0') then