⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hostmot2.vhd

📁 CNC 的开放码,EMC2 V2.2.8版
💻 VHD
📖 第 1 页 / 共 4 页
字号:
library IEEE;use IEEE.std_logic_1164.all;  -- defines std_logic typesuse IEEE.std_logic_ARITH.ALL;use IEEE.std_logic_UNSIGNED.ALL;---- Copyright (C) 2007, Peter C. Wallace, Mesa Electronics-- http://www.mesanet.com---- This program is is licensed under a disjunctive dual license giving you-- the choice of one of the two following sets of free software/open source-- licensing terms:----    * GNU General Public License (GPL), version 2.0 or later--    * 3-clause BSD License-- ---- The GNU GPL License:-- --     This program is free software; you can redistribute it and/or modify--     it under the terms of the GNU General Public License as published by--     the Free Software Foundation; either version 2 of the License, or--     (at your option) any later version.-- --     This program is distributed in the hope that it will be useful,--     but WITHOUT ANY WARRANTY; without even the implied warranty of--     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the--     GNU General Public License for more details.-- --     You should have received a copy of the GNU General Public License--     along with this program; if not, write to the Free Software--     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA-- -- -- The 3-clause BSD License:-- --     Redistribution and use in source and binary forms, with or without--     modification, are permitted provided that the following conditions--     are met:-- --         * Redistributions of source code must retain the above copyright--           notice, this list of conditions and the following disclaimer.-- --         * Redistributions in binary form must reproduce the above--           copyright notice, this list of conditions and the following--           disclaimer in the documentation and/or other materials--           provided with the distribution.-- --         * Neither the name of Mesa Electronics nor the names of its--           contributors may be used to endorse or promote products--           derived from this software without specific prior written--           permission.-- -- -- Disclaimer:-- --     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS--     "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT--     LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS--     FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE--     COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,--     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,--     BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;--     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER--     CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT--     LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN--     ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE--     POSSIBILITY OF SUCH DAMAGE.-- use work.IDROMParms.all;	library UNISIM;use UNISIM.VComponents.all;	entity HostMot2 is  	generic	(  		STEPGENs: integer;		QCOUNTERS: integer;		PWMGens: integer;		SPIs: integer;		SSIs: integer;		UARTs: integer;		PWMRefWidth: integer;		StepGenTableWidth: integer;		IDROMType: integer;			   SepClocks: boolean;		OneWS: boolean;		SVST8_24Pinout: boolean;		SVST8_8Pinout: boolean;		SVST4_8Pinout: boolean;		SVST8_4Pinout: boolean;		SVST4_4Pinout: boolean;		SVST4_6Pinout: boolean;		I30Pinout: boolean;		I44Pinout: boolean;		Qctronlypinout: boolean;		Qctronlypinoutwithimask: boolean;		ConnsWithI30: integer;		Startingi30Conn: integer;		ConnsWithI44: integer;		StartingI44conn: integer;		ConnsWithStepGen: integer;		Startingstepgenconn: integer; 				UseStepGenPrescaler : boolean;		UseIRQLogic: boolean;		UseWatchDog: boolean;		OffsetToModules: integer;		OffsetToPinDesc: integer;		ClockHigh: integer;		ClockLow: integer;		BoardNameLow : std_Logic_Vector(31 downto 0);		BoardNameHigh : std_Logic_Vector(31 downto 0);		FPGASize: integer;		FPGAPins: integer;		IOPorts: integer;		IOWidth: integer;		PortWidth: integer;		BusWidth: integer;		AddrWidth: integer;		InstStride0: integer;		InstStride1: integer;		RegStride0: integer;		RegStride1: integer;		LEDCount: integer		);	port    (     -- Generic 32  bit bus interface signals --	ibus: in std_logic_vector(buswidth -1 downto 0);	obus: out std_logic_vector(buswidth -1 downto 0);	addr: in std_logic_vector(addrwidth -1 downto 2);	read: in std_logic;	write: in std_logic;	clklow: in std_logic;	clkhigh: in std_logic;	int: out std_logic; 	iobits: inout std_logic_vector (iowidth -1 downto 0);				leds: out std_logic_vector(ledcount-1 downto 0)	);end HostMot2;architecture dataflow of HostMot2 is-- decodes ----	IDROM related signals	signal A : std_logic_vector(addrwidth -1 downto 2);	signal LoadIDROM: std_logic;	signal ReadIDROM: std_logic;	signal LoadIDROMWEn: std_logic;	signal ReadIDROMWEn: std_logic;	signal IDROMWEn: std_logic_vector(0 downto 0);	signal ROMAdd: std_logic_vector(7 downto 0);-- I/O port related signals	signal AltData :  std_logic_vector(IOWidth-1 downto 0);	signal PortSel: std_logic;		signal LoadPortCmd: std_logic_vector(IOPorts -1 downto 0);	signal ReadPortCmd: std_logic_vector(IOPorts -1 downto 0);	signal DDRSel: std_logic;		signal LoadDDRCmd: std_logic_vector(IOPorts -1 downto 0);	signal ReadDDRCmd: std_logic_vector(IOPorts -1 downto 0);		signal AltDataSrcSel: std_logic;	signal LoadAltDataSrcCmd: std_logic_vector(IOPorts -1 downto 0);	signal OpenDrainModeSel: std_logic;	signal LoadOpenDrainModeCmd: std_logic_vector(IOPorts -1 downto 0);	signal OutputInvSel: std_logic;	signal LoadOutputInvCmd: std_logic_vector(IOPorts -1 downto 0);-- Step generator related signals		signal StepGenRateSel: std_logic;	signal LoadStepGenRate: std_logic_vector(StepGens -1 downto 0);	signal ReadStepGenRate: std_logic_vector(StepGens -1 downto 0);	signal StepGenAccumSel: std_logic;	signal LoadStepGenAccum: std_logic_vector(StepGens -1 downto 0);	signal ReadStepGenAccum: std_logic_vector(StepGens -1 downto 0);		signal StepGenModeSel: std_logic;	signal LoadStepGenMode: std_logic_vector(StepGens -1 downto 0);	signal ReadStepGenMode: std_logic_vector(StepGens -1 downto 0);	signal StepGenDSUTimeSel: std_logic;	signal LoadStepGenDSUTime: std_logic_vector(StepGens -1 downto 0);	signal ReadStepGenDSUTime: std_logic_vector(StepGens -1 downto 0);	signal StepGenDHLDTimeSel: std_logic;	signal LoadStepGenDHLDTime: std_logic_vector(StepGens -1 downto 0);	signal ReadStepGenDHLDTime: std_logic_vector(StepGens -1 downto 0);	signal StepGenPulseATimeSel: std_logic;	signal LoadStepGenPulseATime: std_logic_vector(StepGens -1 downto 0);	signal ReadStepGenPulseATime: std_logic_vector(StepGens -1 downto 0);	signal StepGenPulseITimeSel: std_logic;	signal LoadStepGenPulseITime: std_logic_vector(StepGens -1 downto 0);	signal ReadStepGenPulseITime: std_logic_vector(StepGens -1 downto 0);	signal StepGenTableMaxSel: std_logic;	signal LoadStepGenTableMax: std_logic_vector(StepGens -1 downto 0);	signal ReadStepGenTableMax: std_logic_vector(StepGens -1 downto 0);	signal StepGenTableSel: std_logic;	signal LoadStepGenTable: std_logic_vector(StepGens -1 downto 0);	signal ReadStepGenTable: std_logic_vector(StepGens -1 downto 0);		type StepGenOutType is array(StepGens-1 downto 0) of std_logic_vector(StepGenTableWidth-1 downto 0);	signal StepGenOut : StepGenOutType;-- Step generators master rate related signals	signal LoadStepGenBasicRate: std_logic;	signal ReadStepGenBasicRate: std_logic; 	signal StepGenBasicRate: std_logic;-- Quadrature counter related signals	signal QCounterSel : std_logic;	signal LoadQCounter: std_logic_vector(QCOUNTERs-1 downto 0);	signal ReadQCounter: std_logic_vector(QCOUNTERs-1 downto 0);		signal QCounterCCRSel : std_logic;	signal LoadQCounterCCR: std_logic_vector(QCOUNTERs-1 downto 0);	signal ReadQCounterCCR: std_logic_vector(QCOUNTERs-1 downto 0);-- Quadrature counter timestamp reference counter	signal LoadTSDiv : std_logic;	signal ReadTSDiv : std_logic;	signal ReadTS : std_logic;	signal TimeStampBus: std_logic_vector(15 downto 0);-- Quadrature counter filter rate signals	signal LoadQCountRate : std_logic;	signal QCountFilterRate : std_logic;	-- Quadrature counter input signals	signal QuadA: std_logic_vector(QCounters-1 downto 0);	signal QuadB: std_logic_vector(QCounters-1 downto 0);	signal Index: std_logic_vector(QCounters -1 downto 0);	signal IndexMask: std_logic_vector(QCounters -1 downto 0);-- PWM generator related signals	signal PWMGenOutA: std_logic_vector(PWMGens -1 downto 0);	signal PWMGenOutB: std_logic_vector(PWMGens -1 downto 0);	signal PWMGenOutC: std_logic_vector(PWMGens -1 downto 0);	signal LoadPWMRate : std_logic;	signal LoadPDMRate : std_logic;	signal RefCountBus : std_logic_vector(PWMRefWidth-1 downto 0);	signal PDMRate : std_logic;	signal PWMValSel : std_logic;	signal PWMCRSel : std_logic;	signal LoadPWMVal: std_logic_vector(PWMGens -1 downto 0);	signal LoadPWMCR: std_logic_vector(PWMGens -1 downto 0);	signal LoadPWMEnas: std_logic;	signal ReadPWMEnas: std_logic;--- SPI interface related signals	signal SPIBitCountSel : std_logic;	signal SPIBitrateSel : std_logic;	signal SPIDataSel : std_logic;		signal LoadSPIBitCount: std_logic_vector(SPIs -1 downto 0);	signal LoadSPIBitRate: std_logic_vector(SPIs -1 downto 0);	signal LoadSPIData: std_logic_vector(SPIs -1 downto 0);	signal ReadSPIData: std_logic_vector(SPIs -1 downto 0);           	signal ReadSPIBitCOunt: std_logic_vector(SPIs -1 downto 0);	signal ReadSPIBitRate: std_logic_vector(SPIs -1 downto 0);	signal SPIClk: std_logic_vector(SPIs -1 downto 0);	signal SPIIn: std_logic_vector(SPIs -1 downto 0);	signal SPIOut: std_logic_vector(SPIs -1 downto 0);	signal SPIFrame: std_logic_vector(SPIs -1 downto 0);	signal SPIDAV: std_logic_vector(SPIs -1 downto 0);	--- UARTX interface related signals			signal UARTXDataSel : std_logic;	signal UARTXBitrateSel : std_logic;	signal UARTXFIFOCountSel : std_logic;	signal UARTXModeRegSel : std_logic; 	signal LoadUARTXData: std_logic_vector(UARTs -1 downto 0);	signal LoadUARTXBitRate: std_logic_vector(UARTs -1 downto 0);	signal LoadUARTXModeReg: std_logic_vector(UARTs -1 downto 0);		signal CLearUARTXFIFO: std_logic_vector(UARTs -1 downto 0);	signal ReadUARTXFIFOCount: std_logic_vector(UARTs -1 downto 0);	signal ReadUARTXBitrate: std_logic_vector(UARTs -1 downto 0);	signal ReadUARTXModeReg: std_logic_vector(UARTs -1 downto 0);	signal UARTXFIFOEmpty: std_logic_vector(UARTs -1 downto 0);	signal UTDrvEn: std_logic_vector(UARTs -1 downto 0);	signal UTXData: std_logic_vector(UARTs -1 downto 0);--- UARTR interface related signals		signal UARTRDataSel : std_logic;	signal UARTRBitrateSel : std_logic;	signal UARTRFIFOCountSel : std_logic;	signal UARTRModeSel : std_logic;		signal LoadUARTRData: std_logic_vector(UARTs -1 downto 0);	signal LoadUARTRBitRate: std_logic_vector(UARTs -1 downto 0);	signal ReadUARTRBitrate: std_logic_vector(UARTs -1 downto 0);	signal ClearUARTRFIFO: std_logic_vector(UARTs -1 downto 0);	signal ReadUARTRFIFOCount: std_logic_vector(UARTs -1 downto 0);	signal ReadUARTRMode: std_logic_vector(UARTs -1 downto 0);	signal LoadUARTRMode: std_logic_vector(UARTs -1 downto 0);	signal UARTRFIFOHasData: std_logic_vector(UARTs -1 downto 0);	signal UTRData: std_logic_vector(UARTs -1 downto 0);			--- Watchdog related signals 	signal LoadWDTime : std_logic; 	signal ReadWDTime : std_logic;	signal LoadWDStatus : std_logic;	signal ReadWDStatus : std_logic;	signal WDCookie: std_logic;	signal WDBite : std_logic;	signal WDLatchedBite : std_logic;--- IRQ related signals 	signal LoadIRQDiv : std_logic;	signal ReadIRQDiv : std_logic;	signal LoadIRQStatus : std_logic;	signal ReadIrqStatus : std_logic;	signal ClearIRQ : std_logic;--- ID related signals	signal ReadID : std_logic;--- LED related signals	signal LoadLEDS : std_logic;	function OneOfNdecode(width : integer;ena1 : std_logic;ena2 : std_logic; dec : std_logic_vector) return std_logic_vector is	variable result   : std_logic_vector(width-1 downto 0);	begin		if ena1 = '1' and ena2 = '1' then			for i in 0 to width -1 loop				if CONV_INTEGER(dec) = i then					result(i) := '1';				else					result(i) := '0';				end if;				end loop;				else			result := (others => '0');		end if;		return result;	end OneOfNDecode;					function bitreverse(v: in std_logic_vector) -- Thanks: J. Bromley	return std_logic_vector is	variable result: std_logic_vector(v'RANGE);	alias tv: std_logic_vector(v'REVERSE_RANGE) is v;	begin		for i in tv'RANGE loop			result(i) := tv(i);		end loop;		return result;	end;		begin	ahosmotid : entity hostmotid		generic map ( 			buswidth => BusWidth,			cookie => Cookie,			namelow => HostMotNameLow ,			namehigh => HostMotNameHigh,			idromoffset => IDROMOffset			)					port map ( 			readid => ReadID,			addr => A(3 downto 2),			obus => obus			);	makeoports: for i in 0 to IOPorts -1 generate		oportx: entity WordPR 		generic map (			size => PortWidth,			buswidth => BusWidth			)				port map (			clear => WDBite,			clk => clklow,			ibus => ibus,			obus => obus,			loadport => LoadPortCmd(i),			loadddr => LoadDDRCmd(i),			loadaltdatasrc => LoadAltDataSrcCmd(i),			loadopendrainmode => LoadOpenDrainModeCmd(i),			loadinvert => LoadOutputInvCmd(i),			readddr => ReadDDRCmd(i),			portdata => IOBits((((i+1)*PortWidth) -1) downto (i*PortWidth)), 			altdata => Altdata((((i+1)*PortWidth) -1) downto (i*PortWidth))			);		end generate;

⌨️ 快捷键说明

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