instructions.vhd

来自「Actel Fusion System Management Developme」· VHDL 代码 · 共 1,177 行 · 第 1/5 页

VHD
1,177
字号
-- ********************************************************************/ 
-- Copyright 2007 Actel Corporation.  All rights reserved.
-- IP Engineering 
--
-- ANY USE OR REDISTRIBUTION IN PART OR IN WHOLE MUST BE HANDLED IN 
-- ACCORDANCE WITH THE ACTEL LICENSE AGREEMENT AND MUST BE APPROVED 
-- IN ADVANCE IN WRITING.  
--  
-- File:  instructions.vhd
--     
-- Description: Simple APB Bus Controller
--              Top Level  
--
-- Rev: 2.3   01Mar07 IPB  : Production Release   
--
-- Notes:
--   TESTMODE is used to set what tests are used for verification tests
--   based on the core configuration.
--
-- *********************************************************************/ 

library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_arith.all;
use IEEE.std_logic_unsigned.all;

use work.support.all;


entity INSTRUCTIONS is
  generic ( AWIDTH   : integer range 1 to 16;  
            DWIDTH   : integer range 8 to 32;   
            SWIDTH   : integer range 0 to 4 ;    
            ICWIDTH  : integer range 1 to 16;  
            IIWIDTH  : integer range 1 to 32;
            IFWIDTH  : integer range 0 to 28;     
            IWWIDTH  : integer range 1 to 64;
            EN_MULT  : integer range 0 to 3;
            EN_INC   : integer range 0 to 1;
            ID       : integer range 0 to 9;
            TESTMODE : integer range 0 to 99
           );
  port     ( ADDRESS     : in  std_logic_vector(ICWIDTH-1 downto 0);
             INSTRUCTION : out std_logic_vector(IWWIDTH-1 downto 0)        
           );
end INSTRUCTIONS;


architecture RTL of INSTRUCTIONS is

constant AW : integer := AWIDTH;
constant DW : integer := DWIDTH;
constant SW : integer := max(SWIDTH,1);
constant IW : integer := ICWIDTH;

signal INS : std_logic_vector(IWWIDTH-1 downto 0);         

-- These allow the passing of IFWIDTH to the support package
constant  iJUMP    : integer := iJUMPB   + IFWIDTH;
constant  iCALL    : integer := iCALLB   + IFWIDTH;
constant  iRETURN  : integer := iRETURNB + IFWIDTH;
constant  iRETISR  : integer := iRETISRB + IFWIDTH;
constant  iWAIT    : integer := iWAITB   + IFWIDTH;
constant  iHALT    : integer := iHALTB   + IFWIDTH;
constant  iINC     : integer := iINCB    + 2*EN_MULT + 1 - EN_INC;

-- These constants used internally for CoreAI
constant  iACM_CTRLSTAT          : integer := 16#00#;
constant  iACM_ADDR_ADDR         : integer := 16#04#;
constant  iACM_DATA_ADDR         : integer := 16#08#;
constant  iADC_CTRL2_HI_ADDR     : integer := 16#10#;
constant  iADC_STAT_HI_ADDR      : integer := 16#20#;

-- CCDirective Insert constants
--Constants for ABCD_COREABC ID=0
constant Label_LOOP : integer := 4;
constant Label_VIIVE : integer := 6;
constant Label_VIIVE2 : integer := 10;
constant Label_VIIVE3 : integer := 14;
constant Label_VIIVE4 : integer := 18;
constant Label_VIIVE5 : integer := 22;
constant Label_VIIVE6 : integer := 26;
constant Label_VIIVE7 : integer := 30;
constant Label_VIIVE8 : integer := 34;
constant Label_LOPPU : integer := 38;


begin

-- These are the procedure calls to create the instruction sequence

PROM:
process(ADDRESS)
variable ADDRINT : integer range 0 to 2**ICWIDTH-1;
begin
   ADDRINT := conv_integer(ADDRESS);
   ---------------------------------------------------------------------------------------------
   case TESTMODE is 
     when 0 =>
      if ID=0 then
        case ADDRINT is 
          -- A MANUALLY CREATED USER INSTRUCTION SEQUENCE SHOULD BE INSERTED HERE
          when 0   =>    INS <= doins( iJUMP,0);        
          when others => INS <= ( others => '-');    -- default is dont cares, reduces tile counts
        end case;
      end if;

-- Automatically created code will be inserted by CC here
-- CCDirective Insert code
--Program for ABCD_COREABC ID=0
if ID=0 then
   case ADDRINT is
      --   ---- Start Of Example 2 ----
      --   Sample code that sends text to a UART
      when  0 => INS <= doins( iAPBWRT, iDAT8, 0, 8, 16#20#);
      when  1 => INS <= doins( iAPBWRT, iDAT8, 0, 12, 16#01#);
      when  2 => INS <= doins( iLOAD, iDAT, 1);
      when  3 => INS <= doins( iWAIT, iIFNOT, iINPUT0);
      -- $LOOP
      when  4 => INS <= doins( iJUMP, iIF, iZERO, Label_LOPPU);
      when  5 => INS <= doins( iLOADLOOP, iDAT, 20000);
      -- $VIIVE
      when  6 => INS <= doins( iDECLOOP);
      when  7 => INS <= doins( iJUMP, iIFNOT, iLOOPZ, Label_VIIVE);
      when  8 => INS <= doins( iAPBWRT, iDAT8, 0, 0, chartoint('T'));
      when  9 => INS <= doins( iLOADLOOP, iDAT, 20000);
      -- $VIIVE2
      when 10 => INS <= doins( iDECLOOP);
      when 11 => INS <= doins( iJUMP, iIFNOT, iLOOPZ, Label_VIIVE2);
      when 12 => INS <= doins( iAPBWRT, iDAT8, 0, 0, chartoint('O'));
      when 13 => INS <= doins( iLOADLOOP, iDAT, 20000);
      -- $VIIVE3
      when 14 => INS <= doins( iDECLOOP);
      when 15 => INS <= doins( iJUMP, iIFNOT, iLOOPZ, Label_VIIVE3);
      when 16 => INS <= doins( iAPBWRT, iDAT8, 0, 0, chartoint('I'));
      when 17 => INS <= doins( iLOADLOOP, iDAT, 20000);
      -- $VIIVE4
      when 18 => INS <= doins( iDECLOOP);
      when 19 => INS <= doins( iJUMP, iIFNOT, iLOOPZ, Label_VIIVE4);
      when 20 => INS <= doins( iAPBWRT, iDAT8, 0, 0, chartoint('M'));
      when 21 => INS <= doins( iLOADLOOP, iDAT, 20000);
      -- $VIIVE5
      when 22 => INS <= doins( iDECLOOP);
      when 23 => INS <= doins( iJUMP, iIFNOT, iLOOPZ, Label_VIIVE5);
      when 24 => INS <= doins( iAPBWRT, iDAT8, 0, 0, chartoint('I'));
      when 25 => INS <= doins( iLOADLOOP, iDAT, 20000);
      -- $VIIVE6
      when 26 => INS <= doins( iDECLOOP);
      when 27 => INS <= doins( iJUMP, iIFNOT, iLOOPZ, Label_VIIVE6);
      when 28 => INS <= doins( iAPBWRT, iDAT8, 0, 0, chartoint('I'));
      when 29 => INS <= doins( iLOADLOOP, iDAT, 20000);
      -- $VIIVE7
      when 30 => INS <= doins( iDECLOOP);
      when 31 => INS <= doins( iJUMP, iIFNOT, iLOOPZ, Label_VIIVE7);
      when 32 => INS <= doins( iAPBWRT, iDAT8, 0, 0, chartoint('!'));
      when 33 => INS <= doins( iLOADLOOP, iDAT, 20000);
      -- $VIIVE8
      when 34 => INS <= doins( iDECLOOP);
      when 35 => INS <= doins( iJUMP, iIFNOT, iLOOPZ, Label_VIIVE8);
      when 36 => INS <= doins( iDEC);
      when 37 => INS <= doins( iJUMP, Label_LOOP);
      -- $LOPPU
      when 38 => INS <= doins( iHALT);
      --   ---- End Of Example 2 ----
      when others => INS <= ( others => '-');
   end case;

end if;


   ---------------------------------------------------------------------------------------------
   -- 8-Bit operation simple core
   when 1 =>
      case ADDRINT is 
        -- Jump to test start point 
        when 0   => INS <= doins( iJUMP,1);
        -- Simple Test of Boolean Operations
        when 1   => INS <= doins( iLOAD,16#55#);               -- Set Accumalator to 55hex
        when 2   => INS <= doins( iAND,16#0F#);                -- Do some maths and jump to error if one occurs
        when 3   => INS <= doins( iCMP,16#05#);
        when 4   => INS <= doins( iJUMP,iNOTIF,ZERO,30);
        
        -- APB Bus Cycles, immediate data
        when 5  => INS <= doins( iLOAD,16#12#);
        when 6  => INS <= doins( iAPBWRT, iDAT, 0,16#10#,16#12#);
        when 7  => INS <= doins( iAPBREAD, 0,16#10#);
        when 8  => INS <= doins( iCMP,16#12#);
        when 9  => INS <= doins( iJUMP,iNOTIF,ZERO,30);
        -- Accumalator writes
        when 10 => INS <= doins( iLOAD,16#23#);
        when 11 => INS <= doins( iAPBWRT, iACC,  0,16#20#);
        when 12 => INS <= doins( iAPBREAD, 0,16#20#);
        when 13 => INS <= doins( iCMP,16#23#);
        when 14 => INS <= doins( iJUMP,iNOTIF,ZERO,30);
    
        -- Flag Conditions                                 
        when 15 => INS <= doins( iLOAD,255);                       -- set zero flag
        when 16 => INS <= doins( iINC, 1);
        when 17 => INS <= doins( iJUMP,iNOTIF,ZERO,30);
        when 18 => INS <= doins( iINC, 1);                         -- not set
        when 19 => INS <= doins( iCALL,iIF,ZERO,30);
        when 20 => INS <= doins( iCALL,iIF,NEGATIVE,30);           -- number is positive
                
        -- Big negative value
		when 23 => INS <= doins( iLOAD,0);                              -- Try loading big negative values
        when 24 => INS <= doins( iXOR, -1);
        when 25 => INS <= doins( iINC );                              -- not set
        when 26 => INS <= doins( iJUMP,iNOTIF,ZERO,30);
  
        -- Done tests, jump to signal all done
        when 27 => INS <= doins( iJUMP, 28);
        ------------------------------------------------------------------------------------
        -- All tests complete                                                        
        when 28 => INS <= doins( iIOWRT, iDAT, 253);
        when 29 => INS <= doins( iJUMP, 29);
        
        -- Error Condition
        when 30 => INS <= doins( iIOWRT, iDAT, 254);                  -- Error Condition
        when 31 => INS <= doins( iJUMP, 31);
        
        when others => INS <= doins( iNOP);
     end case;
   
   ---------------------------------------------------------------------------------------------
   -- 16-Bit operation simple core
   when 2 =>
      case ADDRINT is 
        -- Jump to test start point 
        when 0   => INS <= doins( iJUMP,1);
        -- Simple Test of Boolean Operations
        when 1   => INS <= doins( iLOAD,16#1255#);               -- Set Accumalator to 55hex
        when 2   => INS <= doins( iAND,16#0F0F#);                -- Do some maths and jump to error if one occurs
        when 3   => INS <= doins( iCMP,16#0205#);
        when 4   => INS <= doins( iJUMP,iNOTIF,ZERO,30);
        
        -- APB Bus Cycles, immediate data

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?