diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2013-10-30 02:28:57 -0500 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2013-10-30 12:13:17 -0500 |
commit | 8faa3da1094d1785d3343c2869d9f8c95f01cf97 (patch) | |
tree | d6a7e029810759972c17395a22593a75256f611c /fpga | |
parent | b783a269490763ec242e967fa713dbf732e5ac13 (diff) | |
download | ulab-8faa3da1094d1785d3343c2869d9f8c95f01cf97.tar.gz ulab-8faa3da1094d1785d3343c2869d9f8c95f01cf97.zip |
Fix image distortion when certain greyscale values are utilized
Store last used values in FPGA viewer and programmer GUI for convenience on GUI restart
Diffstat (limited to 'fpga')
-rw-r--r-- | fpga/common/remote_access.v | 293 | ||||
-rw-r--r-- | fpga/xilinx/digilent/spartan_6/s6_remotefpga_test/data_storage.v | 24 |
2 files changed, 157 insertions, 160 deletions
diff --git a/fpga/common/remote_access.v b/fpga/common/remote_access.v index 33fc99b..1482cfb 100644 --- a/fpga/common/remote_access.v +++ b/fpga/common/remote_access.v @@ -50,10 +50,13 @@ module remote_access( output remote_access_lcd_rs_out, output remote_access_lcd_rw_out, output remote_access_lcd_enable_out); + + parameter RAM_ADDR_BITS = 14; reg [7:0] remote_access_4_bit_input_reg; reg [7:0] remote_access_8_bit_input_reg; reg [15:0] remote_access_16_bit_input_reg; + reg [15:0] remote_access_data_ram_size_reg = (2**RAM_ADDR_BITS); reg [3:0] remote_access_lcd_data_out_reg; reg remote_access_lcd_rs_out_reg; reg remote_access_lcd_rw_out_reg; @@ -197,7 +200,7 @@ module remote_access( reg [13:0] data_storage_addra_reg; reg data_storage_write_enable_reg; - data_storage data_storage(.clka(data_storage_clka), .dina(data_storage_dina), .addra(data_storage_addra), + data_storage #(RAM_ADDR_BITS) data_storage(.clka(data_storage_clka), .dina(data_storage_dina), .addra(data_storage_addra), .wea(data_storage_write_enable), .douta(data_storage_data_out)); assign data_storage_clka = (data_storage_remote_enable) ? main_fifty_clock : sram_clock_in; @@ -258,7 +261,6 @@ module remote_access( reg enable_remote_access_input = 1; reg remote_access_input_enable_prev = 0; - reg prev_was_carriage_return = 0; reg [7:0] lcd_display_string [31:0]; @@ -370,7 +372,7 @@ module remote_access( if ((transmit_dsp_rx_complete == 1) && (transmit_dsp_rx_complete_done == 0)) begin TxD_data = 77; - + TxD_start = 1; tx_toggle = 1; @@ -385,13 +387,13 @@ module remote_access( end else begin data_storage_write_enable_reg = 0; TxD_data = data_storage_data_out; - + TxD_start = 1; tx_toggle = 1; transmit_dsp_status_counter = transmit_dsp_status_counter + 1; data_storage_addra_reg = transmit_dsp_status_counter; - if (transmit_dsp_status_counter > 16384) begin + if (transmit_dsp_status_counter >= (2**RAM_ADDR_BITS)) begin transmit_dsp_status_done = 1; data_storage_write_enable_reg = 1'bz; data_storage_addra_reg = 14'bz; @@ -571,164 +573,165 @@ module remote_access( transmit_dsp_status = 1; end - if (RxD_data_ready == 1) begin + if (RxD_data_ready == 1) begin if (serial_character_received == 0) begin serial_rx_data_reg = RxD_data; serial_rx_strobe_reg = 1; // Signal new data... if (seize_serial_tx == 0) begin - // Parse the command and see what it is - serial_character_received = 1; - if (RxD_data == 13) begin - // Carriage Return! The serial_command_buffer holds the command! Parse it! - if (next_byte_is_command == 0) begin - if (serial_command_buffer == 65) begin - // Display update requested - next_byte_is_command = 1; - serial_update_counter = 0; - next_byte_is_command_prev_command = 65; - end + if (next_byte_is_command_prev_command == 77) begin + // DSP input data + if (dsp_update_counter < (2**RAM_ADDR_BITS)) begin + data_storage_remote_enable = 1; + data_storage_addra_reg = dsp_update_counter; + data_storage_dina_reg = serial_rx_data_reg; + data_storage_write_enable_reg = 1; + data_write_timer = 3; + dsp_update_counter = dsp_update_counter + 1; - if (serial_command_buffer == 66) begin - // 8 bit input update - if (enable_remote_access_input == 1) begin + // TESTING ONLY!!! + //if (dsp_update_counter < 17) begin + // received_lcd_display_string[dsp_update_counter - 1] = serial_command_buffer; + //end + + if (dsp_update_counter >= (2**RAM_ADDR_BITS)) begin + next_byte_is_command = 0; + data_storage_write_enable_reg = 0; + data_storage_remote_enable = 0; + sram_available_reg = 1; + data_storage_write_enable_reg = 1'bz; + data_storage_addra_reg = 14'bz; + waiting_on_dsp_processing = 1; + transmit_dsp_rx_complete = 1; + next_byte_is_command_prev_command = 0; + + // TESTING ONLY!!! + //transmit_dsp_status = 1; + end + end + end else begin + // Parse the command and see what it is + serial_character_received = 1; + if (serial_rx_data_reg == 13) begin + // Carriage Return! The serial_command_buffer holds the command! Parse it! + if (next_byte_is_command == 0) begin + if (serial_command_buffer == 65) begin + // Display update requested next_byte_is_command = 1; serial_update_counter = 0; - next_byte_is_command_prev_command = 66; + next_byte_is_command_prev_command = 65; end - end - - if (serial_command_buffer == 67) begin - // 16 bit input update - next_byte_is_command = 1; - serial_update_counter = 0; - next_byte_is_command_prev_command = 67; - end - - if (serial_command_buffer == 68) begin - // 8 bit output status - transmit_8_bit_status = 1; - end - - if (serial_command_buffer == 69) begin - // 16 bit output status - transmit_16_bit_status = 1; - end - - if (serial_command_buffer == 70) begin - // System status - transmit_main_status = 1; - end - - if (serial_command_buffer == 71) begin - // Simulate center button press - enable_remote_access_input = !enable_remote_access_input; - end - - if (serial_command_buffer == 72) begin - // Local input status - transmit_input_status = 1; - end - - if (serial_command_buffer == 73) begin - // 4 bit input update - if (enable_remote_access_input == 1) begin + + if (serial_command_buffer == 66) begin + // 8 bit input update + if (enable_remote_access_input == 1) begin + next_byte_is_command = 1; + serial_update_counter = 0; + next_byte_is_command_prev_command = 66; + end + end + + if (serial_command_buffer == 67) begin + // 16 bit input update next_byte_is_command = 1; serial_update_counter = 0; - next_byte_is_command_prev_command = 73; + next_byte_is_command_prev_command = 67; end - end - - if (serial_command_buffer == 74) begin - // 4 bit output status - transmit_4_bit_status = 1; - end - - if (serial_command_buffer == 75) begin - // Transmit the contents of the LCD... - transmit_lcd_status = 1; - end - - if (serial_command_buffer == 76) begin - // Transmit the contents of the LCD... - transmit_all_data_state = 1; - transmit_lcd_status = 1; - end - - if (serial_command_buffer == 77) begin - // Receive offline DSP data - next_byte_is_command = 1; - dsp_update_counter = 0; - next_byte_is_command_prev_command = 77; - end - - if (serial_command_buffer == 78) begin - // Transmit the contents of RAM... - transmit_dsp_status = 1; - end - end else begin - if (next_byte_is_command == 1) begin - // The previous byte was the command--now load in the data! - if (next_byte_is_command_prev_command == 65) begin - if (serial_update_counter < 32) begin - received_lcd_display_string[serial_update_counter] = serial_command_buffer; - serial_update_counter = serial_update_counter + 1; - end else begin - update_lcd_display = 1; - serial_command_timer = 255; - next_byte_is_command = 0; - end + + if (serial_command_buffer == 68) begin + // 8 bit output status + transmit_8_bit_status = 1; end - // 4 bit input update - if (next_byte_is_command_prev_command == 73) begin - remote_access_4_bit_input_reg = serial_command_buffer; - next_byte_is_command = 0; + if (serial_command_buffer == 69) begin + // 16 bit output status + transmit_16_bit_status = 1; end - // 8 bit input update - if (next_byte_is_command_prev_command == 66) begin - remote_access_8_bit_input_reg = serial_command_buffer; - next_byte_is_command = 0; + if (serial_command_buffer == 70) begin + // System status + transmit_main_status = 1; end - // 16 bit input update - if (next_byte_is_command_prev_command == 67) begin - if (serial_update_counter == 0) begin - remote_access_16_bit_input_reg[15:8] = serial_command_buffer; - serial_update_counter = 1; - end else begin - remote_access_16_bit_input_reg[7:0] = serial_command_buffer; - next_byte_is_command = 0; + if (serial_command_buffer == 71) begin + // Simulate center button press + enable_remote_access_input = !enable_remote_access_input; + end + + if (serial_command_buffer == 72) begin + // Local input status + transmit_input_status = 1; + end + + if (serial_command_buffer == 73) begin + // 4 bit input update + if (enable_remote_access_input == 1) begin + next_byte_is_command = 1; + serial_update_counter = 0; + next_byte_is_command_prev_command = 73; end end - // DSP input data - if (next_byte_is_command_prev_command == 77) begin - if (dsp_update_counter < 16384) begin - data_storage_remote_enable = 1; - data_storage_addra_reg = dsp_update_counter; - data_storage_dina_reg = serial_command_buffer; - data_storage_write_enable_reg = 1; - data_write_timer = 3; - dsp_update_counter = dsp_update_counter + 1; - - // TESTING ONLY!!! - //if (dsp_update_counter < 17) begin - // received_lcd_display_string[dsp_update_counter - 1] = serial_command_buffer; - //end - - if (dsp_update_counter >= 16384) begin + if (serial_command_buffer == 74) begin + // 4 bit output status + transmit_4_bit_status = 1; + end + + if (serial_command_buffer == 75) begin + // Transmit the contents of the LCD... + transmit_lcd_status = 1; + end + + if (serial_command_buffer == 76) begin + // Transmit the contents of the LCD... + transmit_all_data_state = 1; + transmit_lcd_status = 1; + end + + if (serial_command_buffer == 77) begin + // Receive offline DSP data + next_byte_is_command = 1; + dsp_update_counter = 0; + next_byte_is_command_prev_command = 77; + end + + if (serial_command_buffer == 78) begin + // Transmit the contents of RAM... + transmit_dsp_status = 1; + end + end else begin + if (next_byte_is_command == 1) begin + // The previous byte was the command--now load in the data! + if (next_byte_is_command_prev_command == 65) begin + if (serial_update_counter < 32) begin + received_lcd_display_string[serial_update_counter] = serial_command_buffer; + serial_update_counter = serial_update_counter + 1; + end else begin + update_lcd_display = 1; + serial_command_timer = 255; + next_byte_is_command = 0; + end + end + + // 4 bit input update + if (next_byte_is_command_prev_command == 73) begin + remote_access_4_bit_input_reg = serial_command_buffer; + next_byte_is_command = 0; + end + + // 8 bit input update + if (next_byte_is_command_prev_command == 66) begin + remote_access_8_bit_input_reg = serial_command_buffer; + next_byte_is_command = 0; + end + + // 16 bit input update + if (next_byte_is_command_prev_command == 67) begin + if (serial_update_counter == 0) begin + remote_access_16_bit_input_reg[15:8] = serial_command_buffer; + serial_update_counter = 1; + end else begin + remote_access_16_bit_input_reg[7:0] = serial_command_buffer; next_byte_is_command = 0; - data_storage_write_enable_reg = 0; - data_storage_remote_enable = 0; - sram_available_reg = 1; - data_storage_write_enable_reg = 1'bz; - data_storage_addra_reg = 14'bz; - waiting_on_dsp_processing = 1; - transmit_dsp_rx_complete = 1; - - // TESTING ONLY!!! - //transmit_dsp_status = 1; end end end @@ -740,12 +743,6 @@ module remote_access( //if (RxD_data != 10) begin // Ignore linefeeds serial_command_buffer = RxD_data; //end - - if (RxD_data == 13) begin - prev_was_carriage_return = 1; - end else begin - prev_was_carriage_return = 0; - end serial_receiver_toggler = serial_receiver_toggler + 1; end diff --git a/fpga/xilinx/digilent/spartan_6/s6_remotefpga_test/data_storage.v b/fpga/xilinx/digilent/spartan_6/s6_remotefpga_test/data_storage.v index f1d10be..60c1dff 100644 --- a/fpga/xilinx/digilent/spartan_6/s6_remotefpga_test/data_storage.v +++ b/fpga/xilinx/digilent/spartan_6/s6_remotefpga_test/data_storage.v @@ -13,20 +13,20 @@ module data_storage( input wea, output reg [7:0] douta); - parameter RAM_WIDTH = 8; - parameter RAM_ADDR_BITS = 14; - - // Xilinx specific directive - (* RAM_STYLE="BLOCK" *) - - reg [RAM_WIDTH-1:0] data_storage_ram [(2**RAM_ADDR_BITS)-1:0]; - - always @(posedge clka) begin - if (wea) begin + parameter RAM_ADDR_BITS = 14; + parameter RAM_WIDTH = 8; + + // Xilinx specific directive + (* RAM_STYLE="BLOCK" *) + + reg [RAM_WIDTH-1:0] data_storage_ram [(2**RAM_ADDR_BITS)-1:0]; + + always @(posedge clka) begin + if (wea) begin data_storage_ram[addra] <= dina; douta <= dina; - end else begin - douta <= data_storage_ram[addra]; + end else begin + douta <= data_storage_ram[addra]; end end |