source: PROJECT_CORE_MPI/CORE_MPI/BRANCHES/v1.00/SetBit.vhd @ 76

Last change on this file since 76 was 76, checked in by rolagamo, 10 years ago
File size: 3.7 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 n,State,Next_State:natural range 0 to 15 :=0;
55signal dma_rd,dma_wr,rd_ok ,wr_ok:std_logic:='0';
56begin
57PSetBit_sync:process(clk,reset)
58
59begin
60if rising_edge(clk) then
61if reset='1' then
62        n<=0;
63        State<=0;
64else
65  State<=Next_State;
66end if;
67end if;
68end process;
69
70PSetBit:process (State,Start,whole,BitMask,BitVal,Dma_rd_grant,Dma_wr_grant,ram_data_out)
71  variable tempval : std_logic_vector(Word-1 downto 0);
72  begin
73    Next_State<=State;
74
75   
76if State >0  then     
77                       
78                dma_wr<='1';  --demander un accès exclusif au bus
79                dma_rd<='1'; -- pour éviter une mauvaise mise à jour des données
80        else
81                dma_wr<='0';                                                                           
82                dma_rd<='0';
83        end if;
84case State is
85when 0 =>
86  rd_ok<='0';
87                Wr_ok<='0';
88                done<='0';
89        if  start='1' and whole='1' then
90         Next_State<=5;
91         wr_ok<='1';
92         ram_data_in<=bitmask;
93         elsif start='1' then
94                Next_State<=State+1;
95                end if;
96               
97when 1=>        if dma_rd_grant='1' then
98                Next_State<=State+1;
99               
100                end if;
101                rd_ok<='1';
102                wr_ok<='0';
103                done<='0';
104        When 2|3=>
105                if dma_rd_grant='1' then --cycle d'attente
106                        Next_State<=State+1;
107                else
108                  Next_State<=1; --recommencer l'attente si perte de priorité
109                end if;
110                        rd_ok<='1';
111                        wr_ok<='0';
112                        done<='0';
113        When 4 =>
114                        if dma_rd_grant='1' and dma_wr_grant='1' then
115                                Next_State<=6;
116                                tempval:=Ram_data_out;
117                                if bitval='1' then 
118                                        tempval:= tempval or BitMask;   
119                                else
120                                        tempval:= tempval and not (BitMask);
121                                end if;
122                                if whole='1' then
123                                  ram_data_in<=bitmask;
124                                 else
125                                  ram_data_in<=tempval;
126                                end if;
127                                rd_ok<='1';
128                                wr_ok<='1';
129                        else
130                          Next_State<=State;
131                          report "SetBit:Impossible d'avoir accès en R/W à la RAM";
132                        end if;
133        When 5 =>
134          if dma_wr_grant='1' then
135               if whole='1' then
136                                    ram_data_in<=bitmask;
137                                 else
138                                    ram_data_in<=tempval;
139                                end if;
140                                Next_State<=6;
141                end if;
142                wr_ok<='1';
143        When 6=>
144                done<='1';
145                if start='0' then
146                Next_State<=0;
147            wr_ok<='0'; 
148                end if;
149                rd_ok<='0';
150                wr_ok<='1';
151        When others =>
152          Next_State<=0;
153          rd_ok<='0';
154                wr_ok<='0';
155                done<='0';
156end case;
157
158end process PSetBit;
159dma_rd_request <= dma_rd;
160dma_wr_request <=dma_wr;
161Ram_wr<=wr_ok;
162Ram_rd<=rd_ok;
163--Ram_data_out<=data_to_ram;
164 
165end Behavioral;
166
Note: See TracBrowser for help on using the repository browser.