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

Subversion Repositories tv80

[/] [tv80/] [branches/] [s80_env_devel/] [env/] [env_io.v] - Diff between revs 13 and 84

Only display areas with differences | Details | Blame | View Log

Rev 13 Rev 84
 
 
module env_io (/*AUTOARG*/
module env_io (/*AUTOARG*/
  // Outputs
  // Outputs
  DI,
  DI,
  // Inputs
  // Inputs
  clk, iorq_n, rd_n, wr_n, addr, DO
  clk, iorq_n, rd_n, wr_n, addr, DO
  );
  );
 
 
  parameter str_buf_sz = 256;
  parameter str_buf_sz = 256;
 
 
  input clk;
  input clk;
  input iorq_n;
  input iorq_n;
  input rd_n;
  input rd_n;
  input wr_n;
  input wr_n;
  input [7:0] addr;
  input [7:0] addr;
  input [7:0] DO;
  input [7:0] DO;
  inout [7:0] DI;
  inout [7:0] DI;
 
 
  reg [7:0]    io_data;
  reg [7:0]    io_data;
 
 
  reg [7:0]    str_buf [0:str_buf_sz-1];
  reg [7:0]    str_buf [0:str_buf_sz-1];
  reg          io_cs;
  reg          io_cs;
  integer      buf_ptr, i;
  integer      buf_ptr, i;
 
 
  reg [7:0]    timeout_ctl;
  reg [7:0]    timeout_ctl;
  reg [15:0]   cur_timeout;
  reg [15:0]   cur_timeout;
  reg [15:0]   max_timeout;
  reg [15:0]   max_timeout;
 
 
  reg [7:0]    int_countdown;
  reg [7:0]    int_countdown;
 
 
  assign       DI = (!iorq_n & !rd_n & io_cs) ? io_data : {8{1'bz}};
  assign       DI = (!iorq_n & !rd_n & io_cs) ? io_data : {8{1'bz}};
 
 
  initial
  initial
    begin
    begin
      io_cs = 0;
      io_cs = 0;
      buf_ptr = 0;
      buf_ptr = 0;
      cur_timeout = 0;
      cur_timeout = 0;
      max_timeout = 10000;
      max_timeout = 10000;
      timeout_ctl = 1;
      timeout_ctl = 1;
      int_countdown = 0;
      int_countdown = 0;
    end
    end
 
 
  always @(posedge clk)
  always @(posedge clk)
    begin
    begin
      if (!iorq_n & !wr_n)
      if (!iorq_n & !wr_n)
        case (addr)
        case (addr)
          8'h80 :
          8'h80 :
            begin
            begin
              case (DO)
              case (DO)
                1 : tb_top.test_pass;
                1 : tb_top.test_pass;
 
 
                2 : tb_top.test_fail;
                2 : tb_top.test_fail;
 
 
                3 : tb_top.dumpon;
                3 : tb_top.dumpon;
 
 
                4 : tb_top.dumpoff;
                4 : tb_top.dumpoff;
 
 
                default :
                default :
                  begin
                  begin
                    $display ("%t: ERROR   : Unknown I/O command %x", $time, DO);
                    $display ("%t: ERROR   : Unknown I/O command %x", $time, DO);
                  end
                  end
              endcase // case(DO)
              endcase // case(DO)
            end // case: :...
            end // case: :...
 
 
          8'h81 :
          8'h81 :
            begin
            begin
              str_buf[buf_ptr] = DO;
              str_buf[buf_ptr] = DO;
              buf_ptr = buf_ptr + 1;
              buf_ptr = buf_ptr + 1;
 
 
              if (buf_ptr == str_buf_sz)
              if (buf_ptr == str_buf_sz)
                begin
                begin
                  $display ("%t: WARNING : String buffer reached maximum size without detecting EOL", $time);
                  $display ("%t: WARNING : String buffer reached maximum size without detecting EOL", $time);
                  $write ("%t: WARNING : Contents: ", $time);
                  $write ("%t: WARNING : Contents: ", $time);
                  for (i=0; i<buf_ptr; i=i+1)
                  for (i=0; i<buf_ptr; i=i+1)
                    $write ("%s", str_buf[i]);
                    $write ("%s", str_buf[i]);
                  $write ("\n");
                  $write ("\n");
                  buf_ptr = 0;
                  buf_ptr = 0;
                end
                end
 
 
              //$display ("%t: DEBUG   : Detected write of character %x", $time, DO);
              //$display ("%t: DEBUG   : Detected write of character %x", $time, DO);
              if (DO == 8'h0A)
              if (DO == 8'h0A)
                begin
                begin
                  $write ("%t: PROGRAM : ", $time);
                  $write ("%t: PROGRAM : ", $time);
 
 
                  for (i=0; i<buf_ptr; i=i+1)
                  for (i=0; i<buf_ptr; i=i+1)
                    $write ("%s", str_buf[i]);
                    $write ("%s", str_buf[i]);
 
 
                  buf_ptr = 0;
                  buf_ptr = 0;
                end
                end
            end // case: 8'h81
            end // case: 8'h81
 
 
          8'h82 :
          8'h82 :
            begin
            begin
              timeout_ctl = DO;
              timeout_ctl = DO;
            end
            end
 
 
          8'h83 : max_timeout[7:0] = DO;
          8'h83 : max_timeout[7:0] = DO;
          8'h84 : max_timeout[15:8] = DO;
          8'h84 : max_timeout[15:8] = DO;
 
 
          8'h90 : int_countdown = DO;
          8'h90 : int_countdown = DO;
        endcase // case(addr)
        endcase // case(addr)
    end // always @ (posedge clk)
    end // always @ (posedge clk)
 
 
  always @(posedge clk)
  always @(posedge clk)
    begin
    begin
      if (timeout_ctl[1])
      if (timeout_ctl[1])
        cur_timeout = 0;
        cur_timeout = 0;
      else if (timeout_ctl[0])
      else if (timeout_ctl[0])
        cur_timeout = cur_timeout + 1;
        cur_timeout = cur_timeout + 1;
 
 
      if (cur_timeout >= max_timeout)
      if (cur_timeout >= max_timeout)
        begin
        begin
          $display ("%t: ERROR   : Reached timeout %d cycles", $time, max_timeout);
          $display ("%t: ERROR   : Reached timeout %d cycles", $time, max_timeout);
          tb_top.test_fail;
          tb_top.test_fail;
        end
        end
    end // always @ (posedge clk)
    end // always @ (posedge clk)
 
 
  always @(posedge clk)
  always @(posedge clk)
    begin
    begin
      if (int_countdown == 1)
      if (int_countdown == 1)
        begin
        begin
          tb_top.int_n  <= #1 1'b0;
          tb_top.int_n  <= #1 1'b0;
          int_countdown = 0;
          int_countdown = 0;
        end
        end
      else if (int_countdown > 1)
      else if (int_countdown > 1)
        int_countdown = int_countdown - 1;
        int_countdown = int_countdown - 1;
    end
    end
 
 
endmodule // env_io
endmodule // env_io
 
 

powered by: WebSVN 2.1.0

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