OpenCores
URL https://opencores.org/ocsvn/t48/t48/trunk

Subversion Repositories t48

[/] [t48/] [tags/] [rel_1_0/] [rtl/] [vhdl/] [decoder.vhd] - Diff between revs 78 and 92

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 78 Rev 92
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.10 2004-04-25 16:22:03 arniml Exp $
-- $Id: decoder.vhd,v 1.11 2004-05-16 15:33:39 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 171... Line 171...
use work.t48_tb_pack.tb_istrobe_s;
use work.t48_tb_pack.tb_istrobe_s;
-- pragma translate_on
-- pragma translate_on
 
 
architecture rtl of decoder is
architecture rtl of decoder is
 
 
 
  -- Enable fixing a bug of Quartus II 4.0
 
  constant enable_quartus_bugfix_c : boolean := true;
 
 
  -- Opcode Decoder
  -- Opcode Decoder
  signal opc_multi_cycle_s : boolean;
  signal opc_multi_cycle_s : boolean;
  signal opc_read_bus_s    : boolean;
  signal opc_read_bus_s    : boolean;
  signal opc_inj_int_s     : boolean;
  signal opc_inj_int_s     : boolean;
  signal opc_opcode_s      : word_t;
  signal opc_opcode_s      : word_t;
Line 404... Line 407...
                   int_pending_s)
                   int_pending_s)
 
 
    procedure address_indirect_3_f is
    procedure address_indirect_3_f is
    begin
    begin
      -- apply dmem address from selected register for indirect mode
      -- apply dmem address from selected register for indirect mode
      if opc_opcode_s(3) = '0' then
      if opc_opcode_s(3) = '0' or enable_quartus_bugfix_c then
        dm_read_dmem_o       <= true;
        dm_read_dmem_o       <= true;
        dm_write_dmem_addr_o <= true;
        dm_write_dmem_addr_o <= true;
        dm_addr_type_o       <= DM_PLAIN;
        dm_addr_type_o       <= DM_PLAIN;
      end if;
      end if;
    end;
    end;
Line 430... Line 433...
 
 
    procedure cond_jump_c2_m1_f is
    procedure cond_jump_c2_m1_f is
    begin
    begin
      -- store address in Program Counter low byte if branch has to
      -- store address in Program Counter low byte if branch has to
      -- be taken
      -- be taken
      if clk_mstate_i = MSTATE1 and cnd_take_branch_i then
--      if clk_mstate_i = MSTATE1 and cnd_take_branch_i then
        pm_write_pcl_o       <= true;
        pm_write_pcl_o       <= true;
        branch_taken_s       <= true;
        branch_taken_s       <= true;
      end if;
--      end if;
    end;
    end;
 
 
  begin
  begin
    -- default assignments
    -- default assignments
    data_s                 <= (others => '-');
    data_s                 <= (others => '-');
Line 532... Line 535...
      -- Mnemonic ADD ---------------------------------------------------------
      -- Mnemonic ADD ---------------------------------------------------------
      when MN_ADD =>
      when MN_ADD =>
        case clk_mstate_i is
        case clk_mstate_i is
          -- read RAM once for indirect address mode
          -- read RAM once for indirect address mode
          when MSTATE3 =>
          when MSTATE3 =>
 
            if not enable_quartus_bugfix_c or
 
               opc_opcode_s(3) = '0' then
            address_indirect_3_f;
            address_indirect_3_f;
 
            end if;
 
 
          -- store data from RAM to Temp Reg
          -- store data from RAM to Temp Reg
          when MSTATE4 =>
          when MSTATE4 =>
            and_or_xor_add_4_f;
            and_or_xor_add_4_f;
 
 
Line 589... Line 595...
      -- Mnemonic ANL ---------------------------------------------------------
      -- Mnemonic ANL ---------------------------------------------------------
      when MN_ANL =>
      when MN_ANL =>
        case clk_mstate_i is
        case clk_mstate_i is
          -- read RAM once for indirect address mode
          -- read RAM once for indirect address mode
          when MSTATE3 =>
          when MSTATE3 =>
 
            if not enable_quartus_bugfix_c or
 
               opc_opcode_s(3) = '0' then
            address_indirect_3_f;
            address_indirect_3_f;
 
            end if;
 
 
          -- store data from RAM to Temp Reg
          -- store data from RAM to Temp Reg
          when MSTATE4 =>
          when MSTATE4 =>
            and_or_xor_add_4_f;
            and_or_xor_add_4_f;
 
 
Line 932... Line 941...
          end case;
          end case;
 
 
        else
        else
          -- store address in Program Counter low byte if branch has to
          -- store address in Program Counter low byte if branch has to
          -- be taken
          -- be taken
 
          if clk_mstate_i = MSTATE1 and cnd_take_branch_i then
          cond_jump_c2_m1_f;
          cond_jump_c2_m1_f;
 
          end if;
 
 
        end if;
        end if;
 
 
      -- Mnemonic ENT0_CLK ----------------------------------------------------
      -- Mnemonic ENT0_CLK ----------------------------------------------------
      when MN_ENT0_CLK =>
      when MN_ENT0_CLK =>
Line 969... Line 980...
      -- Mnemonic INC ---------------------------------------------------------
      -- Mnemonic INC ---------------------------------------------------------
      when MN_INC =>
      when MN_INC =>
        case clk_mstate_i is
        case clk_mstate_i is
          -- read RAM once for indirect address mode
          -- read RAM once for indirect address mode
          when MSTATE3 =>
          when MSTATE3 =>
 
            if not enable_quartus_bugfix_c or
 
               opc_opcode_s(3) = '0' then
            address_indirect_3_f;
            address_indirect_3_f;
 
            end if;
 
 
          when MSTATE4 =>
          when MSTATE4 =>
            -- INC Rr; INC @ Rr: store data from RAM to shadow Accumulator
            -- INC Rr; INC @ Rr: store data from RAM to shadow Accumulator
            if opc_opcode_s(3 downto 2) /= "01" then
            if opc_opcode_s(3 downto 2) /= "01" then
              dm_read_dmem_o         <= true;
              dm_read_dmem_o         <= true;
Line 1011... Line 1025...
          end if;
          end if;
 
 
        else
        else
          -- store address in Program Counter low byte if branch has to
          -- store address in Program Counter low byte if branch has to
          -- be taken
          -- be taken
 
          if clk_mstate_i = MSTATE1 and cnd_take_branch_i then
          cond_jump_c2_m1_f;
          cond_jump_c2_m1_f;
 
          end if;
 
 
        end if;
        end if;
 
 
      -- Mnemonic JC ----------------------------------------------------------
      -- Mnemonic JC ----------------------------------------------------------
      when MN_JC =>
      when MN_JC =>
Line 1030... Line 1046...
          end if;
          end if;
 
 
        else
        else
          -- store address in Program Counter low byte if branch has to
          -- store address in Program Counter low byte if branch has to
          -- be taken
          -- be taken
 
          if clk_mstate_i = MSTATE1 and cnd_take_branch_i then
          cond_jump_c2_m1_f;
          cond_jump_c2_m1_f;
 
          end if;
 
 
        end if;
        end if;
 
 
      -- Mnemonic JF ----------------------------------------------------------
      -- Mnemonic JF ----------------------------------------------------------
      when MN_JF =>
      when MN_JF =>
Line 1055... Line 1073...
          end if;
          end if;
 
 
        else
        else
          -- store address in Program Counter low byte if branch has to
          -- store address in Program Counter low byte if branch has to
          -- be taken
          -- be taken
 
          if clk_mstate_i = MSTATE1 and cnd_take_branch_i then
          cond_jump_c2_m1_f;
          cond_jump_c2_m1_f;
 
          end if;
 
 
        end if;
        end if;
 
 
 
 
      -- Mnemonic JMP ---------------------------------------------------------
      -- Mnemonic JMP ---------------------------------------------------------
Line 1120... Line 1140...
          end if;
          end if;
 
 
        else
        else
          -- store address in Program Counter low byte if branch has to
          -- store address in Program Counter low byte if branch has to
          -- be taken
          -- be taken
 
          if clk_mstate_i = MSTATE1 and cnd_take_branch_i then
          cond_jump_c2_m1_f;
          cond_jump_c2_m1_f;
 
          end if;
 
 
        end if;
        end if;
 
 
      -- Mnemonic JT ----------------------------------------------------------
      -- Mnemonic JT ----------------------------------------------------------
      when MN_JT =>
      when MN_JT =>
Line 1143... Line 1165...
          end if;
          end if;
 
 
        else
        else
          -- store address in Program Counter low byte if branch has to
          -- store address in Program Counter low byte if branch has to
          -- be taken
          -- be taken
 
          if clk_mstate_i = MSTATE1 and cnd_take_branch_i then
          cond_jump_c2_m1_f;
          cond_jump_c2_m1_f;
 
          end if;
 
 
        end if;
        end if;
 
 
      -- Mnemonic JTF ---------------------------------------------------------
      -- Mnemonic JTF ---------------------------------------------------------
      when MN_JTF =>
      when MN_JTF =>
Line 1162... Line 1186...
          end if;
          end if;
 
 
        else
        else
          -- store address in Program Counter low byte if branch has to
          -- store address in Program Counter low byte if branch has to
          -- be taken
          -- be taken
 
          if clk_mstate_i = MSTATE1 and cnd_take_branch_i then
          cond_jump_c2_m1_f;
          cond_jump_c2_m1_f;
 
          end if;
 
 
        end if;
        end if;
 
 
      -- Mnemonic JZ ----------------------------------------------------------
      -- Mnemonic JZ ----------------------------------------------------------
      when MN_JZ =>
      when MN_JZ =>
Line 1182... Line 1208...
          end if;
          end if;
 
 
        else
        else
          -- store address in Program Counter low byte if branch has to
          -- store address in Program Counter low byte if branch has to
          -- be taken
          -- be taken
 
          if clk_mstate_i = MSTATE1 and cnd_take_branch_i then
          cond_jump_c2_m1_f;
          cond_jump_c2_m1_f;
 
          end if;
 
 
        end if;
        end if;
 
 
      -- Mnemonic MOV_A_DATA --------------------------------------------------
      -- Mnemonic MOV_A_DATA --------------------------------------------------
      when MN_MOV_A_DATA =>
      when MN_MOV_A_DATA =>
Line 1201... Line 1229...
      -- Mnemonic MOV_A_RR ----------------------------------------------------
      -- Mnemonic MOV_A_RR ----------------------------------------------------
      when MN_MOV_A_RR =>
      when MN_MOV_A_RR =>
        case clk_mstate_i is
        case clk_mstate_i is
          -- read RAM once for indirect address mode
          -- read RAM once for indirect address mode
          when MSTATE3 =>
          when MSTATE3 =>
 
            if not enable_quartus_bugfix_c or
 
               opc_opcode_s(3) = '0' then
            address_indirect_3_f;
            address_indirect_3_f;
 
            end if;
 
 
          -- read data from RAM and store in Accumulator
          -- read data from RAM and store in Accumulator
          when MSTATE4 =>
          when MSTATE4 =>
            and_or_xor_add_4_f;
            and_or_xor_add_4_f;
            alu_write_accu_o <= true;
            alu_write_accu_o <= true;
Line 1234... Line 1265...
      -- Mnemonic MOV_RR ------------------------------------------------------
      -- Mnemonic MOV_RR ------------------------------------------------------
      when MN_MOV_RR =>
      when MN_MOV_RR =>
        case clk_mstate_i is
        case clk_mstate_i is
          -- read RAM once for indirect address mode
          -- read RAM once for indirect address mode
          when MSTATE3 =>
          when MSTATE3 =>
 
            if not enable_quartus_bugfix_c or
 
               opc_opcode_s(3) = '0' then
            address_indirect_3_f;
            address_indirect_3_f;
 
            end if;
 
 
          -- write Accumulator to dmem
          -- write Accumulator to dmem
          when MSTATE5 =>
          when MSTATE5 =>
            alu_read_alu_o       <= true;
            alu_read_alu_o       <= true;
            dm_write_dmem_s      <= true;
            dm_write_dmem_s      <= true;
Line 1252... Line 1286...
      when MN_MOV_RR_DATA =>
      when MN_MOV_RR_DATA =>
        assert_psen_s     <= true;
        assert_psen_s     <= true;
 
 
        -- read RAM once for indirect address mode
        -- read RAM once for indirect address mode
        if not clk_second_cycle_i and clk_mstate_i = MSTATE3 then
        if not clk_second_cycle_i and clk_mstate_i = MSTATE3 then
 
          if not enable_quartus_bugfix_c or
 
             opc_opcode_s(3) = '0' then
          address_indirect_3_f;
          address_indirect_3_f;
        end if;
        end if;
 
        end if;
 
 
        -- Write Data Memory when contents of Program Memory is on bus
        -- Write Data Memory when contents of Program Memory is on bus
        -- during machine state 1 of second cycle.
        -- during machine state 1 of second cycle.
        if clk_second_cycle_i and clk_mstate_i = MSTATE1 then
        if clk_second_cycle_i and clk_mstate_i = MSTATE1 then
          dm_write_dmem_s <= true;
          dm_write_dmem_s <= true;
Line 1453... Line 1490...
      -- Mnemonic ORL ---------------------------------------------------------
      -- Mnemonic ORL ---------------------------------------------------------
      when MN_ORL =>
      when MN_ORL =>
        case clk_mstate_i is
        case clk_mstate_i is
          -- read RAM once for indirect address mode
          -- read RAM once for indirect address mode
          when MSTATE3 =>
          when MSTATE3 =>
 
            if not enable_quartus_bugfix_c or
 
               opc_opcode_s(3) = '0' then
            address_indirect_3_f;
            address_indirect_3_f;
 
            end if;
 
 
          -- store data from RAM to Temp Reg
          -- store data from RAM to Temp Reg
          when MSTATE4 =>
          when MSTATE4 =>
            and_or_xor_add_4_f;
            and_or_xor_add_4_f;
 
 
Line 1685... Line 1725...
      -- Mnemonic XCH ---------------------------------------------------------
      -- Mnemonic XCH ---------------------------------------------------------
      when MN_XCH =>
      when MN_XCH =>
        case clk_mstate_i is
        case clk_mstate_i is
          -- read RAM once for indirect address mode
          -- read RAM once for indirect address mode
          when MSTATE3 =>
          when MSTATE3 =>
 
            if not enable_quartus_bugfix_c or
 
               opc_opcode_s(3) = '0' then
            address_indirect_3_f;
            address_indirect_3_f;
 
            end if;
 
 
          -- store data from RAM in Accumulator and Temp Reg
          -- store data from RAM in Accumulator and Temp Reg
          -- Accumulator is already shadowed!
          -- Accumulator is already shadowed!
          when MSTATE4 =>
          when MSTATE4 =>
            dm_read_dmem_o       <= true;
            dm_read_dmem_o       <= true;
Line 1719... Line 1762...
      -- Mnemonic XRL ---------------------------------------------------------
      -- Mnemonic XRL ---------------------------------------------------------
      when MN_XRL =>
      when MN_XRL =>
        case clk_mstate_i is
        case clk_mstate_i is
          -- read RAM once for indirect address mode
          -- read RAM once for indirect address mode
          when MSTATE3 =>
          when MSTATE3 =>
 
            if not enable_quartus_bugfix_c or
 
               opc_opcode_s(3) = '0' then
            address_indirect_3_f;
            address_indirect_3_f;
 
            end if;
 
 
          -- store data from RAM to Temp Reg
          -- store data from RAM to Temp Reg
          when MSTATE4 =>
          when MSTATE4 =>
            and_or_xor_add_4_f;
            and_or_xor_add_4_f;
 
 
Line 1883... Line 1929...
 
 
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- File History:
-- File History:
--
--
-- $Log: not supported by cvs2svn $
-- $Log: not supported by cvs2svn $
 
-- Revision 1.10  2004/04/25 16:22:03  arniml
 
-- adjust external timing of BUS
 
--
-- Revision 1.9  2004/04/24 11:22:55  arniml
-- Revision 1.9  2004/04/24 11:22:55  arniml
-- removed superfluous signal from sensitivity list
-- removed superfluous signal from sensitivity list
--
--
-- Revision 1.8  2004/04/18 18:57:43  arniml
-- Revision 1.8  2004/04/18 18:57:43  arniml
-- + enhance instruction strobe generation
-- + enhance instruction strobe generation

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.