forked from Firmware/Firmwares
		
	raven_spn: add check if input-/ref-data fits into memory
This commit is contained in:
		
										
											Binary file not shown.
										
									
								
							| @@ -48,6 +48,17 @@ int main() { | |||||||
|     configure_irq(2, spn1_interrupt_handler); |     configure_irq(2, spn1_interrupt_handler); | ||||||
|     configure_irq(22, spn2_interrupt_handler); |     configure_irq(22, spn2_interrupt_handler); | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  |     uint32_t step = 100000; | ||||||
|  |     uint32_t iterations = 10; | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  |     int in_addr   = 0x30000000; // place input samples in the SPI memory | ||||||
|  |     int out_addr1 = 0x3C000000; | ||||||
|  |     int out_addr2 = 0x3E000000; | ||||||
|  |  | ||||||
|     spn_1::mode_reg() = 1; |     spn_1::mode_reg() = 1; | ||||||
|     spn_1::start_reg() = 1; |     spn_1::start_reg() = 1; | ||||||
|     wait_for_spn1_interrupt(); |     wait_for_spn1_interrupt(); | ||||||
| @@ -74,39 +85,44 @@ int main() { | |||||||
|     uint32_t result_bytes = 8; |     uint32_t result_bytes = 8; | ||||||
|     printf("Result Bytes: %d\n", result_bytes); |     printf("Result Bytes: %d\n", result_bytes); | ||||||
|  |  | ||||||
|     const uint32_t amount_of_input_samples = 50000; |     uint32_t in_bytes = step * sample_bytes; | ||||||
|     uint32_t step = 50000; |     uint32_t out_bytes = step * result_bytes; | ||||||
|     uint32_t iterations = 5; |  | ||||||
|  |     uint32_t total_in = in_bytes * iterations; | ||||||
|  |  | ||||||
|  |     if (total_in > (out_addr1 - in_addr)) { | ||||||
|  |         printf("ERROR: input data requires %d bytes, only %d bytes available\n", total_in, out_addr1 - in_addr); | ||||||
|  |         return 1; | ||||||
|  |     } | ||||||
|  |     if (out_bytes > (out_addr2 - out_addr1)) { | ||||||
|  |         printf("ERROR: output data requires %d bytes, only %d bytes available\n", out_bytes, out_addr2 - out_addr1); | ||||||
|  |         return 1; | ||||||
|  |     } | ||||||
|  |  | ||||||
|      |      | ||||||
|     uint32_t in_beats = (step * sample_bytes) / axi_bytes; |     uint32_t in_beats = in_bytes / axi_bytes; | ||||||
|     if (in_beats * axi_bytes < step * sample_bytes) in_beats++; |     if (in_beats * axi_bytes < step * sample_bytes) in_beats++; | ||||||
|     uint32_t out_beats = (step * result_bytes) / axi_bytes; |     uint32_t out_beats = out_bytes / axi_bytes; | ||||||
|     if (out_beats * axi_bytes < step * result_bytes) out_beats++; |     if (out_beats * axi_bytes < step * result_bytes) out_beats++; | ||||||
|  |  | ||||||
|     int in_addr   = 0x20010000; // place input samples in the SPI memory |     uint32_t current_in_addr = in_addr; | ||||||
|     int out_addr1 = 0x20510000; |      | ||||||
|     int out_addr2 = 0x205F0000; |  | ||||||
|  |  | ||||||
|     // inject SPN input data |     // inject SPN input data | ||||||
|     spn_checker::input_addr_reg() = in_addr; |     spn_checker::input_addr_reg() = current_in_addr; | ||||||
|     spn_checker::num_input_samples_reg() = sample_bytes * step * iterations; |     spn_checker::num_input_samples_reg() = sample_bytes * step * iterations; | ||||||
|     spn_checker::start_data_trans_reg() = 1; |     spn_checker::start_data_trans_reg() = 1; | ||||||
|  |  | ||||||
|     spn_checker::output_addr_reg() = out_addr1; |     spn_checker::output_addr_reg() = out_addr1; | ||||||
|     spn_checker::output_addr2_reg() = out_addr2; |     spn_checker::output_addr2_reg() = out_addr2; | ||||||
|     for (int k = 0; k < iterations*step; k+=step) { |     for (int k = 0; k < iterations*step; k+=step) { | ||||||
|         run_xspn1(in_addr, out_addr1, step, in_beats, out_beats); |         run_xspn1(current_in_addr, out_addr1, step, in_beats, out_beats); | ||||||
|         run_xspn2(in_addr, out_addr2, step, in_beats, out_beats); |         run_xspn2(current_in_addr, out_addr2, step, in_beats, out_beats); | ||||||
|         wait_for_spn_interrupts(); |         wait_for_spn_interrupts(); | ||||||
|         printf("XSPN finished\n"); |         printf("XSPN finished\n"); | ||||||
|         spn_checker::offset_reg() = k; |         spn_checker::offset_reg() = k; | ||||||
|         spn_checker::length_reg() = step; |         spn_checker::length_reg() = step; | ||||||
|         spn_checker::start_result_check_reg() = 1; |         spn_checker::start_result_check_reg() = 1; | ||||||
|  |  | ||||||
|         in_addr += step * sample_bytes; // 5 bytes in each sample |         current_in_addr += step * sample_bytes; // 5 bytes in each sample (NIPS5) | ||||||
|         if (k == amount_of_input_samples) { |  | ||||||
|         	in_addr = 0x20010000; |  | ||||||
|         } |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     return 0; |     return 0; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Johannes Wirth
					Johannes Wirth