/////////////////////////////////////////////////////////////////////////////// // // 6.111 FPGA Labkit -- Lab 3 Memory Tester Template // // // Created: February 19, 2007 // Author: Nathan Ickes // // This is a template for implementing the memory tester for Lab 3. This file // includes four modules: // // - labkit: the top-level labkit module // - display: the alphanumeric display interface module // - debounce: the synchronize/debounce module // - dots: generates bitmaps the alphanumeric display // // Students should modify and add modules according to the directions outlined // in the lab 3 manual. // /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// // // 6.111 FPGA Labkit -- Template Toplevel Module // // For Labkit Revision 004 // // // Created: October 31, 2004, from revision 003 file // Author: Nathan Ickes // /////////////////////////////////////////////////////////////////////////////// // // CHANGES FOR BOARD REVISION 004 // // 1) Added signals for logic analyzer pods 2-4. // 2) Expanded "tv_in_ycrcb" to 20 bits. // 3) Renamed "tv_out_data" to "tv_out_i2c_data" and "tv_out_sclk" to // "tv_out_i2c_clock". // 4) Reversed disp_data_in and disp_data_out signals, so that "out" is an // output of the FPGA, and "in" is an input. // // CHANGES FOR BOARD REVISION 003 // // 1) Combined flash chip enables into a single signal, flash_ce_b. // // CHANGES FOR BOARD REVISION 002 // // 1) Added SRAM clock feedback path input and output // 2) Renamed "mousedata" to "mouse_data" // 3) Renamed some ZBT memory signals. Parity bits are now incorporated into // the data bus, and the byte write enables have been combined into the // 4-bit ram#_bwe_b bus. // 4) Removed the "systemace_clock" net, since the SystemACE clock is now // hardwired on the PCB to the oscillator. // /////////////////////////////////////////////////////////////////////////////// // // Complete change history (including bug fixes) // // 2006-Mar-08: Corrected default assignments to "vga_out_red", "vga_out_green" // and "vga_out_blue". (Was 10'h0, now 8'h0.) // // 2005-Sep-09: Added missing default assignments to "ac97_sdata_out", // "disp_data_out", "analyzer[2-3]_clock" and // "analyzer[2-3]_data". // // 2005-Jan-23: Reduced flash address bus to 24 bits, to match 128Mb devices // actually populated on the boards. (The boards support up to // 256Mb devices, with 25 address lines.) // // 2004-Oct-31: Adapted to new revision 004 board. // // 2004-May-01: Changed "disp_data_in" to be an output, and gave it a default // value. (Previous versions of this file declared this port to // be an input.) // // 2004-Apr-29: Reduced SRAM address busses to 19 bits, to match 18Mb devices // actually populated on the boards. (The boards support up to // 72Mb devices, with 21 address lines.) // // 2004-Apr-29: Change history started // /////////////////////////////////////////////////////////////////////////////// module labkit (beep, audio_reset_b, ac97_sdata_out, ac97_sdata_in, ac97_synch, ac97_bit_clock, vga_out_red, vga_out_green, vga_out_blue, vga_out_sync_b, vga_out_blank_b, vga_out_pixel_clock, vga_out_hsync, vga_out_vsync, tv_out_ycrcb, tv_out_reset_b, tv_out_clock, tv_out_i2c_clock, tv_out_i2c_data, tv_out_pal_ntsc, tv_out_hsync_b, tv_out_vsync_b, tv_out_blank_b, tv_out_subcar_reset, tv_in_ycrcb, tv_in_data_valid, tv_in_line_clock1, tv_in_line_clock2, tv_in_aef, tv_in_hff, tv_in_aff, tv_in_i2c_clock, tv_in_i2c_data, tv_in_fifo_read, tv_in_fifo_clock, tv_in_iso, tv_in_reset_b, tv_in_clock, ram0_data, ram0_address, ram0_adv_ld, ram0_clk, ram0_cen_b, ram0_ce_b, ram0_oe_b, ram0_we_b, ram0_bwe_b, ram1_data, ram1_address, ram1_adv_ld, ram1_clk, ram1_cen_b, ram1_ce_b, ram1_oe_b, ram1_we_b, ram1_bwe_b, clock_feedback_out, clock_feedback_in, flash_data, flash_address, flash_ce_b, flash_oe_b, flash_we_b, flash_reset_b, flash_sts, flash_byte_b, rs232_txd, rs232_rxd, rs232_rts, rs232_cts, mouse_clock, mouse_data, keyboard_clock, keyboard_data, clock_27mhz, clock1, clock2, disp_blank, disp_data_out, disp_clock, disp_rs, disp_ce_b, disp_reset_b, disp_data_in, button0, button1, button2, button3, button_enter, button_right, button_left, button_down, button_up, switch, led, user1, user2, user3, user4, daughtercard, systemace_data, systemace_address, systemace_ce_b, systemace_we_b, systemace_oe_b, systemace_irq, systemace_mpbrdy, analyzer1_data, analyzer1_clock, analyzer2_data, analyzer2_clock, analyzer3_data, analyzer3_clock, analyzer4_data, analyzer4_clock); output beep, audio_reset_b, ac97_synch, ac97_sdata_out; input ac97_bit_clock, ac97_sdata_in; output [7:0] vga_out_red, vga_out_green, vga_out_blue; output vga_out_sync_b, vga_out_blank_b, vga_out_pixel_clock, vga_out_hsync, vga_out_vsync; output [9:0] tv_out_ycrcb; output tv_out_reset_b, tv_out_clock, tv_out_i2c_clock, tv_out_i2c_data, tv_out_pal_ntsc, tv_out_hsync_b, tv_out_vsync_b, tv_out_blank_b, tv_out_subcar_reset; input [19:0] tv_in_ycrcb; input tv_in_data_valid, tv_in_line_clock1, tv_in_line_clock2, tv_in_aef, tv_in_hff, tv_in_aff; output tv_in_i2c_clock, tv_in_fifo_read, tv_in_fifo_clock, tv_in_iso, tv_in_reset_b, tv_in_clock; inout tv_in_i2c_data; inout [35:0] ram0_data; output [18:0] ram0_address; output ram0_adv_ld, ram0_clk, ram0_cen_b, ram0_ce_b, ram0_oe_b, ram0_we_b; output [3:0] ram0_bwe_b; inout [35:0] ram1_data; output [18:0] ram1_address; output ram1_adv_ld, ram1_clk, ram1_cen_b, ram1_ce_b, ram1_oe_b, ram1_we_b; output [3:0] ram1_bwe_b; input clock_feedback_in; output clock_feedback_out; inout [15:0] flash_data; output [23:0] flash_address; output flash_ce_b, flash_oe_b, flash_we_b, flash_reset_b, flash_byte_b; input flash_sts; output rs232_txd, rs232_rts; input rs232_rxd, rs232_cts; input mouse_clock, mouse_data, keyboard_clock, keyboard_data; input clock_27mhz, clock1, clock2; output disp_blank, disp_clock, disp_rs, disp_ce_b, disp_reset_b; input disp_data_in; output disp_data_out; input button0, button1, button2, button3, button_enter, button_right, button_left, button_down, button_up; input [7:0] switch; output [7:0] led; inout [31:0] user1, user2, user3, user4; inout [43:0] daughtercard; inout [15:0] systemace_data; output [6:0] systemace_address; output systemace_ce_b, systemace_we_b, systemace_oe_b; input systemace_irq, systemace_mpbrdy; output [15:0] analyzer1_data, analyzer2_data, analyzer3_data, analyzer4_data; output analyzer1_clock, analyzer2_clock, analyzer3_clock, analyzer4_clock; //////////////////////////////////////////////////////////////////////////// // // I/O Assignments // //////////////////////////////////////////////////////////////////////////// // Audio Input and Output assign beep= 1'b0; assign audio_reset_b = 1'b0; assign ac97_synch = 1'b0; assign ac97_sdata_out = 1'b0; // VGA Output assign vga_out_red = 8'h0; assign vga_out_green = 8'h0; assign vga_out_blue = 8'h0; assign vga_out_sync_b = 1'b1; assign vga_out_blank_b = 1'b1; assign vga_out_pixel_clock = 1'b0; assign vga_out_hsync = 1'b0; assign vga_out_vsync = 1'b0; // Video Output assign tv_out_ycrcb = 10'h0; assign tv_out_reset_b = 1'b0; assign tv_out_clock = 1'b0; assign tv_out_i2c_clock = 1'b0; assign tv_out_i2c_data = 1'b0; assign tv_out_pal_ntsc = 1'b0; assign tv_out_hsync_b = 1'b1; assign tv_out_vsync_b = 1'b1; assign tv_out_blank_b = 1'b1; assign tv_out_subcar_reset = 1'b0; // Video Input assign tv_in_i2c_clock = 1'b0; assign tv_in_fifo_read = 1'b0; assign tv_in_fifo_clock = 1'b0; assign tv_in_iso = 1'b0; assign tv_in_reset_b = 1'b0; assign tv_in_clock = 1'b0; assign tv_in_i2c_data = 1'bZ; // SRAMs assign ram0_data = 36'hZ; assign ram0_address = 19'h0; assign ram0_adv_ld = 1'b0; assign ram0_clk = 1'b0; assign ram0_cen_b = 1'b1; assign ram0_ce_b = 1'b1; assign ram0_oe_b = 1'b1; assign ram0_we_b = 1'b1; assign ram0_bwe_b = 4'hF; assign ram1_data = 36'hZ; assign ram1_address = 19'h0; assign ram1_adv_ld = 1'b0; assign ram1_clk = 1'b0; assign ram1_cen_b = 1'b1; assign ram1_ce_b = 1'b1; assign ram1_oe_b = 1'b1; assign ram1_we_b = 1'b1; assign ram1_bwe_b = 4'hF; assign clock_feedback_out = 1'b0; // Flash ROM assign flash_data = 16'hZ; assign flash_address = 24'h0; assign flash_ce_b = 1'b1; assign flash_oe_b = 1'b1; assign flash_we_b = 1'b1; assign flash_reset_b = 1'b0; assign flash_byte_b = 1'b1; // RS-232 Interface assign rs232_txd = 1'b1; assign rs232_rts = 1'b1; // LED Displays assign disp_blank = 1'b1; assign disp_clock = 1'b0; assign disp_rs = 1'b0; assign disp_ce_b = 1'b1; assign disp_reset_b = 1'b0; assign disp_data_out = 1'b0; // Buttons, Switches, and Individual LEDs assign led = 8'hFF; // User I/Os assign user1 = 32'hZ; assign user2 = 32'hZ; assign user3 = 32'hZ; assign user4 = 32'hZ; // Daughtercard Connectors assign daughtercard = 44'hZ; // SystemACE Microprocessor Port assign systemace_data = 16'hZ; assign systemace_address = 7'h0; assign systemace_ce_b = 1'b1; assign systemace_we_b = 1'b1; assign systemace_oe_b = 1'b1; // Logic Analyzer assign analyzer1_data = 16'h0; assign analyzer1_clock = 1'b1; assign analyzer2_data = 16'h0; assign analyzer2_clock = 1'b1; assign analyzer3_data = 16'h0; assign analyzer3_clock = 1'b1; assign analyzer4_data = 16'h0; assign analyzer4_clock = 1'b1; endmodule /////////////////////////////////////////////////////////////////////////////// // // 6.111 FPGA Labkit -- Alphanumeric Display Interface // // // Created: November 5, 2003 // Author: Nathan Ickes // /////////////////////////////////////////////////////////////////////////////// // // Change history // // 2007-02-09: Fixed register-select race condition. (Thanks to Chris // Buenrostro for finding this bug and David Wentzloff for // implementing the fix.) // 2005-05-09: Made input registered, and converted the 640-input MUX // to a 640-bit shift register. // /////////////////////////////////////////////////////////////////////////////// module display (reset, clock_27mhz, disp_blank, disp_clock, disp_rs, disp_ce_b, disp_reset_b, disp_data_out, dots); input reset; // Active high input clock_27mhz; output disp_blank, disp_clock, disp_data_out, disp_rs, disp_ce_b, disp_reset_b; input [639:0] dots; reg disp_data_out, disp_rs, disp_ce_b, disp_reset_b; // // Display Clock // // Generate a 500kHz clock for driving the displays. // reg [4:0] count; reg [7:0] reset_count; reg clock; wire dreset; always @(posedge clock_27mhz) begin if (reset) begin count = 0; clock = 0; end else if (count == 26) begin clock = ~clock; count = 5'h00; end else count = count+1; end always @(posedge clock_27mhz) if (reset) reset_count <= 100; else reset_count <= (reset_count==0) ? 0 : reset_count-1; assign dreset = (reset_count != 0); assign disp_clock = ~clock; // // Display State Machine // reg [7:0] state; reg [9:0] dot_index; reg [31:0] control; reg [639:0] ldots; assign disp_blank = 1'b0; // low = not blanked always @(posedge clock) if (dreset) begin state <= 0; dot_index <= 0; control <= 32'h7F7F7F7F; end else casex (state) 8'h00: begin // Reset displays disp_data_out <= 1'b0; disp_rs <= 1'b0; // 0 = dot register disp_ce_b <= 1'b1; disp_reset_b <= 1'b0; dot_index <= 0; state <= state+1; end 8'h01: begin // End reset disp_reset_b <= 1'b1; state <= state+1; end 8'h02: begin // Initialize dot register disp_ce_b <= 1'b0; disp_data_out <= 1'b0; // dot_index[0]; if (dot_index == 639) state <= state+1; else dot_index <= dot_index+1; end 8'h03: begin // Latch dot data disp_rs <= 1'b1; // Select the control register disp_ce_b <= 1'b1; dot_index <= 31; state <= state+1; end 8'h04: begin // Setup the control register disp_ce_b <= 1'b0; disp_data_out <= control[31]; control <= {control[30:0], 1'b0}; if (dot_index == 0) state <= state+1; else dot_index <= dot_index-1; end 8'h05: begin // Latch the control register data disp_rs <= 1'b0; // Select the dot register disp_ce_b <= 1'b1; dot_index <= 639; ldots <= dots; state <= state+1; end 8'h06: begin // Load the user's dot data into the dot register disp_ce_b <= 1'b0; disp_data_out <= ldots[639]; ldots <= ldots<<1; if (dot_index == 0) state <= 5; else dot_index <= dot_index-1; end endcase endmodule //////////////////////////////////////////////////////////////////////////////// // // 6.111 FPGA Labkit -- Debounce/Synchronize module // // // Use your system clock for the clock input to produce a synchronous, // debounced output // //////////////////////////////////////////////////////////////////////////////// module debounce (reset, clock, noisy, clean); parameter DELAY = 270000; // .01 sec with a 27Mhz clock input reset, clock, noisy; output clean; reg [18:0] count; reg new, clean; always @(posedge clock) if (reset) begin count <= 0; new <= noisy; clean <= noisy; end else if (noisy != new) begin new <= noisy; count <= 0; end else if (count == DELAY) clean <= new; else count <= count+1; endmodule //////////////////////////////////////////////////////////////////////////////// // // 6.111 FPGA Labkit -- Number to bitmap decoder // // // Author: Yun Wu, Nathan Ickes // Date: March 8, 2006 // // This module converts a 4-bit input to a 80-dot (2 digit) bitmap representing // the numbers ' 0' through '15'. // //////////////////////////////////////////////////////////////////////////////// module dots(clk, num, dots); input clk; input [3:0] num; output [79:0] dots; reg [79:0] dots; always @ (posedge clk) case (num) 4'd15: dots <= {40'b00000000_01000010_01111111_01000000_00000000, // '15' 40'b00100111_01000101_01000101_01000101_00111001}; 4'd14: dots <= {40'b00000000_01000010_01111111_01000000_00000000, // '14' 40'b00011000_00010100_00010010_01111111_00010000}; 4'd13: dots <= {40'b00000000_01000010_01111111_01000000_00000000, // '13' 40'b00100010_01000001_01001001_01001001_00110110}; 4'd12: dots <= {40'b00000000_01000010_01111111_01000000_00000000, // '12' 40'b01100010_01010001_01001001_01001001_01000110}; 4'd11: dots <= {40'b00000000_01000010_01111111_01000000_00000000, // '11' 40'b00000000_01000010_01111111_01000000_00000000}; 4'd10: dots <= {40'b00000000_01000010_01111111_01000000_00000000, // '10' 40'b00111110_01010001_01001001_01000101_00111110}; 4'd09: dots <= {40'b00000000_00000000_00000000_00000000_00000000, // ' 9' 40'b00000110_01001001_01001001_00101001_00011110}; 4'd08: dots <= {40'b00000000_00000000_00000000_00000000_00000000, // ' 8' 40'b00110110_01001001_01001001_01001001_00110110}; 4'd07: dots <= {40'b00000000_00000000_00000000_00000000_00000000, // ' 7' 40'b00000001_01110001_00001001_00000101_00000011}; 4'd06: dots <= {40'b00000000_00000000_00000000_00000000_00000000, // ' 6' 40'b00111100_01001010_01001001_01001001_00110000}; 4'd05: dots <= {40'b00000000_00000000_00000000_00000000_00000000, // ' 5' 40'b00100111_01000101_01000101_01000101_00111001}; 4'd04: dots <= {40'b00000000_00000000_00000000_00000000_00000000, // ' 4' 40'b00011000_00010100_00010010_01111111_00010000}; 4'd03: dots <= {40'b00000000_00000000_00000000_00000000_00000000, // ' 3' 40'b00100010_01000001_01001001_01001001_00110110}; 4'd02: dots <= {40'b00000000_00000000_00000000_00000000_00000000, // ' 2' 40'b01100010_01010001_01001001_01001001_01000110}; 4'd01: dots <= {40'b00000000_00000000_00000000_00000000_00000000, // ' 1' 40'b00000000_01000010_01111111_01000000_00000000}; 4'd00: dots <= {40'b00000000_00000000_00000000_00000000_00000000, // ' 0' 40'b00111110_01010001_01001001_01000101_00111110}; // No default case, becase every case is already accounted for. endcase endmodule