用Max3032做了个HC595的串转并来扩充单片机的IO口,只做了8位,用掉24个宏单元,请教如何写才能减少宏单元的使用,这芯片总共就32个宏单位,我还想做成2个HC595级联的方式,估计是不够用了。
源程序VHDL语言如下:
-- Library Clause(s) (optional)
-- Use Clause(s) (optional)
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity MC_PLD is
port
(
-- Input ports
-- <name> : in <type>;
-- <name> : in <type> := <default_value>;
PL2303_DTR : in std_logic;
PL2303_RTS : in std_logic;
-- Inout ports
-- <name> : inout <type>;
-- Output ports
-- <name> : out <type>;
-- <name> : out <type> := <default_value>
MCU_RES : in std_logic;
MCU_P014 : in std_logic;
LED_O1 : out std_logic;
LED_O2 : out std_logic;
LED_O3 : out std_logic;
LED_O4 : out std_logic;
LED_O5 : out std_logic;
LED_O6 : out std_logic;
LED_O7 : out std_logic;
LED_O8 : out std_logic
);
end MC_PLD;
architecture MC_CTRL_ARCH of MC_PLD is
-- Declarations (optional)
signal HC595_DO1,HC595_DO2,HC595_DO3,HC595_DO4,HC595_DO5 ,HC595_DO6,HC595_DO7,HC595_DO8 :std_logic;
signal HC595_Shift_D0,HC595_Shift_D1,HC595_Shift_D2,HC595_Shift_D3,HC595_Shift_D4,HC595_Shift_D5,HC595_Shift_D6,HC595_Shift_D7 :std_logic;
begin
-- LED_O1 <= PL2303_DTR;
-- LED_O2 <= PL2303_RTS;
-- LED_O1 <= MCU_RES;
-- LED_O2 <= MCU_P014;
-- LED_O3 <= PL2303_DTR;
-- LED_O4 <= PL2303_RTS;
-- LED_O3 <= '1';
-- LED_O4 <= '1';
-- LED_O5 <= '1';
-- LED_O6 <= '1';
-- LED_O7 <= '1';
-- LED_O8 <= '1';
-- LED_O5 <= NOT(MCU_RES);
-- LED_O6 <= not(MCU_P014);
-- LED_O7 <= not(PL2303_DTR);
-- LED_O8 <= not(PL2303_RTS);
process(PL2303_DTR)
begin
if(PL2303_DTR 'event and pl2303_DTR = '1')then
-- if(MCU_RES 'event and MCU_RES = '1')then
HC595_Shift_D0 <= PL2303_RTS;
HC595_Shift_D1 <= HC595_Shift_D0;
HC595_Shift_D2 <= HC595_Shift_D1;
HC595_Shift_D3 <= HC595_Shift_D2;
HC595_Shift_D4 <= HC595_Shift_D3;
HC595_Shift_D5 <= HC595_Shift_D4;
HC595_Shift_D6 <= HC595_Shift_D5;
HC595_Shift_D7 <= HC595_Shift_D6;
end if;
end process;
process(MCU_RES)
begin
if(MCU_RES 'event and MCU_RES = '1')then
HC595_DO1 <= HC595_Shift_D0;
HC595_DO2 <= HC595_Shift_D1;
HC595_DO3 <= HC595_Shift_D2;
HC595_DO4 <= HC595_Shift_D3;
HC595_DO5 <= HC595_Shift_D4;
HC595_DO6 <= HC595_Shift_D5;
HC595_DO7 <= HC595_Shift_D6;
HC595_DO8 <= HC595_Shift_D7;
LED_O1 <= HC595_DO1;
LED_O2 <= HC595_DO2;
LED_O3 <= HC595_DO3;
LED_O4 <= HC595_DO4;
LED_O5 <= HC595_DO5;
LED_O6 <= HC595_DO6;
LED_O7 <= HC595_DO7;
LED_O8 <= HC595_DO8;
end if;
end process;
-- Process Statement (optional)
-- Concurrent Procedure Call (optional)
-- Concurrent Signal Assignment (optional)
-- Conditional Signal Assignment (optional)
-- Selected Signal Assignment (optional)
-- Component Instantiation Statement (optional)
-- Generate Statement (optional)
end MC_CTRL_ARCH; |