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

Subversion Repositories dbg_interface

[/] [dbg_interface/] [trunk/] [rtl/] [verilog/] [dbg_top.v] - Diff between revs 128 and 138

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

Rev 128 Rev 138
Line 41... Line 41...
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//
//
// CVS Revision History
// CVS Revision History
//
//
// $Log: not supported by cvs2svn $
// $Log: not supported by cvs2svn $
 
// Revision 1.42  2004/01/30 10:24:31  mohor
 
// Defines WISHBONE_SUPPORTED and CPU_SUPPORTED added. By default both are
 
// turned on.
 
//
// Revision 1.41  2004/01/25 14:04:18  mohor
// Revision 1.41  2004/01/25 14:04:18  mohor
// All flipflops are reset.
// All flipflops are reset.
//
//
// Revision 1.40  2004/01/20 14:23:47  mohor
// Revision 1.40  2004/01/20 14:23:47  mohor
// Define name changed.
// Define name changed.
Line 275... Line 279...
output        wb_cab_o;
output        wb_cab_o;
input         wb_err_i;
input         wb_err_i;
output  [2:0] wb_cti_o;
output  [2:0] wb_cti_o;
output  [1:0] wb_bte_o;
output  [1:0] wb_bte_o;
 
 
reg           wishbone_scan_chain;
reg           wishbone_module;
reg           wishbone_ce;
reg           wishbone_ce;
wire          tdi_wb;
wire          tdi_wb;
wire          tdo_wb;
wire          tdo_wb;
wire          crc_en_wb;
wire          crc_en_wb;
wire          shift_crc_wb;
wire          shift_crc_wb;
Line 301... Line 305...
output [`CPU_NUM -1:0]  cpu_sel_o;
output [`CPU_NUM -1:0]  cpu_sel_o;
output        cpu_we_o;
output        cpu_we_o;
input         cpu_ack_i;
input         cpu_ack_i;
output        cpu_rst_o;
output        cpu_rst_o;
 
 
reg           cpu_debug_scan_chain;
reg           cpu_debug_module;
reg           cpu_ce;
reg           cpu_ce;
wire          tdi_cpu;
wire          tdi_cpu;
wire          tdo_cpu;
wire          tdo_cpu;
wire          crc_en_cpu;
wire          crc_en_cpu;
wire          shift_crc_cpu;
wire          shift_crc_cpu;
Line 315... Line 319...
`endif
`endif
 
 
 
 
reg [`DATA_CNT -1:0]        data_cnt;
reg [`DATA_CNT -1:0]        data_cnt;
reg [`CRC_CNT -1:0]         crc_cnt;
reg [`CRC_CNT -1:0]         crc_cnt;
reg [`STATUS_CNT -1:0]      status_cnt;
reg [`DBG_TOP_STATUS_CNT_WIDTH -1:0]      status_cnt;
reg [`CHAIN_DATA_LEN -1:0]  chain_dr;
reg [`MODULE_DATA_LEN -1:0]  module_dr;
reg [`CHAIN_ID_LENGTH -1:0] chain;
reg [`MODULE_ID_LENGTH -1:0] module_id;
 
 
wire chain_latch_en;
wire module_latch_en;
wire data_cnt_end;
wire data_cnt_end;
wire crc_cnt_end;
wire crc_cnt_end;
wire status_cnt_end;
wire status_cnt_end;
reg  crc_cnt_end_q;
reg  crc_cnt_end_q;
reg  chain_select;
reg  module_select;
reg  chain_select_error;
reg  module_select_error;
wire crc_out;
wire crc_out;
wire crc_match;
wire crc_match;
 
 
wire data_shift_en;
wire data_shift_en;
wire selecting_command;
wire selecting_command;
Line 351... Line 355...
  else if (update_dr_i)
  else if (update_dr_i)
    data_cnt <= #1 {`DATA_CNT{1'b0}};
    data_cnt <= #1 {`DATA_CNT{1'b0}};
end
end
 
 
 
 
assign data_cnt_end = data_cnt == `CHAIN_DATA_LEN;
assign data_cnt_end = data_cnt == `MODULE_DATA_LEN;
 
 
 
 
// crc counter
// crc counter
always @ (posedge tck_i or posedge rst_i)
always @ (posedge tck_i or posedge rst_i)
begin
begin
  if (rst_i)
  if (rst_i)
    crc_cnt <= #1 {`CRC_CNT{1'b0}};
    crc_cnt <= #1 {`CRC_CNT{1'b0}};
  else if(shift_dr_i & data_cnt_end & (~crc_cnt_end) & chain_select)
  else if(shift_dr_i & data_cnt_end & (~crc_cnt_end) & module_select)
    crc_cnt <= #1 crc_cnt + 1'b1;
    crc_cnt <= #1 crc_cnt + 1'b1;
  else if (update_dr_i)
  else if (update_dr_i)
    crc_cnt <= #1 {`CRC_CNT{1'b0}};
    crc_cnt <= #1 {`CRC_CNT{1'b0}};
end
end
 
 
assign crc_cnt_end = crc_cnt == `CRC_LEN;
assign crc_cnt_end = crc_cnt == `DBG_TOP_CRC_LEN;
 
 
 
 
always @ (posedge tck_i or posedge rst_i)
always @ (posedge tck_i or posedge rst_i)
begin
begin
  if (rst_i)
  if (rst_i)
Line 381... Line 385...
 
 
// status counter
// status counter
always @ (posedge tck_i or posedge rst_i)
always @ (posedge tck_i or posedge rst_i)
begin
begin
  if (rst_i)
  if (rst_i)
    status_cnt <= #1 {`STATUS_CNT{1'b0}};
    status_cnt <= #1 {`DBG_TOP_STATUS_CNT_WIDTH{1'b0}};
  else if(shift_dr_i & crc_cnt_end & (~status_cnt_end))
  else if(shift_dr_i & crc_cnt_end & (~status_cnt_end))
    status_cnt <= #1 status_cnt + 1'b1;
    status_cnt <= #1 status_cnt + 1'b1;
  else if (update_dr_i)
  else if (update_dr_i)
    status_cnt <= #1 {`STATUS_CNT{1'b0}};
    status_cnt <= #1 {`DBG_TOP_STATUS_CNT_WIDTH{1'b0}};
end
end
 
 
assign status_cnt_end = status_cnt == `STATUS_LEN;
assign status_cnt_end = status_cnt == `DBG_TOP_STATUS_LEN;
 
 
 
 
assign selecting_command = shift_dr_i & (data_cnt == `DATA_CNT'h0) & debug_select_i;
assign selecting_command = shift_dr_i & (data_cnt == `DATA_CNT'h0) & debug_select_i;
 
 
 
 
always @ (posedge tck_i or posedge rst_i)
always @ (posedge tck_i or posedge rst_i)
begin
begin
  if (rst_i)
  if (rst_i)
    chain_select <= #1 1'b0;
    module_select <= #1 1'b0;
  else if(selecting_command & tdi_i)       // Chain select
  else if(selecting_command & tdi_i)       // Chain select
    chain_select <= #1 1'b1;
    module_select <= #1 1'b1;
  else if (update_dr_i)
  else if (update_dr_i)
    chain_select <= #1 1'b0;
    module_select <= #1 1'b0;
end
end
 
 
 
 
always @ (chain)
always @ (module_id)
begin
begin
  `ifdef CPU_SUPPORTED
  `ifdef CPU_SUPPORTED
  cpu_debug_scan_chain  <= #1 1'b0;
  cpu_debug_module  <= #1 1'b0;
  `endif
  `endif
  `ifdef WISHBONE_SUPPORTED
  `ifdef WISHBONE_SUPPORTED
  wishbone_scan_chain   <= #1 1'b0;
  wishbone_module   <= #1 1'b0;
  `endif
  `endif
  chain_select_error    <= #1 1'b0;
  module_select_error    <= #1 1'b0;
 
 
  case (chain)                /* synthesis parallel_case */
  case (module_id)                /* synthesis parallel_case */
    `ifdef CPU_SUPPORTED
    `ifdef CPU_SUPPORTED
      `CPU_DEBUG_CHAIN      :   cpu_debug_scan_chain  <= #1 1'b1;
      `CPU_DEBUG_MODULE     :   cpu_debug_module  <= #1 1'b1;
    `endif
    `endif
    `ifdef WISHBONE_SUPPORTED
    `ifdef WISHBONE_SUPPORTED
      `WISHBONE_DEBUG_CHAIN :   wishbone_scan_chain   <= #1 1'b1;
      `WISHBONE_DEBUG_MODULE:   wishbone_module   <= #1 1'b1;
    `endif
    `endif
    default                 :   chain_select_error    <= #1 1'b1;
    default                 :   module_select_error    <= #1 1'b1;
  endcase
  endcase
end
end
 
 
 
 
assign chain_latch_en = chain_select & crc_cnt_end & (~crc_cnt_end_q);
assign module_latch_en = module_select & crc_cnt_end & (~crc_cnt_end_q);
 
 
 
 
always @ (posedge tck_i or posedge rst_i)
always @ (posedge tck_i or posedge rst_i)
begin
begin
  if (rst_i)
  if (rst_i)
    chain <= `CHAIN_ID_LENGTH'b111;
    module_id <= {`MODULE_ID_LENGTH{1'b1}};
  else if(chain_latch_en & crc_match)
  else if(module_latch_en & crc_match)
    chain <= #1 chain_dr[`CHAIN_DATA_LEN -1:1];
    module_id <= #1 module_dr[`MODULE_DATA_LEN -2:0];
end
end
 
 
 
 
assign data_shift_en = shift_dr_i & (~data_cnt_end);
assign data_shift_en = shift_dr_i & (~data_cnt_end);
 
 
 
 
always @ (posedge tck_i or posedge rst_i)
always @ (posedge tck_i or posedge rst_i)
begin
begin
  if (rst_i)
  if (rst_i)
    chain_dr <= #1 `CHAIN_DATA_LEN'h0;
    module_dr <= #1 `MODULE_DATA_LEN'h0;
  else if (data_shift_en)
  else if (data_shift_en)
    chain_dr[`CHAIN_DATA_LEN -1:0] <= #1 {tdi_i, chain_dr[`CHAIN_DATA_LEN -1:1]};
    module_dr[`MODULE_DATA_LEN -1:0] <= #1 {module_dr[`MODULE_DATA_LEN -2:0], tdi_i};
end
end
 
 
 
 
// Calculating crc for input data
// Calculating crc for input data
dbg_crc32_d1 i_dbg_crc32_d1_in
dbg_crc32_d1 i_dbg_crc32_d1_in
Line 465... Line 469...
              .clk        (tck_i),
              .clk        (tck_i),
              .crc_match  (crc_match)
              .crc_match  (crc_match)
             );
             );
 
 
 
 
reg tdo_chain_select;
reg tdo_module_select;
wire crc_en;
wire crc_en;
wire crc_en_dbg;
wire crc_en_dbg;
reg crc_started;
reg crc_started;
 
 
assign crc_en = crc_en_dbg | crc_en_wb | crc_en_cpu;
assign crc_en = crc_en_dbg | crc_en_wb | crc_en_cpu;
Line 503... Line 507...
              .clk        (tck_i),
              .clk        (tck_i),
              .crc_match  ()
              .crc_match  ()
             );
             );
 
 
// Following status is shifted out: 
// Following status is shifted out: 
// 1. bit:          1 if crc is OK, else 0
// 1. bit:          0 if crc is OK, else 1
// 2. bit:          1 if command is "chain select", else 0
// 2. bit:          0 if command is "module_id select", else 1
// 3. bit:          1 if non-existing chain is selected else 0
// 3. bit:          0 if existing module_id is selected else, 1 if non-existing module_id is selected
// 4. bit:          always 1
// 4. bit:          0 (always)
 
 
reg [799:0] current_on_tdo;
 
 
 
always @ (status_cnt or chain_select or crc_match or chain_select_error or crc_out)
always @ (status_cnt or module_select or crc_match or module_select_error or crc_out)
begin
begin
  case (status_cnt)                   /* synthesis full_case parallel_case */
  case (status_cnt)                   /* synthesis full_case parallel_case */
    `STATUS_CNT'd0  : begin
    `DBG_TOP_STATUS_CNT_WIDTH'd0  : begin
                        tdo_chain_select = crc_match;
                        tdo_module_select = ~crc_match;
                        current_on_tdo = "crc_match";
                      end
                      end
    `DBG_TOP_STATUS_CNT_WIDTH'd1  : begin
    `STATUS_CNT'd1  : begin
                        tdo_module_select = ~module_select;
                        tdo_chain_select = chain_select;
                      end
                        current_on_tdo = "chain_select";
    `DBG_TOP_STATUS_CNT_WIDTH'd2  : begin
                      end
                        tdo_module_select = module_select_error;
    `STATUS_CNT'd2  : begin
                      end
                        tdo_chain_select = chain_select_error;
    `DBG_TOP_STATUS_CNT_WIDTH'd3  : begin
                        current_on_tdo = "chain_select_error";
                        tdo_module_select = 1'b0;
                      end
                      end
    `STATUS_CNT'd3  : begin
    `DBG_TOP_STATUS_CNT_WIDTH'd4  : begin
                        tdo_chain_select = 1'b1;
                        tdo_module_select = crc_out;
                        current_on_tdo = "one 1";
 
                      end
 
    `STATUS_CNT'd4  : begin
 
                        tdo_chain_select = crc_out;
 
                  //      tdo_chain_select = 1'hz;
 
                        current_on_tdo = "crc_out";
 
                      end
                      end
  endcase
  endcase
end
end
 
 
 
 
 
 
 
 
assign shift_crc = shift_crc_wb | shift_crc_cpu;
assign shift_crc = shift_crc_wb | shift_crc_cpu;
 
 
always @ (shift_crc or crc_out or tdo_chain_select
always @ (shift_crc or crc_out or tdo_module_select
`ifdef WISHBONE_SUPPORTED
`ifdef WISHBONE_SUPPORTED
 or wishbone_ce or tdo_wb
 or wishbone_ce or tdo_wb
`endif
`endif
`ifdef CPU_SUPPORTED
`ifdef CPU_SUPPORTED
 or cpu_ce or tdo_cpu
 or cpu_ce or tdo_cpu
Line 562... Line 559...
  `ifdef CPU_SUPPORTED
  `ifdef CPU_SUPPORTED
  else if (cpu_ce)        // shifting data from cpu
  else if (cpu_ce)        // shifting data from cpu
    tdo_tmp = tdo_cpu;
    tdo_tmp = tdo_cpu;
  `endif
  `endif
  else
  else
    tdo_tmp = tdo_chain_select;
    tdo_tmp = tdo_module_select;
end
end
 
 
 
 
always @ (negedge tck_i)
always @ (negedge tck_i)
begin
begin
Line 591... Line 588...
      `endif
      `endif
    end
    end
  else if(selecting_command & (~tdi_i))
  else if(selecting_command & (~tdi_i))
    begin
    begin
      `ifdef WISHBONE_SUPPORTED
      `ifdef WISHBONE_SUPPORTED
      if (wishbone_scan_chain)      // wishbone CE
      if (wishbone_module)      // wishbone CE
        wishbone_ce <= #1 1'b1;
        wishbone_ce <= #1 1'b1;
      `endif
      `endif
      `ifdef CPU_SUPPORTED
      `ifdef CPU_SUPPORTED
      if (cpu_debug_scan_chain)     // CPU CE
      if (cpu_debug_module)     // CPU CE
        cpu_ce <= #1 1'b1;
        cpu_ce <= #1 1'b1;
      `endif
      `endif
    end
    end
  else if (update_dr_i)   // igor !!! This needs to be changed?
  else if (update_dr_i)
    begin
    begin
      `ifdef WISHBONE_SUPPORTED
      `ifdef WISHBONE_SUPPORTED
      wishbone_ce <= #1 1'b0;
      wishbone_ce <= #1 1'b0;
      `endif
      `endif
      `ifdef CPU_SUPPORTED
      `ifdef CPU_SUPPORTED

powered by: WebSVN 2.1.0

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