/* lauta5 - Test for Mefisto Board through User Extension Port and Interface. */ module lauta5(CLK,PB_IN,SW_IN,BCOL_IN,BCOL_OUT,BROW,LED_OUT); input CLK; input [3:0] PB_IN; input [7:0] SW_IN; input [7:0] BCOL_IN; output [7:0] BCOL_OUT; output [7:0] BROW; output [7:0] LED_OUT; reg [7:0] USR1IN = 8'b0; reg [7:0] USR1OUT = 8'b0; // The multiplexed row, one-hot in 8-bit shift register: reg [7:0] sel_row = 8'b00000001; // 50 MHz/50Hz = 1 million ~= 2^20 parameter msb = 15; // Use 26; for a little over second. reg [msb:0] delay_counter = 0; parameter kuuw = 2; wire [kuuw:0] kuu = delay_counter[msb:msb-kuuw]; // We turn the 1/8th time the row signals completely off // (after switch from one row to next), so that we don't // get dim, but superfluous "pre-" and "afterglows" below and // on the top of each LED that should glow. // (This because the slowness of the optoisolators // in the interface module). assign BROW = ((~|kuu) ? 8'b00000000 : sel_row); // assign BCOL_OUT = ~BCOL_IN; assign BCOL_OUT = USR1IN; assign LED_OUT = {USR1IN[0],USR1IN[1],USR1IN[2],USR1IN[3],USR1IN[4],USR1IN[5],USR1IN[6],USR1IN[7]}; always @(posedge CLK) begin delay_counter <= delay_counter+1; // Wraps around, eventually. USR1IN <= ~BCOL_IN; USR1OUT <= {SW_IN[0],SW_IN[1],SW_IN[2],SW_IN[3],SW_IN[4],SW_IN[5],SW_IN[6],SW_IN[7]}; // USR1OUT[3:0] <= {PB_IN[0],PB_IN[1],PB_IN[2],PB_IN[3]}; // USR1OUT[7:4] <= {PB_IN[0],PB_IN[1],PB_IN[2],PB_IN[3]}; if(0 == delay_counter) sel_row <= {sel_row[6],sel_row[5],sel_row[4],sel_row[3],sel_row[2],sel_row[1],sel_row[0],sel_row[7]}; end endmodule