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

Subversion Repositories usbhostslave

[/] [usbhostslave/] [trunk/] [usbDevice/] [bench/] [testHarness.v] - Blame information for rev 43

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 37 sfielding
`include "timescale.v"
2
 
3
module testHarness(     );
4
 
5
 
6
// -----------------------------------
7
// Local Wires
8
// -----------------------------------
9
reg clk;
10
reg rst;
11
wire [8:0] adr;
12
wire [7:0] masterDout;
13
wire [7:0] masterDin;
14
wire [7:0] usbSlaveDout;
15
wire [7:0] usbHostDout;
16
wire stb;
17
wire we;
18
wire ack;
19
wire host_stb;
20
wire DPlusPullup;
21
wire DPlusPullDown;
22
wire DMinusPullup;
23
wire DMinusPulDown;
24
reg USBWireVP;
25
reg USBWireVM;
26
wire [1:0] hostUSBWireDataIn;
27
wire [1:0] hostUSBWireDataOut;
28
wire hostUSBWireCtrlOut;
29
wire usbSlaveOE_n;
30
wire usbSlaveVP_out;
31
wire usbSlaveVM_out;
32
wire USBDMinusPullup;
33
 
34
assign USBDMinusPullup = 1'b0;
35
 
36
initial begin
37
$dumpfile("wave.vcd");
38
$dumpvars(0, testHarness);
39
end
40
 
41
pullup(DPlusPullup);
42
pulldown(DPlusPullDown);
43
pullup(DMinusPullup);
44
pulldown(DMinusPullDown);
45
 
46
assign hostUSBWireDataIn = {USBWireVP, USBWireVM};
47
always @(*) begin
48
  if (hostUSBWireCtrlOut == 1'b1 && usbSlaveOE_n == 1'b1)
49
    {USBWireVP, USBWireVM} <= hostUSBWireDataOut;
50
  else if (hostUSBWireCtrlOut == 1'b0 && usbSlaveOE_n == 1'b0)
51
    {USBWireVP, USBWireVM} <= {usbSlaveVP_out, usbSlaveVM_out};
52
  else if (hostUSBWireCtrlOut == 1'b1 && usbSlaveOE_n == 1'b0)
53
    {USBWireVP, USBWireVM} <= 2'bxx;
54
  else if (hostUSBWireCtrlOut == 1'b0 && usbSlaveOE_n == 1'b1) begin
55
    if (USBDPlusPullup == 1'b1)
56
      USBWireVP <= DPlusPullup;
57
    else
58
      USBWireVP <= DPlusPullDown;
59
    if (USBDMinusPullup == 1'b1)
60
      USBWireVM <= DMinusPullup;
61
    else
62
      USBWireVM <= DMinusPullDown;
63
  end
64
end
65
 
66
assign host_stb = stb;
67
assign masterDin = usbHostDout;
68
 
69
//Parameters declaration: 
70
defparam u_usbHost.HOST_FIFO_DEPTH = 64;
71
parameter HOST_FIFO_DEPTH = 64;
72
defparam u_usbHost.HOST_FIFO_ADDR_WIDTH = 6;
73
parameter HOST_FIFO_ADDR_WIDTH = 6;
74
usbHost u_usbHost (
75
  .clk_i(clk),
76
  .rst_i(rst),
77
  .address_i(adr[7:0]),
78
  .data_i(masterDout),
79
  .data_o(usbHostDout),
80
  .we_i(we),
81
  .strobe_i(host_stb),
82
  .ack_o(ack),
83
  .usbClk(clk),
84
  .hostSOFSentIntOut(hostSOFSentIntOut),
85
  .hostConnEventIntOut(hostConnEventIntOut),
86
  .hostResumeIntOut(hostResumeIntOut),
87
  .hostTransDoneIntOut(hostTransDoneIntOut),
88
  .USBWireDataIn(hostUSBWireDataIn),
89
  .USBWireDataInTick(USBWireDataInTick),
90
  .USBWireDataOut(hostUSBWireDataOut),
91
  .USBWireDataOutTick(USBWireDataOutTick),
92
  .USBWireCtrlOut(hostUSBWireCtrlOut),
93
  .USBFullSpeed(USBFullSpeed)
94
);
95
 
96
usbDevice u_usbDevice (
97
  .clk(clk),
98
  .rst(rst),
99
  .usbSlaveVP_in(USBWireVP),
100
  .usbSlaveVM_in(USBWireVM),
101
  .usbSlaveVP_out(usbSlaveVP_out),
102
  .usbSlaveVM_out(usbSlaveVM_out),
103
  .usbSlaveOE_n(usbSlaveOE_n),
104
  .usbDPlusPullup(USBDPlusPullup),
105
  .vBusDetect(1'b1)
106
);
107
 
108
 
109
wb_master_model #(.dwidth(8), .awidth(9)) u_wb_master_model (
110
  .clk(clk),
111
  .rst(rst),
112
  .adr(adr),
113
  .din(masterDin),
114
  .dout(masterDout),
115
  .cyc(),
116
  .stb(stb),
117
  .we(we),
118
  .sel(),
119
  .ack(ack),
120
  .err(1'b0),
121
  .rty(1'b0)
122
);
123
 
124
 
125
//--------------- reset ---------------
126
initial begin
127
  @(posedge clk);
128
  @(posedge clk);
129
  @(posedge clk);
130
  @(posedge clk);
131
  @(posedge clk);
132
  @(posedge clk);
133
  @(posedge clk);
134
  @(posedge clk);
135
  rst <= 1'b1;
136
  @(posedge clk);
137
  rst <= 1'b0;
138
  @(posedge clk);
139
end
140
 
141
// ******************************  Clock section  ******************************
142
`define CLK_50MHZ_HALF_PERIOD 10
143
`define CLK_25MHZ_HALF_PERIOD 20
144
 
145
always begin
146
  #`CLK_25MHZ_HALF_PERIOD clk <= 1'b0;
147
  #`CLK_25MHZ_HALF_PERIOD clk <= 1'b1;
148
end
149
 
150
 
151
 
152
 
153
 
154
endmodule
155
 

powered by: WebSVN 2.1.0

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