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

Subversion Repositories openmsp430

[/] [openmsp430/] [trunk/] [core/] [sim/] [rtl_sim/] [src/] [dbg_uart.v] - Diff between revs 106 and 111

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

Rev 106 Rev 111
Line 30... Line 30...
/*                                                                           */
/*                                                                           */
/* Author(s):                                                                */
/* Author(s):                                                                */
/*             - Olivier Girard,    olgirard@gmail.com                       */
/*             - Olivier Girard,    olgirard@gmail.com                       */
/*                                                                           */
/*                                                                           */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* $Rev: 106 $                                                                */
/* $Rev: 111 $                                                                */
/* $LastChangedBy: olivier.girard $                                          */
/* $LastChangedBy: olivier.girard $                                          */
/* $LastChangedDate: 2011-03-25 23:01:03 +0100 (Fri, 25 Mar 2011) $          */
/* $LastChangedDate: 2011-05-20 22:39:02 +0200 (Fri, 20 May 2011) $          */
/*===========================================================================*/
/*===========================================================================*/
 
 
`define LONG_TIMEOUT
`define LONG_TIMEOUT
 
 
reg [15:0] dbg_id_pmem;
reg  [2:0] cpu_version;
reg [15:0] dbg_id_dmem;
reg        cpu_asic;
 
reg  [4:0] user_version;
 
reg  [6:0] per_space;
 
reg        mpy_info;
 
reg  [8:0] dmem_size;
 
reg  [5:0] pmem_size;
reg [31:0] dbg_id;
reg [31:0] dbg_id;
 
 
initial
initial
   begin
   begin
      $display(" ===============================================");
      $display(" ===============================================");
      $display("|                 START SIMULATION              |");
      $display("|                 START SIMULATION              |");
      $display(" ===============================================");
      $display(" ===============================================");
 
`ifdef DBG_EN
 
`ifdef DBG_UART
      #1 dbg_en = 1;
      #1 dbg_en = 1;
      repeat(30) @(posedge mclk);
      repeat(30) @(posedge mclk);
      stimulus_done = 0;
      stimulus_done = 0;
 
 
      // SEND UART SYNCHRONIZATION FRAME
      // SEND UART SYNCHRONIZATION FRAME
Line 59... Line 66...
      dbg_uart_wr(CPU_CTL,  16'h0002);  // RUN
      dbg_uart_wr(CPU_CTL,  16'h0002);  // RUN
   `endif
   `endif
 
 
      // TEST CPU REGISTERS
      // TEST CPU REGISTERS
      //--------------------------------------------------------
      //--------------------------------------------------------
      dbg_id_pmem = `PMEM_SIZE;
 
      dbg_id_dmem = `DMEM_SIZE;
      cpu_version  =  `CPU_VERSION;
      dbg_id      = {dbg_id_pmem, dbg_id_dmem};
`ifdef ASIC
 
      cpu_asic     =  1'b1;
 
`else
 
      cpu_asic     =  1'b0;
 
`endif
 
      user_version =  `USER_VERSION;
 
      per_space    = (`PER_SIZE  >> 9);
 
`ifdef MULTIPLIER
 
      mpy_info     =  1'b1;
 
`else
 
      mpy_info     =  1'b0;
 
`endif
 
      dmem_size    = (`DMEM_SIZE >> 7);
 
      pmem_size    = (`PMEM_SIZE >> 10);
 
 
 
      dbg_id       = {pmem_size,
 
                      dmem_size,
 
                      mpy_info,
 
                      per_space,
 
                      user_version,
 
                      cpu_asic,
 
                      cpu_version};
 
 
      dbg_uart_wr(CPU_ID_LO  ,  16'hffff);
      dbg_uart_wr(CPU_ID_LO  ,  16'hffff);
      dbg_uart_rd(CPU_ID_LO);
      dbg_uart_rd(CPU_ID_LO);
      if (dbg_uart_buf !== dbg_id[15:0])  tb_error("====== CPU_ID_LO uncorrect =====");
      if (dbg_uart_buf !== dbg_id[15:0])  tb_error("====== CPU_ID_LO uncorrect =====");
      dbg_uart_wr(CPU_ID_LO  ,  16'h0000);
      dbg_uart_wr(CPU_ID_LO  ,  16'h0000);
Line 126... Line 154...
      if (dbg_uart_buf !== 16'h0000)      tb_error("====== MEM_CNT uncorrect =====");
      if (dbg_uart_buf !== 16'h0000)      tb_error("====== MEM_CNT uncorrect =====");
 
 
 
 
      // TEST HARDWARE BREAKPOINT 0 REGISTERS
      // TEST HARDWARE BREAKPOINT 0 REGISTERS
      //--------------------------------------------------------
      //--------------------------------------------------------
 
`ifdef DBG_HWBRK_0
      dbg_uart_wr(BRK0_CTL   ,  16'hffff);
      dbg_uart_wr(BRK0_CTL   ,  16'hffff);
      dbg_uart_rd(BRK0_CTL);
      dbg_uart_rd(BRK0_CTL);
      if (`HWBRK_RANGE)
      if (`HWBRK_RANGE)
        begin
        begin
           if (dbg_uart_buf !== 16'h001F)      tb_error("====== BRK0_CTL uncorrect =====");
           if (dbg_uart_buf !== 16'h001F)      tb_error("====== BRK0_CTL uncorrect =====");
Line 161... Line 189...
      dbg_uart_rd(BRK0_ADDR1);
      dbg_uart_rd(BRK0_ADDR1);
      if (dbg_uart_buf !== 16'hffff)      tb_error("====== BRK0_ADDR1 uncorrect =====");
      if (dbg_uart_buf !== 16'hffff)      tb_error("====== BRK0_ADDR1 uncorrect =====");
      dbg_uart_wr(BRK0_ADDR1 ,  16'h0000);
      dbg_uart_wr(BRK0_ADDR1 ,  16'h0000);
      dbg_uart_rd(BRK0_ADDR1);
      dbg_uart_rd(BRK0_ADDR1);
      if (dbg_uart_buf !== 16'h0000)      tb_error("====== BRK0_ADDR1 uncorrect =====");
      if (dbg_uart_buf !== 16'h0000)      tb_error("====== BRK0_ADDR1 uncorrect =====");
 
`endif
 
 
      // TEST HARDWARE BREAKPOINT 1 REGISTERS
      // TEST HARDWARE BREAKPOINT 1 REGISTERS
      //--------------------------------------------------------
      //--------------------------------------------------------
 
`ifdef DBG_HWBRK_1
      dbg_uart_wr(BRK1_CTL   ,  16'hffff);
      dbg_uart_wr(BRK1_CTL   ,  16'hffff);
      dbg_uart_rd(BRK1_CTL);
      dbg_uart_rd(BRK1_CTL);
      if (`HWBRK_RANGE)
      if (`HWBRK_RANGE)
        begin
        begin
           if (dbg_uart_buf !== 16'h001F)      tb_error("====== BRK1_CTL uncorrect =====");
           if (dbg_uart_buf !== 16'h001F)      tb_error("====== BRK1_CTL uncorrect =====");
Line 200... Line 228...
      dbg_uart_rd(BRK1_ADDR1);
      dbg_uart_rd(BRK1_ADDR1);
      if (dbg_uart_buf !== 16'hffff)      tb_error("====== BRK1_ADDR1 uncorrect =====");
      if (dbg_uart_buf !== 16'hffff)      tb_error("====== BRK1_ADDR1 uncorrect =====");
      dbg_uart_wr(BRK1_ADDR1 ,  16'h0000);
      dbg_uart_wr(BRK1_ADDR1 ,  16'h0000);
      dbg_uart_rd(BRK1_ADDR1);
      dbg_uart_rd(BRK1_ADDR1);
      if (dbg_uart_buf !== 16'h0000)      tb_error("====== BRK1_ADDR1 uncorrect =====");
      if (dbg_uart_buf !== 16'h0000)      tb_error("====== BRK1_ADDR1 uncorrect =====");
 
`endif
 
 
      // TEST HARDWARE BREAKPOINT 2 REGISTERS
      // TEST HARDWARE BREAKPOINT 2 REGISTERS
      //--------------------------------------------------------
      //--------------------------------------------------------
 
`ifdef DBG_HWBRK_2
      dbg_uart_wr(BRK2_CTL   ,  16'hffff);
      dbg_uart_wr(BRK2_CTL   ,  16'hffff);
      dbg_uart_rd(BRK2_CTL);
      dbg_uart_rd(BRK2_CTL);
      if (`HWBRK_RANGE)
      if (`HWBRK_RANGE)
        begin
        begin
           if (dbg_uart_buf !== 16'h001F)      tb_error("====== BRK2_CTL uncorrect =====");
           if (dbg_uart_buf !== 16'h001F)      tb_error("====== BRK2_CTL uncorrect =====");
Line 239... Line 267...
      dbg_uart_rd(BRK2_ADDR1);
      dbg_uart_rd(BRK2_ADDR1);
      if (dbg_uart_buf !== 16'hffff)      tb_error("====== BRK2_ADDR1 uncorrect =====");
      if (dbg_uart_buf !== 16'hffff)      tb_error("====== BRK2_ADDR1 uncorrect =====");
      dbg_uart_wr(BRK2_ADDR1 ,  16'h0000);
      dbg_uart_wr(BRK2_ADDR1 ,  16'h0000);
      dbg_uart_rd(BRK2_ADDR1);
      dbg_uart_rd(BRK2_ADDR1);
      if (dbg_uart_buf !== 16'h0000)      tb_error("====== BRK2_ADDR1 uncorrect =====");
      if (dbg_uart_buf !== 16'h0000)      tb_error("====== BRK2_ADDR1 uncorrect =====");
 
`endif
 
 
      // TEST HARDWARE BREAKPOINT 3 REGISTERS
      // TEST HARDWARE BREAKPOINT 3 REGISTERS
      //--------------------------------------------------------
      //--------------------------------------------------------
 
`ifdef DBG_HWBRK_3
      dbg_uart_wr(BRK3_CTL   ,  16'hffff);
      dbg_uart_wr(BRK3_CTL   ,  16'hffff);
      dbg_uart_rd(BRK3_CTL);
      dbg_uart_rd(BRK3_CTL);
      if (`HWBRK_RANGE)
      if (`HWBRK_RANGE)
        begin
        begin
           if (dbg_uart_buf !== 16'h001F)      tb_error("====== BRK3_CTL uncorrect =====");
           if (dbg_uart_buf !== 16'h001F)      tb_error("====== BRK3_CTL uncorrect =====");
Line 278... Line 306...
      dbg_uart_rd(BRK3_ADDR1);
      dbg_uart_rd(BRK3_ADDR1);
      if (dbg_uart_buf !== 16'hffff)      tb_error("====== BRK3_ADDR1 uncorrect =====");
      if (dbg_uart_buf !== 16'hffff)      tb_error("====== BRK3_ADDR1 uncorrect =====");
      dbg_uart_wr(BRK3_ADDR1 ,  16'h0000);
      dbg_uart_wr(BRK3_ADDR1 ,  16'h0000);
      dbg_uart_rd(BRK3_ADDR1);
      dbg_uart_rd(BRK3_ADDR1);
      if (dbg_uart_buf !== 16'h0000)      tb_error("====== BRK3_ADDR1 uncorrect =====");
      if (dbg_uart_buf !== 16'h0000)      tb_error("====== BRK3_ADDR1 uncorrect =====");
 
`endif
 
 
      // TEST 16B WRITE BURSTS (MEMORY)
      // TEST 16B WRITE BURSTS (MEMORY)
      //--------------------------------------------------------
      //--------------------------------------------------------
 
 
      dbg_uart_wr(MEM_ADDR, 16'h0200); // select @0x0200
      dbg_uart_wr(MEM_ADDR, (`PER_SIZE+16'h0000)); // select @0x0200
      dbg_uart_wr(MEM_CNT,  16'h0004); // 5 consecutive access
      dbg_uart_wr(MEM_CNT,  16'h0004); // 5 consecutive access
 
 
      dbg_uart_wr(MEM_CTL,  16'h0003); // Start burst to 16 bit memory write
      dbg_uart_wr(MEM_CTL,  16'h0003); // Start burst to 16 bit memory write
      dbg_uart_tx16(16'h1234);         // write 1st data
      dbg_uart_tx16(16'h1234);         // write 1st data
      repeat(12) @(posedge mclk);
      repeat(12) @(posedge mclk);
Line 303... Line 331...
      if (mem206 !== 16'hdef0)      tb_error("====== 16B WRITE BURSTS (MEMORY) WR ERROR: 4th DATA =====");
      if (mem206 !== 16'hdef0)      tb_error("====== 16B WRITE BURSTS (MEMORY) WR ERROR: 4th DATA =====");
      dbg_uart_tx16(16'h0fed);         // write 5th data
      dbg_uart_tx16(16'h0fed);         // write 5th data
      repeat(12) @(posedge mclk);
      repeat(12) @(posedge mclk);
      if (mem208 !== 16'h0fed)      tb_error("====== 16B WRITE BURSTS (MEMORY) WR ERROR: 5th DATA =====");
      if (mem208 !== 16'h0fed)      tb_error("====== 16B WRITE BURSTS (MEMORY) WR ERROR: 5th DATA =====");
 
 
      dbg_uart_wr(MEM_ADDR, 16'h0200); // select @0x0200
      dbg_uart_wr(MEM_ADDR, (`PER_SIZE+16'h0000)); // select @0x0200
      dbg_uart_wr(MEM_CNT,  16'h0004); // 5 consecutive access
      dbg_uart_wr(MEM_CNT,  16'h0004); // 5 consecutive access
 
 
      dbg_uart_wr(MEM_CTL,  16'h0001); // Start burst to 16 bit registers read
      dbg_uart_wr(MEM_CTL,  16'h0001); // Start burst to 16 bit registers read
      dbg_uart_rx16();                 // read 1st data
      dbg_uart_rx16();                 // read 1st data
      if (dbg_uart_buf !== 16'h1234)      tb_error("====== 16B WRITE BURSTS (MEMORY) RD ERROR: 1st DATA =====");
      if (dbg_uart_buf !== 16'h1234)      tb_error("====== 16B WRITE BURSTS (MEMORY) RD ERROR: 1st DATA =====");
Line 361... Line 389...
 
 
 
 
      // TEST 8B WRITE BURSTS (MEMORY)
      // TEST 8B WRITE BURSTS (MEMORY)
      //--------------------------------------------------------
      //--------------------------------------------------------
 
 
      dbg_uart_wr(MEM_ADDR, 16'h0200); // select @0x0210
      dbg_uart_wr(MEM_ADDR, (`PER_SIZE+16'h0000)); // select @0x0210
      dbg_uart_wr(MEM_CNT,  16'h0004); // 5 consecutive access
      dbg_uart_wr(MEM_CNT,  16'h0004); // 5 consecutive access
 
 
      dbg_uart_wr(MEM_CTL,  16'h000b); // Start burst to 8 bit memory write
      dbg_uart_wr(MEM_CTL,  16'h000b); // Start burst to 8 bit memory write
      dbg_uart_tx(8'h91);         // write 1st data
      dbg_uart_tx(8'h91);         // write 1st data
      repeat(12) @(posedge mclk);
      repeat(12) @(posedge mclk);
Line 381... Line 409...
      if (mem202 !== 16'h6473)      tb_error("====== 8B WRITE BURSTS (MEMORY) WR ERROR: 4th DATA =====");
      if (mem202 !== 16'h6473)      tb_error("====== 8B WRITE BURSTS (MEMORY) WR ERROR: 4th DATA =====");
      dbg_uart_tx(8'h55);         // write 5th data
      dbg_uart_tx(8'h55);         // write 5th data
      repeat(12) @(posedge mclk);
      repeat(12) @(posedge mclk);
      if (mem204 !== 16'h9a55)      tb_error("====== 8B WRITE BURSTS (MEMORY) WR ERROR: 5th DATA =====");
      if (mem204 !== 16'h9a55)      tb_error("====== 8B WRITE BURSTS (MEMORY) WR ERROR: 5th DATA =====");
 
 
      dbg_uart_wr(MEM_ADDR, 16'h0200); // select @0x0200
      dbg_uart_wr(MEM_ADDR, (`PER_SIZE+16'h0000)); // select @0x0200
      dbg_uart_wr(MEM_CNT,  16'h0004); // 5 consecutive access
      dbg_uart_wr(MEM_CNT,  16'h0004); // 5 consecutive access
 
 
      dbg_uart_wr(MEM_CTL,  16'h0009); // Start burst to 8 bit registers read
      dbg_uart_wr(MEM_CTL,  16'h0009); // Start burst to 8 bit registers read
      dbg_uart_rx8();                 // read 1st data
      dbg_uart_rx8();                 // read 1st data
      if (dbg_uart_buf !== 16'h0091)      tb_error("====== 8B WRITE BURSTS (MEMORY) RD ERROR: 1st DATA =====");
      if (dbg_uart_buf !== 16'h0091)      tb_error("====== 8B WRITE BURSTS (MEMORY) RD ERROR: 1st DATA =====");
Line 404... Line 432...
 
 
      dbg_uart_wr(CPU_CTL    ,  16'h0002);
      dbg_uart_wr(CPU_CTL    ,  16'h0002);
      repeat(10) @(posedge mclk);
      repeat(10) @(posedge mclk);
 
 
      stimulus_done = 1;
      stimulus_done = 1;
 
`else
 
 
 
       $display(" ===============================================");
 
       $display("|               SIMULATION SKIPPED              |");
 
       $display("|   (serial debug interface UART not included)  |");
 
       $display(" ===============================================");
 
       $finish;
 
`endif
 
`else
 
 
 
       $display(" ===============================================");
 
       $display("|               SIMULATION SKIPPED              |");
 
       $display("|      (serial debug interface not included)    |");
 
       $display(" ===============================================");
 
       $finish;
 
`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.