- Timestamp:
- 08/11/10 09:01:09 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
FPGA/FTU/FTU_top.vhd
r268 r9827 19 19 -- 20 20 ---------------------------------------------------------------------------------- 21 21 22 library IEEE; 22 23 use IEEE.STD_LOGIC_1164.ALL; 23 24 use IEEE.STD_LOGIC_ARITH.ALL; 24 25 use IEEE.STD_LOGIC_UNSIGNED.ALL; 26 25 27 library ftu_definitions; 26 28 USE ftu_definitions.ftu_array_types.all; … … 83 85 84 86 signal clk_50M_sig : STD_LOGIC; -- generated by internal DCM 85 signal clk_ready_sig : STD_LOGIC := '0'; -- set high by FTU_clk_gen when DCMs have locked 86 87 signal ram_wea_sig : STD_LOGIC_VECTOR(0 downto 0) := "0"; -- RAM write enable for port A 88 signal ram_web_sig : STD_LOGIC_VECTOR(0 downto 0) := "0"; -- RAM write enable for port B 89 signal ram_ada_cntr : INTEGER range 0 to 2**5 - 1 := 0; 90 signal ram_adb_cntr : INTEGER range 0 to 2**4 - 1 := 0; 91 signal ram_ada_sig : STD_LOGIC_VECTOR(4 downto 0); 92 signal ram_adb_sig : STD_LOGIC_VECTOR(3 downto 0); 93 signal ram_dia_sig : STD_LOGIC_VECTOR(7 downto 0); 94 signal ram_dib_sig : STD_LOGIC_VECTOR(15 downto 0); 95 signal ram_doa_sig : STD_LOGIC_VECTOR(7 downto 0); 96 signal ram_dob_sig : STD_LOGIC_VECTOR(15 downto 0); 97 98 type FTU_top_StateType is (IDLE, INIT, RUNNING, RESET); 99 signal FTU_top_State, FTU_top_NextState: FTU_top_StateType; 100 87 signal clk_ready_sig : STD_LOGIC := '0'; -- set high by FTU_clk_gen when DCMs have locked 88 89 --signal ram_wea_sig : STD_LOGIC_VECTOR(0 downto 0) := "0"; -- RAM write enable for port A 90 --signal ram_web_sig : STD_LOGIC_VECTOR(0 downto 0) := "0"; -- RAM write enable for port B 91 --signal ram_ada_cntr : INTEGER range 0 to 2**5 - 1 := 0; 92 --signal ram_adb_cntr : INTEGER range 0 to 2**4 - 1 := 0; 93 --signal ram_ada_sig : STD_LOGIC_VECTOR(4 downto 0); 94 --signal ram_adb_sig : STD_LOGIC_VECTOR(3 downto 0); 95 --signal ram_dia_sig : STD_LOGIC_VECTOR(7 downto 0); 96 --signal ram_dib_sig : STD_LOGIC_VECTOR(15 downto 0); 97 --signal ram_doa_sig : STD_LOGIC_VECTOR(7 downto 0); 98 --signal ram_dob_sig : STD_LOGIC_VECTOR(15 downto 0); 99 101 100 component FTU_clk_gen 102 port 101 port( 103 102 clk : IN STD_LOGIC; 104 103 rst : IN STD_LOGIC; … … 108 107 end component; 109 108 109 component FTU_control 110 port( 111 clk_50MHz : IN std_logic; 112 clk_ready : IN std_logic; 113 config_ready : IN std_logic; 114 reset : OUT std_logic; 115 config_start : OUT std_logic 116 ); 117 end component; 118 110 119 component FTU_spi_interface 111 120 port( … … 121 130 end component; 122 131 123 component FTU_dual_port_ram124 port(125 clka : IN std_logic;126 ena : IN std_logic;127 wea : IN std_logic_VECTOR(0 downto 0);128 addra : IN std_logic_VECTOR(4 downto 0);129 dina : IN std_logic_VECTOR(7 downto 0);130 douta : OUT std_logic_VECTOR(7 downto 0);131 clkb : IN std_logic;132 enb : IN std_logic;133 web : IN std_logic_VECTOR(0 downto 0);134 addrb : IN std_logic_VECTOR(3 downto 0);135 dinb : IN std_logic_VECTOR(15 downto 0);136 doutb : OUT std_logic_VECTOR(15 downto 0)137 );138 end component;132 --component FTU_dual_port_ram 133 -- port( 134 -- clka : IN std_logic; 135 -- ena : IN std_logic; 136 -- wea : IN std_logic_VECTOR(0 downto 0); 137 -- addra : IN std_logic_VECTOR(4 downto 0); 138 -- dina : IN std_logic_VECTOR(7 downto 0); 139 -- douta : OUT std_logic_VECTOR(7 downto 0); 140 -- clkb : IN std_logic; 141 -- enb : IN std_logic; 142 -- web : IN std_logic_VECTOR(0 downto 0); 143 -- addrb : IN std_logic_VECTOR(3 downto 0); 144 -- dinb : IN std_logic_VECTOR(15 downto 0); 145 -- doutb : OUT std_logic_VECTOR(15 downto 0) 146 -- ); 147 --end component; 139 148 140 149 -- Synplicity black box declaration 141 attribute syn_black_box : boolean;142 attribute syn_black_box of FTU_dual_port_ram: component is true;150 --attribute syn_black_box : boolean; 151 --attribute syn_black_box of FTU_dual_port_ram: component is true; 143 152 144 153 begin … … 147 156 148 157 Inst_FTU_clk_gen : FTU_clk_gen 149 port map 158 port map( 150 159 clk => ext_clk, 151 160 rst => reset_sig, … … 154 163 ); 155 164 165 Inst_FTU_control : FTU_control 166 port map( 167 clk_50MHz => clk_50M_sig, 168 clk_ready => clk_ready_sig, 169 config_ready => config_ready_sig, 170 reset => reset_sig, 171 config_start => config_start_sig 172 ); 173 156 174 Inst_FTU_spi_interface : FTU_spi_interface 157 175 port map( … … 166 184 ); 167 185 168 Inst_FTU_dual_port_ram : FTU_dual_port_ram 169 port map( 170 clka => clk_50M_sig, 171 ena => '1', 172 wea => ram_wea_sig, 173 addra => ram_ada_sig, 174 dina => ram_dia_sig, 175 douta => ram_doa_sig, 176 clkb => clk_50M_sig, 177 enb => '1', 178 web => ram_web_sig, 179 addrb => ram_adb_sig, 180 dinb => ram_dib_sig, 181 doutb => ram_dob_sig 182 ); 183 184 --FTU main state machine (two-process implementation) 185 --sensitive to external clock 186 187 FTU_top_Registers: process (ext_clk) 188 begin 189 if Rising_edge(ext_clk) then 190 FTU_top_State <= FTU_top_NextState; 191 end if; 192 end process FTU_top_Registers; 193 194 FTU_top_C_logic: process (FTU_top_State, clk_ready_sig, config_ready_sig, ram_adb_cntr) 195 begin 196 FTU_top_NextState <= FTU_top_State; 197 case FTU_top_State is 198 when IDLE => -- wait for DMCs to lock 199 reset_sig <= '0'; 200 dac_clr_sig <= '1'; 201 config_start_sig <= '0'; 202 ram_web_sig <= "0"; 203 if (clk_ready_sig = '1') then 204 FTU_top_NextState <= RUNNING; 205 end if; 206 when INIT => -- load default config data to RAM 207 reset_sig <= '0'; 208 dac_clr_sig <= '1'; 209 config_start_sig <= '0'; 210 ram_web_sig <= "1"; 211 ram_adb_cntr <= ram_adb_cntr + 1; 212 ram_adb_sig <= conv_std_logic_vector(ram_adb_cntr, 4); 213 if (ram_adb_cntr < 4) then 214 ram_dib_sig <= DEFAULT_ENABLE(ram_adb_cntr); 215 FTU_top_NextState <= INIT; 216 elsif (ram_adb_cntr < 4 + 5) then 217 ram_dib_sig <= conv_std_logic_vector(DEFAULT_DAC(ram_adb_cntr - 4), 16); 218 FTU_top_NextState <= INIT; 219 elsif (ram_adb_cntr < 32) then 220 ram_dib_sig <= (others => '0'); 221 FTU_top_NextState <= INIT; 222 else 223 ram_adb_cntr <= 0; 224 ram_web_sig <= "0"; 225 FTU_top_NextState <= RUNNING; 226 end if; 227 when RUNNING => -- count triggers and react to commands 228 reset_sig <= '0'; 229 dac_clr_sig <= '1'; 230 config_start_sig <= '0'; 231 ram_web_sig <= "0"; 232 when RESET => -- reset/clear and start from scratch 233 reset_sig <= '1'; 234 dac_clr_sig <= '0'; 235 config_start_sig <= '0'; 236 ram_web_sig <= "0"; 237 FTU_top_NextState <= IDLE; 238 end case; 239 end process FTU_top_C_logic; 186 --Inst_FTU_dual_port_ram : FTU_dual_port_ram 187 -- port map( 188 -- clka => clk_50M_sig, 189 -- ena => '1', 190 -- wea => ram_wea_sig, 191 -- addra => ram_ada_sig, 192 -- dina => ram_dia_sig, 193 -- douta => ram_doa_sig, 194 -- clkb => clk_50M_sig, 195 -- enb => '1', 196 -- web => ram_web_sig, 197 -- addrb => ram_adb_sig, 198 -- dinb => ram_dib_sig, 199 -- doutb => ram_dob_sig 200 -- ); 240 201 241 202 end Behavioral;
Note:
See TracChangeset
for help on using the changeset viewer.