source: PROJECT_CORE_MPI/MPI_HCL/TRUNK/Ex5_FSM.vhd @ 96

Last change on this file since 96 was 96, checked in by rolagamo, 10 years ago
File size: 3.7 KB
Line 
1----------------------------------------------------------------------------------
2-- Company:
3-- Engineer:
4--
5-- Create Date:    14:00:24 08/01/2013
6-- Design Name:
7-- Module Name:    Ex5_FSM - Behavioral
8-- Project Name:
9-- Target Devices:
10-- Tool versions:
11-- Description:
12--
13-- Dependencies:
14--
15-- Revision:
16-- Revision 0.01 - File Created
17-- Additional Comments:
18--
19----------------------------------------------------------------------------------
20library IEEE;
21use IEEE.STD_LOGIC_1164.ALL;
22
23-- Uncomment the following library declaration if using
24-- arithmetic functions with Signed or Unsigned values
25--use IEEE.NUMERIC_STD.ALL;
26
27-- Uncomment the following library declaration if instantiating
28-- any Xilinx primitives in this code.
29--library UNISIM;
30--use UNISIM.VComponents.all;
31
32entity Ex5_FSM is
33    Port ( clk : in  STD_LOGIC;
34           reset : in  STD_LOGIC;
35                               
36                          SpawnOn : in  STD_LOGIC;
37           NocPortFree : in  STD_LOGIC;
38           InterCSet : in  STD_LOGIC;
39           TaskLoaded : in  STD_LOGIC;
40           TaskInit : in  STD_LOGIC;
41           TaskOn : in  STD_LOGIC;
42           TimeOut : out  STD_LOGIC;
43           DataReceived : in  STD_LOGIC_VECTOR (7 downto 0);
44           DataToSend : out  STD_LOGIC_VECTOR (7 downto 0));
45end Ex5_FSM;
46
47architecture Behavioral of Ex5_FSM is
48type Spawn_type is (Init,CheckFree,LoadTask,CountTask,StartTask,WaitTaskInit,SetGroup,SetInterCom,RetInterCom,ErrSpawn,EndSpawn); 
49   signal spawn_st, next_spawn : spawn_type; 
50begin
51--Insert the following in the architecture after the begin keyword
52   SYNC_spawn: process (clk)
53   begin
54      if (clk'event and clk = '1') then
55         if (reset = '1') then
56            spawn_st <= init;
57           
58         else
59           spawn_st <= next_spawn;
60            --<output> <= <output>_i;
61         -- assign other outputs to internal signals
62         end if;       
63      end if;
64   end process;
65 
66   --MOORE State-Machine - Outputs based on state only
67   OUTPUT_DECODE: process (Spawn_st)
68   begin
69      --insert statements to decode internal output signals
70      --below is simple example
71      case (spawn_st) is
72         when init =>
73           
74         when CheckFree =>
75           
76         when LoadTask =>
77           
78                        when StartTask =>
79                       
80                        when CountTask =>               
81                       
82                         when WaitAllTaskInit =>
83                         
84                         when SetGroup =>
85                         
86                         when SetInterCom =>
87                         
88                         when RetInterCom =>
89                         
90                         when EndSpawn =>
91                         
92         when others =>
93           
94      end case;     
95   end process;
96 
97   NEXT_STATE_DECODE: process (spawn_st, spawnOn,Datareceived)
98   begin
99      --declare default state for next_state to avoid latches
100      next_spawn <= spawn_st;  --default is to stay in current state
101      --insert statements to decode next_state
102      --below is a simple example
103      case (spawn_st) is
104         when init =>
105            if spawnOn = '1' then
106               next_spawn <= Checkfree;
107            end if;
108         when CheckFree =>
109            if NoCPortFree = '1' then
110               next_spawn<= LoadTask;
111            end if;
112         when LoadTask =>
113           next_spawn <= CountTask;
114                        when StartTask =>
115                                 if TaskInit = '1' then
116           next_spawn <= WaitAllTaskInit;
117                          end if;
118                         when WaitAllTaskInit =>
119                         if InterComSet = '1' then
120           next_spawn <= SetGroup;
121                         end if;
122                         when SetGroup =>
123                         if InterComSet = '1' then
124           next_spawn <= SetInterCom ;
125                         end if;
126                         when SetInterCom =>
127                         if InterComSet = '1' then
128           next_spawn <= RetInterCom ;
129                         end if;
130                         when RetInterCom =>
131                         if AppAck = '1' then
132                                next_spawn <= EndSpawn;
133                        end if;
134         when others =>
135            next_spawn <= init;
136      end case;     
137   end process;
138
139
140end Behavioral;
141
Note: See TracBrowser for help on using the repository browser.