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);
10 -- signal dbg_ea_carry : out std_logic;
13 set_clk : in std_logic;
14 trig_clk : in std_logic;
19 instruction : in std_logic_vector (dsize - 1 downto 0);
20 exec_cycle : in std_logic_vector (5 downto 0);
21 next_cycle : out std_logic_vector (5 downto 0);
22 status_reg : inout std_logic_vector (dsize - 1 downto 0);
23 inst_we_n : out std_logic;
24 ad_oe_n : out std_logic;
25 dbuf_int_oe_n : out std_logic;
26 dl_al_we_n : out std_logic;
27 dl_ah_we_n : out std_logic;
28 dl_al_oe_n : out std_logic;
29 dl_ah_oe_n : out std_logic;
30 dl_dh_oe_n : out std_logic;
31 pcl_inc_n : out std_logic;
32 pch_inc_n : out std_logic;
33 pcl_cmd : out std_logic_vector(3 downto 0);
34 pch_cmd : out std_logic_vector(3 downto 0);
35 sp_cmd : out std_logic_vector(3 downto 0);
36 sp_oe_n : out std_logic;
37 sp_push_n : out std_logic;
38 sp_pop_n : out std_logic;
39 acc_cmd : out std_logic_vector(3 downto 0);
40 x_cmd : out std_logic_vector(3 downto 0);
41 y_cmd : out std_logic_vector(3 downto 0);
42 abs_xy_n : out std_logic;
43 ea_carry : in std_logic;
44 pg_next_n : out std_logic;
46 zp_xy_n : out std_logic;
47 rel_calc_n : out std_logic;
48 indir_n : out std_logic;
49 indir_x_n : out std_logic;
50 indir_y_n : out std_logic;
51 arith_en_n : out std_logic;
52 stat_dec_oe_n : out std_logic;
53 stat_bus_oe_n : out std_logic;
54 stat_set_flg_n : out std_logic;
55 stat_flg : out std_logic;
56 stat_bus_all_n : out std_logic;
57 stat_bus_nz_n : out std_logic;
58 stat_alu_we_n : out std_logic;
59 r_vec_oe_n : out std_logic;
60 n_vec_oe_n : out std_logic;
61 i_vec_oe_n : out std_logic;
63 ;---for parameter check purpose!!!
64 check_bit : out std_logic_vector(1 to 5)
68 architecture rtl of decoder is
70 component d_flip_flop_bit
82 -- bit 5 : pcl increment carry flag
83 -- bit 4,3 : cycle type: 00 normal, 01 reset , 10 nmi, 11 irq
86 --00xxx : exec cycle : T0 > T1 > T2 > T3 > T4 > T5 > T6 > T0
87 constant T0 : std_logic_vector (5 downto 0) := "000000";
88 constant T1 : std_logic_vector (5 downto 0) := "000001";
89 constant T2 : std_logic_vector (5 downto 0) := "000010";
90 constant T3 : std_logic_vector (5 downto 0) := "000011";
91 constant T4 : std_logic_vector (5 downto 0) := "000100";
92 constant T5 : std_logic_vector (5 downto 0) := "000101";
93 constant T6 : std_logic_vector (5 downto 0) := "000110";
95 --01xxx : reset cycle : R0 > R1 > R2 > R3 > R4 > R5 > T0
96 constant R0 : std_logic_vector (5 downto 0) := "001000";
97 constant R1 : std_logic_vector (5 downto 0) := "001001";
98 constant R2 : std_logic_vector (5 downto 0) := "001010";
99 constant R3 : std_logic_vector (5 downto 0) := "001011";
100 constant R4 : std_logic_vector (5 downto 0) := "001100";
101 constant R5 : std_logic_vector (5 downto 0) := "001101";
103 --10xxx : nmi cycle : T0 > N1 > N2 > N3 > N4 > N5 > T0
104 constant N1 : std_logic_vector (5 downto 0) := "010001";
105 constant N2 : std_logic_vector (5 downto 0) := "010010";
106 constant N3 : std_logic_vector (5 downto 0) := "010011";
107 constant N4 : std_logic_vector (5 downto 0) := "010100";
108 constant N5 : std_logic_vector (5 downto 0) := "010101";
110 --11xxx : irq cycle : T0 > I1 > I2 > I3 > I4 > I5 > T0
111 constant I1 : std_logic_vector (5 downto 0) := "011001";
112 constant I2 : std_logic_vector (5 downto 0) := "011010";
113 constant I3 : std_logic_vector (5 downto 0) := "011011";
114 constant I4 : std_logic_vector (5 downto 0) := "011100";
115 constant I5 : std_logic_vector (5 downto 0) := "011101";
117 constant ERROR_CYCLE : std_logic_vector (5 downto 0) := "111111";
119 -- SR Flags (bit 7 to bit 0):
124 -- 3 D .... Decimal (use BCD for arithmetics)
125 -- 2 I .... Interrupt (IRQ disable)
128 constant st_N : integer := 7;
129 constant st_V : integer := 6;
130 constant st_B : integer := 4;
131 constant st_D : integer := 3;
132 constant st_I : integer := 2;
133 constant st_Z : integer := 1;
134 constant st_C : integer := 0;
137 signal pch_inc_input : std_logic;
140 signal nmi_handled_n : std_logic;
142 -- page boundary handling
143 signal wk_next_cycle : std_logic_vector (5 downto 0);
144 signal wk_acc_cmd : std_logic_vector(3 downto 0);
145 signal wk_x_cmd : std_logic_vector(3 downto 0);
146 signal wk_y_cmd : std_logic_vector(3 downto 0);
147 signal wk_stat_alu_we_n : std_logic;
148 signal ea_carry_reg : std_logic;
152 ---pc page next is connected to top bit of exec_cycle
153 pch_inc_input <= not exec_cycle(5);
154 pch_inc_reg : d_flip_flop_bit
155 port map(set_clk, '1', '1', '0', pch_inc_input, pch_inc_n);
157 ea_carry_inst: d_flip_flop_bit
158 port map(trig_clk, '1', '1', '0', ea_carry, ea_carry_reg);
160 --acc,x,y next cycle is changed when it goes page across.
161 --The conditional branch instructions all have the form xxy10000
162 next_cycle <= wk_next_cycle;
163 acc_cmd <= wk_acc_cmd(3) & '1' & wk_acc_cmd(1) & '1'
164 when ea_carry = '1' and
165 wk_next_cycle = T0 and instruction(4 downto 0) = "10000" else
168 x_cmd <= wk_x_cmd(3) & '1' & wk_x_cmd(1 downto 0)
169 when ea_carry = '1' and
170 wk_next_cycle = T0 and instruction(4 downto 0) = "10000" else
172 y_cmd <= wk_y_cmd(3) & '1' & wk_y_cmd(1 downto 0)
173 when ea_carry = '1' and
174 wk_next_cycle = T0 and instruction(4 downto 0) = "10000" else
176 stat_alu_we_n <= '1' when ea_carry = '1' and
177 wk_next_cycle = T0 and instruction(4 downto 0) = "10000" else
180 main_p : process (set_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, '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 --following pins are not set in this function.
240 -- inst_we_n : out std_logic;
241 -- ad_oe_n : out std_logic;
242 -- dl_al_oe_n : out std_logic;
243 -- pcl_inc_n : out std_logic;
244 -- pcl_cmd : out std_logic_vector(3 downto 0);
245 -- pch_cmd : out std_logic_vector(3 downto 0);
246 -- r_nw : out std_logic
248 --disable the last opration pins.
249 dbuf_int_oe_n <= '1';
258 wk_acc_cmd <= "1111";
273 stat_bus_oe_n <= '1';
274 stat_set_flg_n <= '1';
276 stat_bus_all_n <= '1';
277 stat_bus_nz_n <= '1';
278 wk_stat_alu_we_n <= '1';
286 procedure fetch_inst (inc_pcl : in std_logic) is
288 if instruction = conv_std_logic_vector(16#4c#, dsize) then
289 --if prior cycle is jump instruction,
290 --fetch opcode from where the latch is pointing to.
296 --fetch opcode and pcl increment.
304 pcl_inc_n <= inc_pcl;
307 d_print(string'("fetch 1"));
311 ---(along with the page boundary condition, the last
312 ---cycle is bypassed and slided to T0.)
313 procedure t0_cycle is
316 if (nmi_n = '0' and nmi_handled_n = '1') then
317 --start nmi handling...
326 ---common routine for single byte instruction.
327 procedure single_inst is
333 procedure fetch_imm is
335 d_print("immediate");
337 --send data from data bus buffer.
338 --receiver is instruction dependent.
339 dbuf_int_oe_n <= '0';
343 procedure set_nz_from_bus is
345 --status register n/z bit update.
346 stat_bus_nz_n <= '0';
349 procedure set_zc_from_alu is
351 --status register n/z bit update.
352 wk_stat_alu_we_n <= '0';
353 stat_dec_oe_n <= '1';
354 status_reg <= "00000011";
357 procedure set_nz_from_alu is
359 --status register n/z/c bit update.
360 wk_stat_alu_we_n <= '0';
361 stat_dec_oe_n <= '1';
362 status_reg <= "10000010";
365 procedure set_nzc_from_alu is
367 --status register n/z/c bit update.
368 wk_stat_alu_we_n <= '0';
369 stat_dec_oe_n <= '1';
370 status_reg <= "10000011";
373 procedure set_nvz_from_alu is
375 --status register n/z/v bit update.
376 wk_stat_alu_we_n <= '0';
377 stat_dec_oe_n <= '1';
378 status_reg <= "11000010";
381 procedure set_nvzc_from_alu is
383 wk_stat_alu_we_n <= '0';
384 stat_dec_oe_n <= '1';
385 status_reg <= "11000011";
388 --flag on/off instruction
389 procedure set_flag (int_flg : in integer; val : in std_logic) is
391 stat_dec_oe_n <= '1';
392 stat_set_flg_n <= '0';
393 --specify which to set.
394 status_reg(7 downto int_flg + 1)
396 status_reg(int_flg - 1 downto 0)
398 status_reg(int_flg) <= '1';
403 procedure set_flag0 (val : in std_logic) is
405 stat_dec_oe_n <= '1';
406 stat_set_flg_n <= '0';
407 status_reg <= "00000001";
411 procedure fetch_low is
413 d_print("fetch low 2");
414 --fetch next opcode (abs low).
416 --latch abs low data.
417 dbuf_int_oe_n <= '0';
422 procedure abs_fetch_high is
424 d_print("abs (xy) 3");
429 dbuf_int_oe_n <= '0';
434 procedure abs_latch_out is
445 procedure ea_x_out is
447 -----calucurate and output effective addr
448 back_oe(wk_x_cmd, '0');
452 procedure ea_y_out is
454 back_oe(wk_y_cmd, '0');
458 --A.2. internal execution on memory data
462 if exec_cycle = T1 then
464 elsif exec_cycle = T2 then
466 dbuf_int_oe_n <= '0';
478 if exec_cycle = T1 then
480 elsif exec_cycle = T2 then
482 elsif exec_cycle = T3 then
484 dbuf_int_oe_n <= '0';
489 procedure a2_page_next is
491 --close open gate if page boundary crossed.
492 back_we(wk_acc_cmd, '1');
493 front_we(wk_acc_cmd, '1');
494 front_we(wk_x_cmd, '1');
495 front_we(wk_y_cmd, '1');
496 wk_stat_alu_we_n <= '1';
499 procedure a2_abs_xy (is_x : in boolean) is
501 if exec_cycle = T1 then
503 elsif exec_cycle = T2 then
505 elsif exec_cycle = T3 then
509 if (is_x = true) then
514 dbuf_int_oe_n <= '0';
517 d_print("absx step 1");
518 elsif (exec_cycle = T0 and ea_carry_reg = '1') then
519 --case page boundary crossed.
521 d_print("absx 5 (page boudary crossed.)");
528 procedure a2_zp_xy (is_x : in boolean) is
530 if exec_cycle = T1 then
532 elsif exec_cycle = T2 then
535 dbuf_int_oe_n <= '0';
542 elsif exec_cycle = T3 then
545 if (is_x = true) then
546 back_oe(wk_x_cmd, '0');
548 back_oe(wk_y_cmd, '0');
554 procedure a2_indir_y is
556 if exec_cycle = T1 then
561 elsif exec_cycle = T2 then
569 dbuf_int_oe_n <= '0';
572 elsif exec_cycle = T3 then
576 dbuf_int_oe_n <= '0';
579 elsif exec_cycle = T4 then
581 dbuf_int_oe_n <= '1';
585 back_oe(wk_y_cmd, '0');
587 dbuf_int_oe_n <= '0';
589 if (ea_carry = '1') then
594 elsif (exec_cycle = T5) then
595 --case page boundary crossed.
597 d_print("(indir), y (page boudary crossed.)");
604 procedure a2_indir_x is
606 if exec_cycle = T1 then
611 elsif exec_cycle = T2 then
616 --output BAL @IAL, but cycle #2 is discarded
621 elsif exec_cycle = T3 then
626 dbuf_int_oe_n <= '0';
627 back_oe(wk_x_cmd, '0');
630 elsif exec_cycle = T4 then
633 --output BAH @IAL+x+1
634 dbuf_int_oe_n <= '0';
635 back_oe(wk_x_cmd, '0');
638 elsif (exec_cycle = T5) then
644 --A.3. store operation.
648 if exec_cycle = T1 then
650 elsif exec_cycle = T2 then
652 dbuf_int_oe_n <= '1';
663 procedure a3_zp_xy (is_x : in boolean) is
665 if exec_cycle = T1 then
667 elsif exec_cycle = T2 then
669 dbuf_int_oe_n <= '1';
676 elsif exec_cycle = T3 then
681 if (is_x = true) then
682 back_oe(wk_x_cmd, '0');
684 back_oe(wk_y_cmd, '0');
695 if exec_cycle = T1 then
697 elsif exec_cycle = T2 then
699 elsif exec_cycle = T3 then
701 dbuf_int_oe_n <= '1';
707 procedure a3_abs_xy (is_x : in boolean) is
709 if exec_cycle = T1 then
711 elsif exec_cycle = T2 then
713 elsif exec_cycle = T3 then
717 dbuf_int_oe_n <= '1';
718 if (is_x = true) then
724 elsif exec_cycle = T4 then
725 if (ea_carry_reg = '1') then
731 if (is_x = true) then
742 procedure a3_indir_y is
744 if exec_cycle = T1 then
749 elsif exec_cycle = T2 then
757 dbuf_int_oe_n <= '0';
760 elsif exec_cycle = T3 then
764 dbuf_int_oe_n <= '0';
767 elsif exec_cycle = T4 then
769 dbuf_int_oe_n <= '1';
773 back_oe(wk_y_cmd, '0');
777 elsif exec_cycle = T5 then
779 back_oe(wk_y_cmd, '1');
782 --ea_carry reg is suspicious. timing is not garanteed...
783 if (ea_carry_reg = '1') then
793 procedure a3_indir_x is
795 if exec_cycle = T1 then
800 elsif exec_cycle = T2 then
805 --output BAL @IAL, but cycle #2 is discarded
810 elsif exec_cycle = T3 then
815 dbuf_int_oe_n <= '0';
816 back_oe(wk_x_cmd, '0');
819 elsif exec_cycle = T4 then
822 --output BAH @IAL+x+1
823 dbuf_int_oe_n <= '0';
824 back_oe(wk_x_cmd, '0');
827 elsif (exec_cycle = T5) then
829 dbuf_int_oe_n <= '1';
835 ---A.4. read-modify-write operation
839 if exec_cycle = T1 then
841 elsif exec_cycle = T2 then
848 --keep data in the alu reg.
850 dbuf_int_oe_n <= '0';
852 elsif exec_cycle = T3 then
853 --t3 fix alu internal register.
857 dbuf_int_oe_n <= '1';
859 elsif exec_cycle = T4 then
860 --t5 cycle writes modified value.
871 if exec_cycle = T1 then
873 elsif exec_cycle = T2 then
875 dbuf_int_oe_n <= '1';
878 --t2 cycle read bal only.
882 elsif exec_cycle = T3 then
883 --t3 cycle read bal + x
887 back_oe(wk_x_cmd, '0');
889 --keep data in the alu reg.
891 dbuf_int_oe_n <= '0';
894 elsif exec_cycle = T4 then
898 back_oe(wk_x_cmd, '0');
900 --fix alu internal register.
902 dbuf_int_oe_n <= '1';
904 elsif exec_cycle = T5 then
905 dbuf_int_oe_n <= '1';
907 --t5 cycle writes modified value.
911 back_oe(wk_x_cmd, '0');
921 if exec_cycle = T1 then
923 elsif exec_cycle = T2 then
925 elsif exec_cycle = T3 then
928 --keep data in the alu reg.
930 dbuf_int_oe_n <= '0';
932 elsif exec_cycle = T4 then
935 --fix alu internal register.
937 dbuf_int_oe_n <= '1';
939 elsif exec_cycle = T5 then
940 dbuf_int_oe_n <= '1';
942 --t5 cycle writes modified value.
949 procedure a4_abs_x is
951 if exec_cycle = T1 then
953 elsif exec_cycle = T2 then
955 elsif exec_cycle = T3 then
956 --T3 cycle discarded.
960 dbuf_int_oe_n <= '0';
963 elsif exec_cycle = T4 then
966 if (ea_carry_reg = '1') then
972 --keep data in the alu reg.
974 dbuf_int_oe_n <= '0';
977 elsif exec_cycle = T5 then
978 --fix alu internal register.
980 dbuf_int_oe_n <= '1';
983 elsif exec_cycle = T6 then
984 --t5 cycle writes modified value.
994 procedure a51_push is
996 if exec_cycle = T1 then
999 elsif exec_cycle = T2 then
1000 back_oe(sp_cmd, '0');
1001 back_we(sp_cmd, '0');
1005 wk_next_cycle <= T0;
1010 procedure a52_pull is
1012 if exec_cycle = T1 then
1014 wk_next_cycle <= T2;
1016 elsif exec_cycle = T2 then
1017 --stack decrement first.
1018 back_oe(sp_cmd, '0');
1019 back_we(sp_cmd, '0');
1022 wk_next_cycle <= T3;
1024 elsif exec_cycle = T3 then
1026 back_we(sp_cmd, '1');
1028 ---pop data from stack.
1029 back_oe(sp_cmd, '0');
1031 dbuf_int_oe_n <= '0';
1032 wk_next_cycle <= T0;
1037 -- A.5.8 branch operations
1039 procedure a58_branch (int_flg : in integer; br_cond : in std_logic) is
1041 if exec_cycle = T1 then
1043 if status_reg(int_flg) = br_cond then
1047 dbuf_int_oe_n <= '0';
1049 wk_next_cycle <= T2;
1051 d_print("no branch");
1052 wk_next_cycle <= T0;
1054 elsif exec_cycle = T2 then
1057 dbuf_int_oe_n <= '1';
1060 --calc relative addr.
1064 back_oe(pcl_cmd, '0');
1065 back_oe(pch_cmd, '0');
1066 back_we(pcl_cmd, '0');
1068 wk_next_cycle <= T0;
1069 elsif (exec_cycle = T0 and ea_carry = '1') then
1070 d_print("page crossed.");
1071 --page crossed. adh calc.
1072 back_we(pcl_cmd, '1');
1073 back_oe(pcl_cmd, '0');
1074 back_oe(pch_cmd, '0');
1075 back_we(pch_cmd, '0');
1080 wk_next_cycle <= T0;
1084 -------------------------------------------------------------
1085 -------------------------------------------------------------
1086 ---------------- main state machine start.... ---------------
1087 -------------------------------------------------------------
1088 -------------------------------------------------------------
1091 if (res_n = '0') then
1092 --prevent status revister from broken.
1093 stat_dec_oe_n <= '0';
1094 stat_bus_oe_n <= '1';
1095 stat_set_flg_n <= '1';
1097 stat_bus_all_n <= '1';
1098 stat_bus_nz_n <= '1';
1099 wk_stat_alu_we_n <= '1';
1101 --pc l/h is reset vector.
1104 wk_next_cycle <= R0;
1106 elsif (rising_edge(set_clk)) then
1107 d_print(string'("-"));
1109 if (nmi_n = '1') then
1110 --nmi handle flag reset.
1111 nmi_handled_n <= '1';
1115 --case dma is runnting.
1124 elsif (exec_cycle = T0 and ea_carry = '0') then
1128 elsif exec_cycle = T1 or exec_cycle = T2 or exec_cycle = T3 or
1129 exec_cycle = T4 or exec_cycle = T5 or exec_cycle = T6 or
1130 (exec_cycle = T0 and ea_carry = '1') then
1133 ---asyncronous page change might happen.
1134 back_we(pch_cmd, '1');
1136 if exec_cycle = T1 then
1137 d_print("decode and execute inst: "
1138 & conv_hex8(conv_integer(instruction)));
1139 --disable pin for jmp instruction
1141 back_we(pcl_cmd, '1');
1142 front_we(pch_cmd, '1');
1144 --grab instruction register data.
1148 --imelementation is wriiten in the order of hardware manual
1151 ----------------------------------------
1152 --A.1. Single byte instruction.
1153 ----------------------------------------
1154 if instruction = conv_std_logic_vector(16#0a#, dsize) then
1158 back_oe(wk_acc_cmd, '0');
1159 front_we(wk_acc_cmd, '0');
1163 elsif instruction = conv_std_logic_vector(16#18#, dsize) then
1168 elsif instruction = conv_std_logic_vector(16#d8#, dsize) then
1170 set_flag (st_D, '0');
1173 elsif instruction = conv_std_logic_vector(16#58#, dsize) then
1175 set_flag (st_I, '0');
1178 elsif instruction = conv_std_logic_vector(16#b8#, dsize) then
1180 set_flag (st_V, '0');
1183 elsif instruction = conv_std_logic_vector(16#ca#, dsize) then
1186 back_oe(wk_x_cmd, '0');
1187 front_we(wk_x_cmd, '0');
1192 elsif instruction = conv_std_logic_vector(16#88#, dsize) then
1195 back_oe(wk_y_cmd, '0');
1196 front_we(wk_y_cmd, '0');
1201 elsif instruction = conv_std_logic_vector(16#e8#, dsize) then
1204 back_oe(wk_x_cmd, '0');
1205 front_we(wk_x_cmd, '0');
1210 elsif instruction = conv_std_logic_vector(16#c8#, dsize) then
1213 back_oe(wk_y_cmd, '0');
1214 front_we(wk_y_cmd, '0');
1218 elsif instruction = conv_std_logic_vector(16#4a#, dsize) then
1222 back_oe(wk_acc_cmd, '0');
1223 front_we(wk_acc_cmd, '0');
1227 elsif instruction = conv_std_logic_vector(16#ea#, dsize) then
1231 elsif instruction = conv_std_logic_vector(16#2a#, dsize) then
1235 back_oe(wk_acc_cmd, '0');
1236 front_we(wk_acc_cmd, '0');
1240 elsif instruction = conv_std_logic_vector(16#6a#, dsize) then
1244 back_oe(wk_acc_cmd, '0');
1245 front_we(wk_acc_cmd, '0');
1249 elsif instruction = conv_std_logic_vector(16#38#, dsize) then
1254 elsif instruction = conv_std_logic_vector(16#f8#, dsize) then
1256 set_flag (st_D, '1');
1259 elsif instruction = conv_std_logic_vector(16#78#, dsize) then
1261 set_flag (st_I, '1');
1264 elsif instruction = conv_std_logic_vector(16#aa#, dsize) then
1268 front_oe(wk_acc_cmd, '0');
1269 front_we(wk_x_cmd, '0');
1271 elsif instruction = conv_std_logic_vector(16#a8#, dsize) then
1275 front_oe(wk_acc_cmd, '0');
1276 front_we(wk_y_cmd, '0');
1278 elsif instruction = conv_std_logic_vector(16#ba#, dsize) then
1282 front_oe(sp_cmd, '0');
1283 front_we(wk_x_cmd, '0');
1285 elsif instruction = conv_std_logic_vector(16#8a#, dsize) then
1289 front_oe(wk_x_cmd, '0');
1290 front_we(wk_acc_cmd, '0');
1292 elsif instruction = conv_std_logic_vector(16#9a#, dsize) then
1296 front_oe(wk_x_cmd, '0');
1297 front_we(sp_cmd, '0');
1299 elsif instruction = conv_std_logic_vector(16#98#, dsize) then
1303 front_oe(wk_y_cmd, '0');
1304 front_we(wk_acc_cmd, '0');
1308 ----------------------------------------
1309 --A.2. internal execution on memory data
1310 ----------------------------------------
1311 elsif instruction = conv_std_logic_vector(16#69#, dsize) then
1316 back_oe(wk_acc_cmd, '0');
1317 back_we(wk_acc_cmd, '0');
1320 elsif instruction = conv_std_logic_vector(16#65#, dsize) then
1324 if exec_cycle = T2 then
1326 back_oe(wk_acc_cmd, '0');
1327 back_we(wk_acc_cmd, '0');
1331 elsif instruction = conv_std_logic_vector(16#75#, dsize) then
1335 if exec_cycle = T3 then
1337 back_oe(wk_acc_cmd, '0');
1338 back_we(wk_acc_cmd, '0');
1342 elsif instruction = conv_std_logic_vector(16#6d#, dsize) then
1346 if exec_cycle = T3 then
1348 back_oe(wk_acc_cmd, '0');
1349 back_we(wk_acc_cmd, '0');
1353 elsif instruction = conv_std_logic_vector(16#7d#, dsize) then
1357 if exec_cycle = T3 or exec_cycle = T0 then
1359 back_oe(wk_acc_cmd, '0');
1360 back_we(wk_acc_cmd, '0');
1364 elsif instruction = conv_std_logic_vector(16#79#, dsize) then
1368 if exec_cycle = T3 or exec_cycle = T0 then
1370 back_oe(wk_acc_cmd, '0');
1371 back_we(wk_acc_cmd, '0');
1375 elsif instruction = conv_std_logic_vector(16#61#, dsize) then
1379 if exec_cycle = T5 then
1381 back_oe(wk_acc_cmd, '0');
1382 back_we(wk_acc_cmd, '0');
1386 elsif instruction = conv_std_logic_vector(16#71#, dsize) then
1390 if exec_cycle = T4 or exec_cycle = T0 then
1392 back_oe(wk_acc_cmd, '0');
1393 back_we(wk_acc_cmd, '0');
1397 elsif instruction = conv_std_logic_vector(16#29#, dsize) then
1402 back_oe(wk_acc_cmd, '0');
1403 back_we(wk_acc_cmd, '0');
1406 elsif instruction = conv_std_logic_vector(16#25#, dsize) then
1410 if exec_cycle = T2 then
1412 back_oe(wk_acc_cmd, '0');
1413 back_we(wk_acc_cmd, '0');
1417 elsif instruction = conv_std_logic_vector(16#35#, dsize) then
1421 if exec_cycle = T3 then
1423 back_oe(wk_acc_cmd, '0');
1424 back_we(wk_acc_cmd, '0');
1428 elsif instruction = conv_std_logic_vector(16#2d#, dsize) then
1432 if exec_cycle = T3 then
1434 back_oe(wk_acc_cmd, '0');
1435 back_we(wk_acc_cmd, '0');
1439 elsif instruction = conv_std_logic_vector(16#3d#, dsize) then
1443 if exec_cycle = T3 or exec_cycle = T0 then
1445 back_oe(wk_acc_cmd, '0');
1446 back_we(wk_acc_cmd, '0');
1450 elsif instruction = conv_std_logic_vector(16#39#, dsize) then
1454 if exec_cycle = T3 or exec_cycle = T0 then
1456 back_oe(wk_acc_cmd, '0');
1457 back_we(wk_acc_cmd, '0');
1461 elsif instruction = conv_std_logic_vector(16#21#, dsize) then
1465 if exec_cycle = T5 then
1467 back_oe(wk_acc_cmd, '0');
1468 back_we(wk_acc_cmd, '0');
1472 elsif instruction = conv_std_logic_vector(16#31#, dsize) then
1476 if exec_cycle = T4 or exec_cycle = T0 then
1478 back_oe(wk_acc_cmd, '0');
1479 back_we(wk_acc_cmd, '0');
1483 elsif instruction = conv_std_logic_vector(16#24#, dsize) then
1487 if exec_cycle = T2 then
1489 back_oe(wk_acc_cmd, '0');
1493 elsif instruction = conv_std_logic_vector(16#2c#, dsize) then
1497 if exec_cycle = T3 then
1499 back_oe(wk_acc_cmd, '0');
1503 elsif instruction = conv_std_logic_vector(16#c9#, dsize) then
1508 back_oe(wk_acc_cmd, '0');
1511 elsif instruction = conv_std_logic_vector(16#c5#, dsize) then
1515 if exec_cycle = T2 then
1517 back_oe(wk_acc_cmd, '0');
1521 elsif instruction = conv_std_logic_vector(16#d5#, dsize) then
1525 if exec_cycle = T3 then
1527 back_oe(wk_acc_cmd, '0');
1531 elsif instruction = conv_std_logic_vector(16#cd#, dsize) then
1535 if exec_cycle = T3 then
1537 back_oe(wk_acc_cmd, '0');
1541 elsif instruction = conv_std_logic_vector(16#dd#, dsize) then
1545 if exec_cycle = T3 or exec_cycle = T0 then
1547 back_oe(wk_acc_cmd, '0');
1551 elsif instruction = conv_std_logic_vector(16#d9#, dsize) then
1555 if exec_cycle = T3 or exec_cycle = T0 then
1557 back_oe(wk_acc_cmd, '0');
1561 elsif instruction = conv_std_logic_vector(16#c1#, dsize) then
1565 if exec_cycle = T5 then
1567 back_oe(wk_acc_cmd, '0');
1571 elsif instruction = conv_std_logic_vector(16#d1#, dsize) then
1575 if exec_cycle = T4 or exec_cycle = T0 then
1577 back_oe(wk_acc_cmd, '0');
1581 elsif instruction = conv_std_logic_vector(16#e0#, dsize) then
1586 back_oe(wk_x_cmd, '0');
1589 elsif instruction = conv_std_logic_vector(16#e4#, dsize) then
1593 if exec_cycle = T2 then
1595 back_oe(wk_x_cmd, '0');
1599 elsif instruction = conv_std_logic_vector(16#ec#, dsize) then
1603 if exec_cycle = T3 then
1605 back_oe(wk_x_cmd, '0');
1609 elsif instruction = conv_std_logic_vector(16#c0#, dsize) then
1614 back_oe(wk_y_cmd, '0');
1617 elsif instruction = conv_std_logic_vector(16#c4#, dsize) then
1621 if exec_cycle = T2 then
1623 back_oe(wk_y_cmd, '0');
1627 elsif instruction = conv_std_logic_vector(16#cc#, dsize) then
1631 if exec_cycle = T3 then
1633 back_oe(wk_y_cmd, '0');
1637 elsif instruction = conv_std_logic_vector(16#49#, dsize) then
1642 back_oe(wk_acc_cmd, '0');
1643 back_we(wk_acc_cmd, '0');
1646 elsif instruction = conv_std_logic_vector(16#45#, dsize) then
1650 if exec_cycle = T2 then
1652 back_oe(wk_acc_cmd, '0');
1653 back_we(wk_acc_cmd, '0');
1657 elsif instruction = conv_std_logic_vector(16#55#, dsize) then
1661 if exec_cycle = T3 then
1663 back_oe(wk_acc_cmd, '0');
1664 back_we(wk_acc_cmd, '0');
1668 elsif instruction = conv_std_logic_vector(16#4d#, dsize) then
1672 if exec_cycle = T3 then
1674 back_oe(wk_acc_cmd, '0');
1675 back_we(wk_acc_cmd, '0');
1679 elsif instruction = conv_std_logic_vector(16#5d#, dsize) then
1683 if exec_cycle = T3 or exec_cycle = T0 then
1685 back_oe(wk_acc_cmd, '0');
1686 back_we(wk_acc_cmd, '0');
1690 elsif instruction = conv_std_logic_vector(16#59#, dsize) then
1694 if exec_cycle = T3 or exec_cycle = T0 then
1696 back_oe(wk_acc_cmd, '0');
1697 back_we(wk_acc_cmd, '0');
1701 elsif instruction = conv_std_logic_vector(16#41#, dsize) then
1705 if exec_cycle = T5 then
1707 back_oe(wk_acc_cmd, '0');
1708 back_we(wk_acc_cmd, '0');
1712 elsif instruction = conv_std_logic_vector(16#51#, dsize) then
1716 if exec_cycle = T4 or exec_cycle = T0 then
1718 back_oe(wk_acc_cmd, '0');
1719 back_we(wk_acc_cmd, '0');
1723 elsif instruction = conv_std_logic_vector(16#a9#, dsize) then
1727 front_we(wk_acc_cmd, '0');
1730 elsif instruction = conv_std_logic_vector(16#a5#, dsize) then
1734 if exec_cycle = T2 then
1735 front_we(wk_acc_cmd, '0');
1739 elsif instruction = conv_std_logic_vector(16#b5#, dsize) then
1743 if exec_cycle = T3 then
1744 front_we(wk_acc_cmd, '0');
1748 elsif instruction = conv_std_logic_vector(16#ad#, dsize) then
1752 if exec_cycle = T3 then
1754 front_we(wk_acc_cmd, '0');
1757 elsif instruction = conv_std_logic_vector(16#bd#, dsize) then
1761 if exec_cycle = T3 or exec_cycle = T0 then
1763 front_we(wk_acc_cmd, '0');
1767 elsif instruction = conv_std_logic_vector(16#b9#, dsize) then
1771 if exec_cycle = T3 or exec_cycle = T0 then
1773 front_we(wk_acc_cmd, '0');
1777 elsif instruction = conv_std_logic_vector(16#a1#, dsize) then
1781 if exec_cycle = T5 then
1782 front_we(wk_acc_cmd, '0');
1786 elsif instruction = conv_std_logic_vector(16#b1#, dsize) then
1790 if exec_cycle = T4 or exec_cycle = T0 then
1792 front_we(wk_acc_cmd, '0');
1796 elsif instruction = conv_std_logic_vector(16#a2#, dsize) then
1801 front_we(wk_x_cmd, '0');
1803 elsif instruction = conv_std_logic_vector(16#a6#, dsize) then
1807 if exec_cycle = T2 then
1808 front_we(wk_x_cmd, '0');
1812 elsif instruction = conv_std_logic_vector(16#b6#, dsize) then
1816 if exec_cycle = T3 then
1817 front_we(wk_x_cmd, '0');
1821 elsif instruction = conv_std_logic_vector(16#ae#, dsize) then
1825 if exec_cycle = T3 then
1827 front_we(wk_x_cmd, '0');
1830 elsif instruction = conv_std_logic_vector(16#be#, dsize) then
1834 if exec_cycle = T3 or exec_cycle = T0 then
1835 front_we(wk_x_cmd, '0');
1839 elsif instruction = conv_std_logic_vector(16#a0#, dsize) then
1844 front_we(wk_y_cmd, '0');
1846 elsif instruction = conv_std_logic_vector(16#a4#, dsize) then
1850 if exec_cycle = T2 then
1851 front_we(wk_y_cmd, '0');
1855 elsif instruction = conv_std_logic_vector(16#b4#, dsize) then
1859 if exec_cycle = T3 then
1860 front_we(wk_y_cmd, '0');
1864 elsif instruction = conv_std_logic_vector(16#ac#, dsize) then
1868 if exec_cycle = T3 then
1870 front_we(wk_y_cmd, '0');
1873 elsif instruction = conv_std_logic_vector(16#bc#, dsize) then
1877 if exec_cycle = T3 or exec_cycle = T0 then
1879 front_we(wk_y_cmd, '0');
1882 elsif instruction = conv_std_logic_vector(16#09#, dsize) then
1887 back_oe(wk_acc_cmd, '0');
1888 back_we(wk_acc_cmd, '0');
1891 elsif instruction = conv_std_logic_vector(16#05#, dsize) then
1895 if exec_cycle = T2 then
1897 back_oe(wk_acc_cmd, '0');
1898 back_we(wk_acc_cmd, '0');
1902 elsif instruction = conv_std_logic_vector(16#15#, dsize) then
1906 if exec_cycle = T3 then
1908 back_oe(wk_acc_cmd, '0');
1909 back_we(wk_acc_cmd, '0');
1913 elsif instruction = conv_std_logic_vector(16#0d#, dsize) then
1917 if exec_cycle = T3 then
1919 back_oe(wk_acc_cmd, '0');
1920 back_we(wk_acc_cmd, '0');
1924 elsif instruction = conv_std_logic_vector(16#1d#, dsize) then
1928 if exec_cycle = T3 or exec_cycle = T0 then
1930 back_oe(wk_acc_cmd, '0');
1931 back_we(wk_acc_cmd, '0');
1935 elsif instruction = conv_std_logic_vector(16#19#, dsize) then
1939 if exec_cycle = T3 or exec_cycle = T0 then
1941 back_oe(wk_acc_cmd, '0');
1942 back_we(wk_acc_cmd, '0');
1946 elsif instruction = conv_std_logic_vector(16#01#, dsize) then
1950 if exec_cycle = T5 then
1952 back_oe(wk_acc_cmd, '0');
1953 back_we(wk_acc_cmd, '0');
1957 elsif instruction = conv_std_logic_vector(16#11#, dsize) then
1961 if exec_cycle = T4 or exec_cycle = T0 then
1963 back_oe(wk_acc_cmd, '0');
1964 back_we(wk_acc_cmd, '0');
1968 elsif instruction = conv_std_logic_vector(16#e9#, dsize) then
1973 back_oe(wk_acc_cmd, '0');
1974 back_we(wk_acc_cmd, '0');
1977 elsif instruction = conv_std_logic_vector(16#e5#, dsize) then
1981 if exec_cycle = T2 then
1983 back_oe(wk_acc_cmd, '0');
1984 back_we(wk_acc_cmd, '0');
1988 elsif instruction = conv_std_logic_vector(16#f5#, dsize) then
1992 if exec_cycle = T3 then
1994 back_oe(wk_acc_cmd, '0');
1995 back_we(wk_acc_cmd, '0');
1999 elsif instruction = conv_std_logic_vector(16#ed#, dsize) then
2003 if exec_cycle = T3 then
2005 back_oe(wk_acc_cmd, '0');
2006 back_we(wk_acc_cmd, '0');
2010 elsif instruction = conv_std_logic_vector(16#fd#, dsize) then
2014 if exec_cycle = T3 or exec_cycle = T0 then
2016 back_oe(wk_acc_cmd, '0');
2017 back_we(wk_acc_cmd, '0');
2021 elsif instruction = conv_std_logic_vector(16#f9#, dsize) then
2025 if exec_cycle = T3 or exec_cycle = T0 then
2027 back_oe(wk_acc_cmd, '0');
2028 back_we(wk_acc_cmd, '0');
2032 elsif instruction = conv_std_logic_vector(16#e1#, dsize) then
2036 if exec_cycle = T5 then
2038 back_oe(wk_acc_cmd, '0');
2039 back_we(wk_acc_cmd, '0');
2043 elsif instruction = conv_std_logic_vector(16#f1#, dsize) then
2047 if exec_cycle = T4 or exec_cycle = T0 then
2049 back_oe(wk_acc_cmd, '0');
2050 back_we(wk_acc_cmd, '0');
2056 ----------------------------------------
2057 ---A.3. store operation.
2058 ----------------------------------------
2059 elsif instruction = conv_std_logic_vector(16#85#, dsize) then
2063 if exec_cycle = T2 then
2064 front_oe(wk_acc_cmd, '0');
2067 elsif instruction = conv_std_logic_vector(16#95#, dsize) then
2071 if exec_cycle = T2 then
2072 front_oe(wk_acc_cmd, '0');
2075 elsif instruction = conv_std_logic_vector(16#8d#, dsize) then
2079 if exec_cycle = T3 then
2080 front_oe(wk_acc_cmd, '0');
2083 elsif instruction = conv_std_logic_vector(16#9d#, dsize) then
2087 if exec_cycle = T4 then
2088 front_oe(wk_acc_cmd, '0');
2091 elsif instruction = conv_std_logic_vector(16#99#, dsize) then
2095 if exec_cycle = T4 then
2096 front_oe(wk_acc_cmd, '0');
2099 elsif instruction = conv_std_logic_vector(16#81#, dsize) then
2103 if exec_cycle = T5 then
2104 front_oe(wk_acc_cmd, '0');
2107 elsif instruction = conv_std_logic_vector(16#91#, dsize) then
2111 if exec_cycle = T5 then
2112 front_oe(wk_acc_cmd, '0');
2115 elsif instruction = conv_std_logic_vector(16#86#, dsize) then
2119 if exec_cycle = T2 then
2120 front_oe(wk_x_cmd, '0');
2123 elsif instruction = conv_std_logic_vector(16#96#, dsize) then
2127 if exec_cycle = T2 then
2128 front_oe(wk_x_cmd, '0');
2131 elsif instruction = conv_std_logic_vector(16#8e#, dsize) then
2135 if exec_cycle = T3 then
2136 front_oe(wk_x_cmd, '0');
2139 elsif instruction = conv_std_logic_vector(16#84#, dsize) then
2143 if exec_cycle = T2 then
2144 front_oe(wk_y_cmd, '0');
2147 elsif instruction = conv_std_logic_vector(16#94#, dsize) then
2151 if exec_cycle = T2 then
2152 front_oe(wk_y_cmd, '0');
2155 elsif instruction = conv_std_logic_vector(16#8c#, dsize) then
2159 if exec_cycle = T3 then
2160 front_oe(wk_y_cmd, '0');
2164 ----------------------------------------
2165 ---A.4. read-modify-write operation
2166 ----------------------------------------
2167 elsif instruction = conv_std_logic_vector(16#06#, dsize) then
2171 if exec_cycle = T4 then
2175 elsif instruction = conv_std_logic_vector(16#16#, dsize) then
2179 if exec_cycle = T5 then
2183 elsif instruction = conv_std_logic_vector(16#0e#, dsize) then
2187 if exec_cycle = T5 then
2191 elsif instruction = conv_std_logic_vector(16#1e#, dsize) then
2195 if exec_cycle = T6 then
2199 elsif instruction = conv_std_logic_vector(16#c6#, dsize) then
2203 if exec_cycle = T4 then
2207 elsif instruction = conv_std_logic_vector(16#d6#, dsize) then
2211 if exec_cycle = T5 then
2215 elsif instruction = conv_std_logic_vector(16#ce#, dsize) then
2219 if exec_cycle = T5 then
2223 elsif instruction = conv_std_logic_vector(16#de#, dsize) then
2227 if exec_cycle = T6 then
2231 elsif instruction = conv_std_logic_vector(16#e6#, dsize) then
2235 if exec_cycle = T4 then
2239 elsif instruction = conv_std_logic_vector(16#f6#, dsize) then
2243 if exec_cycle = T5 then
2247 elsif instruction = conv_std_logic_vector(16#ee#, dsize) then
2251 if exec_cycle = T5 then
2255 elsif instruction = conv_std_logic_vector(16#fe#, dsize) then
2259 if exec_cycle = T6 then
2263 elsif instruction = conv_std_logic_vector(16#46#, dsize) then
2267 if exec_cycle = T4 then
2271 elsif instruction = conv_std_logic_vector(16#56#, dsize) then
2275 if exec_cycle = T5 then
2279 elsif instruction = conv_std_logic_vector(16#4e#, dsize) then
2283 if exec_cycle = T5 then
2287 elsif instruction = conv_std_logic_vector(16#5e#, dsize) then
2291 if exec_cycle = T6 then
2295 elsif instruction = conv_std_logic_vector(16#26#, dsize) then
2299 if exec_cycle = T4 then
2303 elsif instruction = conv_std_logic_vector(16#36#, dsize) then
2307 if exec_cycle = T5 then
2311 elsif instruction = conv_std_logic_vector(16#2e#, dsize) then
2315 if exec_cycle = T5 then
2319 elsif instruction = conv_std_logic_vector(16#3e#, dsize) then
2323 if exec_cycle = T6 then
2327 elsif instruction = conv_std_logic_vector(16#66#, dsize) then
2331 if exec_cycle = T4 then
2335 elsif instruction = conv_std_logic_vector(16#76#, dsize) then
2339 if exec_cycle = T5 then
2343 elsif instruction = conv_std_logic_vector(16#6e#, dsize) then
2347 if exec_cycle = T5 then
2351 elsif instruction = conv_std_logic_vector(16#7e#, dsize) then
2355 if exec_cycle = T6 then
2360 ----------------------------------------
2361 --A.5. miscellaneous oprations.
2362 ----------------------------------------
2365 elsif instruction = conv_std_logic_vector(16#08#, dsize) then
2368 if exec_cycle = T2 then
2369 stat_bus_oe_n <= '0';
2372 elsif instruction = conv_std_logic_vector(16#48#, dsize) then
2375 if exec_cycle = T2 then
2376 front_oe(wk_acc_cmd, '0');
2379 elsif instruction = conv_std_logic_vector(16#28#, dsize) then
2382 if exec_cycle = T3 then
2383 stat_dec_oe_n <= '1';
2384 stat_bus_all_n <= '0';
2387 elsif instruction = conv_std_logic_vector(16#68#, dsize) then
2390 if exec_cycle = T3 then
2391 front_we(wk_acc_cmd, '0');
2396 ----------------------------------------
2398 ----------------------------------------
2399 elsif instruction = conv_std_logic_vector(16#20#, dsize) then
2400 if exec_cycle = T1 then
2401 d_print("jsr abs 2");
2404 dbuf_int_oe_n <= '0';
2407 wk_next_cycle <= T2;
2408 elsif exec_cycle = T2 then
2411 dbuf_int_oe_n <= '1';
2414 --push return addr high into stack.
2417 front_oe(pch_cmd, '0');
2418 back_oe(sp_cmd, '0');
2419 back_we(sp_cmd, '0');
2421 wk_next_cycle <= T3;
2422 elsif exec_cycle = T3 then
2424 front_oe(pch_cmd, '1');
2426 --push return addr low into stack.
2429 front_oe(pcl_cmd, '0');
2430 back_oe(sp_cmd, '0');
2431 back_we(sp_cmd, '0');
2434 wk_next_cycle <= T4;
2435 elsif exec_cycle = T4 then
2439 front_oe(pcl_cmd, '1');
2440 back_oe(sp_cmd, '1');
2441 back_we(sp_cmd, '1');
2445 back_oe(pch_cmd, '0');
2446 back_oe(pcl_cmd, '0');
2447 dbuf_int_oe_n <= '0';
2450 wk_next_cycle <= T5;
2451 elsif exec_cycle = T5 then
2454 back_oe(pch_cmd, '1');
2455 back_oe(pcl_cmd, '1');
2456 dbuf_int_oe_n <= '1';
2462 front_we(pch_cmd, '0');
2466 back_we(pcl_cmd, '0');
2468 wk_next_cycle <= T0;
2469 end if; --if exec_cycle = T1 then
2472 elsif instruction = conv_std_logic_vector(16#00#, dsize) then
2474 ----------------------------------------
2475 -- A.5.5 return from interrupt
2476 ----------------------------------------
2477 elsif instruction = conv_std_logic_vector(16#40#, dsize) then
2478 if exec_cycle = T1 then
2482 --pop stack (decrement only)
2483 back_oe(sp_cmd, '0');
2484 back_we(sp_cmd, '0');
2488 wk_next_cycle <= T2;
2489 elsif exec_cycle = T2 then
2493 back_oe(sp_cmd, '0');
2494 back_we(sp_cmd, '0');
2499 stat_dec_oe_n <= '1';
2500 dbuf_int_oe_n <= '0';
2501 stat_bus_all_n <= '0';
2503 wk_next_cycle <= T3;
2504 elsif exec_cycle = T3 then
2506 stat_bus_all_n <= '1';
2509 back_oe(sp_cmd, '0');
2510 back_we(sp_cmd, '0');
2515 dbuf_int_oe_n <= '0';
2516 front_we(pcl_cmd, '0');
2518 wk_next_cycle <= T4;
2519 elsif exec_cycle = T4 then
2521 --stack decrement stop.
2522 back_we(sp_cmd, '1');
2524 front_we(pcl_cmd, '1');
2527 back_oe(sp_cmd, '0');
2530 dbuf_int_oe_n <= '0';
2531 front_we(pch_cmd, '0');
2533 wk_next_cycle <= T5;
2534 elsif exec_cycle = T5 then
2536 back_oe(sp_cmd, '1');
2539 dbuf_int_oe_n <= '1';
2540 front_we(pch_cmd, '1');
2543 wk_next_cycle <= T0;
2544 end if; --if exec_cycle = T1 then
2546 ----------------------------------------
2548 ----------------------------------------
2549 elsif instruction = conv_std_logic_vector(16#4c#, dsize) then
2551 if exec_cycle = T1 then
2553 --fetch next opcode (abs low).
2556 --latch abs low data.
2557 dbuf_int_oe_n <= '0';
2559 wk_next_cycle <= T2;
2560 elsif exec_cycle = T2 then
2568 dbuf_int_oe_n <= '0';
2571 front_we(pch_cmd, '0');
2573 wk_next_cycle <= T0;
2576 elsif instruction = conv_std_logic_vector(16#6c#, dsize) then
2578 if exec_cycle = T1 then
2580 --fetch next opcode (abs low).
2583 --latch abs low data.
2584 dbuf_int_oe_n <= '0';
2586 wk_next_cycle <= T2;
2587 elsif exec_cycle = T2 then
2595 dbuf_int_oe_n <= '0';
2597 wk_next_cycle <= T3;
2599 elsif exec_cycle = T3 then
2606 front_we(pcl_cmd, '0');
2607 wk_next_cycle <= T4;
2609 elsif exec_cycle = T4 then
2612 front_we(pcl_cmd, '1');
2615 front_we(pch_cmd, '0');
2618 wk_next_cycle <= T0;
2623 ----------------------------------------
2624 -- A.5.7 return from soubroutine
2625 ----------------------------------------
2626 elsif instruction = conv_std_logic_vector(16#60#, dsize) then
2627 if exec_cycle = T1 then
2631 --pop stack (decrement only)
2632 back_oe(sp_cmd, '0');
2633 back_we(sp_cmd, '0');
2637 wk_next_cycle <= T2;
2638 elsif exec_cycle = T2 then
2642 back_oe(sp_cmd, '0');
2643 back_we(sp_cmd, '0');
2648 dbuf_int_oe_n <= '0';
2649 front_we(pcl_cmd, '0');
2651 wk_next_cycle <= T3;
2652 elsif exec_cycle = T3 then
2654 --stack decrement stop.
2655 back_we(sp_cmd, '1');
2657 front_we(pcl_cmd, '1');
2660 back_oe(sp_cmd, '0');
2663 dbuf_int_oe_n <= '0';
2664 front_we(pch_cmd, '0');
2666 wk_next_cycle <= T4;
2667 elsif exec_cycle = T4 then
2669 back_oe(sp_cmd, '1');
2672 dbuf_int_oe_n <= '1';
2673 front_we(pch_cmd, '1');
2675 --complying h/w manual...
2676 wk_next_cycle <= T5;
2677 elsif exec_cycle = T5 then
2682 wk_next_cycle <= T0;
2683 end if; --if exec_cycle = T1 then
2685 ----------------------------------------
2686 -- A.5.8 branch operations
2687 ----------------------------------------
2688 elsif instruction = conv_std_logic_vector(16#90#, dsize) then
2690 a58_branch (st_C, '0');
2692 elsif instruction = conv_std_logic_vector(16#b0#, dsize) then
2694 a58_branch (st_C, '1');
2696 elsif instruction = conv_std_logic_vector(16#f0#, dsize) then
2698 a58_branch (st_Z, '1');
2700 elsif instruction = conv_std_logic_vector(16#30#, dsize) then
2702 a58_branch (st_N, '1');
2704 elsif instruction = conv_std_logic_vector(16#d0#, dsize) then
2706 a58_branch (st_Z, '0');
2708 elsif instruction = conv_std_logic_vector(16#10#, dsize) then
2710 a58_branch (st_N, '0');
2712 elsif instruction = conv_std_logic_vector(16#50#, dsize) then
2714 a58_branch (st_V, '0');
2716 elsif instruction = conv_std_logic_vector(16#70#, dsize) then
2718 a58_branch (st_V, '1');
2721 ---unknown instruction!!!!
2723 report "======== unknow instruction "
2724 & conv_hex8(conv_integer(instruction))
2726 end if; --if instruction = conv_std_logic_vector(16#0a#, dsize)
2728 elsif exec_cycle = R0 then
2729 d_print(string'("reset"));
2731 --initialize port...
2734 dbuf_int_oe_n <= '1';
2747 wk_acc_cmd <= "1111";
2761 stat_dec_oe_n <= '0';
2762 stat_bus_oe_n <= '1';
2763 stat_set_flg_n <= '1';
2765 stat_bus_all_n <= '1';
2766 stat_bus_nz_n <= '1';
2767 wk_stat_alu_we_n <= '1';
2772 nmi_handled_n <= '1';
2775 wk_next_cycle <= R1;
2776 elsif exec_cycle = R1 or exec_cycle = N1 then
2788 --front_oe(pch_cmd, '0');
2789 back_oe(sp_cmd, '0');
2790 back_we(sp_cmd, '0');
2793 if exec_cycle = R1 then
2794 wk_next_cycle <= R2;
2795 elsif exec_cycle = N1 then
2796 wk_next_cycle <= N2;
2799 elsif exec_cycle = R2 or exec_cycle = N2 then
2800 front_oe(pch_cmd, '1');
2805 front_oe(pcl_cmd, '0');
2806 back_oe(sp_cmd, '0');
2807 back_we(sp_cmd, '0');
2810 if exec_cycle = R2 then
2811 wk_next_cycle <= R3;
2812 elsif exec_cycle = N2 then
2813 wk_next_cycle <= N3;
2816 elsif exec_cycle = R3 or exec_cycle = N3 then
2817 front_oe(pcl_cmd, '1');
2822 stat_bus_oe_n <= '0';
2823 back_oe(sp_cmd, '0');
2824 back_we(sp_cmd, '0');
2827 if exec_cycle = R3 then
2828 wk_next_cycle <= R4;
2829 elsif exec_cycle = N3 then
2830 wk_next_cycle <= N4;
2833 elsif exec_cycle = R4 or exec_cycle = N4 then
2834 stat_bus_oe_n <= '1';
2837 front_oe(pcl_cmd, '1');
2838 back_oe(sp_cmd, '1');
2839 back_we(sp_cmd, '1');
2841 --fetch reset vector low
2843 dbuf_int_oe_n <= '0';
2844 front_we(pcl_cmd, '0');
2848 if exec_cycle = R4 then
2851 wk_next_cycle <= R5;
2852 elsif exec_cycle = N4 then
2855 wk_next_cycle <= N5;
2858 elsif exec_cycle = R5 or exec_cycle = N5 then
2859 front_we(pcl_cmd, '1');
2861 --fetch reset vector hi
2863 dbuf_int_oe_n <= '0';
2864 front_we(pch_cmd, '0');
2867 if exec_cycle = N5 then
2868 nmi_handled_n <= '0';
2870 --start execute cycle.
2871 wk_next_cycle <= T0;
2873 elsif exec_cycle(5) = '1' then
2874 ---pc increment and next page.
2875 d_print(string'("pch next page..."));
2876 --pcl stop increment
2878 back_we(pcl_cmd, '1');
2880 if ('0' & exec_cycle(4 downto 0) = T0 and
2881 instruction = conv_std_logic_vector(16#4c#, dsize) ) then
2882 --jmp instruction t0 cycle discards pch increment.
2883 back_we(pch_cmd, '1');
2884 front_we(pch_cmd, '1');
2887 back_we(pch_cmd, '0');
2888 back_oe(pch_cmd, '0');
2891 if ('0' & exec_cycle(4 downto 0) = T0) then
2892 --do the t0 identical routine.
2897 elsif ('0' & exec_cycle(4 downto 0) = T1) then
2898 --if fetch cycle, preserve instrution register
2901 elsif ('0' & exec_cycle(4 downto 0) = T2) then
2902 --disable previous we_n gate.
2903 --t1 cycle is fetch low oprand.
2906 elsif ('0' & exec_cycle(4 downto 0) = T3) then
2907 --t2 cycle is fetch high oprand.
2911 end if; --if rdy = '0' then
2913 end if; -- if (res_n = '0') then