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

Subversion Repositories i2cslave

[/] [i2cslave/] [trunk/] [bench/] [testHarness.v] - Blame information for rev 5

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 sfielding
// -------------------------- testHarness.v -----------------------
2
`include "timescale.v"
3
 
4
module testHarness ();
5
 
6
reg rst;
7
reg clk;
8
reg i2cHostClk;
9
wire sda;
10
wire scl;
11
wire sdaOutEn;
12
wire sdaOut;
13
wire sdaIn;
14
wire [2:0] adr;
15
wire [7:0] masterDout;
16
wire [7:0] masterDin;
17
wire we;
18
wire stb;
19
wire cyc;
20
wire ack;
21
wire scl_pad_i;
22
wire scl_pad_o;
23
wire scl_padoen_o;
24
wire sda_pad_i;
25
wire sda_pad_o;
26
wire sda_padoen_o;
27
 
28
initial begin
29
$dumpfile("wave.vcd");
30
$dumpvars(0, testHarness);
31
end
32
 
33
 
34
i2cSlave u_i2cSlave(
35
  .clk(clk),
36
  .rst(rst),
37
  .sda(sda),
38
  .scl(scl),
39
  .myReg0(),
40
  .myReg1(),
41
  .myReg2(),
42
  .myReg3(),
43
  .myReg4(8'h12),
44
  .myReg5(8'h34),
45
  .myReg6(8'h56),
46
  .myReg7(8'h78)
47
);
48
 
49
i2c_master_top #(.ARST_LVL(1'b1)) u_i2c_master_top (
50
  .wb_clk_i(clk),
51
  .wb_rst_i(rst),
52
  .arst_i(rst),
53
  .wb_adr_i(adr),
54
  .wb_dat_i(masterDout),
55
  .wb_dat_o(masterDin),
56
  .wb_we_i(we),
57
  .wb_stb_i(stb),
58
  .wb_cyc_i(cyc),
59
  .wb_ack_o(ack),
60
  .wb_inta_o(),
61
  .scl_pad_i(scl_pad_i),
62
  .scl_pad_o(scl_pad_o),
63
  .scl_padoen_o(scl_padoen_o),
64
  .sda_pad_i(sda_pad_i),
65
  .sda_pad_o(sda_pad_o),
66
  .sda_padoen_o(sda_padoen_o)
67
);
68
 
69
wb_master_model #(.dwidth(8), .awidth(3)) u_wb_master_model (
70
  .clk(clk),
71
  .rst(rst),
72
  .adr(adr),
73
  .din(masterDin),
74
  .dout(masterDout),
75
  .cyc(cyc),
76
  .stb(stb),
77
  .we(we),
78
  .sel(),
79
  .ack(ack),
80
  .err(1'b0),
81
  .rty(1'b0)
82
);
83
 
84
assign sda = (sda_padoen_o == 1'b0) ? sda_pad_o : 1'bz;
85
assign sda_pad_i = sda;
86
pullup(sda);
87
 
88
assign scl = (scl_padoen_o == 1'b0) ? scl_pad_o : 1'bz;
89
assign scl_pad_i = scl;
90
pullup(scl);
91
 
92
 
93
// ******************************  Clock section  ******************************
94
//approx 48MHz clock
95
`define CLK_HALF_PERIOD 10
96
always begin
97
  #`CLK_HALF_PERIOD clk <= 1'b0;
98
  #`CLK_HALF_PERIOD clk <= 1'b1;
99
end
100
 
101
 
102
// ******************************  reset  ****************************** 
103
task reset;
104
begin
105
  rst <= 1'b1;
106
  @(posedge clk);
107
  @(posedge clk);
108
  @(posedge clk);
109
  @(posedge clk);
110
  @(posedge clk);
111
  @(posedge clk);
112
  rst <= 1'b0;
113
  @(posedge clk);
114
  @(posedge clk);
115
  @(posedge clk);
116
end
117
endtask
118
 
119
endmodule

powered by: WebSVN 2.1.0

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