--------------------------------------------------------------------------------------------------------------- -- RISA Project -- Author: A.Greensted -- Module: SnapPkg -- Description: Snap Package -- History: --------------------------------------------------------------------------------------------------------------- library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all; library CommonLib; use CommonLib.CommonPkg.all; package SnapPkg is ----------------------------------------------------------------------------------------- -- Types / Constants ----------------------------------------------------------------------------------------- type SNAPTYPE_CPU_CYCLE is ( SNAP_CYCLE_0, SNAP_CYCLE_1); type SNAPTYPE_INSN_TYPE is ( SNAP_TYPE_0, SNAP_TYPE_1); constant SNAP_REG_INSN : SNAPTYPE_INSN_TYPE := SNAP_TYPE_0; constant SNAP_LIT_INSN : SNAPTYPE_INSN_TYPE := SNAP_TYPE_1; type SNAPTYPE_OPCODE is ( SNAP_OP_ADD, -- 0 SNAP_OP_ADDC, -- 1 SNAP_OP_SUB, -- 2 SNAP_OP_SUBC, -- 3 SNAP_OP_NEG, -- 4 SNAP_OP_AND, -- 5 SNAP_OP_OR, -- 6 SNAP_OP_XOR, -- 7 SNAP_OP_ROL, -- 8 SNAP_OP_ROR, -- 9 SNAP_OP_BS, -- 10 SNAP_OP_BC, -- 11 SNAP_OP_MOV, -- 12 SNAP_OP_LD, -- 13 SNAP_OP_ST, -- 14 SNAP_OP_SPECIAL); -- 15 type SNAPTYPE_SUB_OPCODE is ( SNAP_SUBOP_BRA, -- 0 SNAP_SUBOP_RETI, -- 1 SNAP_SUBOP_FSET, -- 2 SNAP_SUBOP_CSET); -- 3 subtype SNAPTYPE_REG_NUM is integer range 0 to 127; type SNAPTYPE_CONDITION_CODE is ( SNAP_CC_ZERO, -- 0 SNAP_CC_NOT_ZERO, -- 1 SNAP_CC_CARRYBORROW, -- 2 SNAP_CC_NOT_CARRYBORROW, -- 3 SNAP_CC_NEGATIVE, -- 4 SNAP_CC_NOT_NEGATIVE, -- 5 SNAP_CC_OVERFLOW, -- 6 SNAP_CC_NOT_OVERFLOW, -- 7 SNAP_CC_EQT0, -- 8 SNAP_CC_NOT_EQT0, -- 9 SNAP_CC_EQT1, -- 10 SNAP_CC_NOT_EQT1, -- 11 SNAP_CC_EQT2, -- 12 SNAP_CC_NOT_EQT2, -- 13 SNAP_CC_GIE, -- 14 SNAP_CC_NOT_GIE, -- 15 SNAP_CC_EF0, -- 16 SNAP_CC_NOT_EF0, -- 17 SNAP_CC_EF1, -- 18 SNAP_CC_NOT_EF1, -- 19 SNAP_CC_EF2, -- 20 SNAP_CC_NOT_EF2, -- 21 SNAP_CC_EF3, -- 22 SNAP_CC_NOT_EF3, -- 23 SNAP_CC_EF4, -- 24 SNAP_CC_NOT_EF4, -- 25 SNAP_CC_EF5, -- 26 SNAP_CC_NOT_EF5, -- 27 SNAP_CC_EF6, -- 28 SNAP_CC_NOT_EF6, -- 29 SNAP_CC_EF7, -- 30 SNAP_CC_NOT_EF7); -- 31 -- Flag Types type SNAPTYPE_ALU_FLAGS is record zero : std_logic; negative : std_logic; carryBorrow : std_logic; overflow : std_logic; end record SNAPTYPE_ALU_FLAGS; type SNAPTYPE_INTERNAL_FLAGS is record aluFlags : SNAPTYPE_ALU_FLAGS; equalityTests : std_logic_vector(2 downto 0); globalInterruptEn : std_logic; end record SNAPTYPE_INTERNAL_FLAGS; type SNAPTYPE_EXTERNAL_FLAGS is record flags : std_logic_vector(7 downto 0); end record SNAPTYPE_EXTERNAL_FLAGS; type SNAPTYPE_FLAGS is record intFlags : SNAPTYPE_INTERNAL_FLAGS; extFlags : SNAPTYPE_EXTERNAL_FLAGS; end record SNAPTYPE_FLAGS; constant SNAP_FLAGS_RESET : SNAPTYPE_FLAGS := (intFlags => (aluFlags => (zero=>'0', negative=>'0', carryBorrow=>'0', overflow=>'0'), equalityTests => b"000", globalInterruptEn => '0'), extFlags => (flags => b"0000_0000") ); constant SNAP_INTERNAL_FLAGS_RESET : SNAPTYPE_INTERNAL_FLAGS := (aluFlags => (zero=>'0', negative=>'0', carryBorrow=>'0', overflow=>'0'), equalityTests => b"000", globalInterruptEn => '0'); subtype SNAPTYPE_MEM_ADD is std_logic_vector(12 downto 0); constant SNAP_ISR_ADD : SNAPTYPE_MEM_ADD := b"0_0000_0000_0110"; -- 0x0006 -- System UART type SNAPTYPE_SYSUART_DATABITS is ( SNAP_SYSUART_5DATABITS, SNAP_SYSUART_6DATABITS, SNAP_SYSUART_7DATABITS, SNAP_SYSUART_8DATABITS, SNAP_SYSUART_9DATABITS, SNAP_SYSUART_10DATABITS); type SNAPTYPE_SYSUART_PARITY is ( SNAP_SYSUART_EVEN_PARITY, SNAP_SYSUART_ODD_PARITY, SNAP_SYSUART_NO_PARITY); type SNAPTYPE_SYSUART_STOPBITS is ( SNAP_SYSUART_1STOPBITS, SNAP_SYSUART_2STOPBITS); -- System UART type SNAPTYPE_SNAPLINK_DATABITS is ( SNAP_SNAPLINK_16DATABITS, SNAP_SNAPLINK_17DATABITS, SNAP_SNAPLINK_18DATABITS); ----------------------------------------------------------------------------------------- -- Type Conversion Functions ----------------------------------------------------------------------------------------- function to_SNAPTYPE_INSN_TYPE( value : std_logic ) return SNAPTYPE_INSN_TYPE; function to_std_logic( value : SNAPTYPE_INSN_TYPE ) return std_logic; function to_SNAPTYPE_OPCODE( value : std_logic_vector(3 downto 0) ) return SNAPTYPE_OPCODE; function to_std_logic_vector( value : SNAPTYPE_OPCODE ) return std_logic_vector; function to_SNAPTYPE_SUB_OPCODE( value : std_logic_vector(1 downto 0) ) return SNAPTYPE_SUB_OPCODE; function to_std_logic_vector( value : SNAPTYPE_SUB_OPCODE ) return std_logic_vector; function to_SNAPTYPE_CONDITION_CODE( value : std_logic_vector(4 downto 0) ) return SNAPTYPE_CONDITION_CODE; function to_std_logic_vector( value : SNAPTYPE_CONDITION_CODE ) return std_logic_vector; function to_std_logic_vector( value : SNAPTYPE_REG_NUM ) return std_logic_vector; ----------------------------------------------------------------------------------------- -- Functions ----------------------------------------------------------------------------------------- function isConditionSatisfied( conditionCode : SNAPTYPE_CONDITION_CODE; flags : SNAPTYPE_FLAGS ) return boolean; function isForwardableRegister( reg : std_logic_vector(6 downto 0) ) return boolean; function isWriteBackInsn( opCode : SNAPTYPE_OPCODE; subOpCode : SNAPTYPE_SUB_OPCODE ) return boolean; -- SystemUART Functions function to_SNAPTYPE_SYSUART_DATABITS( value : std_logic_vector(2 downto 0) ) return SNAPTYPE_SYSUART_DATABITS; function to_std_logic_vector( value : SNAPTYPE_SYSUART_DATABITS ) return std_logic_vector; function to_SNAPTYPE_SYSUART_PARITY( value : std_logic_vector(1 downto 0) ) return SNAPTYPE_SYSUART_PARITY; function to_std_logic_vector( value : SNAPTYPE_SYSUART_PARITY ) return std_logic_vector; function to_SNAPTYPE_SYSUART_STOPBITS( value : std_logic ) return SNAPTYPE_SYSUART_STOPBITS; function to_std_logic( value : SNAPTYPE_SYSUART_STOPBITS ) return std_logic; -- SnapLink Functions function to_SNAPTYPE_SNAPLINK_DATABITS( value : std_logic_vector(1 downto 0) ) return SNAPTYPE_SNAPLINK_DATABITS; function to_std_logic_vector( value : SNAPTYPE_SNAPLINK_DATABITS ) return std_logic_vector; ----------------------------------------------------------------------------------------- -- RegFile 0-31: Working Registers ----------------------------------------------------------------------------------------- -- Working Registers constant SNAP_REG_R00 : SNAPTYPE_REG_NUM := 0; constant SNAP_REG_R01 : SNAPTYPE_REG_NUM := 1; constant SNAP_REG_R02 : SNAPTYPE_REG_NUM := 2; constant SNAP_REG_R03 : SNAPTYPE_REG_NUM := 3; constant SNAP_REG_R04 : SNAPTYPE_REG_NUM := 4; constant SNAP_REG_R05 : SNAPTYPE_REG_NUM := 5; constant SNAP_REG_R06 : SNAPTYPE_REG_NUM := 6; constant SNAP_REG_R07 : SNAPTYPE_REG_NUM := 7; constant SNAP_REG_R08 : SNAPTYPE_REG_NUM := 8; constant SNAP_REG_R09 : SNAPTYPE_REG_NUM := 9; constant SNAP_REG_R10 : SNAPTYPE_REG_NUM := 10; constant SNAP_REG_R11 : SNAPTYPE_REG_NUM := 11; constant SNAP_REG_R12 : SNAPTYPE_REG_NUM := 12; constant SNAP_REG_R13 : SNAPTYPE_REG_NUM := 13; constant SNAP_REG_R14 : SNAPTYPE_REG_NUM := 14; constant SNAP_REG_R15 : SNAPTYPE_REG_NUM := 15; constant SNAP_REG_R16 : SNAPTYPE_REG_NUM := 16; constant SNAP_REG_R17 : SNAPTYPE_REG_NUM := 17; constant SNAP_REG_R18 : SNAPTYPE_REG_NUM := 18; constant SNAP_REG_R19 : SNAPTYPE_REG_NUM := 19; constant SNAP_REG_R20 : SNAPTYPE_REG_NUM := 20; constant SNAP_REG_R21 : SNAPTYPE_REG_NUM := 21; constant SNAP_REG_R22 : SNAPTYPE_REG_NUM := 22; constant SNAP_REG_R23 : SNAPTYPE_REG_NUM := 23; constant SNAP_REG_R24 : SNAPTYPE_REG_NUM := 24; constant SNAP_REG_R25 : SNAPTYPE_REG_NUM := 25; constant SNAP_REG_R26 : SNAPTYPE_REG_NUM := 26; constant SNAP_REG_R27 : SNAPTYPE_REG_NUM := 27; constant SNAP_REG_R28 : SNAPTYPE_REG_NUM := 28; constant SNAP_REG_R29 : SNAPTYPE_REG_NUM := 29; constant SNAP_REG_R30 : SNAPTYPE_REG_NUM := 30; constant SNAP_REG_R31 : SNAPTYPE_REG_NUM := 31; ----------------------------------------------------------------------------------------- -- RegFile 32-63: System ----------------------------------------------------------------------------------------- -- Program Counter constant SNAP_REG_PC_PC : SNAPTYPE_REG_NUM := 32; constant SNAP_REG_PC_BRA_PC : SNAPTYPE_REG_NUM := 33; constant SNAP_REG_PC_ISR_PC : SNAPTYPE_REG_NUM := 34; -- Flags Regsiters constant SNAP_REG_FREG_FLAGS0 : SNAPTYPE_REG_NUM := 35; constant SNAP_REG_FREG_FLAGS1 : SNAPTYPE_REG_NUM := 36; -- Interrupt Controller constant SNAP_REG_INTC_FLAGS_0 : SNAPTYPE_REG_NUM := 37; constant SNAP_REG_INTC_FLAGS_1 : SNAPTYPE_REG_NUM := 38; constant SNAP_REG_INTC_ENABLE_0 : SNAPTYPE_REG_NUM := 39; constant SNAP_REG_INTC_ENABLE_1 : SNAPTYPE_REG_NUM := 40; constant SNAP_REG_INTC_CLEAR_0 : SNAPTYPE_REG_NUM := 41; constant SNAP_REG_INTC_CLEAR_1 : SNAPTYPE_REG_NUM := 42; constant SNAP_REG_INTC_SET_0 : SNAPTYPE_REG_NUM := 43; constant SNAP_REG_INTC_SET_1 : SNAPTYPE_REG_NUM := 44; ----------------------------------------------------------------------------------------- -- RegFile 64-95: Functions ----------------------------------------------------------------------------------------- -- SnaplLink constant SNAP_REG_SLINK_N_CTRL : SNAPTYPE_REG_NUM := 64; constant SNAP_REG_SLINK_N_DATA : SNAPTYPE_REG_NUM := 65; constant SNAP_REG_SLINK_E_CTRL : SNAPTYPE_REG_NUM := 66; constant SNAP_REG_SLINK_E_DATA : SNAPTYPE_REG_NUM := 67; constant SNAP_REG_SLINK_S_CTRL : SNAPTYPE_REG_NUM := 68; constant SNAP_REG_SLINK_S_DATA : SNAPTYPE_REG_NUM := 69; constant SNAP_REG_SLINK_W_CTRL : SNAPTYPE_REG_NUM := 70; constant SNAP_REG_SLINK_W_DATA : SNAPTYPE_REG_NUM := 71; -- Counters constant SNAP_REG_CNT_0_CTRL : SNAPTYPE_REG_NUM := 72; constant SNAP_REG_CNT_0_COUNTER : SNAPTYPE_REG_NUM := 73; constant SNAP_REG_CNT_0_COMP0 : SNAPTYPE_REG_NUM := 74; constant SNAP_REG_CNT_0_COMP1 : SNAPTYPE_REG_NUM := 75; constant SNAP_REG_CNT_1_CTRL : SNAPTYPE_REG_NUM := 76; constant SNAP_REG_CNT_1_COUNTER : SNAPTYPE_REG_NUM := 77; constant SNAP_REG_CNT_1_COMP0 : SNAPTYPE_REG_NUM := 78; constant SNAP_REG_CNT_1_COMP1 : SNAPTYPE_REG_NUM := 79; -- WatchDogTimer constant SNAP_REG_WDT_CTRL : SNAPTYPE_REG_NUM := 80; constant SNAP_REG_WDT_TIMER : SNAPTYPE_REG_NUM := 81; -- System UART constant SNAP_REG_SUART_CTRL : SNAPTYPE_REG_NUM := 82; constant SNAP_REG_SUART_BAUD : SNAPTYPE_REG_NUM := 83; constant SNAP_REG_SUART_DATA : SNAPTYPE_REG_NUM := 84; -- Random Number Generator constant SNAP_REG_RNG_DATA : SNAPTYPE_REG_NUM := 85; -- IO Ports constant SNAP_REG_IOP_N_DATA : SNAPTYPE_REG_NUM := 86; constant SNAP_REG_IOP_N_OUTEN : SNAPTYPE_REG_NUM := 87; constant SNAP_REG_IOP_E_DATA : SNAPTYPE_REG_NUM := 88; constant SNAP_REG_IOP_E_OUTEN : SNAPTYPE_REG_NUM := 89; constant SNAP_REG_IOP_W_DATA : SNAPTYPE_REG_NUM := 90; constant SNAP_REG_IOP_W_OUTEN : SNAPTYPE_REG_NUM := 91; ----------------------------------------------------------------------------------------- -- RegFile 96-127: FPGA Interfacing ----------------------------------------------------------------------------------------- -- Fabric IO Ports constant SNAP_REG_FABIO_N_DATA : SNAPTYPE_REG_NUM := 96; constant SNAP_REG_FABIO_S_DATA : SNAPTYPE_REG_NUM := 97; constant SNAP_REG_FABIO_E_DATA : SNAPTYPE_REG_NUM := 98; constant SNAP_REG_FABIO_W_DATA : SNAPTYPE_REG_NUM := 99; -- Fabric CAP constant SNAP_REG_CAP_L_CTRL : SNAPTYPE_REG_NUM := 100; constant SNAP_REG_CAP_L_DATA : SNAPTYPE_REG_NUM := 101; constant SNAP_REG_CAP_R_CTRL : SNAPTYPE_REG_NUM := 102; constant SNAP_REG_CAP_R_DATA : SNAPTYPE_REG_NUM := 103; ----------------------------------------------------------------------------------------- -- Components ----------------------------------------------------------------------------------------- component WorkingRegisters is port ( clk : in std_logic; enable : in std_logic; portADIn : in std_logic_vector(15 downto 0); portAWEn : in std_logic; portAAdd : in std_logic_vector(4 downto 0); portBAdd : in std_logic_vector(4 downto 0); portADOut : out std_logic_vector(15 downto 0); portBDOut : out std_logic_vector(15 downto 0)); end component; component ProgramCounter is port ( clk : in std_logic; enable : in std_logic; nReset : in std_logic; dIn : in std_logic_vector(SNAPTYPE_MEM_ADD'range); isrBranchEn : in std_logic; pcWEn : in std_logic; pcOut : out SNAPTYPE_MEM_ADD; activePC : in SNAPTYPE_MEM_ADD; braPCWEn : in std_logic; braPCOut : out SNAPTYPE_MEM_ADD; isrPCWEn : in std_logic; isrPCOut : out SNAPTYPE_MEM_ADD); end component; component FlagsRegisters is port ( clk : in std_logic; enable : in std_logic; nReset : in std_logic; dIn : in std_logic_vector(12 downto 0); flagReg0WEn : in std_logic; flagReg0Out : out std_logic_vector(15 downto 0); flagReg1WEn : in std_logic; flagReg1Out : out std_logic_vector(15 downto 0); extFlagsIn : in SNAPTYPE_EXTERNAL_FLAGS; aluFlagsWEn : in std_logic; aluFlagsIn : in SNAPTYPE_ALU_FLAGS; conditionCodeWEn : in std_logic; conditionCodeIn : in SNAPTYPE_CONDITION_CODE; intFlagsWEn : in std_logic; intFlagsIn : in std_logic_vector(7 downto 0); intFlagsMaskIn : in std_logic_vector(7 downto 0); setGIEEn : in std_logic; clrGIEEn : in std_logic; flagsOut : out SNAPTYPE_FLAGS; conditionCodeOut : out SNAPTYPE_CONDITION_CODE); end component; component InterruptController is port ( clk : in std_logic; enable : in std_logic; nReset : in std_logic; dIn : in std_logic_vector(15 downto 0); flagsReg0WEn : in std_logic; flagsReg0Out : out std_logic_vector(15 downto 0); flagsReg1WEn : in std_logic; flagsReg1Out : out std_logic_vector(15 downto 0); enableReg0WEn : in std_logic; enableReg0Out : out std_logic_vector(15 downto 0); enableReg1WEn : in std_logic; enableReg1Out : out std_logic_vector(15 downto 0); intClr0WEn : in std_logic; intClr1WEn : in std_logic; intSet0WEn : in std_logic; intSet1WEn : in std_logic; interruptsIn : in std_logic_vector(31 downto 0); interruptRequest : out std_logic); end component; component SnapLink is port ( clk : in std_logic; enable : in std_logic; nReset : in std_logic; dIn : in std_logic_vector(15 downto 0); controlRegWEn : in std_logic; controlRegOut : out std_logic_vector(15 downto 0); dataRegWEn : in std_logic; dataRegREn : in std_logic; dataRegOut : out std_logic_vector(15 downto 0); newDataIF : out std_logic; rxFifoFullIF : out std_logic; txFreeIF : out std_logic; linkTxOut : out std_logic; linkRxIn : in std_logic; linkCTSOut : out std_logic; linkCTSIn : in std_logic); end component; component SnapLinkTx is port ( clk : in std_logic; enable : in std_logic; nReset : in std_logic; sampleEn : in std_logic; txReset : in std_logic; dataBits : in SNAPTYPE_SNAPLINK_DATABITS; sendData : in std_logic; txData : in std_logic_vector(17 downto 0); txBusy : out std_logic; serialTxOut : out std_logic); end component; component SnapLinkRx is port ( clk : in std_logic; enable : in std_logic; nReset : in std_logic; sampleEn : in std_logic; rxReset : in std_logic; dataBits : in SNAPTYPE_SNAPLINK_DATABITS; newData : out std_logic; parityError : out std_logic; rxData : out std_logic_vector(17 downto 0); serialRxIn : in std_logic); end component; component Counter is port ( clk : in std_logic; enable : in std_logic; nReset : in std_logic; dIn : in std_logic_vector(15 downto 0); controlRegWEn : in std_logic; controlRegOut : out std_logic_vector(15 downto 0); counterWEn : in std_logic; counterOut : out std_logic_vector(15 downto 0); compareReg0WEn : in std_logic; compareReg0Out : out std_logic_vector(15 downto 0); compareReg1WEn : in std_logic; compareReg1Out : out std_logic_vector(15 downto 0); extCountEn : in std_logic; overflowIF : out std_logic; match0IF : out std_logic; match1IF : out std_logic; match0Out : out std_logic; match1Out : out std_logic); end component; component WatchDogTimer is port ( clk : in std_logic; enable : in std_logic; nReset : in std_logic; dIn : in std_logic_vector(15 downto 0); controlRegWEn : in std_logic; controlRegOut : out std_logic_vector(15 downto 0); timerWEn : in std_logic; timerOut : out std_logic_vector(15 downto 0); timeoutIF : out std_logic); end component; component SystemUART is port ( clk : in std_logic; enable : in std_logic; nReset : in std_logic; dIn : in std_logic_vector(15 downto 0); controlRegWEn : in std_logic; controlRegOut : out std_logic_vector(15 downto 0); dataRegWEn : in std_logic; dataRegREn : in std_logic; dataRegOut : out std_logic_vector(15 downto 0); baudRegWEn : in std_logic; baudRegOut : out std_logic_vector(15 downto 0); newDataIF : out std_logic; rxFifoFullIF : out std_logic; txFreeIF : out std_logic; serialTxOut : out std_logic; serialRxIn : in std_logic); end component; component SystemUARTTx is port ( clk : in std_logic; enable : in std_logic; nReset : in std_logic; sampleEn : in std_logic; txReset : in std_logic; dataBits : in SNAPTYPE_SYSUART_DATABITS; parity : in SNAPTYPE_SYSUART_PARITY; stopBits : in SNAPTYPE_SYSUART_STOPBITS; sendData : in std_logic; txData : in std_logic_vector(9 downto 0); txBusy : out std_logic; serialTxOut : out std_logic); end component; component SystemUARTRx is port ( clk : in std_logic; enable : in std_logic; nReset : in std_logic; sampleEn : in std_logic; rxReset : in std_logic; dataBits : in SNAPTYPE_SYSUART_DATABITS; parity : in SNAPTYPE_SYSUART_PARITY; newData : out std_logic; parityError : out std_logic; rxData : out std_logic_vector(9 downto 0); serialRxIn : in std_logic); end component; component IOPort is port ( clk : in std_logic; enable : in std_logic; nReset : in std_logic; dIn : in std_logic_vector(7 downto 0); dataRegWEn : in std_logic; -- Data write to port dataRegOut : out std_logic_vector(7 downto 0); -- Data read from port dataOutEnWEn : in std_logic; dataOutEnOut : out std_logic_vector(7 downto 0); ioPortDIn : in std_logic_vector(7 downto 0); ioPortOutEn : out std_logic_vector(7 downto 0); ioPortDOut : out std_logic_vector(7 downto 0)); end component; component FabricIOPort is port ( clk : in std_logic; enable : in std_logic; nReset : in std_logic; dIn : in std_logic_vector(5 downto 0); dataRegWEn : in std_logic; -- Data write to fabric dataRegOut : out std_logic_vector(5 downto 0); -- Data read from fabric ioPortDIn : in std_logic_vector(5 downto 0); -- Data from fabric ioPortDOut : out std_logic_vector(5 downto 0)); -- Data to fabric end component; component FabricCAP is port ( clk : in std_logic; enable : in std_logic; nReset : in std_logic; dIn : in std_logic_vector(15 downto 0); controlRegWEn : in std_logic; controlRegOut : out std_logic_vector(15 downto 0); dataRegWEn : in std_logic; dataRegOut : out std_logic_vector(15 downto 0); cnfChainLockRequest : out std_logic; cnfChainLock : in std_logic; cnfChainShiftEn : out std_logic; cnfChainLoadEn : out std_logic; cnfChainReadBackEn : out std_logic; cnfChainOut : out std_logic; cnfChainIn : in std_logic; selChainLockRequest : out std_logic; selChainLock : in std_logic; selChainShiftEn : out std_logic; selChainFeedbackEn : out std_logic; selChainOut : out std_logic; selChainIn : in std_logic); end component; component RegisterFile is port ( clk : in std_logic; enable : in std_logic; nReset : in std_logic; portAWEn : in std_logic; portBREn : in std_logic; portAAdd : in std_logic_vector(6 downto 0); portBAdd : in std_logic_vector(6 downto 0); portADIn : in std_logic_vector(15 downto 0); portADOut : out std_logic_vector(15 downto 0); portBDOut : out std_logic_vector(15 downto 0); -- Program Counter pc_pcOut : out SNAPTYPE_MEM_ADD; pc_isrBranchEn : in std_logic; pc_activePC : in SNAPTYPE_MEM_ADD; pc_braPCWEn : in std_logic; pc_isrPCWEn : in std_logic; -- Flags Registers fReg_extFlagsIn : in SNAPTYPE_EXTERNAL_FLAGS; fReg_aluFlagsWEn : in std_logic; fReg_aluFlagsIn : in SNAPTYPE_ALU_FLAGS; fReg_conditionCodeWEn : in std_logic; fReg_conditionCodeIn : in SNAPTYPE_CONDITION_CODE; fReg_intFlagsWEn : in std_logic; fReg_intFlagsIn : in std_logic_vector(7 downto 0); fReg_intFlagsMaskIn : in std_logic_vector(7 downto 0); fReg_setGIEEn : in std_logic; fReg_clrGIEEn : in std_logic; fReg_flagsOut : out SNAPTYPE_FLAGS; fReg_conditionCodeOut : out SNAPTYPE_CONDITION_CODE; -- Interrupt Controller intC_extIRQsIn : in std_logic_vector(7 downto 0); intC_interruptRequest : out std_logic; -- Snap Links sLnk_N_linkTxOut : out std_logic; sLnk_N_linkRxIn : in std_logic; sLnk_N_linkCTSOut : out std_logic; sLnk_N_linkCTSIn : in std_logic; sLnk_E_linkTxOut : out std_logic; sLnk_E_linkRxIn : in std_logic; sLnk_E_linkCTSOut : out std_logic; sLnk_E_linkCTSIn : in std_logic; sLnk_S_linkTxOut : out std_logic; sLnk_S_linkRxIn : in std_logic; sLnk_S_linkCTSOut : out std_logic; sLnk_S_linkCTSIn : in std_logic; sLnk_W_linkTxOut : out std_logic; sLnk_W_linkRxIn : in std_logic; sLnk_W_linkCTSOut : out std_logic; sLnk_W_linkCTSIn : in std_logic; -- Counter 0 cnt_0_extCountEn : in std_logic; cnt_0_match0Out : out std_logic; cnt_0_match1Out : out std_logic; -- Counter 1 cnt_1_extCountEn : in std_logic; cnt_1_match0Out : out std_logic; cnt_1_match1Out : out std_logic; -- System UART sUART_serialTxOut : out std_logic; sUART_serialRxIn : in std_logic; -- Randon Number Generator rng_randomDataIn : in std_logic_vector(15 downto 0); -- IO Ports ioP_N_dIn : in std_logic_vector(7 downto 0); ioP_N_outEn : out std_logic_vector(7 downto 0); ioP_N_dOut : out std_logic_vector(7 downto 0); ioP_E_dIn : in std_logic_vector(7 downto 0); ioP_E_outEn : out std_logic_vector(7 downto 0); ioP_E_dOut : out std_logic_vector(7 downto 0); ioP_W_dIn : in std_logic_vector(7 downto 0); ioP_W_outEn : out std_logic_vector(7 downto 0); ioP_W_dOut : out std_logic_vector(7 downto 0); -- Fabric Ports fabIO_N_dIn : in std_logic_vector(5 downto 0); fabIO_N_dOut : out std_logic_vector(5 downto 0); fabIO_S_dIn : in std_logic_vector(5 downto 0); fabIO_S_dOut : out std_logic_vector(5 downto 0); fabIO_E_dIn : in std_logic_vector(5 downto 0); fabIO_E_dOut : out std_logic_vector(5 downto 0); fabIO_W_dIn : in std_logic_vector(5 downto 0); fabIO_W_dOut : out std_logic_vector(5 downto 0); -- Fabric CAP Logic cap_L_cnfChainLockRequest : out std_logic; cap_L_cnfChainLock : in std_logic; cap_L_cnfChainShiftEn : out std_logic; cap_L_cnfChainLoadEn : out std_logic; cap_L_cnfChainReadBackEn : out std_logic; cap_L_cnfChainOut : out std_logic; cap_L_cnfChainIn : in std_logic; cap_L_selChainLockRequest : out std_logic; cap_L_selChainLock : in std_logic; cap_L_selChainShiftEn : out std_logic; cap_L_selChainFeedbackEn : out std_logic; cap_L_selChainOut : out std_logic; cap_L_selChainIn : in std_logic; -- Fabric CAP Route cap_R_cnfChainLockRequest : out std_logic; cap_R_cnfChainLock : in std_logic; cap_R_cnfChainShiftEn : out std_logic; cap_R_cnfChainLoadEn : out std_logic; cap_R_cnfChainReadBackEn : out std_logic; cap_R_cnfChainOut : out std_logic; cap_R_cnfChainIn : in std_logic; cap_R_selChainLockRequest : out std_logic; cap_R_selChainLock : in std_logic; cap_R_selChainShiftEn : out std_logic; cap_R_selChainFeedbackEn : out std_logic; cap_R_selChainOut : out std_logic; cap_R_selChainIn : in std_logic); end component; component ALU is port ( opCode : in SNAPTYPE_OPCODE; opA : in std_logic_vector(15 downto 0); opB : in std_logic_vector(15 downto 0); carryBorrowIn : in std_logic; overflowIn : in std_logic; flags : out SNAPTYPE_ALU_FLAGS; dOut : out std_logic_vector(15 downto 0)); end component; component Snap is port ( clk : in std_logic; enable : in std_logic; nReset : in std_logic; -- Memory Interface mem_wEn : out std_logic; mem_add : out std_logic_vector(12 downto 0); mem_dIn : out std_logic_vector(15 downto 0); mem_dOutLU : in std_logic_vector(15 downto 0); mem_dOutU : in std_logic_vector(15 downto 0); -- Flags Registers extFlagsIn : in std_logic_vector(7 downto 0); -- Interrupt Controller extIRQsIn : in std_logic_vector(7 downto 0); -- Snap Links sLnk_N_txOut : out std_logic; sLnk_N_rxIn : in std_logic; sLnk_N_CTSOut : out std_logic; sLnk_N_CTSIn : in std_logic; sLnk_E_txOut : out std_logic; sLnk_E_rxIn : in std_logic; sLnk_E_CTSOut : out std_logic; sLnk_E_CTSIn : in std_logic; sLnk_S_txOut : out std_logic; sLnk_S_rxIn : in std_logic; sLnk_S_CTSOut : out std_logic; sLnk_S_CTSIn : in std_logic; sLnk_W_txOut : out std_logic; sLnk_W_rxIn : in std_logic; sLnk_W_CTSOut : out std_logic; sLnk_W_CTSIn : in std_logic; -- Counter 0 cnt_0_extCountEn : in std_logic; cnt_0_match0Out : out std_logic; cnt_0_match1Out : out std_logic; -- Counter 1 cnt_1_extCountEn : in std_logic; cnt_1_match0Out : out std_logic; cnt_1_match1Out : out std_logic; -- System UART sysUART_txOut : out std_logic; sysUART_rxIn : in std_logic; -- Randon Number Generator rngDIn : in std_logic_vector(15 downto 0); -- IO Ports ioP_N_dIn : in std_logic_vector(7 downto 0); ioP_N_outEn : out std_logic_vector(7 downto 0); ioP_N_dOut : out std_logic_vector(7 downto 0); ioP_E_dIn : in std_logic_vector(7 downto 0); ioP_E_outEn : out std_logic_vector(7 downto 0); ioP_E_dOut : out std_logic_vector(7 downto 0); ioP_W_dIn : in std_logic_vector(7 downto 0); ioP_W_outEn : out std_logic_vector(7 downto 0); ioP_W_dOut : out std_logic_vector(7 downto 0); -- Fabric Ports fabIO_N_dIn : in std_logic_vector(5 downto 0); fabIO_N_dOut : out std_logic_vector(5 downto 0); fabIO_S_dIn : in std_logic_vector(5 downto 0); fabIO_S_dOut : out std_logic_vector(5 downto 0); fabIO_E_dIn : in std_logic_vector(5 downto 0); fabIO_E_dOut : out std_logic_vector(5 downto 0); fabIO_W_dIn : in std_logic_vector(5 downto 0); fabIO_W_dOut : out std_logic_vector(5 downto 0); -- Fabric CAP Logic cap_L_cnfChainLockRequest : out std_logic; cap_L_cnfChainLock : in std_logic; cap_L_cnfChainShiftEn : out std_logic; cap_L_cnfChainLoadEn : out std_logic; cap_L_cnfChainReadBackEn : out std_logic; cap_L_cnfChainOut : out std_logic; cap_L_cnfChainIn : in std_logic; cap_L_selChainLockRequest : out std_logic; cap_L_selChainLock : in std_logic; cap_L_selChainShiftEn : out std_logic; cap_L_selChainFeedbackEn : out std_logic; cap_L_selChainOut : out std_logic; cap_L_selChainIn : in std_logic; -- Fabric CAP Route cap_R_cnfChainLockRequest : out std_logic; cap_R_cnfChainLock : in std_logic; cap_R_cnfChainShiftEn : out std_logic; cap_R_cnfChainLoadEn : out std_logic; cap_R_cnfChainReadBackEn : out std_logic; cap_R_cnfChainOut : out std_logic; cap_R_cnfChainIn : in std_logic; cap_R_selChainLockRequest : out std_logic; cap_R_selChainLock : in std_logic; cap_R_selChainShiftEn : out std_logic; cap_R_selChainFeedbackEn : out std_logic; cap_R_selChainOut : out std_logic; cap_R_selChainIn : in std_logic); end component; end SnapPkg; package body SnapPkg is --------------------------------------------------------------------------------------------------------------- -- Conversion: std_logic_vector <-> Snap Opcode --------------------------------------------------------------------------------------------------------------- -- {{{ function to_SNAPTYPE_OPCODE( value : std_logic_vector(3 downto 0) ) return SNAPTYPE_OPCODE is variable result : SNAPTYPE_OPCODE; begin case value is when b"0000" => result := SNAP_OP_ADD; -- 0 when b"0001" => result := SNAP_OP_ADDC; -- 1 when b"0010" => result := SNAP_OP_SUB; -- 2 when b"0011" => result := SNAP_OP_SUBC; -- 3 when b"0100" => result := SNAP_OP_NEG; -- 4 when b"0101" => result := SNAP_OP_AND; -- 5 when b"0110" => result := SNAP_OP_OR; -- 6 when b"0111" => result := SNAP_OP_XOR; -- 7 when b"1000" => result := SNAP_OP_ROL; -- 8 when b"1001" => result := SNAP_OP_ROR; -- 9 when b"1010" => result := SNAP_OP_BS; -- 10 when b"1011" => result := SNAP_OP_BC; -- 11 when b"1100" => result := SNAP_OP_MOV; -- 12 when b"1101" => result := SNAP_OP_LD; -- 13 when b"1110" => result := SNAP_OP_ST; -- 14 when b"1111" => result := SNAP_OP_SPECIAL; -- 15 when others => assert false report "to_SNAPTYPE_OPCODE: unconvertable std_logic value" severity failure; end case; return result; end function to_SNAPTYPE_OPCODE; function to_std_logic_vector( value : SNAPTYPE_OPCODE ) return std_logic_vector is variable result : std_logic_vector(3 downto 0); begin case value is when SNAP_OP_ADD => result := b"0000"; -- 0 when SNAP_OP_ADDC => result := b"0001"; -- 1 when SNAP_OP_SUB => result := b"0010"; -- 2 when SNAP_OP_SUBC => result := b"0011"; -- 3 when SNAP_OP_NEG => result := b"0100"; -- 4 when SNAP_OP_AND => result := b"0101"; -- 5 when SNAP_OP_OR => result := b"0110"; -- 6 when SNAP_OP_XOR => result := b"0111"; -- 7 when SNAP_OP_ROL => result := b"1000"; -- 8 when SNAP_OP_ROR => result := b"1001"; -- 9 when SNAP_OP_BS => result := b"1010"; -- 10 when SNAP_OP_BC => result := b"1011"; -- 11 when SNAP_OP_MOV => result := b"1100"; -- 12 when SNAP_OP_LD => result := b"1101"; -- 13 when SNAP_OP_ST => result := b"1110"; -- 14 when SNAP_OP_SPECIAL => result := b"1111"; -- 15 end case; return result; end function to_std_logic_vector; -- }}} --------------------------------------------------------------------------------------------------------------- -- Conversion: std_logic_vector <-> Snap SUB Opcode --------------------------------------------------------------------------------------------------------------- -- {{{ function to_SNAPTYPE_SUB_OPCODE( value : std_logic_vector(1 downto 0) ) return SNAPTYPE_SUB_OPCODE is variable result : SNAPTYPE_SUB_OPCODE; begin case value is when b"00" => result := SNAP_SUBOP_BRA; -- 0 when b"01" => result := SNAP_SUBOP_RETI; -- 1 when b"10" => result := SNAP_SUBOP_FSET; -- 2 when b"11" => result := SNAP_SUBOP_CSET; -- 3 when others => assert false report "to_SNAPTYPE_SUB_OPCODE: unconvertable std_logic value" severity failure; end case; return result; end function to_SNAPTYPE_SUB_OPCODE; function to_std_logic_vector( value : SNAPTYPE_SUB_OPCODE ) return std_logic_vector is variable result : std_logic_vector(1 downto 0); begin case value is when SNAP_SUBOP_BRA => result := b"00"; -- 0 when SNAP_SUBOP_RETI => result := b"01"; -- 1 when SNAP_SUBOP_FSET => result := b"10"; -- 2 when SNAP_SUBOP_CSET => result := b"11"; -- 3 end case; return result; end function to_std_logic_vector; -- }}} --------------------------------------------------------------------------------------------------------------- -- Conversion: std_logic_vector <-> Snap Condition Code --------------------------------------------------------------------------------------------------------------- -- {{{ function to_SNAPTYPE_CONDITION_CODE( value : std_logic_vector(4 downto 0) ) return SNAPTYPE_CONDITION_CODE is variable result : SNAPTYPE_CONDITION_CODE; begin case value is when b"00000" => result := SNAP_CC_ZERO; -- 0 when b"00001" => result := SNAP_CC_NOT_ZERO; -- 1 when b"00010" => result := SNAP_CC_CARRYBORROW; -- 2 when b"00011" => result := SNAP_CC_NOT_CARRYBORROW; -- 3 when b"00100" => result := SNAP_CC_NEGATIVE; -- 4 when b"00101" => result := SNAP_CC_NOT_NEGATIVE; -- 5 when b"00110" => result := SNAP_CC_OVERFLOW; -- 6 when b"00111" => result := SNAP_CC_NOT_OVERFLOW; -- 7 when b"01000" => result := SNAP_CC_EQT0; -- 8 when b"01001" => result := SNAP_CC_NOT_EQT0; -- 9 when b"01010" => result := SNAP_CC_EQT1; -- 10 when b"01011" => result := SNAP_CC_NOT_EQT1; -- 11 when b"01100" => result := SNAP_CC_EQT2; -- 12 when b"01101" => result := SNAP_CC_NOT_EQT2; -- 13 when b"01110" => result := SNAP_CC_GIE; -- 14 when b"01111" => result := SNAP_CC_NOT_GIE; -- 15 when b"10000" => result := SNAP_CC_EF0; -- 16 when b"10001" => result := SNAP_CC_NOT_EF0; -- 17 when b"10010" => result := SNAP_CC_EF1; -- 18 when b"10011" => result := SNAP_CC_NOT_EF1; -- 19 when b"10100" => result := SNAP_CC_EF2; -- 20 when b"10101" => result := SNAP_CC_NOT_EF2; -- 21 when b"10110" => result := SNAP_CC_EF3; -- 22 when b"10111" => result := SNAP_CC_NOT_EF3; -- 23 when b"11000" => result := SNAP_CC_EF4; -- 24 when b"11001" => result := SNAP_CC_NOT_EF4; -- 25 when b"11010" => result := SNAP_CC_EF5; -- 26 when b"11011" => result := SNAP_CC_NOT_EF5; -- 27 when b"11100" => result := SNAP_CC_EF6; -- 28 when b"11101" => result := SNAP_CC_NOT_EF6; -- 29 when b"11110" => result := SNAP_CC_EF7; -- 30 when b"11111" => result := SNAP_CC_NOT_EF7; -- 31 when others => assert false report "to_SNAPTYPE_CONDITION_CODE: unconvertable std_logic value " & toString(value) severity warning; end case; return result; end function to_SNAPTYPE_CONDITION_CODE; function to_std_logic_vector( value : SNAPTYPE_CONDITION_CODE ) return std_logic_vector is variable result : std_logic_vector(4 downto 0); begin case value is when SNAP_CC_ZERO => result := b"00000"; -- 0 when SNAP_CC_NOT_ZERO => result := b"00001"; -- 1 when SNAP_CC_CARRYBORROW => result := b"00010"; -- 2 when SNAP_CC_NOT_CARRYBORROW => result := b"00011"; -- 3 when SNAP_CC_NEGATIVE => result := b"00100"; -- 4 when SNAP_CC_NOT_NEGATIVE => result := b"00101"; -- 5 when SNAP_CC_OVERFLOW => result := b"00110"; -- 6 when SNAP_CC_NOT_OVERFLOW => result := b"00111"; -- 7 when SNAP_CC_EQT0 => result := b"01000"; -- 8 when SNAP_CC_NOT_EQT0 => result := b"01001"; -- 9 when SNAP_CC_EQT1 => result := b"01010"; -- 10 when SNAP_CC_NOT_EQT1 => result := b"01011"; -- 11 when SNAP_CC_EQT2 => result := b"01100"; -- 12 when SNAP_CC_NOT_EQT2 => result := b"01101"; -- 13 when SNAP_CC_GIE => result := b"01110"; -- 14 when SNAP_CC_NOT_GIE => result := b"01111"; -- 15 when SNAP_CC_EF0 => result := b"10000"; -- 16 when SNAP_CC_NOT_EF0 => result := b"10001"; -- 17 when SNAP_CC_EF1 => result := b"10010"; -- 18 when SNAP_CC_NOT_EF1 => result := b"10011"; -- 19 when SNAP_CC_EF2 => result := b"10100"; -- 20 when SNAP_CC_NOT_EF2 => result := b"10101"; -- 21 when SNAP_CC_EF3 => result := b"10110"; -- 22 when SNAP_CC_NOT_EF3 => result := b"10111"; -- 23 when SNAP_CC_EF4 => result := b"11000"; -- 24 when SNAP_CC_NOT_EF4 => result := b"11001"; -- 25 when SNAP_CC_EF5 => result := b"11010"; -- 26 when SNAP_CC_NOT_EF5 => result := b"11011"; -- 27 when SNAP_CC_EF6 => result := b"11100"; -- 28 when SNAP_CC_NOT_EF6 => result := b"11101"; -- 29 when SNAP_CC_EF7 => result := b"11110"; -- 30 when SNAP_CC_NOT_EF7 => result := b"11111"; -- 31 end case; return result; end function to_std_logic_vector; -- }}} --------------------------------------------------------------------------------------------------------------- -- Conversion: std_logic <-> Snap Instruction Type --------------------------------------------------------------------------------------------------------------- -- {{{ function to_SNAPTYPE_INSN_TYPE( value : std_logic ) return SNAPTYPE_INSN_TYPE is variable result : SNAPTYPE_INSN_TYPE; begin case value is when '1' => result := SNAP_LIT_INSN; when '0' => result := SNAP_REG_INSN; when others => assert false report "to_SNAPTYPE_INSN_TYPE: unconvertable std_logic value" severity failure; end case; return result; end function to_SNAPTYPE_INSN_TYPE; function to_std_logic( value : SNAPTYPE_INSN_TYPE ) return std_logic is variable result : std_logic; begin case value is when SNAP_LIT_INSN => result := '1'; when SNAP_REG_INSN => result := '0'; end case; return result; end function to_std_logic; -- }}} --------------------------------------------------------------------------------------------------------------- -- Conversion: std_logic_vector <-- SNAPTYPE_REG_NUM --------------------------------------------------------------------------------------------------------------- -- {{{ function to_std_logic_vector( value : SNAPTYPE_REG_NUM ) return std_logic_vector is begin return std_logic_vector(to_unsigned(value, 7)); end function to_std_logic_vector; -- }}} --------------------------------------------------------------------------------------------------------------- -- Function isConditionSatisfied --------------------------------------------------------------------------------------------------------------- -- {{{ function isConditionSatisfied( conditionCode : SNAPTYPE_CONDITION_CODE; flags : SNAPTYPE_FLAGS) return boolean is variable satisfied : boolean; begin satisfied := false; case conditionCode is -- ALU Flags when SNAP_CC_ZERO => if (flags.intFlags.aluFlags.zero = '1') then satisfied := true; end if; when SNAP_CC_NOT_ZERO => if (flags.intFlags.aluFlags.zero = '0') then satisfied := true; end if; when SNAP_CC_CARRYBORROW => if (flags.intFlags.aluFlags.carryBorrow = '1') then satisfied := true; end if; when SNAP_CC_NOT_CARRYBORROW => if (flags.intFlags.aluFlags.carryBorrow = '0') then satisfied := true; end if; when SNAP_CC_NEGATIVE => if (flags.intFlags.aluFlags.negative = '1') then satisfied := true; end if; when SNAP_CC_NOT_NEGATIVE => if (flags.intFlags.aluFlags.negative = '0') then satisfied := true; end if; when SNAP_CC_OVERFLOW => if (flags.intFlags.aluFlags.overflow = '1') then satisfied := true; end if; when SNAP_CC_NOT_OVERFLOW => if (flags.intFlags.aluFlags.overflow = '0') then satisfied := true; end if; -- Equality Flags when SNAP_CC_EQT0 => if (flags.intFlags.equalityTests(0) = '1') then satisfied := true; end if; when SNAP_CC_NOT_EQT0 => if (flags.intFlags.equalityTests(0) = '0') then satisfied := true; end if; when SNAP_CC_EQT1 => if (flags.intFlags.equalityTests(1) = '1') then satisfied := true; end if; when SNAP_CC_NOT_EQT1 => if (flags.intFlags.equalityTests(1) = '0') then satisfied := true; end if; when SNAP_CC_EQT2 => if (flags.intFlags.equalityTests(2) = '1') then satisfied := true; end if; when SNAP_CC_NOT_EQT2 => if (flags.intFlags.equalityTests(2) = '0') then satisfied := true; end if; -- Global Interrupt Enable Flag when SNAP_CC_GIE => if (flags.intFlags.globalInterruptEn = '1') then satisfied := true; end if; when SNAP_CC_NOT_GIE => if (flags.intFlags.globalInterruptEn = '0') then satisfied := true; end if; -- External Flags when SNAP_CC_EF0 => if (flags.extFlags.flags(0) = '1') then satisfied := true; end if; when SNAP_CC_NOT_EF0 => if (flags.extFlags.flags(0) = '0') then satisfied := true; end if; when SNAP_CC_EF1 => if (flags.extFlags.flags(1) = '1') then satisfied := true; end if; when SNAP_CC_NOT_EF1 => if (flags.extFlags.flags(1) = '0') then satisfied := true; end if; when SNAP_CC_EF2 => if (flags.extFlags.flags(2) = '1') then satisfied := true; end if; when SNAP_CC_NOT_EF2 => if (flags.extFlags.flags(2) = '0') then satisfied := true; end if; when SNAP_CC_EF3 => if (flags.extFlags.flags(3) = '1') then satisfied := true; end if; when SNAP_CC_NOT_EF3 => if (flags.extFlags.flags(3) = '0') then satisfied := true; end if; when SNAP_CC_EF4 => if (flags.extFlags.flags(4) = '1') then satisfied := true; end if; when SNAP_CC_NOT_EF4 => if (flags.extFlags.flags(4) = '0') then satisfied := true; end if; when SNAP_CC_EF5 => if (flags.extFlags.flags(5) = '1') then satisfied := true; end if; when SNAP_CC_NOT_EF5 => if (flags.extFlags.flags(5) = '0') then satisfied := true; end if; when SNAP_CC_EF6 => if (flags.extFlags.flags(6) = '1') then satisfied := true; end if; when SNAP_CC_NOT_EF6 => if (flags.extFlags.flags(6) = '0') then satisfied := true; end if; when SNAP_CC_EF7 => if (flags.extFlags.flags(7) = '1') then satisfied := true; end if; when SNAP_CC_NOT_EF7 => if (flags.extFlags.flags(7) = '0') then satisfied := true; end if; when others => null; end case; return satisfied; end function isConditionSatisfied; -- }}} --------------------------------------------------------------------------------------------------------------- -- Function isForwardableRegister --------------------------------------------------------------------------------------------------------------- -- {{{ function isForwardableRegister( reg : std_logic_vector(6 downto 0) ) return boolean is variable forward : boolean; begin forward := false; if (reg(6 downto 5) = b"00") then forward := true; end if; return forward; end function isForwardableRegister; -- }}} --------------------------------------------------------------------------------------------------------------- -- Function isWriteBackInsn --------------------------------------------------------------------------------------------------------------- -- {{{ function isWriteBackInsn( opCode : SNAPTYPE_OPCODE; subOpCode : SNAPTYPE_SUB_OPCODE ) return boolean is variable writeBack : boolean; begin writeBack := true; if (opCode=SNAP_OP_ST) then writeBack := false; elsif (opCode=SNAP_OP_SPECIAL) then if (subOpCode=SNAP_SUBOP_CSET or subOpCode=SNAP_SUBOP_FSET) then writeBack := false; end if; end if; return writeBack; end function isWriteBackInsn; -- }}} --------------------------------------------------------------------------------------------------------------- -- Conversion: std_logic_vector <-> SNAPTYPE_SYSUART_DATABITS --------------------------------------------------------------------------------------------------------------- -- {{{ function to_SNAPTYPE_SYSUART_DATABITS( value : std_logic_vector(2 downto 0) ) return SNAPTYPE_SYSUART_DATABITS is variable result : SNAPTYPE_SYSUART_DATABITS; begin case value is when b"000" => result := SNAP_SYSUART_5DATABITS; -- 0 when b"001" => result := SNAP_SYSUART_6DATABITS; -- 1 when b"010" => result := SNAP_SYSUART_7DATABITS; -- 2 when b"011" => result := SNAP_SYSUART_8DATABITS; -- 3 when b"100" => result := SNAP_SYSUART_9DATABITS; -- 0 when b"101" => result := SNAP_SYSUART_10DATABITS; -- 1 when b"110" => result := SNAP_SYSUART_8DATABITS; -- 2 when b"111" => result := SNAP_SYSUART_8DATABITS; -- 3 when others => assert false report "to_SNAPTYPE_SYSUART_DATABITS: unconvertable std_logic value" severity failure; end case; return result; end function to_SNAPTYPE_SYSUART_DATABITS; function to_std_logic_vector( value : SNAPTYPE_SYSUART_DATABITS ) return std_logic_vector is variable result : std_logic_vector(2 downto 0); begin case value is when SNAP_SYSUART_5DATABITS => result := b"000"; -- 0 when SNAP_SYSUART_6DATABITS => result := b"001"; -- 1 when SNAP_SYSUART_7DATABITS => result := b"010"; -- 2 when SNAP_SYSUART_8DATABITS => result := b"011"; -- 3 when SNAP_SYSUART_9DATABITS => result := b"100"; -- 4 when SNAP_SYSUART_10DATABITS => result := b"101"; -- 5 end case; return result; end function to_std_logic_vector; -- }}} --------------------------------------------------------------------------------------------------------------- -- Conversion: std_logic_vector <-> SNAPTYPE_SYSUART_PARITY --------------------------------------------------------------------------------------------------------------- -- {{{ function to_SNAPTYPE_SYSUART_PARITY( value : std_logic_vector(1 downto 0) ) return SNAPTYPE_SYSUART_PARITY is variable result : SNAPTYPE_SYSUART_PARITY; begin case value is when b"00" => result := SNAP_SYSUART_EVEN_PARITY; -- 0 when b"01" => result := SNAP_SYSUART_ODD_PARITY; -- 1 when b"10" => result := SNAP_SYSUART_NO_PARITY; -- 2 when b"11" => result := SNAP_SYSUART_NO_PARITY; -- 3 when others => assert false report "to_SNAPTYPE_SYSUART_PARITY: unconvertable std_logic value" severity failure; end case; return result; end function to_SNAPTYPE_SYSUART_PARITY; function to_std_logic_vector( value : SNAPTYPE_SYSUART_PARITY ) return std_logic_vector is variable result : std_logic_vector(1 downto 0); begin case value is when SNAP_SYSUART_EVEN_PARITY => result := b"00"; -- 0 when SNAP_SYSUART_ODD_PARITY => result := b"01"; -- 1 when SNAP_SYSUART_NO_PARITY => result := b"10"; -- 2 end case; return result; end function to_std_logic_vector; -- }}} --------------------------------------------------------------------------------------------------------------- -- Conversion: std_logic_vector <-> SNAPTYPE_SYSUART_STOPBITS --------------------------------------------------------------------------------------------------------------- -- {{{ function to_SNAPTYPE_SYSUART_STOPBITS( value : std_logic ) return SNAPTYPE_SYSUART_STOPBITS is variable result : SNAPTYPE_SYSUART_STOPBITS; begin case value is when '0' => result := SNAP_SYSUART_1STOPBITS; -- 0 when '1' => result := SNAP_SYSUART_2STOPBITS; -- 1 when others => assert false report "to_SNAPTYPE_SYSUART_STOPBITS: unconvertable std_logic value" severity failure; end case; return result; end function to_SNAPTYPE_SYSUART_STOPBITS; function to_std_logic( value : SNAPTYPE_SYSUART_STOPBITS ) return std_logic is variable result : std_logic; begin case value is when SNAP_SYSUART_1STOPBITS => result := '0'; -- 0 when SNAP_SYSUART_2STOPBITS => result := '1'; -- 1 end case; return result; end function to_std_logic; -- }}} --------------------------------------------------------------------------------------------------------------- -- Conversion: std_logic_vector <-> SNAPTYPE_SNAPLINK_DATABITS --------------------------------------------------------------------------------------------------------------- -- {{{ function to_SNAPTYPE_SNAPLINK_DATABITS( value : std_logic_vector(1 downto 0) ) return SNAPTYPE_SNAPLINK_DATABITS is variable result : SNAPTYPE_SNAPLINK_DATABITS; begin case value is when b"00" => result := SNAP_SNAPLINK_16DATABITS; -- 0 when b"01" => result := SNAP_SNAPLINK_17DATABITS; -- 1 when b"10" => result := SNAP_SNAPLINK_18DATABITS; -- 2 when b"11" => result := SNAP_SNAPLINK_16DATABITS; -- 3 when others => assert false report "to_SNAPTYPE_SNAPLINK_DATABITS: unconvertable std_logic value" severity failure; end case; return result; end function to_SNAPTYPE_SNAPLINK_DATABITS; function to_std_logic_vector( value : SNAPTYPE_SNAPLINK_DATABITS ) return std_logic_vector is variable result : std_logic_vector(1 downto 0); begin case value is when SNAP_SNAPLINK_16DATABITS => result := b"00"; -- 0 when SNAP_SNAPLINK_17DATABITS => result := b"01"; -- 1 when SNAP_SNAPLINK_18DATABITS => result := b"10"; -- 2 end case; return result; end function to_std_logic_vector; -- }}} end SnapPkg;