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

Subversion Repositories spi_verilog_master_slave

[/] [spi_verilog_master_slave/] [trunk/] [testbench/] [TB_SPI_MasSlv.v] - Blame information for rev 7

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 7 santhg
////////////////////////////////////////////////////////////////////////////////
2
////                                                                        ////
3
//// Project Name: SPI (Verilog)                                            ////
4
////                                                                        ////
5
//// Module Name: Master_Slave_Testbench                                    ////
6
////                                                                        ////
7
////                                                                        ////
8
////  This file is part of the Ethernet IP core project                     ////
9
////  http://opencores.com/project,spi_verilog_master_slave                 ////
10
////                                                                        ////
11
////  Author(s):                                                            ////
12
////      Santhosh G (santhg@opencores.org)                                 ////
13
////                                                                        ////
14
////  Refer to Readme.txt for more information                              ////
15
////                                                                        ////
16
////////////////////////////////////////////////////////////////////////////////
17
////                                                                        ////
18
//// Copyright (C) 2014, 2015 Authors                                       ////
19
////                                                                        ////
20
//// This source file may be used and distributed without                   ////
21
//// restriction provided that this copyright statement is not              ////
22
//// removed from the file and that any derivative work contains            ////
23
//// the original copyright notice and the associated disclaimer.           ////
24
////                                                                        ////
25
//// This source file is free software; you can redistribute it             ////
26
//// and/or modify it under the terms of the GNU Lesser General             ////
27
//// Public License as published by the Free Software Foundation;           ////
28
//// either version 2.1 of the License, or (at your option) any             ////
29
//// later version.                                                         ////
30
////                                                                        ////
31
//// This source is distributed in the hope that it will be                 ////
32
//// useful, but WITHOUT ANY WARRANTY; without even the implied             ////
33
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR                ////
34
//// PURPOSE.  See the GNU Lesser General Public License for more           ////
35
//// details.                                                               ////
36
////                                                                        ////
37
//// You should have received a copy of the GNU Lesser General              ////
38
//// Public License along with this source; if not, download it             ////
39
//// from http://www.opencores.org/lgpl.shtml                               ////
40
////                                                                        ////
41
////////////////////////////////////////////////////////////////////////////////
42
 
43
`timescale 1ns/10ps
44
module TB_SPI_MasSlv;
45
    reg rstb;
46
    reg clk = 1'b0;
47
    reg mlb = 1'b0;
48
    reg start = 1'b0;
49
    reg [7:0] m_tdat = 8'b00000000;
50
    reg [1:0] cdiv = 0;
51
    wire din;
52
    wire ss;
53
    wire sck;
54
    wire dout;
55
    wire Mdone;
56
    wire [7:0] Mrdata;
57
        reg ten = 1'b0;
58
    reg [7:0] s_tdata = 8'b00000000;
59
    wire SLVdone;
60
    wire [7:0] SLVrdata;
61
 
62
    parameter PERIOD = 50;
63
    parameter real DUTY_CYCLE = 0.5;
64
    parameter OFFSET = 100;
65
    initial begin  // Clock process for clk
66
        #OFFSET;
67
        forever
68
        begin
69
            clk = 1'b0;
70
            #(PERIOD-(PERIOD*DUTY_CYCLE)) clk = 1'b1;
71
            #(PERIOD*DUTY_CYCLE);
72
        end
73
    end
74
// to end simulation
75
        initial #10000 $stop;
76
 
77
//uut MASTER instantiation
78
    spi_master MAS (
79
        .rstb(rstb),
80
        .clk(clk),
81
        .mlb(mlb),
82
        .start(start),
83
        .tdat(m_tdat),
84
        .cdiv(cdiv),
85
        .din(din),
86
        .ss(ss),
87
        .sck(sck),
88
        .dout(dout),
89
        .done(Mdone),
90
        .rdata(Mrdata));
91
//uut SLAVE instantiation
92
        spi_slave SLV (
93
        .rstb(rstb),
94
        .ten(ten),
95
        .tdata(s_tdata),
96
        .mlb(mlb),
97
        .ss(ss),
98
        .sck(sck),
99
        .sdin(dout),
100
        .sdout(din),
101
        .done(SLVdone),
102
        .rdata(SLVrdata));
103
 
104
// timed contrl signals
105
initial begin
106
        #10 rstb = 1'b0;
107
        #100;
108
                        rstb = 1'b1;start = 1'b0;
109
                        m_tdat = 8'b01111100;
110
                        cdiv = 2'b00;
111
 
112
        #100  start = 1'b1;ten=1; //s_tdata=8'hAC;
113
        #100  start = 1'b0;
114
 
115
 
116
        #1800 mlb = 1'b1; cdiv=2'b01; m_tdat=8'b00011100;//s_tdata=8'h64;
117
        #100  start = 1'b1;
118
                #100  start = 1'b0;
119
                #2202;
120
 
121
        #100  start = 1'b1;
122
                #100  start = 1'b0;
123
                #2000;
124
 
125
        m_tdat=~m_tdat;
126
        #100  start = 1'b1;
127
                #100  start = 1'b0;
128
                #2000;
129
 
130
   end
131
 
132
 
133
 always @ (rstb or Mrdata) begin
134
    if(rstb==0)
135
            s_tdata = 8'hAA;
136
    else
137
     begin
138
            # 10 s_tdata = Mrdata;
139
     end
140
 end
141
 
142
endmodule
143
 
144
 

powered by: WebSVN 2.1.0

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