m3s010bo.vhd
来自「another 8051 core porocesssor vhdl sourc」· VHDL 代码 · 共 417 行 · 第 1/2 页
VHD
417 行
INTA => INTA );--*********************************************************************--*********************************************************************--Process Definitions --*********************************************************************--*********************************************************************gen1:process(STATD,CYC,PCADD,SFRW,AG)begin STACK_DATA_EN <= (CYC(1) and STATD(5) and PCADD(10)) or (CYC(1) and STATD(2)); DPL_EN <= (SFRW(14) and PCADD(8)) or (AG and not PCADD(8)); DPH_EN <= (SFRW(15) and PCADD(8)) or (STATD(6) and CYC(1) and not PCADD(8));end process gen1;--*********************************************************************misc1:process(STATD,CYC,PCADD)begin AG <= (CYC(1) and PCADD(7) and STATD(3)) or (CYC(2) and STATD(6) and not PCADD(7));end process misc1;--*********************************************************************pc_load_controller:process(NX1)-- Determine whether program counter loads from brancher/incrementer-- (the default condition) or from another source. Loading from-- another source normally takes place for both bytes at c2s4p1,-- with the exception of the JMP @A+DPTR instruction. -- These signals are registered to break a combinatorial path from-- the opcode to the program counter, for the benefit of synthesis-- tools.-- Jump and call instructions using 11-bit addresses load upper three-- address bits from the opcode register.begin if NX1'event and NX1 ='1' then if DLM = '1' then NFBL <= '0'; NFBH <= '0'; SEL_11BIT_ADDR <= '0'; elsif (STATD(2) and not DIV2CK) = '1' then NFBL <= (CYC(2) xor JMPADPTR) and not PCADD(3); NFBH <= CYC(2) and not JMPADPTR and PCADD(4); SEL_11BIT_ADDR <= not DLM and CYC(2) and ADDR_11BIT; elsif (STATD(5) and not DIV2CK) = '1' then NFBL <= '0'; NFBH <= CYC(1) and JMPADPTR and PCADD(4); SEL_11BIT_ADDR <= '0'; end if; end if; end process pc_load_controller;--*********************************************************************misc2:process(NX1)-- Look ahead logic for program counter incrementer.-- The program counter will always increment after an opcode load.begin if NX1'event and NX1 ='1' then if (STATD(1) and not DIV2CK) = '1' then BA <= (PCADD(9) and CYC(1)) or (PCADD(11) and CYC(2)); elsif (STATD(4)and not DIV2CK) = '1' then BA <= LCYC or (PCADD(10) and CYC(1)); end if; end if; end process misc2;--*********************************************************************determine_carry:process(DLM,INTA,BA)-- Determine whether a program counter increment is required.begin PC_INCR <= DLM or (BA and not INTA);end process determine_carry;--*********************************************************************set_rel:process(NX1)-- Determine whether a relative jump calculation is required.begin if NX1'event and NX1 ='1' then if (DLM or (STATD(4) and not DIV2CK)) = '1' then JMP_REL <= '0'; elsif (STATD(1) and not DIV2CK) = '1' then JMP_REL <= CYC(2) and ( PCADD(5) or PCADD(12) ); end if; end if; end process set_rel;--*********************************************************************pc_load_enable:process(DLM, STATD, IDLE, PCADD, CYC, C_TRUE)-- Program counter is updated at the end of every S1P1 and S4P1-- with the exception that no load takes place during conditional branch-- instructions at C2S5P1 if the branch condition (C_TRUE) is not met.begin PROGRAM_COUNT_EN <= not DLM and ((STATD(1) and not IDLE) or (STATD(4) and ( CYC(1) or not(PCADD(5)) or C_TRUE) ));end process pc_load_enable;--*********************************************************************update_program_counter:process(NX1)-- The Program Counter is updated at the end of S1P1 and S4P1.begin if NX1'event and NX1 ='1' then if (CLEAR and not DLM) = '1' then L_PROGRAM_COUNT <= "0000000000000000"; elsif ((PROGRAM_COUNT_EN and DIV2CK) or DLMSTB)= '1' then L_PROGRAM_COUNT(15 downto 0) <= NEXT_PROGRAM_COUNT(15 downto 0); end if; end if;end process update_program_counter; --********************************************************************* save_addr16_low: process(NX1)-- save low part of 16-bit address from ALU in cycle 1 for use in-- cycle 2.begin if NX1'event and NX1 ='1' then if (CYC(1) and STATD(3) and not DIV2CK) = '1' then ADDR_16BIT_LOW <= ALUDAT; end if; end if;end process save_addr16_low;--********************************************************************* select_movc_addr: process(L_PROGRAM_COUNT, ALUDAT, ADDR_16BIT_LOW, PCADD, CYC, STATD)-- Multiplex MOVC address into next program address during cycle 2.begin if (PCADD(6) and CYC(2) and STATD(1)) = '1' then NEXT_PROGRAM_ADDR(15 downto 8) <= ALUDAT; NEXT_PROGRAM_ADDR(7 downto 0) <= ADDR_16BIT_LOW; else NEXT_PROGRAM_ADDR <= L_PROGRAM_COUNT; end if;end process select_movc_addr;--********************************************************************* select_program_source: process(MSIZ, NEXT_PROGRAM_ADDR)begin if NEXT_PROGRAM_ADDR(15 downto 8) > MSIZ then L_EXT_ROM <= '1'; else L_EXT_ROM <= '0'; end if;end process select_program_source;--********************************************************************* update_program_address: process(NX1)-- program address updates at the end of every S1P2 and S4P2 and-- generally follows the program counter except during MOVC and -- JMP@A+DPTR instructions. Update external program memory enable.begin if NX1'event and NX1 ='1' then if (CLEAR and not STATD(4) and not STATD(5) and not DLM) = '1' then PROGRAM_ADDR <= "0000000000000000"; EXT_PROG_EN <= '0'; elsif ((( (STATD(1) and not (JMPADPTR and CYC(2))) or(STATD(4) and not (JMPADPTR and CYC(1))) ) and not DIV2CK) or DLM) = '1' then PROGRAM_ADDR <= NEXT_PROGRAM_ADDR; EXT_PROG_EN <= (L_EXT_ROM or not NEA) and not DLM; end if; end if;end process update_program_address;--********************************************************************* save_stack_data:process(NX1)begin if NX1'event and NX1 ='1' then if (STACK_DATA_EN and DIV2CK)= '1' then STACK_DATA(15 downto 0) <= NEXT_REL_PC(15 downto 0); end if; end if;end process save_stack_data; --********************************************************************* set_data_pointer:process(NX1)-- load data pointer special function registersbegin if NX1'event and NX1 ='1' then if CLEAR = '1' then DPL <= "00000000"; DPH <= "00000000"; else if (DPL_EN and not DIV2CK) = '1' then DPL <= DPTR_DATA; end if; if (DPH_EN and not DIV2CK) = '1' then DPH <= DPTR_DATA; end if; end if; end if;end process set_data_pointer; --********************************************************************* muxlocala:process(PCADD,IMMDAT,ALUDAT)begin if PCADD(7) = '0' then LOCALA(7 downto 0) <= IMMDAT(7 downto 0); else LOCALA(7 downto 0) <= ALUDAT(7 downto 0); end if;end process muxlocala;--********************************************************************* muxop:process(PCADD,LOCALA,RAMDI)begin if PCADD(8) = '0' then DPTR_DATA(7 downto 0) <= LOCALA(7 downto 0); else DPTR_DATA(7 downto 0) <= RAMDI(7 downto 0); end if;end process muxop;--********************************************************************* localout:process(L_PROGRAM_COUNT, L_EXT_ROM)begin PROGRAM_COUNT <= L_PROGRAM_COUNT; EXT_ROM <= L_EXT_ROM;end process localout;--********************************************************************* --********************************************************************* end m3s010bo_rtl;--*********************************************************************
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?