##// END OF EJS Templates
MINI LFR - WFP&MS - 0.1.7...
pellion -
r332:d5b2e267f44d (MINI-LFR) WFP_MS-0-1-7 JC
parent child
Show More
@@ -425,7 +425,7 BEGIN -- beh
425 pirq_ms => 6,
425 pirq_ms => 6,
426 pirq_wfp => 14,
426 pirq_wfp => 14,
427 hindex => 2,
427 hindex => 2,
428 top_lfr_version => X"000106") -- aa.bb.cc version
428 top_lfr_version => X"000107") -- aa.bb.cc version
429 PORT MAP (
429 PORT MAP (
430 clk => clk_25,
430 clk => clk_25,
431 rstn => reset,
431 rstn => reset,
@@ -150,10 +150,44 BEGIN -- beh
150 WAIT UNTIL clk25MHz = '1';
150 WAIT UNTIL clk25MHz = '1';
151 grspw_tick <= '0';
151 grspw_tick <= '0';
152
152
153
153 WAIT FOR 250 ms;
154
154 TB_string <= "READ 1 ";
155
155 apbi.psel(0) <= '1';
156 WAIT FOR 750 ms;
156 apbi.pwrite <= '0';
157 apbi.penable <= '1';
158 apbi.paddr <= X"00000008";
159 WAIT UNTIL clk25MHz = '1';
160 apbi.psel(0) <= '0';
161 apbi.pwrite <= '0';
162 apbi.penable <= '0';
163 apbi.paddr <= (OTHERS => '0');
164 WAIT UNTIL clk25MHz = '1';
165 WAIT FOR 250 ms;
166 TB_string <= "READ 2 ";
167 apbi.psel(0) <= '1';
168 apbi.pwrite <= '0';
169 apbi.penable <= '1';
170 apbi.paddr <= X"00000008";
171 WAIT UNTIL clk25MHz = '1';
172 apbi.psel(0) <= '0';
173 apbi.pwrite <= '0';
174 apbi.penable <= '0';
175 apbi.paddr <= (OTHERS => '0');
176 WAIT UNTIL clk25MHz = '1';
177 WAIT FOR 250 ms;
178 TB_string <= "READ 3 ";
179 apbi.psel(0) <= '1';
180 apbi.pwrite <= '0';
181 apbi.penable <= '1';
182 apbi.paddr <= X"00000008";
183 WAIT UNTIL clk25MHz = '1';
184 apbi.psel(0) <= '0';
185 apbi.pwrite <= '0';
186 apbi.penable <= '0';
187 apbi.paddr <= (OTHERS => '0');
188 WAIT UNTIL clk25MHz = '1';
189
190
157
191
158 REPORT "*** END simulation ***" SEVERITY failure;
192 REPORT "*** END simulation ***" SEVERITY failure;
159 WAIT;
193 WAIT;
@@ -161,6 +195,10 BEGIN -- beh
161 END PROCESS;
195 END PROCESS;
162
196
163
197
198 -----------------------------------------------------------------------------
199 --
200 -----------------------------------------------------------------------------
201
164 global_time <= coarse_time & fine_time;
202 global_time <= coarse_time & fine_time;
165
203
166 PROCESS (clk25MHz, resetn)
204 PROCESS (clk25MHz, resetn)
@@ -12,8 +12,11 add wave -noupdate /tb/apb_lfr_time_mana
12 add wave -noupdate -group OUTPUT /tb/apb_lfr_time_management_1/fine_time
12 add wave -noupdate -group OUTPUT /tb/apb_lfr_time_management_1/fine_time
13 add wave -noupdate -group OUTPUT /tb/apb_lfr_time_management_1/coarse_time
13 add wave -noupdate -group OUTPUT /tb/apb_lfr_time_management_1/coarse_time
14 add wave -noupdate /tb/apb_lfr_time_management_1/lfr_time_management_1/fine_time_new
14 add wave -noupdate /tb/apb_lfr_time_management_1/lfr_time_management_1/fine_time_new
15 add wave -noupdate -radix hexadecimal -expand -subitemconfig {/tb/apbi.psel {-radix hexadecimal} /tb/apbi.psel(0) {-radix hexadecimal} /tb/apbi.psel(1) {-radix hexadecimal} /tb/apbi.psel(2) {-radix hexadecimal} /tb/apbi.psel(3) {-radix hexadecimal} /tb/apbi.psel(4) {-radix hexadecimal} /tb/apbi.psel(5) {-radix hexadecimal} /tb/apbi.psel(6) {-radix hexadecimal} /tb/apbi.psel(7) {-radix hexadecimal} /tb/apbi.psel(8) {-radix hexadecimal} /tb/apbi.psel(9) {-radix hexadecimal} /tb/apbi.psel(10) {-radix hexadecimal} /tb/apbi.psel(11) {-radix hexadecimal} /tb/apbi.psel(12) {-radix hexadecimal} /tb/apbi.psel(13) {-radix hexadecimal} /tb/apbi.psel(14) {-radix hexadecimal} /tb/apbi.psel(15) {-radix hexadecimal} /tb/apbi.penable {-radix hexadecimal} /tb/apbi.paddr {-radix hexadecimal} /tb/apbi.pwrite {-radix hexadecimal} /tb/apbi.pwdata {-radix hexadecimal} /tb/apbi.pirq {-radix hexadecimal} /tb/apbi.testen {-radix hexadecimal} /tb/apbi.testrst {-radix hexadecimal} /tb/apbi.scanen {-radix hexadecimal} /tb/apbi.testoen {-radix hexadecimal} /tb/apbi.testin {-radix hexadecimal}} /tb/apbi
16 add wave -noupdate -radix hexadecimal -expand -subitemconfig {/tb/apbo.prdata {-radix hexadecimal} /tb/apbo.pirq {-radix hexadecimal} /tb/apbo.pconfig {-radix hexadecimal} /tb/apbo.pindex {-radix hexadecimal}} /tb/apbo
17 add wave -noupdate -radix hexadecimal -expand -subitemconfig {/tb/apb_lfr_time_management_1/r.ctrl {-radix hexadecimal} /tb/apb_lfr_time_management_1/r.coarse_time_load {-radix hexadecimal} /tb/apb_lfr_time_management_1/r.coarse_time {-radix hexadecimal} /tb/apb_lfr_time_management_1/r.fine_time {-radix hexadecimal}} /tb/apb_lfr_time_management_1/r
15 TreeUpdate [SetDefaultTree]
18 TreeUpdate [SetDefaultTree]
16 WaveRestoreCursors {{FT 1} {15279095 ps} 1} {{FT 1 + 1s} {1000012719095 ps} 1} {{Cursor 3} {369333380000 ps} 0} {TRANSITION {169333245705 ps} 1}
19 WaveRestoreCursors {{FT 1} {15279095 ps} 1} {{FT 1 + 1s} {1000012719095 ps} 1} {{Cursor 3} {750199620000 ps} 0} {TRANSITION {169333245705 ps} 1}
17 configure wave -namecolwidth 512
20 configure wave -namecolwidth 512
18 configure wave -valuecolwidth 139
21 configure wave -valuecolwidth 139
19 configure wave -justifyvalue left
22 configure wave -justifyvalue left
@@ -28,4 +31,4 configure wave -griddelta 40
28 configure wave -timeline 0
31 configure wave -timeline 0
29 configure wave -timelineunits ps
32 configure wave -timelineunits ps
30 update
33 update
31 WaveRestoreZoom {0 ps} {243152392641 ps}
34 WaveRestoreZoom {0 ps} {1185800469 ns}
@@ -131,6 +131,7 BEGIN
131 r.coarse_time_load <= apbi.pwdata(31 DOWNTO 0);
131 r.coarse_time_load <= apbi.pwdata(31 DOWNTO 0);
132 coarsetime_reg_updated <= '1';
132 coarsetime_reg_updated <= '1';
133 WHEN OTHERS =>
133 WHEN OTHERS =>
134 NULL;
134 END CASE;
135 END CASE;
135 ELSIF r.ctrl = '1' THEN
136 ELSIF r.ctrl = '1' THEN
136 r.ctrl <= '0';
137 r.ctrl <= '0';
@@ -140,16 +141,17 BEGIN
140 IF (apbi.psel(pindex) AND (NOT apbi.pwrite)) = '1' THEN
141 IF (apbi.psel(pindex) AND (NOT apbi.pwrite)) = '1' THEN
141 CASE apbi.paddr(7 DOWNTO 2) IS
142 CASE apbi.paddr(7 DOWNTO 2) IS
142 WHEN "000000" =>
143 WHEN "000000" =>
143 Rdata(0) <= r.ctrl;
144 Rdata(0) <= r.ctrl;
145 Rdata(31 DOWNTO 1) <= (others => '0');
144 WHEN "000001" =>
146 WHEN "000001" =>
145 Rdata(31 DOWNTO 0) <= r.coarse_time_load(31 DOWNTO 0);
147 Rdata(31 DOWNTO 0) <= r.coarse_time_load(31 DOWNTO 0);
146 WHEN "000010" =>
148 WHEN "000010" =>
147 Rdata(31 DOWNTO 0) <= r.coarse_time(31 DOWNTO 0);
149 Rdata(31 DOWNTO 0) <= r.coarse_time(31 DOWNTO 0);
148 WHEN "000011" =>
150 WHEN "000011" =>
149 Rdata(31 DOWNTO 16) <= (OTHERS => '0');
151 Rdata(31 DOWNTO 16) <= (OTHERS => '0');
150 Rdata(15 DOWNTO 0) <= r.fine_time(15 DOWNTO 0);
152 Rdata(15 DOWNTO 0) <= r.fine_time(15 DOWNTO 0);
151 WHEN OTHERS =>
153 WHEN OTHERS =>
152 Rdata(31 DOWNTO 0) <= x"00000000";
154 Rdata(31 DOWNTO 0) <= (others => '0');
153 END CASE;
155 END CASE;
154 END IF;
156 END IF;
155
157
@@ -271,4 +273,4 BEGIN
271 coarse_time => coarse_time_49,
273 coarse_time => coarse_time_49,
272 coarse_time_new => coarse_time_new_49);
274 coarse_time_new => coarse_time_new_49);
273
275
274 END Behavioral;
276 END Behavioral; No newline at end of file
This diff has been collapsed as it changes many lines, (825 lines changed) Show them Hide them
@@ -1,394 +1,431
1
1
2 ------------------------------------------------------------------------------
2 ------------------------------------------------------------------------------
3 -- This file is a part of the LPP VHDL IP LIBRARY
3 -- This file is a part of the LPP VHDL IP LIBRARY
4 -- Copyright (C) 2009 - 2010, Laboratory of Plasmas Physic - CNRS
4 -- Copyright (C) 2009 - 2010, Laboratory of Plasmas Physic - CNRS
5 --
5 --
6 -- This program is free software; you can redistribute it and/or modify
6 -- This program is free software; you can redistribute it and/or modify
7 -- it under the terms of the GNU General Public License as published by
7 -- it under the terms of the GNU General Public License as published by
8 -- the Free Software Foundation; either version 3 of the License, or
8 -- the Free Software Foundation; either version 3 of the License, or
9 -- (at your option) any later version.
9 -- (at your option) any later version.
10 --
10 --
11 -- This program is distributed in the hope that it will be useful,
11 -- This program is distributed in the hope that it will be useful,
12 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
13 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 -- GNU General Public License for more details.
14 -- GNU General Public License for more details.
15 --
15 --
16 -- You should have received a copy of the GNU General Public License
16 -- You should have received a copy of the GNU General Public License
17 -- along with this program; if not, write to the Free Software
17 -- along with this program; if not, write to the Free Software
18 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 -------------------------------------------------------------------------------
19 -------------------------------------------------------------------------------
20 -- Author : Jean-christophe Pellion
20 -- Author : Jean-christophe Pellion
21 -- Mail : jean-christophe.pellion@lpp.polytechnique.fr
21 -- Mail : jean-christophe.pellion@lpp.polytechnique.fr
22 -- jean-christophe.pellion@easii-ic.com
22 -- jean-christophe.pellion@easii-ic.com
23 -------------------------------------------------------------------------------
23 -------------------------------------------------------------------------------
24 -- 1.0 - initial version
24 -- 1.0 - initial version
25 -------------------------------------------------------------------------------
25 -------------------------------------------------------------------------------
26 LIBRARY ieee;
26 LIBRARY ieee;
27 USE ieee.std_logic_1164.ALL;
27 USE ieee.std_logic_1164.ALL;
28 USE ieee.numeric_std.ALL;
28 USE ieee.numeric_std.ALL;
29 LIBRARY grlib;
29 LIBRARY grlib;
30 USE grlib.amba.ALL;
30 USE grlib.amba.ALL;
31 USE grlib.stdlib.ALL;
31 USE grlib.stdlib.ALL;
32 USE grlib.devices.ALL;
32 USE grlib.devices.ALL;
33 USE GRLIB.DMA2AHB_Package.ALL;
33 USE GRLIB.DMA2AHB_Package.ALL;
34 LIBRARY lpp;
34 LIBRARY lpp;
35 USE lpp.lpp_amba.ALL;
35 USE lpp.lpp_amba.ALL;
36 USE lpp.apb_devices_list.ALL;
36 USE lpp.apb_devices_list.ALL;
37 USE lpp.lpp_memory.ALL;
37 USE lpp.lpp_memory.ALL;
38 USE lpp.lpp_dma_pkg.ALL;
38 USE lpp.lpp_dma_pkg.ALL;
39 LIBRARY techmap;
39 LIBRARY techmap;
40 USE techmap.gencomp.ALL;
40 USE techmap.gencomp.ALL;
41
41
42
42
43 ENTITY lpp_lfr_ms_fsmdma IS
43 ENTITY lpp_lfr_ms_fsmdma IS
44 PORT (
44 PORT (
45 -- AMBA AHB system signals
45 -- AMBA AHB system signals
46 HCLK : IN STD_ULOGIC;
46 HCLK : IN STD_ULOGIC;
47 HRESETn : IN STD_ULOGIC;
47 HRESETn : IN STD_ULOGIC;
48
48
49 --TIME
49 --TIME
50 data_time : IN STD_LOGIC_VECTOR(47 DOWNTO 0);
50 data_time : IN STD_LOGIC_VECTOR(47 DOWNTO 0);
51
51
52 -- fifo interface
52 -- fifo interface
53 fifo_data : IN STD_LOGIC_VECTOR(31 DOWNTO 0);
53 fifo_data : IN STD_LOGIC_VECTOR(31 DOWNTO 0);
54 fifo_empty : IN STD_LOGIC;
54 fifo_empty : IN STD_LOGIC;
55 fifo_ren : OUT STD_LOGIC;
55 fifo_ren : OUT STD_LOGIC;
56
56
57 -- header
57 -- header
58 header : IN STD_LOGIC_VECTOR(31 DOWNTO 0);
58 header : IN STD_LOGIC_VECTOR(31 DOWNTO 0);
59 header_val : IN STD_LOGIC;
59 header_val : IN STD_LOGIC;
60 header_ack : OUT STD_LOGIC;
60 header_ack : OUT STD_LOGIC;
61
61
62 -- DMA
62 -- DMA
63 dma_addr : OUT STD_LOGIC_VECTOR(31 DOWNTO 0);
63 dma_addr : OUT STD_LOGIC_VECTOR(31 DOWNTO 0);
64 dma_data : OUT STD_LOGIC_VECTOR(31 DOWNTO 0);
64 dma_data : OUT STD_LOGIC_VECTOR(31 DOWNTO 0);
65 dma_valid : OUT STD_LOGIC;
65 dma_valid : OUT STD_LOGIC;
66 dma_valid_burst : OUT STD_LOGIC;
66 dma_valid_burst : OUT STD_LOGIC;
67 dma_ren : IN STD_LOGIC;
67 dma_ren : IN STD_LOGIC;
68 dma_done : IN STD_LOGIC;
68 dma_done : IN STD_LOGIC;
69
69
70 -- Reg out
70 -- Reg out
71 ready_matrix_f0_0 : OUT STD_LOGIC;
71 ready_matrix_f0_0 : OUT STD_LOGIC;
72 ready_matrix_f0_1 : OUT STD_LOGIC;
72 ready_matrix_f0_1 : OUT STD_LOGIC;
73 ready_matrix_f1 : OUT STD_LOGIC;
73 ready_matrix_f1 : OUT STD_LOGIC;
74 ready_matrix_f2 : OUT STD_LOGIC;
74 ready_matrix_f2 : OUT STD_LOGIC;
75 error_anticipating_empty_fifo : OUT STD_LOGIC;
75 error_anticipating_empty_fifo : OUT STD_LOGIC;
76 error_bad_component_error : OUT STD_LOGIC;
76 error_bad_component_error : OUT STD_LOGIC;
77 debug_reg : OUT STD_LOGIC_VECTOR(31 DOWNTO 0);
77 debug_reg : OUT STD_LOGIC_VECTOR(31 DOWNTO 0);
78
78
79 -- Reg In
79 -- Reg In
80 status_ready_matrix_f0_0 : IN STD_LOGIC;
80 status_ready_matrix_f0_0 : IN STD_LOGIC;
81 status_ready_matrix_f0_1 : IN STD_LOGIC;
81 status_ready_matrix_f0_1 : IN STD_LOGIC;
82 status_ready_matrix_f1 : IN STD_LOGIC;
82 status_ready_matrix_f1 : IN STD_LOGIC;
83 status_ready_matrix_f2 : IN STD_LOGIC;
83 status_ready_matrix_f2 : IN STD_LOGIC;
84 status_error_anticipating_empty_fifo : IN STD_LOGIC;
84 status_error_anticipating_empty_fifo : IN STD_LOGIC;
85 status_error_bad_component_error : IN STD_LOGIC;
85 status_error_bad_component_error : IN STD_LOGIC;
86
86
87 config_active_interruption_onNewMatrix : IN STD_LOGIC;
87 config_active_interruption_onNewMatrix : IN STD_LOGIC;
88 config_active_interruption_onError : IN STD_LOGIC;
88 config_active_interruption_onError : IN STD_LOGIC;
89 addr_matrix_f0_0 : IN STD_LOGIC_VECTOR(31 DOWNTO 0);
89 addr_matrix_f0_0 : IN STD_LOGIC_VECTOR(31 DOWNTO 0);
90 addr_matrix_f0_1 : IN STD_LOGIC_VECTOR(31 DOWNTO 0);
90 addr_matrix_f0_1 : IN STD_LOGIC_VECTOR(31 DOWNTO 0);
91 addr_matrix_f1 : IN STD_LOGIC_VECTOR(31 DOWNTO 0);
91 addr_matrix_f1 : IN STD_LOGIC_VECTOR(31 DOWNTO 0);
92 addr_matrix_f2 : IN STD_LOGIC_VECTOR(31 DOWNTO 0);
92 addr_matrix_f2 : IN STD_LOGIC_VECTOR(31 DOWNTO 0);
93
93
94 matrix_time_f0_0 : OUT STD_LOGIC_VECTOR(47 DOWNTO 0);
94 matrix_time_f0_0 : OUT STD_LOGIC_VECTOR(47 DOWNTO 0);
95 matrix_time_f0_1 : OUT STD_LOGIC_VECTOR(47 DOWNTO 0);
95 matrix_time_f0_1 : OUT STD_LOGIC_VECTOR(47 DOWNTO 0);
96 matrix_time_f1 : OUT STD_LOGIC_VECTOR(47 DOWNTO 0);
96 matrix_time_f1 : OUT STD_LOGIC_VECTOR(47 DOWNTO 0);
97 matrix_time_f2 : OUT STD_LOGIC_VECTOR(47 DOWNTO 0)
97 matrix_time_f2 : OUT STD_LOGIC_VECTOR(47 DOWNTO 0)
98
98
99 );
99 );
100 END;
100 END;
101
101
102 ARCHITECTURE Behavioral OF lpp_lfr_ms_fsmdma IS
102 ARCHITECTURE Behavioral OF lpp_lfr_ms_fsmdma IS
103 -----------------------------------------------------------------------------
103 -----------------------------------------------------------------------------
104 -- SIGNAL DMAIn : DMA_In_Type;
104 -- SIGNAL DMAIn : DMA_In_Type;
105 -- SIGNAL header_dmai : DMA_In_Type;
105 -- SIGNAL header_dmai : DMA_In_Type;
106 -- SIGNAL component_dmai : DMA_In_Type;
106 -- SIGNAL component_dmai : DMA_In_Type;
107 -- SIGNAL DMAOut : DMA_OUt_Type;
107 -- SIGNAL DMAOut : DMA_OUt_Type;
108 -----------------------------------------------------------------------------
108 -----------------------------------------------------------------------------
109
109
110 -----------------------------------------------------------------------------
110 -----------------------------------------------------------------------------
111 -----------------------------------------------------------------------------
111 -----------------------------------------------------------------------------
112 TYPE state_DMAWriteBurst IS (IDLE,
112 TYPE state_DMAWriteBurst IS (IDLE,
113 CHECK_COMPONENT_TYPE,
113 CHECK_COMPONENT_TYPE,
114 WRITE_COARSE_TIME,
114 WRITE_COARSE_TIME,
115 WRITE_FINE_TIME,
115 WRITE_FINE_TIME,
116 TRASH_FIFO,
116 TRASH_FIFO,
117 SEND_DATA,
117 SEND_DATA,
118 WAIT_DATA_ACK
118 WAIT_DATA_ACK
119 );
119 );
120 SIGNAL state : state_DMAWriteBurst; -- := IDLE;
120 SIGNAL state : state_DMAWriteBurst; -- := IDLE;
121
121
122 -- SIGNAL nbSend : INTEGER;
122 -- SIGNAL nbSend : INTEGER;
123 SIGNAL matrix_type : STD_LOGIC_VECTOR(1 DOWNTO 0);
123 SIGNAL matrix_type : STD_LOGIC_VECTOR(1 DOWNTO 0);
124 SIGNAL component_type : STD_LOGIC_VECTOR(3 DOWNTO 0);
124 SIGNAL component_type : STD_LOGIC_VECTOR(3 DOWNTO 0);
125 SIGNAL component_type_pre : STD_LOGIC_VECTOR(3 DOWNTO 0);
125 SIGNAL component_type_pre : STD_LOGIC_VECTOR(3 DOWNTO 0);
126 SIGNAL header_check_ok : STD_LOGIC;
126 SIGNAL header_check_ok : STD_LOGIC;
127 SIGNAL address_matrix : STD_LOGIC_VECTOR(31 DOWNTO 0);
127 SIGNAL address_matrix : STD_LOGIC_VECTOR(31 DOWNTO 0);
128 SIGNAL send_matrix : STD_LOGIC;
128 SIGNAL send_matrix : STD_LOGIC;
129 -- SIGNAL request : STD_LOGIC;
129 -- SIGNAL request : STD_LOGIC;
130 -- SIGNAL remaining_data_request : INTEGER;
130 -- SIGNAL remaining_data_request : INTEGER;
131 SIGNAL Address : STD_LOGIC_VECTOR(31 DOWNTO 0);
131 SIGNAL Address : STD_LOGIC_VECTOR(31 DOWNTO 0);
132 -----------------------------------------------------------------------------
132 -----------------------------------------------------------------------------
133 -----------------------------------------------------------------------------
133 -----------------------------------------------------------------------------
134 SIGNAL header_select : STD_LOGIC;
134 SIGNAL header_select : STD_LOGIC;
135
135
136 SIGNAL header_send : STD_LOGIC;
136 SIGNAL header_send : STD_LOGIC;
137 SIGNAL header_data : STD_LOGIC_VECTOR(31 DOWNTO 0);
137 SIGNAL header_data : STD_LOGIC_VECTOR(31 DOWNTO 0);
138 SIGNAL header_send_ok : STD_LOGIC;
138 SIGNAL header_send_ok : STD_LOGIC;
139 SIGNAL header_send_ko : STD_LOGIC;
139 SIGNAL header_send_ko : STD_LOGIC;
140
140
141 SIGNAL component_send : STD_LOGIC;
141 SIGNAL component_send : STD_LOGIC;
142 SIGNAL component_send_ok : STD_LOGIC;
142 SIGNAL component_send_ok : STD_LOGIC;
143 SIGNAL component_send_ko : STD_LOGIC;
143 SIGNAL component_send_ko : STD_LOGIC;
144 -----------------------------------------------------------------------------
144 -----------------------------------------------------------------------------
145 SIGNAL fifo_ren_trash : STD_LOGIC;
145 SIGNAL fifo_ren_trash : STD_LOGIC;
146 SIGNAL component_fifo_ren : STD_LOGIC;
146 SIGNAL component_fifo_ren : STD_LOGIC;
147
147
148 -----------------------------------------------------------------------------
148 -----------------------------------------------------------------------------
149 SIGNAL debug_reg_s : STD_LOGIC_VECTOR(31 DOWNTO 0);
149 SIGNAL debug_reg_s : STD_LOGIC_VECTOR(31 DOWNTO 0);
150 SIGNAL fine_time_reg : STD_LOGIC_VECTOR(15 DOWNTO 0);
150 SIGNAL fine_time_reg : STD_LOGIC_VECTOR(15 DOWNTO 0);
151
151
152 -----------------------------------------------------------------------------
152 -----------------------------------------------------------------------------
153 SIGNAL log_empty_fifo : STD_LOGIC;
153 SIGNAL log_empty_fifo : STD_LOGIC;
154
154 -----------------------------------------------------------------------------
155 BEGIN
155 SIGNAL header_reg : STD_LOGIC_VECTOR(31 DOWNTO 0);
156
156 SIGNAL header_reg_val : STD_LOGIC;
157 debug_reg <= debug_reg_s;
157 SIGNAL header_reg_ack : STD_LOGIC;
158
158 SIGNAL header_error : STD_LOGIC;
159
159
160 send_matrix <= '1' WHEN matrix_type = "00" AND status_ready_matrix_f0_0 = '0' ELSE
160 BEGIN
161 '1' WHEN matrix_type = "01" AND status_ready_matrix_f0_1 = '0' ELSE
161
162 '1' WHEN matrix_type = "10" AND status_ready_matrix_f1 = '0' ELSE
162 debug_reg <= debug_reg_s;
163 '1' WHEN matrix_type = "11" AND status_ready_matrix_f2 = '0' ELSE
163
164 '0';
164
165
165 send_matrix <= '1' WHEN matrix_type = "00" AND status_ready_matrix_f0_0 = '0' ELSE
166 header_check_ok <= '0' WHEN component_type = "1111" ELSE -- ?? component_type_pre = "1111"
166 '1' WHEN matrix_type = "01" AND status_ready_matrix_f0_1 = '0' ELSE
167 '1' WHEN component_type = "0000" AND component_type_pre = "0000" ELSE
167 '1' WHEN matrix_type = "10" AND status_ready_matrix_f1 = '0' ELSE
168 '1' WHEN component_type = component_type_pre + "0001" ELSE
168 '1' WHEN matrix_type = "11" AND status_ready_matrix_f2 = '0' ELSE
169 '0';
169 '0';
170
170
171 address_matrix <= addr_matrix_f0_0 WHEN matrix_type = "00" ELSE
171 header_check_ok <= '0' WHEN component_type = "1111" ELSE -- ?? component_type_pre = "1111"
172 addr_matrix_f0_1 WHEN matrix_type = "01" ELSE
172 '1' WHEN component_type = "0000" AND component_type_pre = "0000" ELSE
173 addr_matrix_f1 WHEN matrix_type = "10" ELSE
173 '1' WHEN component_type = component_type_pre + "0001" ELSE
174 addr_matrix_f2 WHEN matrix_type = "11" ELSE
174 '0';
175 (OTHERS => '0');
175
176
176 address_matrix <= addr_matrix_f0_0 WHEN matrix_type = "00" ELSE
177 -----------------------------------------------------------------------------
177 addr_matrix_f0_1 WHEN matrix_type = "01" ELSE
178 -- DMA control
178 addr_matrix_f1 WHEN matrix_type = "10" ELSE
179 -----------------------------------------------------------------------------
179 addr_matrix_f2 WHEN matrix_type = "11" ELSE
180 DMAWriteFSM_p : PROCESS (HCLK, HRESETn)
180 (OTHERS => '0');
181 BEGIN -- PROCESS DMAWriteBurst_p
181
182 IF HRESETn = '0' THEN -- asynchronous reset (active low)
182 -----------------------------------------------------------------------------
183 matrix_type <= (OTHERS => '0');
183 -- DMA control
184 component_type <= (OTHERS => '0');
184 -----------------------------------------------------------------------------
185 state <= IDLE;
185 DMAWriteFSM_p : PROCESS (HCLK, HRESETn)
186 header_ack <= '0';
186 BEGIN -- PROCESS DMAWriteBurst_p
187 ready_matrix_f0_0 <= '0';
187 IF HRESETn = '0' THEN -- asynchronous reset (active low)
188 ready_matrix_f0_1 <= '0';
188 matrix_type <= (OTHERS => '0');
189 ready_matrix_f1 <= '0';
189 component_type <= (OTHERS => '0');
190 ready_matrix_f2 <= '0';
190 state <= IDLE;
191 error_anticipating_empty_fifo <= '0';
191 -- header_ack <= '0';
192 error_bad_component_error <= '0';
192 ready_matrix_f0_0 <= '0';
193 component_type_pre <= "0000";
193 ready_matrix_f0_1 <= '0';
194 fifo_ren_trash <= '1';
194 ready_matrix_f1 <= '0';
195 component_send <= '0';
195 ready_matrix_f2 <= '0';
196 address <= (OTHERS => '0');
196 error_anticipating_empty_fifo <= '0';
197 header_select <= '0';
197 error_bad_component_error <= '0';
198 header_send <= '0';
198 component_type_pre <= "0000";
199 header_data <= (OTHERS => '0');
199 fifo_ren_trash <= '1';
200 fine_time_reg <= (OTHERS => '0');
200 component_send <= '0';
201
201 address <= (OTHERS => '0');
202 debug_reg_s(31 DOWNTO 0) <= (OTHERS => '0');
202 header_select <= '0';
203
203 header_send <= '0';
204 log_empty_fifo <= '0';
204 header_data <= (OTHERS => '0');
205
205 fine_time_reg <= (OTHERS => '0');
206 ELSIF HCLK'EVENT AND HCLK = '1' THEN -- rising clock edge
206
207 debug_reg_s(31 DOWNTO 10) <= (OTHERS => '0');
207 debug_reg_s( 2 DOWNTO 0) <= (OTHERS => '0');
208
208 debug_reg_s(31 DOWNTO 4) <= (OTHERS => '0');
209 CASE state IS
209
210 WHEN IDLE =>
210 log_empty_fifo <= '0';
211 debug_reg_s(2 DOWNTO 0) <= "000";
211
212
212 ELSIF HCLK'EVENT AND HCLK = '1' THEN -- rising clock edge
213 matrix_type <= header(1 DOWNTO 0);
213 debug_reg_s(31 DOWNTO 10) <= (OTHERS => '0');
214 --component_type <= header(5 DOWNTO 2);
214 header_reg_ack <= '0';
215
215
216 ready_matrix_f0_0 <= '0';
216 CASE state IS
217 ready_matrix_f0_1 <= '0';
217 WHEN IDLE =>
218 ready_matrix_f1 <= '0';
218 debug_reg_s(2 DOWNTO 0) <= "000";
219 ready_matrix_f2 <= '0';
219
220 error_bad_component_error <= '0';
220 matrix_type <= header(1 DOWNTO 0);
221 header_select <= '1';
221 --component_type <= header(5 DOWNTO 2);
222 IF header_val = '1' THEN
222
223 header_ack <= '1';
223 ready_matrix_f0_0 <= '0';
224 END IF;
224 ready_matrix_f0_1 <= '0';
225 IF header_val = '1' AND fifo_empty = '0' AND send_matrix = '1' THEN
225 ready_matrix_f1 <= '0';
226 debug_reg_s(5 DOWNTO 4) <= header(1 DOWNTO 0);
226 ready_matrix_f2 <= '0';
227 debug_reg_s(9 DOWNTO 6) <= header(5 DOWNTO 2);
227 error_bad_component_error <= '0';
228
228 header_select <= '1';
229 matrix_type <= header(1 DOWNTO 0);
229
230 component_type <= header(5 DOWNTO 2);
230 IF header_reg_val = '1' AND fifo_empty = '0' AND send_matrix = '1' THEN
231 component_type_pre <= component_type;
231 header_reg_ack <= '1';
232 state <= CHECK_COMPONENT_TYPE;
232 debug_reg_s(5 DOWNTO 4) <= header_reg(1 DOWNTO 0);
233 END IF;
233 debug_reg_s(9 DOWNTO 6) <= header_reg(5 DOWNTO 2);
234 log_empty_fifo <= '0';
234
235
235 matrix_type <= header_reg(1 DOWNTO 0);
236 WHEN CHECK_COMPONENT_TYPE =>
236 component_type <= header_reg(5 DOWNTO 2);
237 debug_reg_s(2 DOWNTO 0) <= "001";
237 component_type_pre <= component_type;
238 header_ack <= '0';
238 state <= CHECK_COMPONENT_TYPE;
239
239 END IF;
240 IF header_check_ok = '1' THEN
240 log_empty_fifo <= '0';
241 header_send <= '0';
241
242 --
242 WHEN CHECK_COMPONENT_TYPE =>
243 IF component_type = "0000" THEN
243 debug_reg_s(2 DOWNTO 0) <= "001";
244 address <= address_matrix;
244 --header_ack <= '0';
245 CASE matrix_type IS
245
246 WHEN "00" => matrix_time_f0_0 <= data_time;
246 IF header_check_ok = '1' THEN
247 WHEN "01" => matrix_time_f0_1 <= data_time;
247 header_send <= '0';
248 WHEN "10" => matrix_time_f1 <= data_time;
248 --
249 WHEN "11" => matrix_time_f2 <= data_time ;
249 IF component_type = "0000" THEN
250 WHEN OTHERS => NULL;
250 address <= address_matrix;
251 END CASE;
251 CASE matrix_type IS
252
252 WHEN "00" => matrix_time_f0_0 <= data_time;
253 header_data <= data_time(31 DOWNTO 0);
253 WHEN "01" => matrix_time_f0_1 <= data_time;
254 fine_time_reg <= data_time(47 DOWNTO 32);
254 WHEN "10" => matrix_time_f1 <= data_time;
255 --state <= WRITE_COARSE_TIME;
255 WHEN "11" => matrix_time_f2 <= data_time ;
256 --header_send <= '1';
256 WHEN OTHERS => NULL;
257 state <= SEND_DATA;
257 END CASE;
258 header_send <= '0';
258
259 component_send <= '1';
259 header_data <= data_time(31 DOWNTO 0);
260 header_select <= '0';
260 fine_time_reg <= data_time(47 DOWNTO 32);
261 ELSE
261 --state <= WRITE_COARSE_TIME;
262 state <= SEND_DATA;
262 --header_send <= '1';
263 END IF;
263 state <= SEND_DATA;
264 --
264 header_send <= '0';
265 ELSE
265 component_send <= '1';
266 error_bad_component_error <= '1';
266 header_select <= '0';
267 component_type_pre <= "0000";
267 ELSE
268 state <= TRASH_FIFO;
268 state <= SEND_DATA;
269 END IF;
269 END IF;
270
270 --
271 --WHEN WRITE_COARSE_TIME =>
271 ELSE
272 -- debug_reg_s(2 DOWNTO 0) <= "010";
272 error_bad_component_error <= '1';
273
273 component_type_pre <= "0000";
274 -- header_ack <= '0';
274 state <= TRASH_FIFO;
275
275 END IF;
276 -- IF dma_ren = '0' THEN
276
277 -- header_send <= '0';
277 --WHEN WRITE_COARSE_TIME =>
278 -- ELSE
278 -- debug_reg_s(2 DOWNTO 0) <= "010";
279 -- header_send <= header_send;
279
280 -- END IF;
280 -- header_ack <= '0';
281
281
282
282 -- IF dma_ren = '0' THEN
283 -- IF header_send_ko = '1' THEN
283 -- header_send <= '0';
284 -- header_send <= '0';
284 -- ELSE
285 -- state <= TRASH_FIFO;
285 -- header_send <= header_send;
286 -- error_anticipating_empty_fifo <= '1';
286 -- END IF;
287 -- -- TODO : error sending header
287
288 -- ELSIF header_send_ok = '1' THEN
288
289 -- header_send <= '1';
289 -- IF header_send_ko = '1' THEN
290 -- header_select <= '1';
290 -- header_send <= '0';
291 -- header_data(15 DOWNTO 0) <= fine_time_reg;
291 -- state <= TRASH_FIFO;
292 -- header_data(31 DOWNTO 16) <= (OTHERS => '0');
292 -- error_anticipating_empty_fifo <= '1';
293 -- state <= WRITE_FINE_TIME;
293 -- -- TODO : error sending header
294 -- address <= address + 4;
294 -- ELSIF header_send_ok = '1' THEN
295 -- END IF;
295 -- header_send <= '1';
296
296 -- header_select <= '1';
297
297 -- header_data(15 DOWNTO 0) <= fine_time_reg;
298 --WHEN WRITE_FINE_TIME =>
298 -- header_data(31 DOWNTO 16) <= (OTHERS => '0');
299 -- debug_reg_s(2 DOWNTO 0) <= "011";
299 -- state <= WRITE_FINE_TIME;
300
300 -- address <= address + 4;
301 -- header_ack <= '0';
301 -- END IF;
302
302
303 -- IF dma_ren = '0' THEN
303
304 -- header_send <= '0';
304 --WHEN WRITE_FINE_TIME =>
305 -- ELSE
305 -- debug_reg_s(2 DOWNTO 0) <= "011";
306 -- header_send <= header_send;
306
307 -- END IF;
307 -- header_ack <= '0';
308
308
309 -- IF header_send_ko = '1' THEN
309 -- IF dma_ren = '0' THEN
310 -- header_send <= '0';
310 -- header_send <= '0';
311 -- state <= TRASH_FIFO;
311 -- ELSE
312 -- error_anticipating_empty_fifo <= '1';
312 -- header_send <= header_send;
313 -- -- TODO : error sending header
313 -- END IF;
314 -- ELSIF header_send_ok = '1' THEN
314
315 -- header_send <= '0';
315 -- IF header_send_ko = '1' THEN
316 -- header_select <= '0';
316 -- header_send <= '0';
317 -- state <= SEND_DATA;
317 -- state <= TRASH_FIFO;
318 -- address <= address + 4;
318 -- error_anticipating_empty_fifo <= '1';
319 -- END IF;
319 -- -- TODO : error sending header
320
320 -- ELSIF header_send_ok = '1' THEN
321 WHEN TRASH_FIFO =>
321 -- header_send <= '0';
322 debug_reg_s(2 DOWNTO 0) <= "100";
322 -- header_select <= '0';
323
323 -- state <= SEND_DATA;
324 header_ack <= '0';
324 -- address <= address + 4;
325 error_bad_component_error <= '0';
325 -- END IF;
326 error_anticipating_empty_fifo <= '0';
326
327 IF fifo_empty = '1' THEN
327 WHEN TRASH_FIFO =>
328 state <= IDLE;
328 debug_reg_s(2 DOWNTO 0) <= "100";
329 fifo_ren_trash <= '1';
329
330 ELSE
330 -- header_ack <= '0';
331 fifo_ren_trash <= '0';
331 error_bad_component_error <= '0';
332 END IF;
332 error_anticipating_empty_fifo <= '0';
333
333 IF fifo_empty = '1' THEN
334 WHEN SEND_DATA =>
334 state <= IDLE;
335 header_ack <= '0';
335 fifo_ren_trash <= '1';
336 debug_reg_s(2 DOWNTO 0) <= "101";
336 ELSE
337
337 fifo_ren_trash <= '0';
338 IF fifo_empty = '1' OR log_empty_fifo = '1' THEN
338 END IF;
339 state <= IDLE;
339
340 IF component_type = "1110" THEN --"1110" -- JC
340 WHEN SEND_DATA =>
341 CASE matrix_type IS
341 -- header_ack <= '0';
342 WHEN "00" => ready_matrix_f0_0 <= '1';
342 debug_reg_s(2 DOWNTO 0) <= "101";
343 WHEN "01" => ready_matrix_f0_1 <= '1';
343
344 WHEN "10" => ready_matrix_f1 <= '1';
344 IF fifo_empty = '1' OR log_empty_fifo = '1' THEN
345 WHEN "11" => ready_matrix_f2 <= '1';
345 state <= IDLE;
346 WHEN OTHERS => NULL;
346 IF component_type = "1110" THEN --"1110" -- JC
347 END CASE;
347 CASE matrix_type IS
348
348 WHEN "00" => ready_matrix_f0_0 <= '1';
349 END IF;
349 WHEN "01" => ready_matrix_f0_1 <= '1';
350 ELSE
350 WHEN "10" => ready_matrix_f1 <= '1';
351 component_send <= '1';
351 WHEN "11" => ready_matrix_f2 <= '1';
352 address <= address;
352 WHEN OTHERS => NULL;
353 state <= WAIT_DATA_ACK;
353 END CASE;
354 END IF;
354
355
355 END IF;
356 WHEN WAIT_DATA_ACK =>
356 ELSE
357 log_empty_fifo <= fifo_empty OR log_empty_fifo;
357 component_send <= '1';
358
358 address <= address;
359 debug_reg_s(2 DOWNTO 0) <= "110";
359 state <= WAIT_DATA_ACK;
360
360 END IF;
361 component_send <= '0';
361
362 IF component_send_ok = '1' THEN
362 WHEN WAIT_DATA_ACK =>
363 address <= address + 64;
363 log_empty_fifo <= fifo_empty OR log_empty_fifo;
364 state <= SEND_DATA;
364
365 ELSIF component_send_ko = '1' THEN
365 debug_reg_s(2 DOWNTO 0) <= "110";
366 error_anticipating_empty_fifo <= '0';
366
367 state <= TRASH_FIFO;
367 component_send <= '0';
368 END IF;
368 IF component_send_ok = '1' THEN
369
369 address <= address + 64;
370
370 state <= SEND_DATA;
371 --WHEN CHECK_LENGTH =>
371 ELSIF component_send_ko = '1' THEN
372 -- component_send <= '0';
372 error_anticipating_empty_fifo <= '0';
373 -- debug_reg_s(2 DOWNTO 0) <= "111";
373 state <= TRASH_FIFO;
374 -- state <= IDLE;
374 END IF;
375
375
376 WHEN OTHERS => NULL;
376
377 END CASE;
377 --WHEN CHECK_LENGTH =>
378
378 -- component_send <= '0';
379 END IF;
379 -- debug_reg_s(2 DOWNTO 0) <= "111";
380 END PROCESS DMAWriteFSM_p;
380 -- state <= IDLE;
381
381
382 dma_valid_burst <= '0' WHEN header_select = '1' ELSE component_send;
382 WHEN OTHERS => NULL;
383 dma_valid <= header_send WHEN header_select = '1' ELSE '0';
383 END CASE;
384 dma_data <= header_data WHEN header_select = '1' ELSE fifo_data;
384
385 dma_addr <= address;
385 END IF;
386 fifo_ren <= fifo_ren_trash WHEN header_select = '1' ELSE dma_ren;
386 END PROCESS DMAWriteFSM_p;
387
387
388 component_send_ok <= '0' WHEN header_select = '1' ELSE dma_done;
388 dma_valid_burst <= '0' WHEN header_select = '1' ELSE component_send;
389 component_send_ko <= '0';
389 dma_valid <= header_send WHEN header_select = '1' ELSE '0';
390
390 dma_data <= header_data WHEN header_select = '1' ELSE fifo_data;
391 header_send_ok <= '0' WHEN header_select = '0' ELSE dma_done;
391 dma_addr <= address;
392 header_send_ko <= '0';
392 fifo_ren <= fifo_ren_trash WHEN header_select = '1' ELSE dma_ren;
393
393
394 END Behavioral;
394 component_send_ok <= '0' WHEN header_select = '1' ELSE dma_done;
395 component_send_ko <= '0';
396
397 header_send_ok <= '0' WHEN header_select = '0' ELSE dma_done;
398 header_send_ko <= '0';
399
400
401 -----------------------------------------------------------------------------
402 -- FSM HEADER ACK
403 -----------------------------------------------------------------------------
404 PROCESS (HCLK, HRESETn)
405 BEGIN -- PROCESS
406 IF HRESETn = '0' THEN -- asynchronous reset (active low)
407 header_ack <= '0';
408 header_reg <= (OTHERS => '0');
409 header_reg_val <= '0';
410 ELSIF HCLK'event AND HCLK = '1' THEN -- rising clock edge
411 header_ack <= '0';
412
413 IF header_val = '1' THEN
414 header_ack <= '1';
415 header_reg <= header;
416 END IF;
417
418 IF header_val = '1' THEN
419 header_reg_val <= '1';
420 ELSIF header_reg_ack = '1' THEN
421 header_reg_val <= '0';
422 END IF;
423
424 header_error <= header_val AND header_reg_val AND (NOT Header_reg_ack);
425
426 END IF;
427 END PROCESS;
428
429 debug_reg_s(3) <= header_error;
430
431 END Behavioral; No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now