r4200b.v 4.99 KB
module r4200b(clock, reset_l, p_valid_l, e_valid_l, e_ok_l, int_l,
    sys_ad, sys_cmd, nmi_l);

`include "rcp.vh"
`include "rdram.vh"
`include "define.vh"

input clock;
input reset_l;
input e_valid_l;
input e_ok_l;
input int_l;
input nmi_l;

output p_valid_l;

inout [SYS_AD_SIZE-1:0] sys_ad;
inout [SYS_CMD_SIZE-1:0] sys_cmd;

reg e_valid;
reg e_ok;
reg int;
reg p_valid;
reg [SYS_AD_SIZE-1:0] sys_ad_in, sys_ad_out;
reg [SYS_CMD_SIZE-1:0] sys_cmd_in, sys_cmd_out;
reg sys_ad_enable;
reg [31:0] data [0:7];
reg test_selected;
reg rdram_ready;

assign sys_ad = sys_ad_enable ? sys_ad_out : 'bz;
assign sys_cmd = sys_ad_enable ? sys_cmd_out : 'bz;
assign p_valid_l = ~p_valid;

reg monitor;
initial monitor = $test$plusargs("r4200_mon");

always @(posedge clock) begin
    e_valid <= ~e_valid_l;
    e_ok <= ~e_ok_l;
    int <= ~int_l;
    sys_ad_in <= sys_ad;
    sys_cmd_in <= sys_cmd;
    end


//  asynchronous reset_l
always @(reset_l) begin
    if (!reset_l) begin
       assign p_valid = LOW;
       assign sys_ad_enable = HIGH;
       end
    else begin
       deassign p_valid;
       deassign sys_ad_enable;
       end
    end

// nmi detector
always @(posedge clock) begin
   if (nmi_l == 0)
   $display (" NMI detected");
end

initial begin
    test_selected <= LOW;
    rdram_ready <= LOW;

    wait(`SYSTEM_READY);

    @(posedge clock);

    if ($test$plusargs("test_4200_mi_version")) mi_version;
    if ($test$plusargs("test_4200_dp_counters")) dp_counters;
    if ($test$plusargs("test_4200_pbus_reg")) pbus_reg;
    if ($test$plusargs("test_4200_pbus_io")) pbus_io;
    if ($test$plusargs("test_4200_pbus_dma")) pbus_dma;
    if ($test$plusargs("test_4200_pif_boot")) pif_boot;
    if ($test$plusargs("test_4200_dmem")) sp_dmem;
    if ($test$plusargs("test_4200_imem")) sp_imem;
    if ($test$plusargs("test_4200_rsp_dma")) rsp_dma;
    if ($test$plusargs("test_4200_sp_reg")) sp_reg;
    if ($test$plusargs("test_4200_sp_dma_copy")) sp_dma_copy;
    if ($test$plusargs("test_4200_sp_dual")) sp_dual;
    if ($test$plusargs("test_4200_cbuf_dma")) cbuf_dma;
    if ($test$plusargs("test_4200_cbuf_dmem")) cbuf_dmem;
    if ($test$plusargs("test_4200_subblock")) test_subblock;
    if ($test$plusargs("test_4200_byte_write")) test_byte_write;
    if ($test$plusargs("test_4200_external")) external;
    if ($test$plusargs("test_4200_data_file")) data_file;
    if ($test$plusargs("test_4200_pif_test")) pif_test;
    if ($test$plusargs("test_4200_nmi_test")) nmi_test;
    if ($test$plusargs("test_4200_pif_interrupt")) pif_interrupt;
    if ($test$plusargs("test_4200_pif_rd_lap1")) pif_rd_lap1;
    if ($test$plusargs("test_4200_pif_rd_lap2")) pif_rd_lap2;
    if ($test$plusargs("test_4200_pif_rd_lap3")) pif_rd_lap3;
    if ($test$plusargs("test_4200_vi_test")) vi_test;
    if ($test$plusargs("test_4200_ai_test")) ai_test;
    if ($test$plusargs("test_4200_pif_rd4Bcpu")) pif_rd4Bcpu;
    if ($test$plusargs("test_4200_pif_io_read_conflict")) pif_io_read_conflict;
    if ($test$plusargs("test_4200_pif_wr4B")) pif_wr4B;
    if ($test$plusargs("test_4200_pif_rd64B")) pif_rd64B;
    if ($test$plusargs("test_4200_pif_wr64B")) pif_wr64B;
    if ($test$plusargs("test_4200_pif_wr_rd")) pif_wr_rd;
    if ($test$plusargs("test_4200_span_buf_test")) span_buf_test;
    end

initial begin
    if ($test$plusargs("help")) begin
       $display("R4200 test arguments include:");

       $display("  +test_4200_mi_version");
       $display("  +test_4200_dp_counters");
       $display("  +test_4200_pbus_reg");
       $display("  +test_4200_pbus_io");
       $display("  +test_4200_pbus_dma");
       $display("  +test_4200_pif_boot");
       $display("  +test_4200_dmem");
       $display("  +test_4200_imem");
       $display("  +test_4200_rsp_dma");
       $display("  +test_4200_sp_reg");
       $display("  +test_4200_sp_dma_copy");
       $display("  +test_4200_sp_dual");
       $display("  +test_4200_cbuf_dma");
       $display("  +test_4200_cbuf_dmem");
       $display("  +test_4200_subblock");
       $display("  +test_4200_byte_write");
       $display("  +test_4200_external");
       $display("  +test_4200_data_file");
       $display("  +test_4200_pif_test");
       $display("  +test_4200_nmi_test");
       $display("  +test_4200_pif_interrupt");
       $display("  +test_4200_pif_rd_lap1");
       $display("  +test_4200_pif_rd_lap2");
       $display("  +test_4200_pif_rd_lap3");
       $display("  +test_4200_vi_test");
       $display("  +test_4200_ai_test");
       $display("  +test_4200_pif_wr4B");
       $display("  +test_4200_pif_rd4Bcpu");
       $display("  +test_4200_pif_io_read_conflict");
       $display("  +test_4200_pif_rd64B");
       $display("  +test_4200_pif_wr64B");
       $display("  +test_4200_pif_wr_rd");
       $display("  +test_4200_span_buf_test");
       $display("");
       #1 $finish;
       end
    end




`include "io_tasks.v"
`include "pif_tasks.v"
`include "audio_tasks.v"
`include "video_tasks.v"
`include "rspdma_tasks.v"
`include "rdp_tasks.v"
`include "support_tasks.v"

`ifdef IPC_PRESENT
`include "ipc_tasks.v"
`endif

endmodule