pch_inc_n : in std_logic;
sph_oe_n : in std_logic;
sp_push_n : in std_logic;
+ sp_pop_n : in std_logic;
abs_ea_n : in std_logic;
zp_ea_n : in std_logic;
arith_en_n : in std_logic;
--stack operation...
abh <= "00000001";
- if (sp_push_n /= '0') then
+ if (sp_push_n /= '0' and sp_pop_n /= '0') then
abl <= bal;
+ elsif (sp_pop_n = '0') then
+ sel <= ALU_INC;
+ d1 <= bal;
+ alu_res <= d_out;
+
+ if (clk = '0') then
+ abl <= bal;
+ else
+ abl <= bal_reg;
+ end if;
else
+ ---case push
sel <= ALU_DEC;
d1 <= bal;
alu_res <= d_out;
sp_cmd : out std_logic_vector(3 downto 0);
sph_oe_n : out std_logic;
sp_push_n : out std_logic;
+ sp_pop_n : out std_logic;
acc_cmd : out std_logic_vector(3 downto 0);
x_cmd : out std_logic_vector(3 downto 0);
y_cmd : out std_logic_vector(3 downto 0);
sp_cmd <= "1111";
sph_oe_n <= '1';
sp_push_n <= '1';
+ sp_pop_n <= '1';
acc_cmd <= "1111";
x_cmd <= "1111";
y_cmd <= "1111";
-- A.5.7 return from soubroutine
----------------------------------------
elsif instruction = conv_std_logic_vector(16#60#, dsize) then
+ if exec_cycle = T1 then
+ d_print("rts 2");
+ back_oe(pcl_cmd, '1');
+ back_oe(pch_cmd, '1');
+ pcl_inc_n <= '1';
+
+ --pop stack (decrement only)
+ back_oe(sp_cmd, '0');
+ back_we(sp_cmd, '0');
+ sp_pop_n <= '0';
+ sph_oe_n <= '0';
+
+ next_cycle <= T2;
+ elsif exec_cycle = T2 then
+ d_print("rts 3");
+
+ --pop pcl
+ back_oe(sp_cmd, '0');
+ back_we(sp_cmd, '0');
+ sp_pop_n <= '0';
+ sph_oe_n <= '0';
+
+ --load lo addr.
+ dbuf_int_oe_n <= '0';
+ front_we(pcl_cmd, '0');
+
+ next_cycle <= T3;
+ elsif exec_cycle = T3 then
+ d_print("rts 4");
+ --stack decrement stop.
+ back_we(sp_cmd, '1');
+ sp_pop_n <= '1';
+ front_we(pcl_cmd, '1');
+
+ --pop pch
+ back_oe(sp_cmd, '0');
+ sph_oe_n <= '0';
+ --load hi addr.
+ dbuf_int_oe_n <= '0';
+ front_we(pch_cmd, '0');
+
+ next_cycle <= T4;
+ elsif exec_cycle = T4 then
+ d_print("rts 5");
+ back_oe(sp_cmd, '1');
+ sph_oe_n <= '1';
+ --load hi addr.
+ dbuf_int_oe_n <= '1';
+ front_we(pch_cmd, '1');
+ --empty cycle.
+ --complying h/w manual...
+ next_cycle <= T5;
+ elsif exec_cycle = T5 then
+ d_print("rts 6");
+
+ --increment pc.
+ pcl_inc_n <= '0';
+ back_we(pcl_cmd, '0');
+ back_oe(pcl_cmd, '0');
+ back_oe(pch_cmd, '0');
+ next_cycle <= T0;
+ end if; --if exec_cycle = T1 then
----------------------------------------
-- A.5.8 branch operations
sp_cmd <= "1111";
sph_oe_n <= '1';
sp_push_n <= '1';
+ sp_pop_n <= '1';
acc_cmd <= "1111";
x_cmd <= "1111";
y_cmd <= "1111";
sp_cmd : out std_logic_vector(3 downto 0);
sph_oe_n : out std_logic;
sp_push_n : out std_logic;
+ sp_pop_n : out std_logic;
acc_cmd : out std_logic_vector(3 downto 0);
x_cmd : out std_logic_vector(3 downto 0);
y_cmd : out std_logic_vector(3 downto 0);
pch_inc_n : in std_logic;
sph_oe_n : in std_logic;
sp_push_n : in std_logic;
+ sp_pop_n : in std_logic;
abs_ea_n : in std_logic;
zp_ea_n : in std_logic;
arith_en_n : in std_logic;
signal y_cmd : std_logic_vector(3 downto 0);
signal sph_oe_n : std_logic;
signal sp_push_n : std_logic;
+ signal sp_pop_n : std_logic;
---status register
signal stat_dec_oe_n : std_logic;
sp_cmd,
sph_oe_n,
sp_push_n,
+ sp_pop_n,
acc_cmd,
x_cmd,
y_cmd,
pch_inc_n,
sph_oe_n,
sp_push_n,
+ sp_pop_n,
abs_ea_n,
zp_ea_n,
arith_en_n,