Line 1... |
Line 1... |
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
--
|
--
|
-- The Decoder unit.
|
-- The Decoder unit.
|
-- It decodes the instruction opcodes and executes them.
|
-- It decodes the instruction opcodes and executes them.
|
--
|
--
|
-- $Id: decoder.vhd,v 1.2 2004-03-28 13:06:32 arniml Exp $
|
-- $Id: decoder.vhd,v 1.3 2004-03-28 21:15:48 arniml Exp $
|
--
|
--
|
-- Copyright (c) 2004, Arnim Laeuger (arniml@opencores.org)
|
-- Copyright (c) 2004, Arnim Laeuger (arniml@opencores.org)
|
--
|
--
|
-- All rights reserved
|
-- All rights reserved
|
--
|
--
|
Line 98... |
Line 98... |
psw_read_sp_o : out boolean;
|
psw_read_sp_o : out boolean;
|
psw_write_psw_o : out boolean;
|
psw_write_psw_o : out boolean;
|
psw_write_sp_o : out boolean;
|
psw_write_sp_o : out boolean;
|
-- ALU Interface ----------------------------------------------------------
|
-- ALU Interface ----------------------------------------------------------
|
alu_carry_i : in std_logic;
|
alu_carry_i : in std_logic;
|
alu_aux_carry_i : in std_logic;
|
|
alu_op_o : out alu_op_t;
|
alu_op_o : out alu_op_t;
|
alu_use_carry_o : out boolean;
|
alu_use_carry_o : out boolean;
|
|
alu_da_low_o : out boolean;
|
|
alu_da_high_o : out boolean;
|
|
alu_p06_temp_reg_o : out boolean;
|
|
alu_p60_temp_reg_o : out boolean;
|
|
alu_da_overflow_i : in boolean;
|
-- BUS Interface ----------------------------------------------------------
|
-- BUS Interface ----------------------------------------------------------
|
bus_output_pcl_o : out boolean;
|
bus_output_pcl_o : out boolean;
|
bus_bidir_bus_o : out boolean;
|
bus_bidir_bus_o : out boolean;
|
-- Clock Controller Interface ---------------------------------------------
|
-- Clock Controller Interface ---------------------------------------------
|
clk_multi_cycle_o : out boolean;
|
clk_multi_cycle_o : out boolean;
|
Line 134... |
Line 138... |
pm_write_pmem_addr_o : out boolean;
|
pm_write_pmem_addr_o : out boolean;
|
pm_addr_type_o : out pmem_addr_ident_t;
|
pm_addr_type_o : out pmem_addr_ident_t;
|
-- Program Status Word Interface ------------------------------------------
|
-- Program Status Word Interface ------------------------------------------
|
psw_special_data_o : out std_logic;
|
psw_special_data_o : out std_logic;
|
psw_carry_i : in std_logic;
|
psw_carry_i : in std_logic;
|
|
psw_aux_carry_i : in std_logic;
|
psw_f0_i : in std_logic;
|
psw_f0_i : in std_logic;
|
psw_inc_stackp_o : out boolean;
|
psw_inc_stackp_o : out boolean;
|
psw_dec_stackp_o : out boolean;
|
psw_dec_stackp_o : out boolean;
|
psw_write_carry_o : out boolean;
|
psw_write_carry_o : out boolean;
|
psw_write_aux_carry_o : out boolean;
|
psw_write_aux_carry_o : out boolean;
|
Line 366... |
Line 371... |
-- Purpose:
|
-- Purpose:
|
-- Indentifies each single instruction and steps through the related
|
-- Indentifies each single instruction and steps through the related
|
-- execution sequence.
|
-- execution sequence.
|
--
|
--
|
decode: process (alu_carry_i,
|
decode: process (alu_carry_i,
|
alu_aux_carry_i,
|
psw_aux_carry_i,
|
|
alu_da_overflow_i,
|
clk_mstate_i,
|
clk_mstate_i,
|
clk_second_cycle_i,
|
clk_second_cycle_i,
|
cnd_take_branch_i,
|
cnd_take_branch_i,
|
opc_opcode_s,
|
opc_opcode_s,
|
opc_mnemonic_s,
|
opc_mnemonic_s,
|
Line 430... |
Line 436... |
assert_psen_s <= false;
|
assert_psen_s <= false;
|
stack_high_o <= false;
|
stack_high_o <= false;
|
alu_write_accu_o <= false;
|
alu_write_accu_o <= false;
|
alu_write_shadow_o <= false;
|
alu_write_shadow_o <= false;
|
alu_write_temp_reg_o <= false;
|
alu_write_temp_reg_o <= false;
|
|
alu_p06_temp_reg_o <= false;
|
|
alu_p60_temp_reg_o <= false;
|
alu_read_alu_o <= false;
|
alu_read_alu_o <= false;
|
bus_write_bus_o <= false;
|
bus_write_bus_o <= false;
|
bus_bidir_bus_o <= false;
|
bus_bidir_bus_o <= false;
|
dm_write_dmem_addr_o <= false;
|
dm_write_dmem_addr_o <= false;
|
dm_write_dmem_s <= false;
|
dm_write_dmem_s <= false;
|
Line 447... |
Line 455... |
psw_read_sp_o <= false;
|
psw_read_sp_o <= false;
|
psw_write_psw_o <= false;
|
psw_write_psw_o <= false;
|
psw_write_sp_o <= false;
|
psw_write_sp_o <= false;
|
alu_op_o <= ALU_NOP;
|
alu_op_o <= ALU_NOP;
|
alu_use_carry_o <= false;
|
alu_use_carry_o <= false;
|
|
alu_da_low_o <= false;
|
|
alu_da_high_o <= false;
|
clk_assert_prog_o <= false;
|
clk_assert_prog_o <= false;
|
clk_assert_rd_o <= false;
|
clk_assert_rd_o <= false;
|
clk_assert_wr_o <= false;
|
clk_assert_wr_o <= false;
|
cnd_branch_cond_o <= COND_ON_BIT;
|
cnd_branch_cond_o <= COND_ON_BIT;
|
cnd_compute_take_o <= false;
|
cnd_compute_take_o <= false;
|
Line 523... |
Line 533... |
alu_use_carry_o <= true;
|
alu_use_carry_o <= true;
|
end if;
|
end if;
|
|
|
psw_special_data_o <= alu_carry_i;
|
psw_special_data_o <= alu_carry_i;
|
psw_write_carry_o <= true;
|
psw_write_carry_o <= true;
|
|
psw_write_aux_carry_o <= true;
|
|
|
when others =>
|
when others =>
|
null;
|
null;
|
|
|
end case;
|
end case;
|
Line 549... |
Line 560... |
alu_use_carry_o <= true;
|
alu_use_carry_o <= true;
|
end if;
|
end if;
|
|
|
psw_special_data_o <= alu_carry_i;
|
psw_special_data_o <= alu_carry_i;
|
psw_write_carry_o <= true;
|
psw_write_carry_o <= true;
|
|
psw_write_aux_carry_o <= true;
|
|
|
when others =>
|
when others =>
|
null;
|
null;
|
|
|
end case;
|
end case;
|
Line 787... |
Line 799... |
cpl_f1_s <= true;
|
cpl_f1_s <= true;
|
end if;
|
end if;
|
|
|
end if;
|
end if;
|
|
|
|
-- Mnemonic DA ----------------------------------------------------------
|
|
when MN_DA =>
|
|
alu_op_o <= ALU_ADD;
|
|
|
|
case clk_mstate_i is
|
|
-- Step 1: Preload Temp Reg with 0x06
|
|
when MSTATE3 =>
|
|
alu_p06_temp_reg_o <= true;
|
|
|
|
-- Step 2: Check Auxiliary Carry and overflow on low nibble
|
|
-- Add 0x06 to shadow Accumulator if one is true
|
|
when MSTATE4 =>
|
|
alu_da_low_o <= true;
|
|
|
|
if psw_aux_carry_i = '1' or alu_da_overflow_i then
|
|
alu_read_alu_o <= true;
|
|
alu_write_shadow_o <= true;
|
|
end if;
|
|
|
|
-- preload Temp Reg with 0x60
|
|
alu_p60_temp_reg_o <= true;
|
|
|
|
-- Step 3: Check overflow on high nibble
|
|
-- Add 0x60 to shadow Accumulator if true and store result
|
|
-- in Accumulator and PSW (only Carry)
|
|
when MSTATE5 =>
|
|
alu_da_high_o <= true;
|
|
|
|
if alu_da_overflow_i then
|
|
psw_special_data_o <= alu_carry_i;
|
|
else
|
|
alu_op_o <= ALU_NOP;
|
|
psw_special_data_o <= '0';
|
|
end if;
|
|
alu_read_alu_o <= true;
|
|
alu_write_accu_o <= true;
|
|
psw_write_carry_o <= true;
|
|
|
|
when others =>
|
|
null;
|
|
|
|
end case;
|
|
|
-- Mnemonic DEC ---------------------------------------------------------
|
-- Mnemonic DEC ---------------------------------------------------------
|
when MN_DEC =>
|
when MN_DEC =>
|
case clk_mstate_i is
|
case clk_mstate_i is
|
when MSTATE4 =>
|
when MSTATE4 =>
|
-- DEC Rr: store data from RAM to shadow Accumulator
|
-- DEC Rr: store data from RAM to shadow Accumulator
|
Line 1757... |
Line 1812... |
|
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
-- File History:
|
-- File History:
|
--
|
--
|
-- $Log: not supported by cvs2svn $
|
-- $Log: not supported by cvs2svn $
|
|
-- Revision 1.2 2004/03/28 13:06:32 arniml
|
|
-- implement mnemonics:
|
|
-- + MOVD_A_PP
|
|
-- + OUTD_PP_A -> ANLD PP, A; MOVD PP, A; ORLD PP, A
|
|
--
|
-- Revision 1.1 2004/03/23 21:31:52 arniml
|
-- Revision 1.1 2004/03/23 21:31:52 arniml
|
-- initial check-in
|
-- initial check-in
|
|
--
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
|
|
No newline at end of file
|
No newline at end of file
|