source: PROJECT_CORE_MPI/MPI_HCL/TRUNK/CORE_MPI/SetBit.vhd.bak @ 100

Last change on this file since 100 was 100, checked in by rolagamo, 10 years ago
File size: 4.3 KB
Line 
1----------------------------------------------------------------------------------
2-- Company:
3-- Engineer:
4--
5-- Create Date:    20:30:11 08/01/2013
6-- Design Name:
7-- Module Name:    SetBit - 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;
22Library NocLib;
23use NoCLib.CoreTypes.all;
24--use work.packet_type.all;
25-- Uncomment the following library declaration if using
26-- arithmetic functions with Signed or Unsigned values
27--use IEEE.NUMERIC_STD.ALL;
28
29-- Uncomment the following library declaration if instantiating
30-- any Xilinx primitives in this code.
31--library UNISIM;
32--use UNISIM.VComponents.all;
33
34entity SetBit is
35    Port ( clk : in  STD_LOGIC;
36           reset : in  STD_LOGIC;
37                          BitMask : in std_logic_vector(Word-1 downto 0);
38                          BitVal : in std_logic;
39                          whole : in std_logic;                   
40                          dma_wr_grant : in  STD_LOGIC;
41                                dma_wr_request : out  STD_LOGIC;
42                                dma_rd_grant : in  STD_LOGIC;
43                                dma_rd_request : out  STD_LOGIC;
44                                ram_rd : out std_logic;
45                                ram_wr : out std_logic;
46                                start : in std_logic;
47                                done :  out std_logic;
48                                ram_address : in std_logic_vector(ADRLEN-1 downto 0);--accès au stockage
49                                Ram_data_in : out STD_LOGIC_VECTOR (Word-1 downto 0);
50                                Ram_data_out : in STD_LOGIC_VECTOR (Word-1 downto 0));
51end SetBit;
52
53architecture Behavioral of SetBit is
54signal State,Next_State:natural range 0 to 15 :=0;
55signal dma_rd,dma_wr,rd_ok ,wr_ok:std_logic:='0';
56signal tempval,tempval_i : std_logic_vector(Word-1 downto 0):=(others=>'1');
57begin
58PSetBit_sync:process(clk,reset)
59
60begin
61if rising_edge(clk) then
62if reset='1' then
63        State<=0;
64        Tempval<=(others=>'0');
65else
66  State<=Next_State;
67  Tempval<=tempval_i;
68end if;
69end if;
70end process;
71
72PSetBit:process (State,tempval,Start,whole,BitMask,BitVal,Dma_rd_grant,Dma_wr_grant,ram_data_out)
73  begin
74    Next_State<=State;
75
76    tempval_i<=tempval;
77         wr_ok<='0';
78         rd_ok<='0';
79if State >0  then     
80                       
81                dma_wr<='1';  --demander un accès exclusif au bus
82                dma_rd<='1'; -- pour éviter une mauvaise mise à jour des données
83        else
84                dma_wr<='0';                                                                           
85                dma_rd<='0';
86        end if;
87case State is
88when 0 =>Ram_data_in<=tempval;
89  rd_ok<='0';
90                Wr_ok<='0';
91                done<='0';
92        if  start='1' and whole='1' then
93         Next_State<=5;
94         wr_ok<='1';
95         ram_data_in<=bitmask;
96         elsif start='1' then
97                Next_State<=State+1;
98                end if;
99               
100when 1=>        Ram_data_in<=tempval;
101                if dma_rd_grant='1' then
102                Next_State<=State+1;
103               
104                end if;
105                rd_ok<='1';
106                wr_ok<='0';
107                done<='0';
108        When 2|3=>Ram_data_in<=Ram_data_out;
109                if dma_rd_grant='1' then --cycle d'attente
110                        Next_State<=State+1;
111                else
112                  Next_State<=1; --recommencer l'attente si perte de priorité
113                end if;
114                        rd_ok<='1';
115                        wr_ok<='0';
116                        done<='0';
117        When 4 =>
118                        Ram_data_in<=ram_data_out;
119                        done<='0';
120                        rd_ok<='1';
121                        if dma_rd_grant='1' and dma_wr_grant='1' then
122                                Next_State<=5;
123                                --tempval<=Ram_data_out;
124--                              if bitval='1' then
125--                                      tempval<= Ram_data_out or BitMask;     
126--                              else
127--                                      tempval<= Ram_data_out and not (BitMask);
128--                              end if;
129                                if whole='1' then
130                                  --ram_data_in<=bitmask;
131                                  tempval_i<=  BitMask;
132                                 else
133                                 if bitval='1' then
134                                        --ram_data_in<=Ram_data_out or BitMask;
135                                        tempval_i<= Ram_data_out or BitMask;
136                                  else
137                                        --Ram_data_in<=Ram_data_out and not (BitMask);
138                                        tempval_i<= Ram_data_out and not (BitMask);
139                                  end if;
140                                end if;
141                                rd_ok<='1';
142                                wr_ok<='1';
143                        else
144                          Next_State<=State;
145                          report "SetBit:Impossible d'avoir accès en R/W à la RAM";
146                        end if;
147        When 5 |6 =>
148        Ram_data_in<=tempval;
149          if dma_wr_grant='1' then
150               if whole='1' then
151                                    ram_data_in<=bitmask;
152                                 else
153                                    ram_data_in<=tempval;
154                                end if;
155                                Next_State<=State+1;
156                else
157                    Next_state<=5;
158                end if;
159                wr_ok<='1';
160                rd_ok<='1';
161                done<='0';
162        When 7=>
163                done<='1';
164                if start='0' then
165                Next_State<=0;
166            wr_ok<='0';
167                end if;
168                rd_ok<='0';
169                wr_ok<='0';
170                Ram_data_in<=tempval;
171        When others =>
172          Next_State<=0;
173          rd_ok<='0';
174                wr_ok<='0';
175                done<='0';
176                Ram_data_in<=tempval;
177end case;
178
179end process PSetBit;
180dma_rd_request <= dma_rd;
181dma_wr_request <=dma_wr;
182Ram_wr<=wr_ok;
183Ram_rd<=rd_ok;
184--Ram_data_out<=data_to_ram;
185 
186end Behavioral;
187
Note: See TracBrowser for help on using the repository browser.