OpenCores
URL https://opencores.org/ocsvn/ps2/ps2/trunk

Subversion Repositories ps2

[/] [ps2/] [tags/] [rel_6/] [bench/] [verilog/] [ps2_test_bench.v] - Diff between revs 15 and 24

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 15 Rev 24
Line 41... Line 41...
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//
//
// CVS Revision History
// CVS Revision History
//
//
// $Log: not supported by cvs2svn $
// $Log: not supported by cvs2svn $
 
// Revision 1.6  2003/05/28 16:26:51  simons
 
// Change the address width.
 
//
// Revision 1.5  2002/04/09 13:17:03  mihad
// Revision 1.5  2002/04/09 13:17:03  mihad
// Mouse interface testcases added
// Mouse interface testcases added
//
//
// Revision 1.4  2002/02/20 16:35:34  mihad
// Revision 1.4  2002/02/20 16:35:34  mihad
// Little/big endian changes continued
// Little/big endian changes continued
Line 161... Line 164...
`endif
`endif
 
 
reg ok ;
reg ok ;
reg error ;
reg error ;
 
 
 
reg ok_o;
 
 
 
integer rem;
 
integer wb_period;
 
reg wb_rem;
 
reg [15:0] wb_dev_data;
 
 
 
 
integer watchdog_timer ;
integer watchdog_timer ;
reg     watchdog_reset ;
reg     watchdog_reset ;
reg     watchdog_reset_previous ;
reg     watchdog_reset_previous ;
 
 
reg [7:0] normal_scancode_set2_mem [0:`PS2_NUM_OF_NORMAL_SCANCODES - 1] ;
reg [7:0] normal_scancode_set2_mem [0:`PS2_NUM_OF_NORMAL_SCANCODES - 1] ;
Line 174... Line 185...
 
 
`define WB_PERIOD (1/`WB_FREQ)
`define WB_PERIOD (1/`WB_FREQ)
initial
initial
begin
begin
 
 
 
 
    $readmemh("../../../bench/data/normal_scancodes_set2.hex", normal_scancode_set2_mem) ;
    $readmemh("../../../bench/data/normal_scancodes_set2.hex", normal_scancode_set2_mem) ;
    $readmemh("../../../bench/data/normal_scancodes_set1.hex", normal_scancode_set1_mem) ;
    $readmemh("../../../bench/data/normal_scancodes_set1.hex", normal_scancode_set1_mem) ;
    $readmemh("../../../bench/data/extended_scancodes_set2.hex", extended_scancode_set2_mem) ;
    $readmemh("../../../bench/data/extended_scancodes_set2.hex", extended_scancode_set2_mem) ;
    $readmemh("../../../bench/data/extended_scancodes_set1.hex", extended_scancode_set1_mem) ;
    $readmemh("../../../bench/data/extended_scancodes_set1.hex", extended_scancode_set1_mem) ;
 
 
    if ( ((`PS2_TIMER_5USEC_VALUE_PP * `WB_PERIOD) < 5000) || ((`PS2_TIMER_5USEC_VALUE_PP * `WB_PERIOD) > 6000) )
 
    begin
 
        $display("Warning! 5us timer max value is not defined correctly regarding to WISHBONE bus clock!") ;
 
        $stop ;
 
    end
 
 
 
    if ( ((`PS2_TIMER_60USEC_VALUE_PP * `WB_PERIOD) < 60000) || ((`PS2_TIMER_60USEC_VALUE_PP * `WB_PERIOD) > 61000) )
 
    begin
 
        $display("Warning! 60us timer max value is not defined correctly regarding to WISHBONE bus clock!") ;
 
        $stop ;
 
    end
 
 
 
    if ( (1 << `PS2_TIMER_5USEC_BITS_PP) < `PS2_TIMER_5USEC_VALUE_PP )
 
    begin
 
        $display("Warning! 5us timer max value is not defined correctly regarding to the length in bits of 5us timer!") ;
 
        $stop ;
 
    end
 
 
 
    if ( (1 << `PS2_TIMER_60USEC_BITS_PP) < `PS2_TIMER_60USEC_VALUE_PP )
    wb_period =50;
    begin
    wb_rem    = 1'b0;
        $display("Warning! 60us timer max value is not defined correctly regarding to the length in bits of 60us timer!") ;
    rem       =0;
        $stop ;
 
    end
 
 
 
    watchdog_timer = 32'h1000_0000 ;
    watchdog_timer = 32'h1000_0000 ;
    watchdog_reset = 0 ;
    watchdog_reset = 0 ;
    watchdog_reset_previous = 0 ;
    watchdog_reset_previous = 0 ;
 
 
Line 214... Line 207...
 
 
    #100 ;
    #100 ;
 
 
    repeat ( 10 )
    repeat ( 10 )
        @(posedge wb_clock) ;
        @(posedge wb_clock) ;
 
 
    wb_reset <= 1'b0 ;
    wb_reset <= 1'b0 ;
 
 
 
    repeat(6)
 
 
 
  begin
 
   @(posedge wb_clock)
 
   begin
 
   rem = 5000 % wb_period;
 
 
 
   if (rem > 0)
 
   begin
 
   wb_rem =  1'b1;
 
 
 
   end
 
   else
 
   begin
 
   wb_rem = 1'b0;
 
 
 
   end
 
   end
 
 
 
   begin
 
      devider_write(4'h8,5000/wb_period + wb_rem ,ok_o);
 
 
 
 
    @(posedge wb_clock) ;
    @(posedge wb_clock) ;
    #1 initialize_controler ;
    #1 initialize_controler ;
 
 
    test_scan_code_receiving ;
    test_scan_code_receiving ;
 
 
Line 241... Line 258...
    end
    end
    join
    join
    `endif
    `endif
 
 
    test_keyboard_inhibit ;
    test_keyboard_inhibit ;
 
     wb_period = wb_period + 10 ;
 
 
 
    end
 
    end
 
    $display("end simulation");
    #400 $stop ;
    #400 $stop ;
end
end
 
 
always
always
    #(`WB_PERIOD / 2) wb_clock = !wb_clock ;
    #(wb_period/2.0) wb_clock = !wb_clock ;
 
 
wire wb_cyc,
wire wb_cyc,
     wb_stb,
     wb_stb,
     wb_we,
     wb_we,
     wb_ack,
     wb_ack,
Line 268... Line 289...
    .wb_rst_i        (wb_reset),
    .wb_rst_i        (wb_reset),
    .wb_cyc_i        (wb_cyc),
    .wb_cyc_i        (wb_cyc),
    .wb_stb_i        (wb_stb),
    .wb_stb_i        (wb_stb),
    .wb_we_i         (wb_we),
    .wb_we_i         (wb_we),
    .wb_sel_i        (wb_sel),
    .wb_sel_i        (wb_sel),
    .wb_adr_i        (wb_adr[2:0]),
    .wb_adr_i        (wb_adr[3:0]),
    .wb_dat_i        (wb_dat_m_s),
    .wb_dat_i        (wb_dat_m_s),
    .wb_dat_o        (wb_dat_s_m),
    .wb_dat_o        (wb_dat_s_m),
    .wb_ack_o        (wb_ack),
    .wb_ack_o        (wb_ack),
 
 
    .wb_int_o        (wb_int),
    .wb_int_o        (wb_int),
Line 874... Line 895...
        ok_o = 0 ;
        ok_o = 0 ;
    end
    end
end
end
endtask // kbd_write
endtask // kbd_write
 
 
 
task devider_write ;
 
    input [31:0] address_i ;
 
    input [31:16] data_i ;
 
    output ok_o ;
 
 
 
    reg `WRITE_STIM_TYPE   write_data ;
 
    reg `WRITE_RETURN_TYPE write_status ;
 
    reg `WB_TRANSFER_FLAGS flags ;
 
begin:main
 
    ok_o = 1 ;
 
    flags`WB_TRANSFER_SIZE     = 1 ;
 
    flags`WB_TRANSFER_AUTO_RTY = 0 ;
 
    flags`WB_TRANSFER_CAB      = 0 ;
 
    flags`INIT_WAITS           = 0 ;
 
    flags`SUBSEQ_WAITS         = 0 ;
 
 
 
    write_data`WRITE_ADDRESS = address_i ;
 
    write_data`WRITE_DATA    = {2{data_i}};
 
    write_data`WRITE_SEL     = 4'hC ;
 
 
 
    i_wb_master.wb_single_write( write_data, flags, write_status ) ;
 
 
 
    if ( write_status`CYC_ACK !== 1 )
 
    begin
 
        $display("Error! Keyboard controller didn't acknowledge single write access") ;
 
        #400 $stop ;
 
        ok_o = 0 ;
 
    end
 
end
 
endtask // devider_write
 
 
task test_scan_code_receiving ;
task test_scan_code_receiving ;
    reg ok_keyboard ;
    reg ok_keyboard ;
    reg ok_controler ;
    reg ok_controler ;
    reg ok ;
    reg ok ;
    reg [7:0] data ;
    reg [7:0] data ;
Line 1232... Line 1284...
    reg ok_keyboard ;
    reg ok_keyboard ;
    reg error ;
    reg error ;
    reg [7:0] data ;
    reg [7:0] data ;
begin:main
begin:main
    // first test, if keyboard stays inhibited after character is received, but not read from the controler
    // first test, if keyboard stays inhibited after character is received, but not read from the controler
 
 
    i_ps2_keyboard_model.kbd_send_char
    i_ps2_keyboard_model.kbd_send_char
    (
    (
        8'hE0,
        8'hE0,
        ok_keyboard,
        ok_keyboard,
        error
        error
Line 1252... Line 1305...
        $display("Something is wrong! Keyboard wasn't able to send a character!") ;
        $display("Something is wrong! Keyboard wasn't able to send a character!") ;
        #1 disable main ;
        #1 disable main ;
    end
    end
 
 
    // wait 5 us to see, if keyboard is inhibited
    // wait 5 us to see, if keyboard is inhibited
    #5000 ;
    #60000 ;
 
 
    // now check, if clock line is low!
    // now check, if clock line is low!
    if ( kbd_clk_cable !== 0 )
    if ( kbd_clk_cable !== 0 )
    begin
    begin
        $display("Error! Keyboard wasn't inhibited when output buffer was filled!") ;
        $display("Error! Keyboard wasn't inhibited when output buffer was filled!") ;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.