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 sph_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 abs_pg_next_n : out std_logic;
41 zp_xy_n : out std_logic;
42 stat_dec_oe_n : out std_logic;
43 stat_bus_oe_n : out std_logic;
44 stat_set_flg_n : out std_logic;
45 stat_flg : out std_logic;
46 stat_bus_all_n : out std_logic;
47 stat_bus_nz_n : out std_logic;
48 stat_alu_we_n : out std_logic;
50 ;---for parameter check purpose!!!
51 check_bit : out std_logic_vector(1 to 5)
55 architecture rtl of decoder is
57 procedure d_print(msg : string) is
59 use ieee.std_logic_textio.all;
60 variable out_l : line;
63 writeline(output, out_l);
66 ---ival : 0x0000 - 0xffff
67 function conv_hex8(ival : integer) return string is
68 variable tmp1, tmp2 : integer;
69 variable hex_chr: string (1 to 16) := "0123456789abcdef";
71 tmp2 := (ival mod 16 ** 2) / 16 ** 1;
72 tmp1 := ival mod 16 ** 1;
73 return hex_chr(tmp2 + 1) & hex_chr(tmp1 + 1);
77 --00xxx : exec cycle : T0 > T1 > T2 > T3 > T4 > T5 > T6 > T7 > T0
78 constant T0 : std_logic_vector (5 downto 0) := "000000";
79 constant T1 : std_logic_vector (5 downto 0) := "000001";
80 constant T2 : std_logic_vector (5 downto 0) := "000010";
81 constant T3 : std_logic_vector (5 downto 0) := "000011";
82 constant T4 : std_logic_vector (5 downto 0) := "000100";
83 constant T5 : std_logic_vector (5 downto 0) := "000101";
84 constant T6 : std_logic_vector (5 downto 0) := "000110";
85 constant T7 : std_logic_vector (5 downto 0) := "000111";
87 --01xxx : reset cycle : R0 > R1 > R2 > R3 > R4 > R5 > T0
88 constant R0 : std_logic_vector (5 downto 0) := "001000";
89 constant R1 : std_logic_vector (5 downto 0) := "001001";
90 constant R2 : std_logic_vector (5 downto 0) := "001010";
91 constant R3 : std_logic_vector (5 downto 0) := "001011";
92 constant R4 : std_logic_vector (5 downto 0) := "001100";
93 constant R5 : std_logic_vector (5 downto 0) := "001101";
95 --10xxx : nmi cycle : N0 > N1 > N2 > N3 > N4 > N5 > T0
96 constant N0 : std_logic_vector (5 downto 0) := "010000";
97 constant N1 : std_logic_vector (5 downto 0) := "010001";
98 constant N2 : std_logic_vector (5 downto 0) := "010010";
99 constant N3 : std_logic_vector (5 downto 0) := "010011";
100 constant N4 : std_logic_vector (5 downto 0) := "010100";
101 constant N5 : std_logic_vector (5 downto 0) := "010101";
103 --11xxx : irq cycle : I0 > I1 > I2 > I3 > I4 > I5 > T0
104 constant I0 : std_logic_vector (5 downto 0) := "011000";
105 constant I1 : std_logic_vector (5 downto 0) := "011001";
106 constant I2 : std_logic_vector (5 downto 0) := "011010";
107 constant I3 : std_logic_vector (5 downto 0) := "011011";
108 constant I4 : std_logic_vector (5 downto 0) := "011100";
109 constant I5 : std_logic_vector (5 downto 0) := "011101";
111 constant ERROR_CYCLE : std_logic_vector (5 downto 0) := "111111";
113 -- SR Flags (bit 7 to bit 0):
118 -- 3 D .... Decimal (use BCD for arithmetics)
119 -- 2 I .... Interrupt (IRQ disable)
122 constant st_N : integer := 7;
123 constant st_V : integer := 6;
124 constant st_B : integer := 4;
125 constant st_D : integer := 3;
126 constant st_I : integer := 2;
127 constant st_Z : integer := 1;
128 constant st_C : integer := 0;
132 main_p : process (set_clk, res_n)
134 -------------------------------------------------------------
135 -------------------------------------------------------------
136 ----------------------- comon routines ----------------------
137 -------------------------------------------------------------
138 -------------------------------------------------------------
140 ----------gate_cmd format
141 ------3 : front port oe_n
142 ------2 : front port we_n
143 ------1 : back port oe_n
144 ------0 : back port we_n
145 procedure front_oe (signal cmd : out std_logic_vector(3 downto 0);
146 val : in std_logic) is
150 procedure front_we (signal cmd : out std_logic_vector(3 downto 0);
151 val : in std_logic) is
155 procedure back_oe (signal cmd : out std_logic_vector(3 downto 0);
156 val : in std_logic) is
160 procedure back_we (signal cmd : out std_logic_vector(3 downto 0);
161 val : in std_logic) is
166 procedure fetch_inst is
168 --fetch opcode and phc increment.
170 back_oe(pcl_cmd, '0');
171 back_oe(pch_cmd, '0');
172 back_we(pcl_cmd, '0');
173 back_we(pch_cmd, '1');
174 front_we(pcl_cmd, '1');
175 front_we(pch_cmd, '1');
181 --disable the last opration pins.
182 dbuf_int_oe_n <= '1';
198 abs_pg_next_n <= '1';
202 stat_dec_oe_n <= '1';
203 stat_bus_oe_n <= '1';
204 stat_set_flg_n <= '1';
206 stat_bus_all_n <= '1';
207 stat_bus_nz_n <= '1';
208 stat_alu_we_n <= '1';
210 d_print(string'("fetch 1"));
213 ---common routine for single byte instruction.
214 procedure single_inst is
216 back_oe(pcl_cmd, '1');
217 back_oe(pch_cmd, '1');
222 procedure fetch_imm is
224 d_print("immediate");
226 back_oe(pcl_cmd, '0');
227 back_oe(pch_cmd, '0');
228 back_we(pcl_cmd, '0');
229 back_we(pch_cmd, '1');
230 --send data from data bus buffer.
231 --receiver is instruction dependent.
232 dbuf_int_oe_n <= '0';
236 procedure set_nz_from_bus is
238 --status register n/z bit update.
239 stat_dec_oe_n <= '1';
240 status_reg <= "10000010";
241 stat_bus_nz_n <= '0';
244 procedure set_nz_from_alu is
248 procedure set_nzc_from_alu is
252 --flag on/off instruction
253 procedure set_flag (int_flg : in integer; val : in std_logic) is
255 stat_dec_oe_n <= '1';
256 stat_set_flg_n <= '0';
257 --specify which to set.
258 status_reg(7 downto int_flg + 1)
260 status_reg(int_flg - 1 downto 0)
262 status_reg(int_flg) <= '1';
267 procedure set_flag0 (val : in std_logic) is
269 stat_dec_oe_n <= '1';
270 stat_set_flg_n <= '0';
271 status_reg <= "00000001";
275 procedure fetch_low is
277 d_print("fetch low 2");
278 --fetch next opcode (abs low).
279 back_oe(pcl_cmd, '0');
280 back_we(pcl_cmd, '0');
281 back_oe(pch_cmd, '0');
283 --latch abs low data.
284 dbuf_int_oe_n <= '0';
289 procedure abs_fetch_high is
291 d_print("abs (xy) 3");
296 back_oe(pcl_cmd, '0');
297 back_we(pcl_cmd, '0');
298 back_oe(pch_cmd, '0');
300 dbuf_int_oe_n <= '0';
305 procedure abs_latch_out is
309 back_oe(pcl_cmd, '1');
310 back_we(pcl_cmd, '1');
311 back_oe(pch_cmd, '1');
319 procedure ea_x_out is
321 -----calucurate and output effective addr
328 --A.2. internal execution on memory data
335 if exec_cycle = T1 then
337 elsif exec_cycle = T2 then
339 elsif exec_cycle = T3 then
343 dbuf_int_oe_n <= '0';
344 --instruction specific operation wriiten in the caller position.
346 elsif exec_cycle = T4 then
347 if ea_carry = '1' then
348 --case page boundary crossed.
349 d_print("absx 5 (page boudary crossed.)");
352 dbuf_int_oe_n <= '0';
354 abs_pg_next_n <= '0';
358 --case page boundary not crossed. do the fetch op.
359 d_print("absx 5 (fetch)");
367 --A.3. store operation.
375 if exec_cycle = T1 then
377 elsif exec_cycle = T2 then
379 elsif exec_cycle = T3 then
381 dbuf_int_oe_n <= '1';
388 -- A.5.8 branch operations
389 procedure a58_branch (int_flg : in integer; br_cond : in std_logic) is
393 -------------------------------------------------------------
394 -------------------------------------------------------------
395 ---------------- main state machine start.... ---------------
396 -------------------------------------------------------------
397 -------------------------------------------------------------
400 if (res_n = '0') then
401 --pc l/h is reset vector.
405 elsif (res_n'event and res_n = '1') then
410 if (set_clk'event and set_clk = '1' and res_n = '1') then
411 d_print(string'("-"));
413 if exec_cycle = T0 then
418 elsif exec_cycle = T1 or exec_cycle = T2 or exec_cycle = T3 or
419 exec_cycle = T4 or exec_cycle = T5 or exec_cycle = T6 or
423 ---asyncronous page change might happen.
424 back_we(pch_cmd, '1');
426 if exec_cycle = T1 then
427 d_print("decode and execute inst: "
428 & conv_hex8(conv_integer(instruction)));
429 --disable pin since jmp instruction
430 --directly enters into t2 cycle.
434 back_we(pcl_cmd, '1');
435 front_we(pch_cmd, '1');
437 --grab instruction register data.
441 --imelementation is wriiten in the order of hardware manual
445 ----------------------------------------
446 --A.1. Single byte instruction.
447 ----------------------------------------
448 if instruction = conv_std_logic_vector(16#0a#, dsize) then
452 elsif instruction = conv_std_logic_vector(16#18#, dsize) then
457 elsif instruction = conv_std_logic_vector(16#d8#, dsize) then
459 set_flag (st_D, '0');
462 elsif instruction = conv_std_logic_vector(16#58#, dsize) then
465 elsif instruction = conv_std_logic_vector(16#b8#, dsize) then
468 elsif instruction = conv_std_logic_vector(16#ca#, dsize) then
474 elsif instruction = conv_std_logic_vector(16#88#, dsize) then
480 elsif instruction = conv_std_logic_vector(16#e8#, dsize) then
486 elsif instruction = conv_std_logic_vector(16#c8#, dsize) then
489 elsif instruction = conv_std_logic_vector(16#4a#, dsize) then
493 elsif instruction = conv_std_logic_vector(16#ea#, dsize) then
496 elsif instruction = conv_std_logic_vector(16#2a#, dsize) then
500 elsif instruction = conv_std_logic_vector(16#38#, dsize) then
505 elsif instruction = conv_std_logic_vector(16#f8#, dsize) then
507 set_flag (st_D, '1');
510 elsif instruction = conv_std_logic_vector(16#78#, dsize) then
512 set_flag (st_I, '1');
515 elsif instruction = conv_std_logic_vector(16#aa#, dsize) then
519 elsif instruction = conv_std_logic_vector(16#a8#, dsize) then
523 elsif instruction = conv_std_logic_vector(16#ba#, dsize) then
527 elsif instruction = conv_std_logic_vector(16#8a#, dsize) then
531 elsif instruction = conv_std_logic_vector(16#9a#, dsize) then
535 front_oe(x_cmd, '0');
536 front_we(sp_cmd, '0');
538 elsif instruction = conv_std_logic_vector(16#98#, dsize) then
544 ----------------------------------------
545 --A.2. internal execution on memory data
546 ----------------------------------------
547 elsif instruction = conv_std_logic_vector(16#69#, dsize) then
551 elsif instruction = conv_std_logic_vector(16#65#, dsize) then
555 elsif instruction = conv_std_logic_vector(16#75#, dsize) then
559 elsif instruction = conv_std_logic_vector(16#6d#, dsize) then
563 elsif instruction = conv_std_logic_vector(16#7d#, dsize) then
567 elsif instruction = conv_std_logic_vector(16#79#, dsize) then
571 elsif instruction = conv_std_logic_vector(16#61#, dsize) then
575 elsif instruction = conv_std_logic_vector(16#71#, dsize) then
579 elsif instruction = conv_std_logic_vector(16#29#, dsize) then
583 elsif instruction = conv_std_logic_vector(16#25#, dsize) then
587 elsif instruction = conv_std_logic_vector(16#35#, dsize) then
591 elsif instruction = conv_std_logic_vector(16#2d#, dsize) then
595 elsif instruction = conv_std_logic_vector(16#3d#, dsize) then
599 elsif instruction = conv_std_logic_vector(16#39#, dsize) then
603 elsif instruction = conv_std_logic_vector(16#21#, dsize) then
607 elsif instruction = conv_std_logic_vector(16#31#, dsize) then
611 elsif instruction = conv_std_logic_vector(16#24#, dsize) then
615 elsif instruction = conv_std_logic_vector(16#2c#, dsize) then
619 elsif instruction = conv_std_logic_vector(16#c9#, dsize) then
625 elsif instruction = conv_std_logic_vector(16#c5#, dsize) then
629 elsif instruction = conv_std_logic_vector(16#d5#, dsize) then
633 elsif instruction = conv_std_logic_vector(16#cd#, dsize) then
637 elsif instruction = conv_std_logic_vector(16#dd#, dsize) then
641 elsif instruction = conv_std_logic_vector(16#d9#, dsize) then
645 elsif instruction = conv_std_logic_vector(16#c1#, dsize) then
649 elsif instruction = conv_std_logic_vector(16#d1#, dsize) then
653 elsif instruction = conv_std_logic_vector(16#e0#, dsize) then
657 elsif instruction = conv_std_logic_vector(16#e4#, dsize) then
661 elsif instruction = conv_std_logic_vector(16#ec#, dsize) then
665 elsif instruction = conv_std_logic_vector(16#c0#, dsize) then
669 elsif instruction = conv_std_logic_vector(16#c4#, dsize) then
673 elsif instruction = conv_std_logic_vector(16#cc#, dsize) then
677 elsif instruction = conv_std_logic_vector(16#49#, dsize) then
681 elsif instruction = conv_std_logic_vector(16#45#, dsize) then
685 elsif instruction = conv_std_logic_vector(16#55#, dsize) then
689 elsif instruction = conv_std_logic_vector(16#4d#, dsize) then
693 elsif instruction = conv_std_logic_vector(16#5d#, dsize) then
697 elsif instruction = conv_std_logic_vector(16#59#, dsize) then
701 elsif instruction = conv_std_logic_vector(16#41#, dsize) then
705 elsif instruction = conv_std_logic_vector(16#51#, dsize) then
709 elsif instruction = conv_std_logic_vector(16#a9#, dsize) then
713 front_we(acc_cmd, '0');
716 elsif instruction = conv_std_logic_vector(16#a5#, dsize) then
720 elsif instruction = conv_std_logic_vector(16#b5#, dsize) then
724 elsif instruction = conv_std_logic_vector(16#ad#, dsize) then
728 if exec_cycle = T3 then
732 elsif instruction = conv_std_logic_vector(16#bd#, dsize) then
736 if exec_cycle = T3 then
738 front_we(acc_cmd, '0');
740 elsif exec_cycle = T4 then
741 if ea_carry = '1' then
743 front_we(acc_cmd, '0');
748 elsif instruction = conv_std_logic_vector(16#b9#, dsize) then
752 elsif instruction = conv_std_logic_vector(16#a1#, dsize) then
756 elsif instruction = conv_std_logic_vector(16#b1#, dsize) then
760 elsif instruction = conv_std_logic_vector(16#a2#, dsize) then
765 front_we(x_cmd, '0');
767 elsif instruction = conv_std_logic_vector(16#a6#, dsize) then
771 elsif instruction = conv_std_logic_vector(16#b6#, dsize) then
775 elsif instruction = conv_std_logic_vector(16#ae#, dsize) then
779 elsif instruction = conv_std_logic_vector(16#be#, dsize) then
783 elsif instruction = conv_std_logic_vector(16#a0#, dsize) then
788 front_we(y_cmd, '0');
790 elsif instruction = conv_std_logic_vector(16#a4#, dsize) then
794 elsif instruction = conv_std_logic_vector(16#b4#, dsize) then
798 elsif instruction = conv_std_logic_vector(16#ac#, dsize) then
802 elsif instruction = conv_std_logic_vector(16#bc#, dsize) then
806 elsif instruction = conv_std_logic_vector(16#09#, dsize) then
810 elsif instruction = conv_std_logic_vector(16#05#, dsize) then
814 elsif instruction = conv_std_logic_vector(16#15#, dsize) then
818 elsif instruction = conv_std_logic_vector(16#0d#, dsize) then
822 elsif instruction = conv_std_logic_vector(16#1d#, dsize) then
826 elsif instruction = conv_std_logic_vector(16#19#, dsize) then
830 elsif instruction = conv_std_logic_vector(16#01#, dsize) then
834 elsif instruction = conv_std_logic_vector(16#11#, dsize) then
838 elsif instruction = conv_std_logic_vector(16#e9#, dsize) then
842 elsif instruction = conv_std_logic_vector(16#e5#, dsize) then
846 elsif instruction = conv_std_logic_vector(16#f5#, dsize) then
850 elsif instruction = conv_std_logic_vector(16#ed#, dsize) then
854 elsif instruction = conv_std_logic_vector(16#fd#, dsize) then
858 elsif instruction = conv_std_logic_vector(16#f9#, dsize) then
862 elsif instruction = conv_std_logic_vector(16#e1#, dsize) then
866 elsif instruction = conv_std_logic_vector(16#f1#, dsize) then
872 ----------------------------------------
873 ---A.3. store operation.
874 ----------------------------------------
875 elsif instruction = conv_std_logic_vector(16#85#, dsize) then
879 if exec_cycle = T2 then
882 elsif instruction = conv_std_logic_vector(16#95#, dsize) then
886 elsif instruction = conv_std_logic_vector(16#8d#, dsize) then
890 if exec_cycle = T3 then
891 front_oe(acc_cmd, '0');
894 elsif instruction = conv_std_logic_vector(16#9d#, dsize) then
898 elsif instruction = conv_std_logic_vector(16#99#, dsize) then
902 elsif instruction = conv_std_logic_vector(16#81#, dsize) then
906 elsif instruction = conv_std_logic_vector(16#91#, dsize) then
910 elsif instruction = conv_std_logic_vector(16#86#, dsize) then
914 if exec_cycle = T2 then
917 elsif instruction = conv_std_logic_vector(16#96#, dsize) then
921 elsif instruction = conv_std_logic_vector(16#8e#, dsize) then
925 elsif instruction = conv_std_logic_vector(16#84#, dsize) then
929 elsif instruction = conv_std_logic_vector(16#94#, dsize) then
933 elsif instruction = conv_std_logic_vector(16#8c#, dsize) then
938 ----------------------------------------
939 ---A.4. read-modify-write operation
940 ----------------------------------------
941 elsif instruction = conv_std_logic_vector(16#06#, dsize) then
945 elsif instruction = conv_std_logic_vector(16#16#, dsize) then
949 elsif instruction = conv_std_logic_vector(16#0e#, dsize) then
953 elsif instruction = conv_std_logic_vector(16#1e#, dsize) then
957 elsif instruction = conv_std_logic_vector(16#c6#, dsize) then
961 elsif instruction = conv_std_logic_vector(16#d6#, dsize) then
965 elsif instruction = conv_std_logic_vector(16#ce#, dsize) then
969 elsif instruction = conv_std_logic_vector(16#de#, dsize) then
973 elsif instruction = conv_std_logic_vector(16#e6#, dsize) then
977 elsif instruction = conv_std_logic_vector(16#f6#, dsize) then
981 elsif instruction = conv_std_logic_vector(16#ee#, dsize) then
985 elsif instruction = conv_std_logic_vector(16#fe#, dsize) then
989 elsif instruction = conv_std_logic_vector(16#46#, dsize) then
993 elsif instruction = conv_std_logic_vector(16#56#, dsize) then
997 elsif instruction = conv_std_logic_vector(16#4e#, dsize) then
1001 elsif instruction = conv_std_logic_vector(16#5e#, dsize) then
1005 elsif instruction = conv_std_logic_vector(16#26#, dsize) then
1009 elsif instruction = conv_std_logic_vector(16#36#, dsize) then
1013 elsif instruction = conv_std_logic_vector(16#2e#, dsize) then
1017 elsif instruction = conv_std_logic_vector(16#3e#, dsize) then
1021 elsif instruction = conv_std_logic_vector(16#66#, dsize) then
1025 elsif instruction = conv_std_logic_vector(16#76#, dsize) then
1029 elsif instruction = conv_std_logic_vector(16#6e#, dsize) then
1033 elsif instruction = conv_std_logic_vector(16#7e#, dsize) then
1038 ----------------------------------------
1039 --A.5. miscellaneous oprations.
1040 ----------------------------------------
1043 elsif instruction = conv_std_logic_vector(16#08#, dsize) then
1046 elsif instruction = conv_std_logic_vector(16#48#, dsize) then
1049 elsif instruction = conv_std_logic_vector(16#28#, dsize) then
1052 elsif instruction = conv_std_logic_vector(16#68#, dsize) then
1056 ----------------------------------------
1058 ----------------------------------------
1059 elsif instruction = conv_std_logic_vector(16#20#, dsize) then
1060 if exec_cycle = T1 then
1061 d_print("jsr abs 2");
1063 back_oe(pcl_cmd, '0');
1064 back_oe(pch_cmd, '0');
1065 back_we(pcl_cmd, '0');
1067 dbuf_int_oe_n <= '0';
1071 elsif exec_cycle = T2 then
1073 back_oe(pcl_cmd, '1');
1074 back_oe(pch_cmd, '1');
1075 back_we(pcl_cmd, '1');
1077 dbuf_int_oe_n <= '1';
1080 --push return addr high into stack.
1083 front_oe(pch_cmd, '0');
1084 back_oe(sp_cmd, '0');
1085 back_we(sp_cmd, '0');
1088 elsif exec_cycle = T3 then
1090 front_oe(pch_cmd, '1');
1092 --push return addr low into stack.
1095 front_oe(pcl_cmd, '0');
1096 back_oe(sp_cmd, '0');
1097 back_we(sp_cmd, '0');
1101 elsif exec_cycle = T4 then
1105 front_oe(pcl_cmd, '1');
1106 back_oe(sp_cmd, '1');
1107 back_we(sp_cmd, '1');
1111 back_oe(pch_cmd, '0');
1112 back_oe(pcl_cmd, '0');
1113 dbuf_int_oe_n <= '0';
1117 elsif exec_cycle = T5 then
1120 back_oe(pch_cmd, '1');
1121 back_oe(pcl_cmd, '1');
1122 dbuf_int_oe_n <= '1';
1129 front_we(pch_cmd, '0');
1133 back_we(pcl_cmd, '0');
1136 end if; --if exec_cycle = T1 then
1139 elsif instruction = conv_std_logic_vector(16#00#, dsize) then
1141 ----------------------------------------
1142 -- A.5.5 return from interrupt
1143 ----------------------------------------
1144 elsif instruction = conv_std_logic_vector(16#40#, dsize) then
1146 ----------------------------------------
1148 ----------------------------------------
1149 elsif instruction = conv_std_logic_vector(16#4c#, dsize) then
1151 if exec_cycle = T1 then
1153 --fetch next opcode (abs low).
1154 back_oe(pcl_cmd, '0');
1155 back_oe(pch_cmd, '0');
1156 back_we(pcl_cmd, '0');
1159 --latch abs low data.
1160 dbuf_int_oe_n <= '0';
1163 elsif exec_cycle = T2 then
1168 back_oe(pcl_cmd, '0');
1169 back_oe(pch_cmd, '0');
1170 back_we(pcl_cmd, '0');
1174 dbuf_int_oe_n <= '0';
1177 elsif exec_cycle = T3 then
1178 d_print("jmp done > next fetch");
1179 back_oe(pcl_cmd, '1');
1180 back_oe(pch_cmd, '1');
1181 dbuf_int_oe_n <= '1';
1189 --fetch inst and goto decode next.
1190 back_we(pcl_cmd, '0');
1191 front_we(pch_cmd, '0');
1197 elsif instruction = conv_std_logic_vector(16#6c#, dsize) then
1201 ----------------------------------------
1202 -- A.5.7 return from soubroutine
1203 ----------------------------------------
1204 elsif instruction = conv_std_logic_vector(16#60#, dsize) then
1205 if exec_cycle = T1 then
1207 back_oe(pcl_cmd, '1');
1208 back_oe(pch_cmd, '1');
1211 --pop stack (decrement only)
1212 back_oe(sp_cmd, '0');
1213 back_we(sp_cmd, '0');
1218 elsif exec_cycle = T2 then
1222 back_oe(sp_cmd, '0');
1223 back_we(sp_cmd, '0');
1228 dbuf_int_oe_n <= '0';
1229 front_we(pcl_cmd, '0');
1232 elsif exec_cycle = T3 then
1234 --stack decrement stop.
1235 back_we(sp_cmd, '1');
1237 front_we(pcl_cmd, '1');
1240 back_oe(sp_cmd, '0');
1243 dbuf_int_oe_n <= '0';
1244 front_we(pch_cmd, '0');
1247 elsif exec_cycle = T4 then
1249 back_oe(sp_cmd, '1');
1252 dbuf_int_oe_n <= '1';
1253 front_we(pch_cmd, '1');
1255 --complying h/w manual...
1257 elsif exec_cycle = T5 then
1262 back_we(pcl_cmd, '0');
1263 back_oe(pcl_cmd, '0');
1264 back_oe(pch_cmd, '0');
1266 end if; --if exec_cycle = T1 then
1268 ----------------------------------------
1269 -- A.5.8 branch operations
1270 ----------------------------------------
1271 elsif instruction = conv_std_logic_vector(16#90#, dsize) then
1273 elsif instruction = conv_std_logic_vector(16#b0#, dsize) then
1275 a58_branch (st_C, '1');
1277 elsif instruction = conv_std_logic_vector(16#f0#, dsize) then
1279 elsif instruction = conv_std_logic_vector(16#30#, dsize) then
1281 elsif instruction = conv_std_logic_vector(16#d0#, dsize) then
1283 a58_branch (st_Z, '0');
1285 elsif instruction = conv_std_logic_vector(16#10#, dsize) then
1287 a58_branch (st_N, '0');
1289 elsif instruction = conv_std_logic_vector(16#50#, dsize) then
1291 elsif instruction = conv_std_logic_vector(16#70#, dsize) then
1295 ---unknown instruction!!!!
1297 report "======== unknow instruction "
1298 & conv_hex8(conv_integer(instruction));
1299 end if; --if instruction = conv_std_logic_vector(16#0a#, dsize)
1301 elsif exec_cycle = R0 then
1302 d_print(string'("reset"));
1307 dbuf_int_oe_n <= '1';
1326 abs_pg_next_n <= '1';
1330 stat_dec_oe_n <= '1';
1331 stat_bus_oe_n <= '1';
1332 stat_set_flg_n <= '1';
1334 stat_bus_all_n <= '1';
1335 stat_bus_nz_n <= '1';
1336 stat_alu_we_n <= '1';
1339 elsif exec_cycle = R1 then
1341 front_we(pch_cmd, '1');
1342 back_we(pcl_cmd, '1');
1344 elsif exec_cycle = R2 then
1347 elsif exec_cycle = R3 then
1350 elsif exec_cycle = R4 then
1353 elsif exec_cycle = R5 then
1356 elsif exec_cycle(5) = '1' then
1357 ---pc increment and next page.
1358 d_print(string'("pch next page..."));
1359 --pcl stop increment
1361 back_we(pcl_cmd, '1');
1364 back_we(pch_cmd, '0');
1366 end if; --if exec_cycle = T0 then
1368 end if; --if (set_clk'event and set_clk = '1')