diff --git a/Nexys4Guitar/bin/nexys4_guitar.bit b/Nexys4Guitar/bin/nexys4_guitar.bit index 8019560..4316653 100644 Binary files a/Nexys4Guitar/bin/nexys4_guitar.bit and b/Nexys4Guitar/bin/nexys4_guitar.bit differ diff --git a/Nexys4Guitar/src/hdl/histogram_saver.v b/Nexys4Guitar/src/hdl/histogram_saver.v index 9263bb1..9f20e74 100644 --- a/Nexys4Guitar/src/hdl/histogram_saver.v +++ b/Nexys4Guitar/src/hdl/histogram_saver.v @@ -22,6 +22,7 @@ module histogram_saver( input clk, + input reset, input start, input [3:0] slot, output reg [9:0] vaddr, @@ -44,8 +45,10 @@ module histogram_saver( reg [1:0] save_state = STANDBY; reg next_half = MSHALF; reg [1:0] sector = 2'b00; + reg last_ready; always @(posedge clk) begin + last_ready <= sd_ready_for_next_byte; case (save_state) STANDBY: begin saving <= 0; @@ -61,8 +64,8 @@ module histogram_saver( if (sd_ready) begin save_state <= START; sd_wr <= 1; - sd_din <= vdata[15:8]; - next_half <= LSHALF; + sd_din <= 8'hFF; + next_half <= MSHALF; end end START: begin @@ -82,7 +85,7 @@ module histogram_saver( save_state <= INIT; end end - else if(sd_ready_for_next_byte) begin + else if(sd_ready_for_next_byte & ~last_ready) begin if (next_half == LSHALF) begin sd_din <= vdata[7:0]; next_half <= MSHALF; @@ -96,6 +99,9 @@ module histogram_saver( end default: save_state <= STANDBY; endcase + if (reset) begin + save_state <= STANDBY; + end end endmodule diff --git a/Nexys4Guitar/src/hdl/nexys4_guitar.v b/Nexys4Guitar/src/hdl/nexys4_guitar.v index 7be5419..6cd659e 100644 --- a/Nexys4Guitar/src/hdl/nexys4_guitar.v +++ b/Nexys4Guitar/src/hdl/nexys4_guitar.v @@ -219,7 +219,7 @@ module nexys4_guitar ( .gain(hist_gain), .pixel(hist_pixel)); - wire sd_cs, sd_mosi, sd_miso, sd_sclk, sd_wr, sd_ready_for_next_byte, sd_ready; + wire sd_cs, sd_mosi, sd_miso, sd_sclk, sd_wr, sd_ready_for_next_byte, sd_ready, sd_reset; wire [7:0] sd_din; wire [31:0] sd_address; sd_controller sdc( @@ -244,7 +244,7 @@ module nexys4_guitar ( .din(sd_din), // Data input for WRITE operation. .ready_for_next_byte(sd_ready_for_next_byte), // A new byte should be presented on [din]. - .reset(0), // Resets controller on assertion. + .reset(sd_reset), // Resets controller on assertion. .ready(sd_ready), // HIGH if the SD card is ready for a read or write operation. .address(sd_address), // Memory address for read/write operation. This MUST // be a multiple of 512 bytes, due to SD sectoring. @@ -255,10 +255,11 @@ module nexys4_guitar ( reg old_center_button = 0; always @(posedge clk_25mhz) old_center_button <= center_button; assign save_start = center_button & ~old_center_button; - wire saving; + wire saver_reset, saving; wire [3:0] save_slot; histogram_saver hsaver( .clk(clk_25mhz), + .reset(saver_reset), .start(save_start), .slot(save_slot), .vaddr(save_addr), @@ -310,8 +311,8 @@ module nexys4_guitar ( // Debounce down btn wire down_button_noisy, down_button; - debounce down_button_debouncer( - .clock(clk_104mhz), + debounce #(.DELAY(250000)) down_button_debouncer( + .clock(clk_25mhz), .reset(reset_debounce), .noisy(down_button_noisy), .clean(down_button)); @@ -364,6 +365,8 @@ module nexys4_guitar ( assign SD_SCK = sd_sclk; assign SD_DAT[2:1] = 2'b11; assign SD_RESET = 0; + assign sd_reset = down_button; + assign saver_reset = down_button; // HISTOGRAM SAVER INTERFACE assign save_slot = SW[7:4]; diff --git a/Nexys4Guitar/src/test/process_fft_tb_func_synth.wcfg b/Nexys4Guitar/src/test/process_fft_tb_func_synth.wcfg index c4129ae..ef42bee 100644 --- a/Nexys4Guitar/src/test/process_fft_tb_func_synth.wcfg +++ b/Nexys4Guitar/src/test/process_fft_tb_func_synth.wcfg @@ -11,11 +11,11 @@ - - - + + + - + clk clk @@ -62,8 +62,4 @@ next_half next_half - - sd_ready_for_next_byte - sd_ready_for_next_byte -