generic ( dsize : integer := 8
);
port (
+ clk : in std_logic;
ah_oe_n : in std_logic;
al_oe_n : in std_logic;
base : in std_logic_vector (dsize - 1 downto 0);
end effective_adder;
architecture rtl of effective_adder is
-signal d_out : std_logic_vector (dsize - 1 downto 0);
+ component dff
+ generic (
+ dsize : integer := 8
+ );
+ port (
+ clk : in std_logic;
+ we_n : in std_logic;
+ oe_n : in std_logic;
+ d : in std_logic_vector (dsize - 1 downto 0);
+ q : out std_logic_vector (dsize - 1 downto 0)
+ );
+ end component;
+
+signal al_out : std_logic_vector (dsize - 1 downto 0);
+signal ah_out : std_logic_vector (dsize - 1 downto 0);
+signal old_al : std_logic_vector (dsize - 1 downto 0);
signal adc_work : std_logic_vector (dsize downto 0);
+
begin
adc_work <= ('0' & base) + ('0' & index);
carry <= adc_work(dsize);
- d_out <= adc_work(dsize - 1 downto 0);
- ah_bus <= d_out when ah_oe_n = '0' else
+ al_out <= adc_work(dsize - 1 downto 0);
+ ---always remory adl.
+ al_buf : dff generic map (dsize)
+ port map (clk, '0', '0', al_out, old_al);
+
+ --both output means, page boundary crossed.
+ --output old effective addr low.
+ al_bus <= old_al when al_oe_n = '0' and ah_oe_n = '0' else
+ al_out when al_oe_n = '0' else
(others => 'Z');
- al_bus <= d_out when al_oe_n = '0' else
+
+ --ah output means, page boundary crossed.
+ ah_bus <= base + '1' when ah_oe_n = '0' else
(others => 'Z');
end rtl;
dl_dl_oe_n <= '1';
x_calc_n <= '1';
ea_al_oe_n <= '1';
+ dl_dh_oe_n <= '1';
+ ea_ah_oe_n <= '1';
cur_cycle <= decode;
dbuf_int_oe_n <= '1';
dl_ah_we_n <= '1';
- -----calucurate and output effective addr
+ -----calucurate and output effective addr low
dl_dl_oe_n <= '0';
x_calc_n <= '0';
ea_al_oe_n <= '0';
---conditional branch instruction..
else
if cur_mode = ad_absx then
- if ea_carry = '1' then
+ if ea_carry = '0' then
--case page boundary crossed.
+ d_print("absx 5 (page boudary crossed.)");
+ dl_dl_oe_n <= '1';
+ dl_ah_oe_n <= '1';
+
--increment eah.
- d_print("absx 5");
+ -----effective addr low is remorized in the calc.
+ dl_dh_oe_n <= '0';
+ x_calc_n <= '0';
+ ea_al_oe_n <= '0';
+ ea_ah_oe_n <= '0';
+ cur_cycle <= fetch;
else
--case page boundary not crossed. do the fetch op.
d_print("absx 5 (fetch)");
ea_al_oe_n <= '1';
dl_ah_oe_n <= '1';
acc_d_we_n <= '1';
+ dl_al_we_n <= '1';
pcl_a_oe_n <= '0';
pch_a_oe_n <= '0';
end if;
end if;
if instruction (1 downto 0) = "00" then
+ elsif instruction (1 downto 0) = "01" then
+ if instruction (7 downto 5) = "100" then
+ d_print("sta 5");
+ --output acc memory..
+ r_nw <= '0';
+ acc_d_oe_n <= '0';
+ elsif instruction (7 downto 5) = "101" then
+ d_print("lda 5");
+ --if page boundary is crossed, redo in the next cycle.
+ acc_d_we_n <= '0';
+ end if;
end if; --instruction (1 downto 0) = "00"
end if; --if instruction = conv_std_logic_vector(16#00#, dsize)
generic ( dsize : integer := 8
);
port (
+ clk : in std_logic;
ah_oe_n : in std_logic;
al_oe_n : in std_logic;
base : in std_logic_vector (dsize - 1 downto 0);
y_buf_addr : tsb generic map (dsize)
port map (y_calc_n, y_out, addr_index);
+ ---effective addres calcurator.
addr_calc: effective_adder generic map (dsize)
- port map (ea_ah_oe_n, ea_al_oe_n,
+ port map (trigger_clk, ea_ah_oe_n, ea_al_oe_n,
internal_dbus, addr_index,
internal_abus_h, internal_abus_l, ea_carry);