`include "timescale.v"
|
`include "timescale.v"
|
|
|
module testHarness( );
|
module testHarness( );
|
|
|
|
|
// -----------------------------------
|
// -----------------------------------
|
// Local Wires
|
// Local Wires
|
// -----------------------------------
|
// -----------------------------------
|
reg clk;
|
reg clk;
|
reg rst;
|
reg rst;
|
wire [8:0] adr;
|
wire [8:0] adr;
|
wire [7:0] masterDout;
|
wire [7:0] masterDout;
|
wire [7:0] masterDin;
|
wire [7:0] masterDin;
|
wire [7:0] usbSlaveDout;
|
wire [7:0] usbSlaveDout;
|
wire [7:0] usbHostDout;
|
wire [7:0] usbHostDout;
|
wire stb;
|
wire stb;
|
wire we;
|
wire we;
|
wire ack;
|
wire ack;
|
wire host_stb;
|
wire host_stb;
|
wire DPlusPullup;
|
wire DPlusPullup;
|
wire DPlusPullDown;
|
wire DPlusPullDown;
|
wire DMinusPullup;
|
wire DMinusPullup;
|
wire DMinusPulDown;
|
wire DMinusPulDown;
|
reg USBWireVP;
|
reg USBWireVP;
|
reg USBWireVM;
|
reg USBWireVM;
|
wire [1:0] hostUSBWireDataIn;
|
wire [1:0] hostUSBWireDataIn;
|
wire [1:0] hostUSBWireDataOut;
|
wire [1:0] hostUSBWireDataOut;
|
wire hostUSBWireCtrlOut;
|
wire hostUSBWireCtrlOut;
|
wire usbSlaveOE_n;
|
wire usbSlaveOE_n;
|
wire usbSlaveVP_out;
|
wire usbSlaveVP_out;
|
wire usbSlaveVM_out;
|
wire usbSlaveVM_out;
|
wire USBDMinusPullup;
|
wire USBDMinusPullup;
|
|
|
assign USBDMinusPullup = 1'b0;
|
assign USBDMinusPullup = 1'b0;
|
|
|
initial begin
|
initial begin
|
$dumpfile("wave.vcd");
|
$dumpfile("wave.vcd");
|
$dumpvars(0, testHarness);
|
$dumpvars(0, testHarness);
|
end
|
end
|
|
|
pullup(DPlusPullup);
|
pullup(DPlusPullup);
|
pulldown(DPlusPullDown);
|
pulldown(DPlusPullDown);
|
pullup(DMinusPullup);
|
pullup(DMinusPullup);
|
pulldown(DMinusPullDown);
|
pulldown(DMinusPullDown);
|
|
|
assign hostUSBWireDataIn = {USBWireVP, USBWireVM};
|
assign hostUSBWireDataIn = {USBWireVP, USBWireVM};
|
always @(*) begin
|
always @(*) begin
|
if (hostUSBWireCtrlOut == 1'b1 && usbSlaveOE_n == 1'b1)
|
if (hostUSBWireCtrlOut == 1'b1 && usbSlaveOE_n == 1'b1)
|
{USBWireVP, USBWireVM} <= hostUSBWireDataOut;
|
{USBWireVP, USBWireVM} <= hostUSBWireDataOut;
|
else if (hostUSBWireCtrlOut == 1'b0 && usbSlaveOE_n == 1'b0)
|
else if (hostUSBWireCtrlOut == 1'b0 && usbSlaveOE_n == 1'b0)
|
{USBWireVP, USBWireVM} <= {usbSlaveVP_out, usbSlaveVM_out};
|
{USBWireVP, USBWireVM} <= {usbSlaveVP_out, usbSlaveVM_out};
|
else if (hostUSBWireCtrlOut == 1'b1 && usbSlaveOE_n == 1'b0)
|
else if (hostUSBWireCtrlOut == 1'b1 && usbSlaveOE_n == 1'b0)
|
{USBWireVP, USBWireVM} <= 2'bxx;
|
{USBWireVP, USBWireVM} <= 2'bxx;
|
else if (hostUSBWireCtrlOut == 1'b0 && usbSlaveOE_n == 1'b1) begin
|
else if (hostUSBWireCtrlOut == 1'b0 && usbSlaveOE_n == 1'b1) begin
|
if (USBDPlusPullup == 1'b1)
|
if (USBDPlusPullup == 1'b1)
|
USBWireVP <= DPlusPullup;
|
USBWireVP <= DPlusPullup;
|
else
|
else
|
USBWireVP <= DPlusPullDown;
|
USBWireVP <= DPlusPullDown;
|
if (USBDMinusPullup == 1'b1)
|
if (USBDMinusPullup == 1'b1)
|
USBWireVM <= DMinusPullup;
|
USBWireVM <= DMinusPullup;
|
else
|
else
|
USBWireVM <= DMinusPullDown;
|
USBWireVM <= DMinusPullDown;
|
end
|
end
|
end
|
end
|
|
|
assign host_stb = stb;
|
assign host_stb = stb;
|
assign masterDin = usbHostDout;
|
assign masterDin = usbHostDout;
|
|
|
//Parameters declaration:
|
//Parameters declaration:
|
defparam u_usbHost.HOST_FIFO_DEPTH = 64;
|
defparam u_usbHost.HOST_FIFO_DEPTH = 64;
|
parameter HOST_FIFO_DEPTH = 64;
|
parameter HOST_FIFO_DEPTH = 64;
|
defparam u_usbHost.HOST_FIFO_ADDR_WIDTH = 6;
|
defparam u_usbHost.HOST_FIFO_ADDR_WIDTH = 6;
|
parameter HOST_FIFO_ADDR_WIDTH = 6;
|
parameter HOST_FIFO_ADDR_WIDTH = 6;
|
usbHost u_usbHost (
|
usbHost u_usbHost (
|
.clk_i(clk),
|
.clk_i(clk),
|
.rst_i(rst),
|
.rst_i(rst),
|
.address_i(adr[7:0]),
|
.address_i(adr[7:0]),
|
.data_i(masterDout),
|
.data_i(masterDout),
|
.data_o(usbHostDout),
|
.data_o(usbHostDout),
|
.we_i(we),
|
.we_i(we),
|
.strobe_i(host_stb),
|
.strobe_i(host_stb),
|
.ack_o(ack),
|
.ack_o(ack),
|
.usbClk(clk),
|
.usbClk(clk),
|
.hostSOFSentIntOut(hostSOFSentIntOut),
|
.hostSOFSentIntOut(hostSOFSentIntOut),
|
.hostConnEventIntOut(hostConnEventIntOut),
|
.hostConnEventIntOut(hostConnEventIntOut),
|
.hostResumeIntOut(hostResumeIntOut),
|
.hostResumeIntOut(hostResumeIntOut),
|
.hostTransDoneIntOut(hostTransDoneIntOut),
|
.hostTransDoneIntOut(hostTransDoneIntOut),
|
.USBWireDataIn(hostUSBWireDataIn),
|
.USBWireDataIn(hostUSBWireDataIn),
|
.USBWireDataInTick(USBWireDataInTick),
|
.USBWireDataInTick(USBWireDataInTick),
|
.USBWireDataOut(hostUSBWireDataOut),
|
.USBWireDataOut(hostUSBWireDataOut),
|
.USBWireDataOutTick(USBWireDataOutTick),
|
.USBWireDataOutTick(USBWireDataOutTick),
|
.USBWireCtrlOut(hostUSBWireCtrlOut),
|
.USBWireCtrlOut(hostUSBWireCtrlOut),
|
.USBFullSpeed(USBFullSpeed)
|
.USBFullSpeed(USBFullSpeed)
|
);
|
);
|
|
|
usbDevice u_usbDevice (
|
usbDevice u_usbDevice (
|
.clk(clk),
|
.clk(clk),
|
.rst(rst),
|
.rst(rst),
|
.usbSlaveVP_in(USBWireVP),
|
.usbSlaveVP_in(USBWireVP),
|
.usbSlaveVM_in(USBWireVM),
|
.usbSlaveVM_in(USBWireVM),
|
.usbSlaveVP_out(usbSlaveVP_out),
|
.usbSlaveVP_out(usbSlaveVP_out),
|
.usbSlaveVM_out(usbSlaveVM_out),
|
.usbSlaveVM_out(usbSlaveVM_out),
|
.usbSlaveOE_n(usbSlaveOE_n),
|
.usbSlaveOE_n(usbSlaveOE_n),
|
.usbDPlusPullup(USBDPlusPullup),
|
.usbDPlusPullup(USBDPlusPullup),
|
.vBusDetect(1'b1)
|
.vBusDetect(1'b1)
|
);
|
);
|
|
|
|
|
wb_master_model #(.dwidth(8), .awidth(9)) u_wb_master_model (
|
wb_master_model #(.dwidth(8), .awidth(9)) u_wb_master_model (
|
.clk(clk),
|
.clk(clk),
|
.rst(rst),
|
.rst(rst),
|
.adr(adr),
|
.adr(adr),
|
.din(masterDin),
|
.din(masterDin),
|
.dout(masterDout),
|
.dout(masterDout),
|
.cyc(),
|
.cyc(),
|
.stb(stb),
|
.stb(stb),
|
.we(we),
|
.we(we),
|
.sel(),
|
.sel(),
|
.ack(ack),
|
.ack(ack),
|
.err(1'b0),
|
.err(1'b0),
|
.rty(1'b0)
|
.rty(1'b0)
|
);
|
);
|
|
|
|
|
//--------------- reset ---------------
|
//--------------- reset ---------------
|
initial begin
|
initial begin
|
@(posedge clk);
|
@(posedge clk);
|
@(posedge clk);
|
@(posedge clk);
|
@(posedge clk);
|
@(posedge clk);
|
@(posedge clk);
|
@(posedge clk);
|
@(posedge clk);
|
@(posedge clk);
|
@(posedge clk);
|
@(posedge clk);
|
@(posedge clk);
|
@(posedge clk);
|
@(posedge clk);
|
@(posedge clk);
|
rst <= 1'b1;
|
rst <= 1'b1;
|
@(posedge clk);
|
@(posedge clk);
|
rst <= 1'b0;
|
rst <= 1'b0;
|
@(posedge clk);
|
@(posedge clk);
|
end
|
end
|
|
|
// ****************************** Clock section ******************************
|
// ****************************** Clock section ******************************
|
`define CLK_50MHZ_HALF_PERIOD 10
|
`define CLK_50MHZ_HALF_PERIOD 10
|
`define CLK_25MHZ_HALF_PERIOD 20
|
`define CLK_25MHZ_HALF_PERIOD 20
|
|
|
always begin
|
always begin
|
#`CLK_25MHZ_HALF_PERIOD clk <= 1'b0;
|
#`CLK_25MHZ_HALF_PERIOD clk <= 1'b0;
|
#`CLK_25MHZ_HALF_PERIOD clk <= 1'b1;
|
#`CLK_25MHZ_HALF_PERIOD clk <= 1'b1;
|
end
|
end
|
|
|
|
|
|
|
|
|
|
|
endmodule
|
endmodule
|
|
|
|
|