hostmot2.vhd

来自「CNC 的开放码,EMC2 V2.2.8版」· VHDL 代码 · 共 1,538 行 · 第 1/4 页

VHD
1,538
字号
			spiframe => BSPIFrame(i),			spicsout => BSPICS(i)			);	end generate;			makeUARTRs: for i in 0 to UARTs -1 generate		auarrx: entity uartr			port map (			clk => clklow,			ibus => ibus,			obus => obus,			addr => A(3 downto 2),			popfifo => LoadUARTRData(i),			loadbitrate => LoadUARTRBitRate(i),			readbitrate => ReadUARTRBitrate(i),			clrfifo => ClearUARTRFIFO(i),			readfifocount => ReadUARTRFIFOCount(i),			loadmode => LoadUARTRModeReg(i),			readmode => ReadUARTRModeReg(i),			fifohasdata => UARTRFIFOHasData(i),			rxmask => UTDrvEn(i),			-- for half duplex rx mask			rxdata => URData(i)         );	end generate;		makeUARTTXs: for i in 0 to UARTs -1 generate		auartx:  entity uartx			port map (			clk => clklow,			ibus => ibus,			obus => obus,			addr => A(3 downto 2),			pushfifo => LoadUARTTData(i),			loadbitrate => LoadUARTTBitRate(i),			readbitrate => ReadUARTTBitrate(i),			clrfifo => ClearUARTTFIFO(i),			readfifocount => ReadUARTTFIFOCount(i),			loadmode => LoadUARTTModeReg(i),			readmode => ReadUARTTModeReg(i),			fifoempty => UARTTFIFOEmpty(i),			txen => '1',			drven => UTDrvEn(i),			txdata => UTData(i)         );	end generate;	LEDReg : entity boutreg 	generic map (		size => LEDCount,		buswidth => LEDCount,		invert => true)	port map (		clk  => clklow,		ibus => ibus(BusWidth-1 downto BusWidth-LEDCount),		obus => obus(BusWidth-1 downto BusWidth-LEDCount),		load => LoadLEDs,		read => '0',		clear => '0',		dout => LEDS		); 			IDROMWP : entity boutreg  		generic map (			size => 1,			buswidth => BusWidth,			invert => false			)		port map (			clk  => clklow,         ibus => ibus,         obus => obus,         load => LoadIDROMWEn,         read => ReadIDROMWEn,			clear => '0',         dout => IDROMWen		); 		 			IDROM : entity IDROM		generic map (			idromtype => IDROMType,			offsettomodules => OffsetToModules,			offsettopindesc => OffsetToPinDesc,			boardnamelow => BoardNameLow,			boardnameHigh => BoardNameHigh,			fpgasize => FPGASize,			fpgapins => FPGAPins,			ioports => IOPorts,			iowidth => IOWidth,			portwidth => PortWidth,					clocklow => ClockLow,			clockhigh => ClockHigh,			inststride0 => InstStride0,			inststride1 => InstStride1,			regstride0 => RegStride0,			regstride1 => RegStride1,			pindesc => ThePinDesc,			moduleid => TheModuleID)		port map (			clk  => clklow, 			we   => LoadIDROM,			re   => ReadIDROM,			radd => addr(9 downto 2),			wadd => A(9 downto 2),			din  => ibus, 			dout => obus		); 		DoPinout: process(PWMGenOutA,PWMGenOutB,PWMGenOutC,StepGenOut,SPIFrame,SPIOut,SPIClk,		                  UTData,UTDrvEn,BSPIFrame,BSPIOut,BSPIClk,BSPICS,IOBits)		begin			Altdata <= (others => '0');			for i in 0 to IOWidth -1 loop 				case ThePinDesc(i)(15 downto 8) is -- GTag					-- all these nasty subranges will go away when pindescs are changed to records					when QCountTag => 						case (ThePinDesc(i)(7 downto 0)) is	--secondary pin function							when QCountQAPin =>								QuadA(conv_integer(ThePinDesc(i)(23 downto 16))) <= IOBits(i); 							when QCountQBPin =>								QuadB(conv_integer(ThePinDesc(i)(23 downto 16))) <= IOBits(i);							when QCountIdxPin =>								Index(conv_integer(ThePinDesc(i)(23 downto 16))) <= IOBits(i);							when QCountIdxMaskPin =>								IndexMask(conv_integer(ThePinDesc(i)(23 downto 16))) <= IOBits(i);							when others => null;						end case;					when MuxedQCountTag => 						case (ThePinDesc(i)(7 downto 0)) is	--secondary pin function							when MuxedQCountQAPin =>								MuxedQuadA(conv_integer(ThePinDesc(i)(23 downto 16))) <= IOBits(i); 							when MuxedQCountQBPin =>								MuxedQuadB(conv_integer(ThePinDesc(i)(23 downto 16))) <= IOBits(i);							when MuxedQCountIdxPin =>								MuxedIndex(conv_integer(ThePinDesc(i)(23 downto 16))) <= IOBits(i);							when MuxedQCountIdxMaskPin =>								MuxedIndexMask(conv_integer(ThePinDesc(i)(23 downto 16))) <= IOBits(i);							when others => null;						end case;					when MuxedQCountSelTag =>						case(ThePinDesc(i)(7 downto 0)) is	--secondary pin function							when MuxedQCountSel0Pin =>								AltData(i) <= MuxedQCtrSel(0);							when MuxedQCountSel1Pin =>								AltData(i) <= MuxedQCtrSel(1);							when others => null;						end case;										when PWMTag =>						case (ThePinDesc(i)(7 downto 0)) is	--secondary pin function							when PWMAOutPin =>								AltData(i) <= PWMGENOutA(conv_integer(ThePinDesc(i)(23 downto 16))); 							when PWMBDirPin =>								AltData(i) <= PWMGENOutB(conv_integer(ThePinDesc(i)(23 downto 16))); 							when PWMCEnaPin =>								AltData(i) <= PWMGENOutC(conv_integer(ThePinDesc(i)(23 downto 16))); 							when others => null;						end case;											when StepGenTag =>												AltData(i) <= StepGenOut(conv_integer(ThePinDesc(i)(23 downto 16)))(conv_integer(ThePinDesc(i)(6 downto 0))-1);											when UARTTTag =>						case (ThePinDesc(i)(7 downto 0)) is	--secondary pin function							when UTDataPin =>								AltData(i) <= UTData(conv_integer(ThePinDesc(i)(23 downto 16)));											when UTDrvEnPin =>								AltData(i) <= UTDrvEn(conv_integer(ThePinDesc(i)(23 downto 16)));								when others => null;														end case;											when UARTRTag =>						if (ThePinDesc(i)(7 downto 0)) = URDataPin then							URData(conv_integer(ThePinDesc(i)(23 downto 16))) <= IOBits(i);						end if;											when SPITag =>						case (ThePinDesc(i)(7 downto 0)) is	--secondary pin function, drop MSB							when SPIFramePin =>								AltData(i) <= SPIFrame(conv_integer(ThePinDesc(i)(23 downto 16)));											when SPIOutPin =>								AltData(i) <= SPIOut(conv_integer(ThePinDesc(i)(23 downto 16)));											when SPIClkPin =>								AltData(i) <= SPIClk(conv_integer(ThePinDesc(i)(23 downto 16)));											when SPIInPin =>										SPIIn(conv_integer(ThePinDesc(i)(23 downto 16))) <= IOBits(i);							when others => null;						end case;											when BSPITag =>						case (ThePinDesc(i)(7 downto 0)) is	--secondary pin function, drop MSB							when BSPIFramePin =>								AltData(i) <= BSPIFrame(conv_integer(ThePinDesc(i)(23 downto 16)));											when BSPIOutPin =>								AltData(i) <= BSPIOut(conv_integer(ThePinDesc(i)(23 downto 16)));											when BSPIClkPin =>								AltData(i) <= BSPIClk(conv_integer(ThePinDesc(i)(23 downto 16)));											when BSPIInPin =>										BSPIIn(conv_integer(ThePinDesc(i)(23 downto 16))) <= IOBits(i);							when others => AltData(i) <= BSPICS(conv_integer(ThePinDesc(i)(23 downto 16)))(conv_integer(ThePinDesc(i)(6 downto 0))-5);							-- magic foo, magic foo, what on earth does it do?													-- (this needs to written more clearly!)													end case;--					when SSITag =>  not done										when others => null;						end case;				end loop;				end process;					   LooseEnds: process(A,clklow)	begin		if rising_edge(clklow) then			A <= addr;		end if;	end process;   MuxedEnc: if  MuxedQCounters > 0 generate			EncoderDeMux: process(clklow)		begin			if rising_edge(clklow) then				if MuxedQCountFilterRate = '1' then					PreMuxedQCtrSel <= PreMuxedQCtrSel + 1;				end if;				MuxedQCtrSel <= PreMuxedQCtrSel;				for i in 0 to ((MuxedQCounters/2) -1) loop -- just 2 deep for now					if PreMuxedQCtrSel(0) = '1' and MuxedQCtrSel(0) = '0' then	-- latch the even inputs							DeMuxedQuadA(2*i) <= MuxedQuadA(i);						DeMuxedQuadB(2*i) <= MuxedQuadB(i);						DeMuxedIndex(2*i) <= MuxedIndex(i);						DeMuxedIndexMask(2*i) <= MuxedIndexMask(i);					end if;					if PreMuxedQCtrSel(0) = '0' and MuxedQCtrSel(0) = '1' then	-- latch the odd inputs						DeMuxedQuadA(2*i+1) <= MuxedQuadA(i);						DeMuxedQuadB(2*i+1) <= MuxedQuadB(i);						DeMuxedIndex(2*i+1) <= MuxedIndex(i);						DeMuxedIndexMask(2*i+1) <= MuxedIndexMask(i);					end if;				end loop;			end if; -- clk		end process;	end generate;						Decode: process(A,write, IDROMWEn, read) 	begin			-- basic multi decodes are at 256 byte increments (64 longs)		-- first decode is 256 x 32 ID ROM		if (A(15 downto 10) = IDROMAddr(7 downto 2)) and Write = '1' and IDROMWEn = "1" then	 -- 400 Hex  			LoadIDROM <= '1';		else			LoadIDROM <= '0';		end if;		if (A(15 downto 10) = IDROMAddr(7 downto 2)) and Read = '1' then	 --  			ReadIDROM <= '1';		else			ReadIDROM <= '0';		end if;		if A(15 downto 8) = PortAddr then  -- basic I/O port select			PortSel <= '1';		else			PortSel <= '0';		end if;		if A(15 downto 8) = DDRAddr then	 -- DDR register select			DDRSel <= '1';		else			DDRSel <= '0';		end if;		if A(15 downto 8) = AltDataSrcAddr then  -- Alt data source register select			AltDataSrcSel <= '1';		else			AltDataSrcSel <= '0';		end if;		if A(15 downto 8) = OpenDrainModeAddr then	 --  OpenDrain  register select			OpendrainModeSel <= '1';		else			OpenDrainModeSel <= '0';		end if;		if A(15 downto 8) = OutputInvAddr then	 --  IO invert register select			OutputInvSel <= '1';		else			OutputInvSel <= '0';		end if;		if A(15 downto 8) = StepGenRateAddr then	 --  stepgen rate register select			StepGenRateSel <= '1';		else			StepGenRateSel <= '0';		end if;		if A(15 downto 8) = StepGenAccumAddr then	 --  stepgen Accumumlator low select			StepGenAccumSel <= '1';		else			StepGenAccumSel <= '0';		end if;		if A(15 downto 8) = StepGenModeAddr then	 --  stepgen mode register select			StepGenModeSel <= '1';		else			StepGenModeSel <= '0';		end if;		if A(15 downto 8) = StepGenDSUTimeAddr then	 --  stepgen Dir setup time register select			StepGenDSUTimeSel <= '1';		else			StepGenDSUTimeSel <= '0';		end if;		if A(15 downto 8) =StepGenDHLDTimeAddr then	 --  stepgen Dir hold time register select			StepGenDHLDTimeSel <= '1';		else			StepGenDHLDTimeSel <= '0';		end if;		if A(15 downto 8) = StepGenPulseATimeAddr then	 --  stepgen pulse width register select			StepGenPulseATimeSel <= '1';		else			StepGenPulseATimeSel <= '0';		end if;		if A(15 downto 8) = StepGenPulseITimeAddr then	 --  stepgen pulse width register select			StepGenPulseITimeSel <= '1';		else			StepGenPulseITimeSel <= '0';		end if;		if A(15 downto 8) = StepGenTableAddr then	 --  stepgen pulse width register select			StepGenTableSel <= '1';		else			StepGenTableSel <= '0';		end if;			if A(15 downto 8) = StepGenTableMaxAddr then	 --  stepgen pulse width register select			StepGenTableMaxSel <= '1';		else			StepGenTableMaxSel <= '0';		end if;		if A(15 downto 8) = QCounterAddr then	 --  QCounter select			QCounterSel <= '1';		else			QCounterSel <= '0';		end if;		if A(15 downto 8) = QCounterCCRAddr then	 --  QCounter CCR register select			QCounterCCRSel <= '1';		else			QCounterCCRSel <= '0';		end if;		if A(15 downto 8) = MuxedQCounterAddr then	 --  QCounter select			MuxedQCounterSel <= '1';		else			MuxedQCounterSel <= '0';		end if;		if A(15 downto 8) = QCounterCCRAddr then	 --  QCounter CCR register select			MuxedQCounterCCRSel <= '1';		else			MuxedQCounterCCRSel <= '0';		end if;		if A(15 downto 8) = PWMValAddr then	 --  PWMVal select			PWMValSel <= '1';		else			PWMValSel <= '0';		end if;		if A(15 downto 8) = PWMCRAddr then	 --  PWM mode register select

⌨️ 快捷键说明

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