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

Subversion Repositories dbg_interface

[/] [dbg_interface/] [tags/] [sdram_test_working/] [rtl/] [verilog/] [dbg_top.v] - Diff between revs 28 and 30

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

Rev 28 Rev 30
Line 43... Line 43...
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//
//
// CVS Revision History
// CVS Revision History
//
//
// $Log: not supported by cvs2svn $
// $Log: not supported by cvs2svn $
 
// Revision 1.16  2001/12/20 11:17:26  mohor
 
// TDO and TDO Enable signal are separated into two signals.
 
//
// Revision 1.15  2001/12/05 13:28:21  mohor
// Revision 1.15  2001/12/05 13:28:21  mohor
// trst signal is synchronized to wb_clk_i.
// trst signal is synchronized to wb_clk_i.
//
//
// Revision 1.14  2001/11/28 09:36:15  mohor
// Revision 1.14  2001/11/28 09:36:15  mohor
// Register length fixed.
// Register length fixed.
Line 218... Line 221...
reg [31:0]  DataOut;
reg [31:0]  DataOut;
 
 
reg [`OPSELECTWIDTH-1:0] opselect_o;      // Operation selection (selecting what kind of data is set to the risc_data_i)
reg [`OPSELECTWIDTH-1:0] opselect_o;      // Operation selection (selecting what kind of data is set to the risc_data_i)
 
 
reg [`CHAIN_ID_LENGTH-1:0] Chain;         // Selected chain
reg [`CHAIN_ID_LENGTH-1:0] Chain;         // Selected chain
reg [31:0]  RISC_DATAINLatch;             // Data from DataIn is latched one risc_clk_i clock cycle after RISC register is
reg [31:0]  DataReadLatch;                // Data when reading register or RISC is latched one risc_clk_i clock after the data is read.
                                          // accessed for reading
 
reg [31:0]  RegisterReadLatch;            // Data when reading register is latched one TCK clock after the register is read.
 
reg         RegAccessTck;                 // Indicates access to the registers (read or write)
reg         RegAccessTck;                 // Indicates access to the registers (read or write)
reg         RISCAccessTck;                // Indicates access to the RISC (read or write)
reg         RISCAccessTck;                // Indicates access to the RISC (read or write)
reg [7:0]   BitCounter;                   // Counting bits in the ShiftDR and Exit1DR stages
reg [7:0]   BitCounter;                   // Counting bits in the ShiftDR and Exit1DR stages
reg         RW;                           // Read/Write bit
reg         RW;                           // Read/Write bit
reg         CrcMatch;                     // The crc that is shifted in and the internaly calculated crc are equal
reg         CrcMatch;                     // The crc that is shifted in and the internaly calculated crc are equal
Line 237... Line 238...
reg         wb_AccessTck;                 // Indicates access to the WISHBONE
reg         wb_AccessTck;                 // Indicates access to the WISHBONE
reg [31:0]  WBReadLatch;                  // Data latched during WISHBONE read
reg [31:0]  WBReadLatch;                  // Data latched during WISHBONE read
reg         WBErrorLatch;                 // Error latched during WISHBONE read
reg         WBErrorLatch;                 // Error latched during WISHBONE read
reg         trst;                         // trst is active high while trst_pad_i is active low
reg         trst;                         // trst is active high while trst_pad_i is active low
 
 
 
reg         BypassRegister;               // Bypass register
 
 
 
 
wire TCK = tck_pad_i;
wire TCK = tck_pad_i;
wire TMS = tms_pad_i;
wire TMS = tms_pad_i;
wire TDI = tdi_pad_i;
wire TDI = tdi_pad_i;
 
 
wire [31:0]             RegDataIn;        // Data from registers (read data)
wire [31:0]             RegDataIn;        // Data from registers (read data)
Line 257... Line 261...
 
 
wire RiscStall_read_access;               // Stalling RISC because of the read access (SPR read)
wire RiscStall_read_access;               // Stalling RISC because of the read access (SPR read)
wire RiscStall_write_access;              // Stalling RISC because of the write access (SPR write)
wire RiscStall_write_access;              // Stalling RISC because of the write access (SPR write)
wire RiscStall_access;                    // Stalling RISC because of the read or write access
wire RiscStall_access;                    // Stalling RISC because of the read or write access
 
 
 
wire BitCounter_Lt4;
 
wire BitCounter_Eq5;
 
wire BitCounter_Eq32;
 
wire BitCounter_Lt38;
 
wire BitCounter_Lt65;
 
 
assign capture_dr_o       = CaptureDR;
assign capture_dr_o       = CaptureDR;
assign shift_dr_o         = ShiftDR;
assign shift_dr_o         = ShiftDR;
assign update_dr_o        = UpdateDR;
assign update_dr_o        = UpdateDR;
assign extest_selected_o  = EXTESTSelected;
assign extest_selected_o  = EXTESTSelected;
Line 326... Line 335...
  wire TraceTestScanChain;                // Trace Test Scan chain selected
  wire TraceTestScanChain;                // Trace Test Scan chain selected
  wire [47:0] Trace_Data;                 // Trace data
  wire [47:0] Trace_Data;                 // Trace data
 
 
  wire [`OPSELECTWIDTH-1:0]opselect_trace;// Operation selection (trace selecting what kind of
  wire [`OPSELECTWIDTH-1:0]opselect_trace;// Operation selection (trace selecting what kind of
                                          // data is set to the risc_data_i)
                                          // data is set to the risc_data_i)
 
  wire BitCounter_Lt40;
 
 
`endif
`endif
 
 
 
 
/**********************************************************************************
/**********************************************************************************
Line 640... Line 650...
/**********************************************************************************
/**********************************************************************************
*                                                                                 *
*                                                                                 *
*   JTAG_DR:  JTAG Data Register                                                  *
*   JTAG_DR:  JTAG Data Register                                                  *
*                                                                                 *
*                                                                                 *
**********************************************************************************/
**********************************************************************************/
wire [31:0] IDCodeValue = `IDCODE_VALUE;  // IDCODE value is 32-bit long.
 
 
 
reg [`DR_LENGTH-1:0]JTAG_DR_IN;    // Data register
reg [`DR_LENGTH-1:0]JTAG_DR_IN;    // Data register
reg TDOData;
reg TDOData;
 
 
 
 
always @ (posedge TCK or posedge trst)
always @ (posedge TCK or posedge trst)
begin
begin
  if(trst)
  if(trst)
    JTAG_DR_IN[`DR_LENGTH-1:0]<=#Tp 0;
    JTAG_DR_IN[`DR_LENGTH-1:0]<=#Tp 0;
  else
  else
 
  if(IDCODESelected)                          // To save space JTAG_DR_IN is also used for shifting out IDCODE
 
    begin
  if(ShiftDR)
  if(ShiftDR)
    JTAG_DR_IN[BitCounter]<=#Tp TDI;
        JTAG_DR_IN[31:0] <= #Tp {TDI, JTAG_DR_IN[31:1]};
 
      else
 
        JTAG_DR_IN[31:0] <= #Tp `IDCODE_VALUE;
 
    end
 
  else
 
  if(CHAIN_SELECTSelected & ShiftDR)
 
    JTAG_DR_IN[12:0] <= #Tp {TDI, JTAG_DR_IN[12:1]};
 
  else
 
  if(DEBUGSelected & ShiftDR)
 
    begin
 
      if(RiscDebugScanChain | WishboneScanChain)
 
        JTAG_DR_IN[73:0] <= #Tp {TDI, JTAG_DR_IN[73:1]};
 
      else
 
      if(RegisterScanChain)
 
        JTAG_DR_IN[46:0] <= #Tp {TDI, JTAG_DR_IN[46:1]};
 
    end
end
end
 
 
wire [73:0] RISC_Data;
wire [73:0] RISC_Data;
wire [46:0] Register_Data;
wire [46:0] Register_Data;
wire [73:0] WISHBONE_Data;
wire [73:0] WISHBONE_Data;
wire [12:0] chain_sel_data;
wire [12:0] chain_sel_data;
wire wb_Access_wbClk;
wire wb_Access_wbClk;
 
 
// assign RISC_Data      = {CalculatedCrcOut, RISC_DATAINLatch, 33'h0};
 
// assign Register_Data  = {CalculatedCrcOut, RegisterReadLatch, 6'h0};
reg select_crc_out;
// assign WISHBONE_Data  = {CalculatedCrcOut, WBReadLatch, 32'h0, WBErrorLatch};
always @ (posedge TCK or posedge trst)
 
begin
wire select_crc_out;
  if(trst)
assign select_crc_out = RegisterScanChain     & JTAG_DR_IN[5]   |     // Calculated CRC is returned when read operation is
    select_crc_out <= 0;
                        RiscDebugScanChain    & JTAG_DR_IN[32]  |     // performed, else received crc is returned (loopback).
  else
                        WishboneScanChain     & JTAG_DR_IN[32]  |
  if( RegisterScanChain  & BitCounter_Eq5  |
                        CHAIN_SELECTSelected;                         // When chain is selected, received crc is returned
      RiscDebugScanChain & BitCounter_Eq32 |
 
      WishboneScanChain  & BitCounter_Eq32 )
 
    select_crc_out <=#Tp TDI;
 
  else
 
  if(CHAIN_SELECTSelected)
 
    select_crc_out <=#Tp 1;
 
  else
 
  if(UpdateDR)
 
    select_crc_out <=#Tp 0;
 
end
 
 
wire [8:0] send_crc;
wire [8:0] send_crc;
 
 
assign send_crc = select_crc_out? {9{JTAG_DR_IN[BitCounter-1]}}   : // Calculated CRC is returned when read operation is
assign send_crc = select_crc_out? {9{BypassRegister}}    :    // Calculated CRC is returned when read operation is
                                  {1'b0, CalculatedCrcOut}        ; // performed, else received crc is returned (loopback).
                                  {CalculatedCrcOut, 1'b0} ;  // performed, else received crc is returned (loopback).
 
 
assign RISC_Data      = {send_crc, RISC_DATAINLatch, 33'h0};
assign RISC_Data      = {send_crc, DataReadLatch, 33'h0};
assign Register_Data  = {send_crc, RegisterReadLatch, 6'h0};
assign Register_Data  = {send_crc, DataReadLatch, 6'h0};
assign WISHBONE_Data  = {send_crc, WBReadLatch, 32'h0, WBErrorLatch};
assign WISHBONE_Data  = {send_crc, WBReadLatch, 32'h0, WBErrorLatch};
assign chain_sel_data = {send_crc, 4'h0};
assign chain_sel_data = {send_crc, 4'h0};
 
 
 
 
`ifdef TRACE_ENABLED
`ifdef TRACE_ENABLED
Line 710... Line 744...
  else
  else
    begin
    begin
      if(ShiftDR)
      if(ShiftDR)
        begin
        begin
          if(IDCODESelected)
          if(IDCODESelected)
            TDOData <= #Tp IDCodeValue[BitCounter];           // IDCODE is shifted out
            TDOData <= #Tp JTAG_DR_IN[0]; // IDCODE is shifted out 32-bits, then TDI is bypassed
          else
          else
          if(CHAIN_SELECTSelected)
          if(CHAIN_SELECTSelected)
            TDOData <= #Tp chain_sel_data[BitCounter];        // Received crc is sent back
            TDOData <= #Tp chain_sel_data[BitCounter];        // Received crc is sent back
          else
          else
          if(DEBUGSelected)
          if(DEBUGSelected)
Line 865... Line 899...
      RISCAccess_q  <=#Tp RISCAccess;
      RISCAccess_q  <=#Tp RISCAccess;
      RISCAccess_q2 <=#Tp RISCAccess_q;
      RISCAccess_q2 <=#Tp RISCAccess_q;
    end
    end
end
end
 
 
 
 
// Latching data read from registers
 
always @ (posedge risc_clk_i or posedge wb_rst_i)
 
begin
 
  if(wb_rst_i)
 
    RegisterReadLatch[31:0]<=#Tp 0;
 
  else
 
  if(RegAccess_q & ~RegAccess_q2)
 
    RegisterReadLatch[31:0]<=#Tp RegDataIn[31:0];
 
end
 
 
 
 
 
// Chip select and read/write signals for accessing RISC
// Chip select and read/write signals for accessing RISC
assign RiscStall_write_access = RISCAccess & ~RISCAccess_q  &  RW;
assign RiscStall_write_access = RISCAccess & ~RISCAccess_q  &  RW;
assign RiscStall_read_access  = RISCAccess & ~RISCAccess_q2 & ~RW;
assign RiscStall_read_access  = RISCAccess & ~RISCAccess_q2 & ~RW;
assign RiscStall_access = RiscStall_write_access | RiscStall_read_access;
assign RiscStall_access = RiscStall_write_access | RiscStall_read_access;
 
 
Line 962... Line 984...
    opselect_o = 3'h0;
    opselect_o = 3'h0;
`endif
`endif
end
end
 
 
 
 
 
// Latching data read from RISC or registers
// Latching data read from RISC
 
always @ (posedge risc_clk_i or posedge wb_rst_i)
always @ (posedge risc_clk_i or posedge wb_rst_i)
begin
begin
  if(wb_rst_i)
  if(wb_rst_i)
    RISC_DATAINLatch[31:0]<=#Tp 0;
    DataReadLatch[31:0]<=#Tp 0;
  else
  else
  if(RISCAccess_q & ~RISCAccess_q2)
  if(RISCAccess_q & ~RISCAccess_q2)
    RISC_DATAINLatch[31:0]<=#Tp risc_data_i[31:0];
    DataReadLatch[31:0]<=#Tp risc_data_i[31:0];
 
  else
 
  if(RegAccess_q & ~RegAccess_q2)
 
    DataReadLatch[31:0]<=#Tp RegDataIn[31:0];
end
end
 
 
assign risc_addr_o = ADDR;
assign risc_addr_o = ADDR;
assign risc_data_o = DataOut;
assign risc_data_o = DataOut;
 
 
Line 1017... Line 1041...
/**********************************************************************************
/**********************************************************************************
*                                                                                 *
*                                                                                 *
*   Bypass logic                                                                  *
*   Bypass logic                                                                  *
*                                                                                 *
*                                                                                 *
**********************************************************************************/
**********************************************************************************/
reg BypassRegister;
 
reg TDOBypassed;
reg TDOBypassed;
 
 
always @ (posedge TCK)
always @ (posedge TCK)
begin
begin
  if(ShiftDR)
  if(ShiftDR)
Line 1221... Line 1244...
**********************************************************************************/
**********************************************************************************/
wire AsyncResetCrc = trst;
wire AsyncResetCrc = trst;
wire SyncResetCrc = UpdateDR_q;
wire SyncResetCrc = UpdateDR_q;
wire [7:0] CalculatedCrcIn;     // crc calculated from the input data (shifted in)
wire [7:0] CalculatedCrcIn;     // crc calculated from the input data (shifted in)
 
 
 
assign BitCounter_Lt4   = BitCounter<4;
 
assign BitCounter_Eq5   = BitCounter==5;
 
assign BitCounter_Eq32  = BitCounter==32;
 
assign BitCounter_Lt38  = BitCounter<38;
 
assign BitCounter_Lt65  = BitCounter<65;
 
 
 
`ifdef TRACE_ENABLED
 
  assign BitCounter_Lt40 = BitCounter<40;
 
`endif
 
 
 
 
wire EnableCrcIn = ShiftDR &
wire EnableCrcIn = ShiftDR &
                  ( (CHAIN_SELECTSelected                 & (BitCounter<4))  |
                  ( (CHAIN_SELECTSelected                 & BitCounter_Lt4) |
                    ((DEBUGSelected & RegisterScanChain)  & (BitCounter<38)) |
                    ((DEBUGSelected & RegisterScanChain)  & BitCounter_Lt38)|
                    ((DEBUGSelected & RiscDebugScanChain) & (BitCounter<65)) |
                    ((DEBUGSelected & RiscDebugScanChain) & BitCounter_Lt65)|
                    ((DEBUGSelected & WishboneScanChain)  & (BitCounter<65))
                    ((DEBUGSelected & WishboneScanChain)  & BitCounter_Lt65)
                  );
                  );
 
 
wire EnableCrcOut= ShiftDR &
wire EnableCrcOut= ShiftDR &
                   (
                   (
                    ((DEBUGSelected & RegisterScanChain)  & (BitCounter<38)) |
                    ((DEBUGSelected & RegisterScanChain)  & BitCounter_Lt38)|
                    ((DEBUGSelected & RiscDebugScanChain) & (BitCounter<65)) |
                    ((DEBUGSelected & RiscDebugScanChain) & BitCounter_Lt65)|
                    ((DEBUGSelected & WishboneScanChain)  & (BitCounter<65))
                    ((DEBUGSelected & WishboneScanChain)  & BitCounter_Lt65)
                    `ifdef TRACE_ENABLED
                    `ifdef TRACE_ENABLED
                                                                             |
                                                                             |
                    ((DEBUGSelected & TraceTestScanChain) & (BitCounter<40))
                    ((DEBUGSelected & TraceTestScanChain) & BitCounter_Lt40)
                    `endif
                    `endif
                   );
                   );
 
 
// Calculating crc for input data
// Calculating crc for input data
dbg_crc8_d1 crc1 (.Data(TDI), .EnableCrc(EnableCrcIn), .Reset(AsyncResetCrc), .SyncResetCrc(SyncResetCrc),
dbg_crc8_d1 crc1 (.Data(TDI), .EnableCrc(EnableCrcIn), .Reset(AsyncResetCrc), .SyncResetCrc(SyncResetCrc),
Line 1259... Line 1293...
  if(Exit1DR)
  if(Exit1DR)
    begin
    begin
      if(CHAIN_SELECTSelected)
      if(CHAIN_SELECTSelected)
        CrcMatch <=#Tp CalculatedCrcIn == JTAG_DR_IN[11:4];
        CrcMatch <=#Tp CalculatedCrcIn == JTAG_DR_IN[11:4];
      else
      else
      if(RegisterScanChain & ~CHAIN_SELECTSelected)
        begin
 
          if(RegisterScanChain)
        CrcMatch <=#Tp CalculatedCrcIn == JTAG_DR_IN[45:38];
        CrcMatch <=#Tp CalculatedCrcIn == JTAG_DR_IN[45:38];
      else
      else
      if(RiscDebugScanChain & ~CHAIN_SELECTSelected)
          if(RiscDebugScanChain)
        CrcMatch <=#Tp CalculatedCrcIn == JTAG_DR_IN[72:65];
        CrcMatch <=#Tp CalculatedCrcIn == JTAG_DR_IN[72:65];
      else
      else
      if(WishboneScanChain & ~CHAIN_SELECTSelected)
          if(WishboneScanChain)
        CrcMatch <=#Tp CalculatedCrcIn == JTAG_DR_IN[72:65];
        CrcMatch <=#Tp CalculatedCrcIn == JTAG_DR_IN[72:65];
    end
    end
end
end
 
end
 
 
 
 
// Active chain
// Active chain
assign RegisterScanChain   = Chain == `REGISTER_SCAN_CHAIN;
assign RegisterScanChain   = Chain == `REGISTER_SCAN_CHAIN;
assign RiscDebugScanChain  = Chain == `RISC_DEBUG_CHAIN;
assign RiscDebugScanChain  = Chain == `RISC_DEBUG_CHAIN;

powered by: WebSVN 2.1.0

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