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

Subversion Repositories openmsp430

[/] [openmsp430/] [trunk/] [core/] [sim/] [rtl_sim/] [src/] [dbg_i2c_rdwr.v] - Diff between revs 175 and 202

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

Rev 175 Rev 202
/*===========================================================================*/
/*===========================================================================*/
/* Copyright (C) 2001 Authors                                                */
/* Copyright (C) 2001 Authors                                                */
/*                                                                           */
/*                                                                           */
/* This source file may be used and distributed without restriction provided */
/* This source file may be used and distributed without restriction provided */
/* that this copyright statement is not removed from the file and that any   */
/* that this copyright statement is not removed from the file and that any   */
/* derivative work contains the original copyright notice and the associated */
/* derivative work contains the original copyright notice and the associated */
/* disclaimer.                                                               */
/* disclaimer.                                                               */
/*                                                                           */
/*                                                                           */
/* This source file is free software; you can redistribute it and/or modify  */
/* This source file is free software; you can redistribute it and/or modify  */
/* it under the terms of the GNU Lesser General Public License as published  */
/* it under the terms of the GNU Lesser General Public License as published  */
/* by the Free Software Foundation; either version 2.1 of the License, or    */
/* by the Free Software Foundation; either version 2.1 of the License, or    */
/* (at your option) any later version.                                       */
/* (at your option) any later version.                                       */
/*                                                                           */
/*                                                                           */
/* This source is distributed in the hope that it will be useful, but WITHOUT*/
/* This source is distributed in the hope that it will be useful, but WITHOUT*/
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or     */
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or     */
/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public       */
/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public       */
/* License for more details.                                                 */
/* License for more details.                                                 */
/*                                                                           */
/*                                                                           */
/* You should have received a copy of the GNU Lesser General Public License  */
/* You should have received a copy of the GNU Lesser General Public License  */
/* along with this source; if not, write to the Free Software Foundation,    */
/* along with this source; if not, write to the Free Software Foundation,    */
/* Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA        */
/* Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA        */
/*                                                                           */
/*                                                                           */
/*===========================================================================*/
/*===========================================================================*/
/*                            DEBUG INTERFACE:  RD / WR                      */
/*                            DEBUG INTERFACE:  RD / WR                      */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Test the UART debug interface:                                            */
/* Test the UART debug interface:                                            */
/*                        - Check RD/WR access to all adressable             */
/*                        - Check RD/WR access to all adressable             */
/*                          debug registers.                                 */
/*                          debug registers.                                 */
/*                                                                           */
/*                                                                           */
/* Author(s):                                                                */
/* Author(s):                                                                */
/*             - Olivier Girard,    olgirard@gmail.com                       */
/*             - Olivier Girard,    olgirard@gmail.com                       */
/*                                                                           */
/*                                                                           */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* $Rev: 95 $                                                                */
/* $Rev: 95 $                                                                */
/* $LastChangedBy: olivier.girard $                                          */
/* $LastChangedBy: olivier.girard $                                          */
/* $LastChangedDate: 2011-02-24 21:37:57 +0100 (Thu, 24 Feb 2011) $          */
/* $LastChangedDate: 2011-02-24 21:37:57 +0100 (Thu, 24 Feb 2011) $          */
/*===========================================================================*/
/*===========================================================================*/
 
 
`define LONG_TIMEOUT
`define LONG_TIMEOUT
 
 
reg  [2:0] cpu_version;
reg  [2:0] cpu_version;
reg        cpu_asic;
reg        cpu_asic;
reg  [4:0] user_version;
reg  [4:0] user_version;
reg  [6:0] per_space;
reg  [6:0] per_space;
reg        mpy_info;
reg        mpy_info;
reg  [8:0] dmem_size;
reg  [8:0] dmem_size;
reg  [5:0] pmem_size;
reg  [5:0] pmem_size;
reg [31:0] dbg_id;
reg [31:0] dbg_id;
 
 
// Set oMSP parameters for later check
// Set oMSP parameters for later check
defparam dut.INST_NR  = 8'h12;
defparam dut.INST_NR  = 8'h12;
defparam dut.TOTAL_NR = 8'h34;
defparam dut.TOTAL_NR = 8'h34;
 
 
integer    ii;
integer    ii;
 
 
 
 
initial
initial
   begin
   begin
      $display(" ===============================================");
      $display(" ===============================================");
      $display("|                 START SIMULATION              |");
      $display("|                 START SIMULATION              |");
      $display(" ===============================================");
      $display(" ===============================================");
`ifdef DBG_EN
`ifdef DBG_EN
`ifdef DBG_I2C
`ifdef DBG_I2C
    #1 dbg_en = 1;
    #1 dbg_en = 1;
      repeat(30) @(posedge mclk);
      repeat(30) @(posedge mclk);
      stimulus_done = 0;
      stimulus_done = 0;
 
 
      // STOP CPU
      // STOP CPU
      dbg_i2c_wr(CPU_CTL ,  16'h0001);
      dbg_i2c_wr(CPU_CTL ,  16'h0001);
 
 
      // TEST READ/WR TO ALL DEBUG REGISTERS
      // TEST READ/WR TO ALL DEBUG REGISTERS
      //--------------------------------------------------------
      //--------------------------------------------------------
 
 
      cpu_version  =  `CPU_VERSION;
      cpu_version  =  `CPU_VERSION;
`ifdef ASIC
`ifdef ASIC
      cpu_asic     =  1'b1;
      cpu_asic     =  1'b1;
`else
`else
      cpu_asic     =  1'b0;
      cpu_asic     =  1'b0;
`endif
`endif
      user_version =  `USER_VERSION;
      user_version =  `USER_VERSION;
      per_space    = (`PER_SIZE  >> 9);
      per_space    = (`PER_SIZE  >> 9);
`ifdef MULTIPLIER
`ifdef MULTIPLIER
      mpy_info     =  1'b1;
      mpy_info     =  1'b1;
`else
`else
      mpy_info     =  1'b0;
      mpy_info     =  1'b0;
`endif
`endif
      dmem_size    = (`DMEM_SIZE >> 7);
      dmem_size    = (`DMEM_SIZE >> 7);
      pmem_size    = (`PMEM_SIZE >> 10);
      pmem_size    = (`PMEM_SIZE >> 10);
 
 
      dbg_id       = {pmem_size,
      dbg_id       = {pmem_size,
                      dmem_size,
                      dmem_size,
                      mpy_info,
                      mpy_info,
                      per_space,
                      per_space,
                      user_version,
                      user_version,
                      cpu_asic,
                      cpu_asic,
                      cpu_version};
                      cpu_version};
 
 
      // Check reset value
      // Check reset value
      for ( ii=0; ii < 64; ii=ii+1)
      for ( ii=0; ii < 64; ii=ii+1)
        begin
        begin
           dbg_i2c_rd(ii[7:0]);
           dbg_i2c_rd(ii[7:0]);
 
 
           case(ii)
           case(ii)
             0       : if (dbg_i2c_buf !== dbg_id[15:0])  tb_error("READ 1 ERROR (CPU_ID_LO)");
             0       : if (dbg_i2c_buf !== dbg_id[15:0])  tb_error("READ 1 ERROR (CPU_ID_LO)");
             1       : if (dbg_i2c_buf !== dbg_id[31:16]) tb_error("READ 1 ERROR (CPU_ID_HI)");
             1       : if (dbg_i2c_buf !== dbg_id[31:16]) tb_error("READ 1 ERROR (CPU_ID_HI)");
             2       : if (dbg_i2c_buf !== 16'h0000)      tb_error("READ 1 ERROR (CPU_CTL)");
             2       : if (dbg_i2c_buf !== 16'h0000)      tb_error("READ 1 ERROR (CPU_CTL)");
             3       : if (dbg_i2c_buf !== 16'h0005)      tb_error("READ 1 ERROR (CPU_STAT)");
             3       : if (dbg_i2c_buf !== 16'h0005)      tb_error("READ 1 ERROR (CPU_STAT)");
            24       : if (dbg_i2c_buf !== 16'h3412)      tb_error("READ 1 ERROR (CPU_NR)");
            24       : if (dbg_i2c_buf !== 16'h3412)      tb_error("READ 1 ERROR (CPU_NR)");
             default : if (dbg_i2c_buf !== 16'h0000)      tb_error("READ 1 ERROR");
             default : if (dbg_i2c_buf !== 16'h0000)      tb_error("READ 1 ERROR");
           endcase
           endcase
        end
        end
 
 
      // Write access
      // Write access
      for ( ii=0; ii < 64; ii=ii+1)
      for ( ii=0; ii < 64; ii=ii+1)
        begin
        begin
           // Skip write for MEM_CNT
           // Skip write for MEM_CNT
           if (ii!=7)
           if (ii!=7)
             dbg_i2c_wr(ii[7:0] ,  16'hffff);
             dbg_i2c_wr(ii[7:0] ,  16'hffff);
        end
        end
 
 
      // Read value back
      // Read value back
      for ( ii=0; ii < 64; ii=ii+1)
      for ( ii=0; ii < 64; ii=ii+1)
        begin
        begin
           dbg_i2c_rd(ii[7:0]);
           dbg_i2c_rd(ii[7:0]);
 
 
           case(ii)
           case(ii)
             0       : if (dbg_i2c_buf !== dbg_id[15:0])  tb_error("READ 2 ERROR (CPU_ID_LO)");
             0       : if (dbg_i2c_buf !== dbg_id[15:0])  tb_error("READ 2 ERROR (CPU_ID_LO)");
             1       : if (dbg_i2c_buf !== dbg_id[31:16]) tb_error("READ 2 ERROR (CPU_ID_HI)");
             1       : if (dbg_i2c_buf !== dbg_id[31:16]) tb_error("READ 2 ERROR (CPU_ID_HI)");
             2       : if (dbg_i2c_buf !== 16'h0078)      tb_error("READ 2 ERROR (CPU_CTL)");
             2       : if (dbg_i2c_buf !== 16'h0078)      tb_error("READ 2 ERROR (CPU_CTL)");
             3       : if ((dbg_i2c_buf !== 16'h0004)&0)  tb_error("READ 2 ERROR (CPU_STAT)");
             3       : if ((dbg_i2c_buf !== 16'h0004)&0)  tb_error("READ 2 ERROR (CPU_STAT)");
             4       : if (dbg_i2c_buf !== 16'h000E)      tb_error("READ 2 ERROR (MEM_CTL)");
             4       : if (dbg_i2c_buf !== 16'h000E)      tb_error("READ 2 ERROR (MEM_CTL)");
             5       : if (dbg_i2c_buf !== 16'hFFFF)      tb_error("READ 2 ERROR (MEM_ADDR)");
             5       : if (dbg_i2c_buf !== 16'hFFFF)      tb_error("READ 2 ERROR (MEM_ADDR)");
             6       : if (dbg_i2c_buf !== 16'hFFFF)      tb_error("READ 2 ERROR (MEM_DATA)");
             6       : if (dbg_i2c_buf !== 16'hFFFF)      tb_error("READ 2 ERROR (MEM_DATA)");
             7       : if (dbg_i2c_buf !== 16'h0000)      tb_error("READ 2 ERROR (MEM_CNT)");
             7       : if (dbg_i2c_buf !== 16'h0000)      tb_error("READ 2 ERROR (MEM_CNT)");
`ifdef DBG_HWBRK_0
`ifdef DBG_HWBRK_0
   `ifdef DBG_HWBRK_RANGE
   `ifdef DBG_HWBRK_RANGE
             8       : if (dbg_i2c_buf !== 16'h001F)      tb_error("READ 2 ERROR (BRK0_CTL)");
             8       : if (dbg_i2c_buf !== 16'h001F)      tb_error("READ 2 ERROR (BRK0_CTL)");
   `else
   `else
             8       : if (dbg_i2c_buf !== 16'h000F)      tb_error("READ 2 ERROR (BRK0_CTL)");
             8       : if (dbg_i2c_buf !== 16'h000F)      tb_error("READ 2 ERROR (BRK0_CTL)");
   `endif
   `endif
             9       : if (dbg_i2c_buf !== 16'h0000)      tb_error("READ 2 ERROR (BRK0_STAT)");
             9       : if (dbg_i2c_buf !== 16'h0000)      tb_error("READ 2 ERROR (BRK0_STAT)");
            10       : if (dbg_i2c_buf !== 16'hFFFF)      tb_error("READ 2 ERROR (BRK0_ADDR0)");
            10       : if (dbg_i2c_buf !== 16'hFFFF)      tb_error("READ 2 ERROR (BRK0_ADDR0)");
            11       : if (dbg_i2c_buf !== 16'hFFFF)      tb_error("READ 2 ERROR (BRK0_ADDR1)");
            11       : if (dbg_i2c_buf !== 16'hFFFF)      tb_error("READ 2 ERROR (BRK0_ADDR1)");
`endif
`endif
`ifdef DBG_HWBRK_1
`ifdef DBG_HWBRK_1
   `ifdef DBG_HWBRK_RANGE
   `ifdef DBG_HWBRK_RANGE
            12       : if (dbg_i2c_buf !== 16'h001F)      tb_error("READ 2 ERROR (BRK1_CTL)");
            12       : if (dbg_i2c_buf !== 16'h001F)      tb_error("READ 2 ERROR (BRK1_CTL)");
   `else
   `else
            12       : if (dbg_i2c_buf !== 16'h000F)      tb_error("READ 2 ERROR (BRK1_CTL)");
            12       : if (dbg_i2c_buf !== 16'h000F)      tb_error("READ 2 ERROR (BRK1_CTL)");
   `endif
   `endif
            13       : if (dbg_i2c_buf !== 16'h0000)      tb_error("READ 2 ERROR (BRK1_STAT)");
            13       : if (dbg_i2c_buf !== 16'h0000)      tb_error("READ 2 ERROR (BRK1_STAT)");
            14       : if (dbg_i2c_buf !== 16'hFFFF)      tb_error("READ 2 ERROR (BRK1_ADDR0)");
            14       : if (dbg_i2c_buf !== 16'hFFFF)      tb_error("READ 2 ERROR (BRK1_ADDR0)");
            15       : if (dbg_i2c_buf !== 16'hFFFF)      tb_error("READ 2 ERROR (BRK1_ADDR1)");
            15       : if (dbg_i2c_buf !== 16'hFFFF)      tb_error("READ 2 ERROR (BRK1_ADDR1)");
`endif
`endif
`ifdef DBG_HWBRK_2
`ifdef DBG_HWBRK_2
   `ifdef DBG_HWBRK_RANGE
   `ifdef DBG_HWBRK_RANGE
            16       : if (dbg_i2c_buf !== 16'h001F)      tb_error("READ 2 ERROR (BRK2_CTL)");
            16       : if (dbg_i2c_buf !== 16'h001F)      tb_error("READ 2 ERROR (BRK2_CTL)");
   `else
   `else
            16       : if (dbg_i2c_buf !== 16'h000F)      tb_error("READ 2 ERROR (BRK2_CTL)");
            16       : if (dbg_i2c_buf !== 16'h000F)      tb_error("READ 2 ERROR (BRK2_CTL)");
   `endif
   `endif
            17       : if (dbg_i2c_buf !== 16'h0000)      tb_error("READ 2 ERROR (BRK2_STAT)");
            17       : if (dbg_i2c_buf !== 16'h0000)      tb_error("READ 2 ERROR (BRK2_STAT)");
            18       : if (dbg_i2c_buf !== 16'hFFFF)      tb_error("READ 2 ERROR (BRK2_ADDR0)");
            18       : if (dbg_i2c_buf !== 16'hFFFF)      tb_error("READ 2 ERROR (BRK2_ADDR0)");
            19       : if (dbg_i2c_buf !== 16'hFFFF)      tb_error("READ 2 ERROR (BRK2_ADDR1)");
            19       : if (dbg_i2c_buf !== 16'hFFFF)      tb_error("READ 2 ERROR (BRK2_ADDR1)");
`endif
`endif
`ifdef DBG_HWBRK_3
`ifdef DBG_HWBRK_3
   `ifdef DBG_HWBRK_RANGE
   `ifdef DBG_HWBRK_RANGE
            20       : if (dbg_i2c_buf !== 16'h001F)      tb_error("READ 2 ERROR (BRK3_CTL)");
            20       : if (dbg_i2c_buf !== 16'h001F)      tb_error("READ 2 ERROR (BRK3_CTL)");
   `else
   `else
            20       : if (dbg_i2c_buf !== 16'h000F)      tb_error("READ 2 ERROR (BRK3_CTL)");
            20       : if (dbg_i2c_buf !== 16'h000F)      tb_error("READ 2 ERROR (BRK3_CTL)");
   `endif
   `endif
            21       : if (dbg_i2c_buf !== 16'h0000)      tb_error("READ 2 ERROR (BRK3_STAT)");
            21       : if (dbg_i2c_buf !== 16'h0000)      tb_error("READ 2 ERROR (BRK3_STAT)");
            22       : if (dbg_i2c_buf !== 16'hFFFF)      tb_error("READ 2 ERROR (BRK3_ADDR0)");
            22       : if (dbg_i2c_buf !== 16'hFFFF)      tb_error("READ 2 ERROR (BRK3_ADDR0)");
            23       : if (dbg_i2c_buf !== 16'hFFFF)      tb_error("READ 2 ERROR (BRK3_ADDR1)");
            23       : if (dbg_i2c_buf !== 16'hFFFF)      tb_error("READ 2 ERROR (BRK3_ADDR1)");
`endif
`endif
            24       : if (dbg_i2c_buf !== 16'h3412)      tb_error("READ 2 ERROR (CPU_NR)");
            24       : if (dbg_i2c_buf !== 16'h3412)      tb_error("READ 2 ERROR (CPU_NR)");
             default : if (dbg_i2c_buf !== 16'h0000)      tb_error("READ 2 ERROR");
             default : if (dbg_i2c_buf !== 16'h0000)      tb_error("READ 2 ERROR");
           endcase
           endcase
        end
        end
 
 
 
 
      dbg_i2c_wr(CPU_CTL    ,  16'h0002);
      dbg_i2c_wr(CPU_CTL    ,  16'h0002);
      repeat(10) @(posedge mclk);
      repeat(10) @(posedge mclk);
 
 
      stimulus_done = 1;
      stimulus_done = 1;
`else
`else
 
 
       $display(" ===============================================");
       tb_skip_finish("|   (serial debug interface I2C not included)  |");
       $display("|               SIMULATION SKIPPED              |");
 
       $display("|   (serial debug interface I2C not included)  |");
 
       $display(" ===============================================");
 
       $finish;
 
`endif
`endif
`else
`else
 
       tb_skip_finish("|      (serial debug interface not included)   |");
       $display(" ===============================================");
 
       $display("|               SIMULATION SKIPPED              |");
 
       $display("|      (serial debug interface not included)    |");
 
       $display(" ===============================================");
 
       $finish;
 
`endif
`endif
   end
   end
 
 
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

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