Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ----------------------------------------------------------------------------------
- -- Company:
- -- Engineer:
- --
- -- Create Date: 23:36:39 12/12/2014
- -- Design Name:
- -- Module Name: MainModule - Behavioral
- -- Project Name:
- -- Target Devices:
- -- Tool versions:
- -- Description:
- --
- -- Dependencies:
- --
- -- Revision:
- -- Revision 0.01 - File Created
- -- Additional Comments:
- --
- ----------------------------------------------------------------------------------
- library IEEE;
- use IEEE.STD_LOGIC_1164.ALL;
- use IEEE.STD_LOGIC_UNSIGNED.ALL;
- -- Uncomment the following library declaration if using
- -- arithmetic functions with Signed or Unsigned values
- --use IEEE.NUMERIC_STD.ALL;
- -- Uncomment the following library declaration if instantiating
- -- any Xilinx primitives in this code.
- --library UNISIM;
- --use UNISIM.VComponents.all;
- entity MainModule is
- Port ( iCLK : in STD_LOGIC;
- inRST : in STD_LOGIC;
- iSEL : in STD_LOGIC_VECTOR (1 downto 0);
- iDURATION : in STD_LOGIC_VECTOR (7 downto 0);
- iSTART : in STD_LOGIC;
- o150W : out STD_LOGIC;
- o300W : out STD_LOGIC;
- o650W : out STD_LOGIC;
- o800W : out STD_LOGIC;
- oWARN : out STD_LOGIC);
- end MainModule;
- architecture Behavioral of MainModule is
- -- FSM
- type tSTATES is (IDLE, HEAT, WARNING);
- signal sSTATE: tSTATES;
- signal sWarn_EN: STD_LOGIC;
- signal sHeat_EN: STD_LOGIC;
- -- WarnCounter
- signal sWarnCNT: STD_LOGIC_VECTOR(2 downto 0);
- signal sWarnCNT_TC: STD_LOGIC;
- signal sWarnCNT_EN: STD_LOGIC;
- -- HeatCounter
- signal sHeatCNT: STD_LOGIC_VECTOR(7 downto 0);
- signal sHeatCNT_TC: STD_LOGIC;
- signal sHeatCNT_EN: STD_LOGIC;
- begin
- WarnCounter: process (iCLK, inRST) begin
- if (inRST = '0') then
- sWarnCNT <= (others => '0');
- sWarnCNT_TC <= '0';
- elsif (rising_edge(iCLK)) then
- if (sWarnCNT_EN = '1') then
- if (sWarnCNT = 7) then
- sWarnCNT_TC <= not sWarnCNT_TC;
- sWarnCNT <= (others => '0');
- else
- sWarnCNT <= sWarnCNT + 1;
- end if;
- end if;
- end if;
- end process;
- HeatCounter: process (iCLK, inRST) begin
- if (inRST = '0') then
- sHeatCNT <= (others => '0');
- sHeatCNT_TC <= '0';
- elsif (rising_edge(iCLK)) then
- if (sHeatCNT_EN = '1') then
- if (sHeatCNT = iDURATION - 1) then
- sHeatCNT_TC <= not sHeatCNT_TC;
- sHeatCNT <= (others => '0');
- else
- sHeatCNT <= sHeatCNT + 1;
- end if;
- end if;
- end if;
- end process;
- FSM: process (iCLK, inRST) begin
- if (inRST = '0') then
- sSTATE <= IDLE;
- sHeatCNT_EN <= '1';
- sWarnCNT_EN <= '1';
- elsif (rising_edge(iCLK)) then
- case (sSTATE) is
- when IDLE => sHeatCNT_EN <= '0';
- sWarnCNT_EN <= '0';
- sWarn_EN <= '0';
- sHeat_EN <= '0';
- if (iSTART = '1') then
- sSTATE <= HEAT;
- end if;
- when HEAT => sHeatCNT_EN <= '1';
- sWarnCNT_EN <= '0';
- sWarn_EN <= '1';
- sHeat_EN <= '0';
- if (sHeatCNT_TC = '1') then
- sSTATE <= WARNING;
- end if;
- when WARNING => sHeatCNT_EN <= '0';
- sWarnCNT_EN <= '1';
- sWarn_EN <= '0';
- sHeat_EN <= '1';
- if (sWarnCNT_TC = '1') then
- sSTATE <= IDLE;
- end if;
- end case;
- end if;
- end process;
- oWARN <= sWARN_EN;
- -- Demux
- o150W <= sHEAT_EN when iSEL = "00" else '0';
- o300W <= sHEAT_EN when iSEL = "01" else '0';
- o650W <= sHEAT_EN when iSEL = "10" else '0';
- o800W <= sHEAT_EN when iSEL = "11" else '0';
- end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement