Line 43... |
Line 43... |
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
//
|
//
|
// CVS Revision History
|
// CVS Revision History
|
//
|
//
|
// $Log: not supported by cvs2svn $
|
// $Log: not supported by cvs2svn $
|
|
// Revision 1.3 2001/09/19 11:54:03 mohor
|
|
// Minor changes for simulation.
|
|
//
|
// Revision 1.2 2001/09/18 14:12:43 mohor
|
// Revision 1.2 2001/09/18 14:12:43 mohor
|
// Trace fixed. Some registers changed, trace simplified.
|
// Trace fixed. Some registers changed, trace simplified.
|
//
|
//
|
// Revision 1.1.1.1 2001/09/13 13:49:19 mohor
|
// Revision 1.1.1.1 2001/09/13 13:49:19 mohor
|
// Initial official release.
|
// Initial official release.
|
Line 74... |
Line 77... |
parameter Tclk = 50; // Clock half period (Clok period = 100 ns => 10 MHz)
|
parameter Tclk = 50; // Clock half period (Clok period = 100 ns => 10 MHz)
|
|
|
|
|
reg P_TMS, P_TCK;
|
reg P_TMS, P_TCK;
|
reg P_TRST, P_TDI;
|
reg P_TRST, P_TDI;
|
reg P_PowerONReset;
|
reg wb_rst_i;
|
reg Mclk;
|
reg Mclk;
|
|
|
reg [10:0] Wp;
|
reg [10:0] Wp;
|
reg Bp;
|
reg Bp;
|
reg [3:0] LsStatus;
|
reg [3:0] LsStatus;
|
Line 88... |
Line 91... |
wire P_TDO;
|
wire P_TDO;
|
wire [31:0] ADDR_RISC;
|
wire [31:0] ADDR_RISC;
|
wire [31:0] DATAIN_RISC; // DATAIN_RISC is connect to DATAOUT
|
wire [31:0] DATAIN_RISC; // DATAIN_RISC is connect to DATAOUT
|
wire RISC_CS;
|
wire RISC_CS;
|
wire RISC_RW;
|
wire RISC_RW;
|
wire RISC_STALL_O;
|
|
wire RISC_RESET_O;
|
|
|
|
wire [31:0] DATAOUT_RISC; // DATAOUT_RISC is connect to DATAIN
|
wire [31:0] DATAOUT_RISC; // DATAOUT_RISC is connect to DATAIN
|
|
|
wire [`OPSELECTWIDTH-1:0] OpSelect;
|
wire [`OPSELECTWIDTH-1:0] OpSelect;
|
|
|
// Connecting TAP module
|
// Connecting TAP module
|
dbg_top dbgTAP1(.P_TMS(P_TMS), .P_TCK(P_TCK), .P_TRST(P_TRST), .P_TDI(P_TDI),
|
dbg_top dbgTAP1(.tms_pad_i(P_TMS), .tck_pad_i(P_TCK), .trst_pad_i(P_TRST), .tdi_pad_i(P_TDI),
|
.P_TDO(P_TDO), .P_PowerONReset(P_PowerONReset), .Mclk(Mclk),
|
.tdo_pad_o(P_TDO), .wb_rst_i(wb_rst_i), .mclk(Mclk),
|
.RISC_ADDR(ADDR_RISC), .RISC_DATA_IN(DATAOUT_RISC), .RISC_DATA_OUT(DATAIN_RISC),
|
.risc_addr_o(ADDR_RISC), .risc_data_i(DATAOUT_RISC), .risc_data_o(DATAIN_RISC),
|
.RISC_CS(RISC_CS), .RISC_RW(RISC_RW), .Wp(Wp), .Bp(Bp),
|
.risc_cs_o(RISC_CS), .risc_rw_o(RISC_RW), .wp_i(Wp), .bp_i(Bp),
|
.OpSelect(OpSelect), .LsStatus(LsStatus), .IStatus(IStatus),
|
.opselect_o(OpSelect), .lsstatus_i(LsStatus), .istatus_i(IStatus),
|
.RISC_STALL_O(RISC_STALL_O), .RISC_RESET_O(RISC_RESET_O), .BS_CHAIN_I(BS_CHAIN_I)
|
. risc_stall_o(), . risc_reset_o()
|
);
|
);
|
|
|
|
|
reg TestEnabled;
|
reg TestEnabled;
|
//integer i;
|
|
|
|
|
|
|
|
initial
|
initial
|
begin
|
begin
|
TestEnabled<=#Tp 0;
|
TestEnabled<=#Tp 0;
|
P_TMS<=#Tp 0;
|
P_TMS<=#Tp 0;
|
P_TCK<=#Tp 0;
|
P_TCK<=#Tp 0;
|
P_TDI<=#Tp 0;
|
P_TDI<=#Tp 0;
|
P_TRST<=#Tp 1;
|
|
|
|
Wp<=#Tp 0;
|
Wp<=#Tp 0;
|
Bp<=#Tp 0;
|
Bp<=#Tp 0;
|
LsStatus<=#Tp 0;
|
LsStatus<=#Tp 0;
|
IStatus<=#Tp 0;
|
IStatus<=#Tp 0;
|
|
|
P_PowerONReset<=#Tp 1;
|
wb_rst_i<=#Tp 0;
|
#100 P_PowerONReset<=#Tp 0; // PowerONReset is active low
|
P_TRST<=#Tp 1;
|
#100 P_PowerONReset<=#Tp 1;
|
#100 wb_rst_i<=#Tp 1;
|
|
P_TRST<=#Tp 0;
|
|
#100 wb_rst_i<=#Tp 0;
|
|
P_TRST<=#Tp 1;
|
#Tp TestEnabled<=#Tp 1;
|
#Tp TestEnabled<=#Tp 1;
|
end
|
end
|
|
|
|
|
// Generating master clock (RISC clock) 200 MHz
|
// Generating master clock (RISC clock) 200 MHz
|
Line 140... |
Line 142... |
end
|
end
|
|
|
|
|
// Generating random number for use in DATAOUT_RISC[31:0]
|
// Generating random number for use in DATAOUT_RISC[31:0]
|
reg [31:0] RandNumb;
|
reg [31:0] RandNumb;
|
always @ (posedge Mclk or negedge P_PowerONReset) // PowerONReset is active low
|
always @ (posedge Mclk or posedge wb_rst_i)
|
begin
|
begin
|
if(~P_PowerONReset)
|
if(wb_rst_i)
|
RandNumb[31:0]<=#Tp 0;
|
RandNumb[31:0]<=#Tp 0;
|
else
|
else
|
RandNumb[31:0]<=#Tp RandNumb[31:0] + 1;
|
RandNumb[31:0]<=#Tp RandNumb[31:0] + 1;
|
end
|
end
|
|
|
Line 177... |
Line 179... |
SetInstruction(`CHAIN_SELECT);
|
SetInstruction(`CHAIN_SELECT);
|
ChainSelect(`REGISTER_SCAN_CHAIN, 8'h0e); // {chain, crc}
|
ChainSelect(`REGISTER_SCAN_CHAIN, 8'h0e); // {chain, crc}
|
SetInstruction(`DEBUG);
|
SetInstruction(`DEBUG);
|
|
|
|
|
/*
|
//
|
// Testing internal registers
|
// Testing internal registers
|
ReadRegister(`MODER_ADR, 8'h00); // {addr, crc}
|
ReadRegister(`MODER_ADR, 8'h00); // {addr, crc}
|
ReadRegister(`TSEL_ADR, 8'h64); // {addr, crc}
|
ReadRegister(`TSEL_ADR, 8'h64); // {addr, crc}
|
ReadRegister(`QSEL_ADR, 8'h32); // {addr, crc}
|
ReadRegister(`QSEL_ADR, 8'h32); // {addr, crc}
|
ReadRegister(`SSEL_ADR, 8'h56); // {addr, crc}
|
ReadRegister(`SSEL_ADR, 8'h56); // {addr, crc}
|
ReadRegister(`RECSEL_ADR, 8'hc4); // {addr, crc}
|
ReadRegister(`RECSEL_ADR, 8'hc4); // {addr, crc}
|
ReadRegister(5'h1f, 8'h04); // {addr, crc} // Register address don't exist. Read should return high-Z.
|
ReadRegister(5'h1f, 8'h04); // {addr, crc} // Register address don't exist. Read should return high-Z.
|
ReadRegister(5'h1f, 8'h04); // {addr, crc} // Register address don't exist. Read should return high-Z.
|
ReadRegister(5'h1f, 8'h04); // {addr, crc} // Register address don't exist. Read should return high-Z.
|
|
|
WriteRegister(32'h00000001, `MODER_ADR, 8'h53); // {data, addr, crc}
|
WriteRegister(32'h00000001, `MODER_ADR, 8'h53); // {data, addr, crc}
|
WriteRegister(32'h00000020, `TSEL_ADR, 8'h5e); // {data, addr, crc}
|
WriteRegister(32'h00000020, `TSEL_ADR, 8'h5e); // {data, addr, crc}
|
WriteRegister(32'h00000300, `QSEL_ADR, 8'hdd); // {data, addr, crc}
|
WriteRegister(32'h00000300, `QSEL_ADR, 8'hdd); // {data, addr, crc}
|
WriteRegister(32'h00004000, `SSEL_ADR, 8'he2); // {data, addr, crc}
|
WriteRegister(32'h00004000, `SSEL_ADR, 8'he2); // {data, addr, crc}
|
WriteRegister(32'h0000dead, `RECSEL_ADR, 8'hfb); // {data, addr, crc}
|
WriteRegister(32'h0000dead, `RECSEL_ADR, 8'hfb); // {data, addr, crc}
|
|
|
ReadRegister(`MODER_ADR, 8'h00); // {addr, crc}
|
ReadRegister(`MODER_ADR, 8'h00); // {addr, crc}
|
ReadRegister(`TSEL_ADR, 8'h64); // {addr, crc}
|
ReadRegister(`TSEL_ADR, 8'h64); // {addr, crc}
|
ReadRegister(`QSEL_ADR, 8'h32); // {addr, crc}
|
ReadRegister(`QSEL_ADR, 8'h32); // {addr, crc}
|
ReadRegister(`SSEL_ADR, 8'h56); // {addr, crc}
|
ReadRegister(`SSEL_ADR, 8'h56); // {addr, crc}
|
ReadRegister(`RECSEL_ADR, 8'hc4); // {addr, crc}
|
ReadRegister(`RECSEL_ADR, 8'hc4); // {addr, crc}
|
ReadRegister(5'h1f, 8'h04); // {addr, crc} // Register address don't exist. Read should return high-Z.
|
ReadRegister(5'h1f, 8'h04); // {addr, crc} // Register address don't exist. Read should return high-Z.
|
ReadRegister(5'h1f, 8'h04); // {addr, crc} // Register address don't exist. Read should return high-Z.
|
ReadRegister(5'h1f, 8'h04); // {addr, crc} // Register address don't exist. Read should return high-Z.
|
*/
|
//
|
|
|
|
|
// testing trigger and qualifier
|
// testing trigger and qualifier
|
`ifdef TRACE_ENABLED
|
`ifdef TRACE_ENABLED
|
|
|
Line 220... |
Line 222... |
#1000 WriteRegister(`ENABLE, `MODER_ADR, 8'hd4); // Trace enabled
|
#1000 WriteRegister(`ENABLE, `MODER_ADR, 8'hd4); // Trace enabled
|
// End: Anything starts trigger and qualifier //
|
// End: Anything starts trigger and qualifier //
|
|
|
|
|
/* Anything starts trigger, breakpoint starts qualifier
|
/* Anything starts trigger, breakpoint starts qualifier
|
|
// Uncomment this part when you want to test it.
|
#1000 WriteRegister(`QUALIFOP_OR | `BPQUALIFVALID | `BPQUALIF, `QSEL_ADR, 8'had); // Any qualifier
|
#1000 WriteRegister(`QUALIFOP_OR | `BPQUALIFVALID | `BPQUALIF, `QSEL_ADR, 8'had); // Any qualifier
|
#1000 WriteRegister(32'h00000000, `TSEL_ADR, 8'h06); // Any trigger
|
#1000 WriteRegister(32'h00000000, `TSEL_ADR, 8'h06); // Any trigger
|
#1000 WriteRegister(32'h0000000c, `RECSEL_ADR, 8'h0f); // Two samples are selected for recording (RECSDATA and RECLDATA)
|
#1000 WriteRegister(32'h0000000c, `RECSEL_ADR, 8'h0f); // Two samples are selected for recording (RECSDATA and RECLDATA)
|
#1000 WriteRegister(32'h00000000, `SSEL_ADR, 8'h34); // No stop signal
|
#1000 WriteRegister(32'h00000000, `SSEL_ADR, 8'h34); // No stop signal
|
#1000 WriteRegister(`ENABLE, `MODER_ADR, 8'hd4); // Trace enabled
|
#1000 WriteRegister(`ENABLE, `MODER_ADR, 8'hd4); // Trace enabled
|
Line 235... |
Line 238... |
#1 Bp = 0; // Clear breakpoint
|
#1 Bp = 0; // Clear breakpoint
|
// End: Anything starts trigger, breakpoint starts qualifier */
|
// End: Anything starts trigger, breakpoint starts qualifier */
|
|
|
|
|
/* Anything starts qualifier, breakpoint starts trigger
|
/* Anything starts qualifier, breakpoint starts trigger
|
|
// Uncomment this part when you want to test it.
|
#1000 WriteRegister(32'h00000000, `QSEL_ADR, 8'h50); // Any qualifier
|
#1000 WriteRegister(32'h00000000, `QSEL_ADR, 8'h50); // Any qualifier
|
#1000 WriteRegister(`LSSTRIG_0 | `LSSTRIG_2 | `LSSTRIGVALID | `WPTRIG_4 | `WPTRIGVALID | `TRIGOP_AND, `TSEL_ADR, 8'had); // Trigger is AND of Watchpoint4 and LSSTRIG[0] and LSSTRIG[2]
|
#1000 WriteRegister(`LSSTRIG_0 | `LSSTRIG_2 | `LSSTRIGVALID | `WPTRIG_4 | `WPTRIGVALID | `TRIGOP_AND, `TSEL_ADR, 8'had); // Trigger is AND of Watchpoint4 and LSSTRIG[0] and LSSTRIG[2]
|
#1000 WriteRegister(32'h00000003, `RECSEL_ADR, 8'h0c); // Two samples are selected for recording (RECPC and RECLSEA)
|
#1000 WriteRegister(32'h00000003, `RECSEL_ADR, 8'h0c); // Two samples are selected for recording (RECPC and RECLSEA)
|
#1000 WriteRegister(32'h00000000, `SSEL_ADR, 8'h34); // No stop signal
|
#1000 WriteRegister(32'h00000000, `SSEL_ADR, 8'h34); // No stop signal
|
#1000 WriteRegister(`ENABLE, `MODER_ADR, 8'hd4); // Trace enabled
|
#1000 WriteRegister(`ENABLE, `MODER_ADR, 8'hd4); // Trace enabled
|
Line 254... |
Line 258... |
|
|
|
|
|
|
|
|
|
|
|
// Reading data from the trace buffer
|
SetInstruction(`CHAIN_SELECT);
|
SetInstruction(`CHAIN_SELECT);
|
ChainSelect(`TRACE_TEST_CHAIN, 8'h24); // {chain, crc}
|
ChainSelect(`TRACE_TEST_CHAIN, 8'h24); // {chain, crc}
|
SetInstruction(`DEBUG);
|
SetInstruction(`DEBUG);
|
ReadTraceBuffer;
|
ReadTraceBuffer;
|
ReadTraceBuffer;
|
ReadTraceBuffer;
|
Line 270... |
Line 275... |
ReadTraceBuffer;
|
ReadTraceBuffer;
|
ReadTraceBuffer;
|
ReadTraceBuffer;
|
ReadTraceBuffer;
|
ReadTraceBuffer;
|
ReadTraceBuffer;
|
ReadTraceBuffer;
|
|
|
// for(i=0;i<1500;i=i+1)
|
|
// ReadTraceBuffer;
|
|
|
|
`endif // TRACE_ENABLED
|
`endif // TRACE_ENABLED
|
|
|
|
|
|
|
Line 602... |
Line 605... |
GenClk(1);
|
GenClk(1);
|
|
|
P_TMS<=#Tp 0;
|
P_TMS<=#Tp 0;
|
GenClk(1); // we are in RunTestIdle
|
GenClk(1); // we are in RunTestIdle
|
|
|
GenClk(5); // Igor !!!! To mora iti ven. Tu je le zato, da se tisti write-i naredijo
|
GenClk(5); // Extra clocks needed for operations to finish
|
|
|
end
|
end
|
endtask
|
endtask
|
|
|
|
|
Line 669... |
Line 672... |
|
|
|
|
// print RISC registers read/write
|
// print RISC registers read/write
|
always @ (posedge Mclk)
|
always @ (posedge Mclk)
|
begin
|
begin
|
if(dbg_tb.dbgTAP1.RISC_CS)
|
if(dbg_tb.dbgTAP1.risc_cs_o)
|
if(dbg_tb.dbgTAP1.RISC_RW)
|
if(dbg_tb.dbgTAP1.risc_rw_o)
|
begin
|
begin
|
$write("\n\t\tWrite to RISC Register (addr=0x%h, data=0x%h)", dbg_tb.dbgTAP1.ADDR[31:0], dbg_tb.dbgTAP1.DataOut[31:0]);
|
$write("\n\t\tWrite to RISC Register (addr=0x%h, data=0x%h)", dbg_tb.dbgTAP1.ADDR[31:0], dbg_tb.dbgTAP1.DataOut[31:0]);
|
end
|
end
|
else
|
else
|
begin
|
begin
|
$write("\n\t\tRead from RISC Register (addr=0x%h, data=0x%h)", dbg_tb.dbgTAP1.ADDR[31:0], dbg_tb.dbgTAP1.RISC_DATA_IN[31:0]);
|
$write("\n\t\tRead from RISC Register (addr=0x%h, data=0x%h)", dbg_tb.dbgTAP1.ADDR[31:0], dbg_tb.dbgTAP1.risc_data_i[31:0]);
|
end
|
end
|
end
|
end
|
|
|
|
|
// print registers read/write
|
// print registers read/write
|
Line 689... |
Line 692... |
if(dbg_tb.dbgTAP1.RegAccess_q & ~dbg_tb.dbgTAP1.RegAccess_q2)
|
if(dbg_tb.dbgTAP1.RegAccess_q & ~dbg_tb.dbgTAP1.RegAccess_q2)
|
begin
|
begin
|
if(dbg_tb.dbgTAP1.RW)
|
if(dbg_tb.dbgTAP1.RW)
|
$write("\n\t\tWrite to Register (addr=0x%h, data=0x%h)", dbg_tb.dbgTAP1.ADDR[4:0], dbg_tb.dbgTAP1.DataOut[31:0]);
|
$write("\n\t\tWrite to Register (addr=0x%h, data=0x%h)", dbg_tb.dbgTAP1.ADDR[4:0], dbg_tb.dbgTAP1.DataOut[31:0]);
|
else
|
else
|
$write("\n\t\tRead from Register (addr=0x%h, data=0x%h)", dbg_tb.dbgTAP1.ADDR[4:0], dbg_tb.dbgTAP1.RegDataIn[31:0]);
|
$write("\n\t\tRead from Register (addr=0x%h, data=0x%h). This data will be shifted out on next read request.", dbg_tb.dbgTAP1.ADDR[4:0], dbg_tb.dbgTAP1.RegDataIn[31:0]);
|
end
|
end
|
end
|
end
|
|
|
|
|
// print CRC error
|
// print CRC error
|