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

Subversion Repositories iso7816_3_master

[/] [iso7816_3_master/] [trunk/] [test/] [TxCoreTestBench.v] - Blame information for rev 14

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

Line No. Rev Author Line
1 11 acapola
/*
2
Author: Sebastien Riou (acapola)
3
Creation date: 22:53:00 08/29/2010
4
 
5
$LastChangedDate: 2011-01-29 13:16:17 +0100 (Sat, 29 Jan 2011) $
6
$LastChangedBy: acapola $
7
$LastChangedRevision: 11 $
8
$HeadURL: file:///svn/iso7816_3_master/iso7816_3_master/trunk/test/TxCoreTestBench.v $
9
 
10
This file is under the BSD licence:
11
Copyright (c) 2011, Sebastien Riou
12
 
13
All rights reserved.
14
 
15
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
16
 
17
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
18
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
19
The names of contributors may not be used to endorse or promote products derived from this software without specific prior written permission.
20
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
*/
32
`default_nettype none
33 2 acapola
`timescale 1ns / 1ps
34
 
35
module tb_TxCore;
36
parameter PARITY        = 1;
37
parameter CLK_PERIOD = 10;//should be %2
38
        // Inputs
39
        reg [7:0] dataIn;
40
        reg loadDataIn;
41
        reg [12:0] clocksPerBit;
42
        reg stopBit2;
43
        wire oddParity=0; //if 1, parity bit is such that data+parity have an odd number of 1
44
   wire msbFirst=0;  //if 1, bits will be send in the order startBit, b7, b6, b5...b0, parity
45
        reg clk;
46
        reg nReset;
47
 
48
        // Outputs
49
        wire serialOut;
50
        wire run;
51
        wire full;
52
   wire stopBits;
53
 
54
        // Instantiate the Unit Under Test (UUT)
55
        TxCore #(.PARITY_POLARITY(PARITY)) uut (
56
                .serialOut(serialOut),
57
                .run(run),
58
                .full(full),
59
      .stopBits(stopBits),
60
                .dataIn(dataIn),
61
                .clocksPerBit(clocksPerBit),
62
                .stopBit2(stopBit2),
63
                .oddParity(oddParity),
64
      .msbFirst(msbFirst),
65
           .loadDataIn(loadDataIn),
66
                .clk(clk),
67
                .nReset(nReset)
68
        );
69
 
70
        //test bench signals
71
        reg tbClock;
72
        reg tbBitCounter;
73
 
74
        initial begin
75
                tbClock=0;
76
                tbBitCounter=0;
77
                // Initialize Inputs
78
                dataIn = 0;
79
                loadDataIn = 0;
80
                clocksPerBit = 8;
81
                stopBit2=0;
82
                clk = 0;
83
                nReset = 0;
84
                #(CLK_PERIOD*10);
85
                nReset = 1;
86
                #(CLK_PERIOD*10);
87
                // Add stimulus here
88
                dataIn = 8'b1000_0000;
89
                loadDataIn = 1;
90
                wait(full==1);
91
                wait(full==0);
92
                //loadDataIn=0;
93
                dataIn = 8'b0111_1111;
94
                //loadDataIn = 1;
95
                wait(full==1);
96
                wait(full==0);
97
                loadDataIn=0;
98
        end
99
 
100
        initial begin
101
                // timeout
102
                #10000;
103
                $finish;
104
        end
105
 
106
        always
107
                #1      tbClock =  ! tbClock;
108
        always
109
                #(CLK_PERIOD/2) clk =  ! clk;
110
 
111
endmodule
112 11 acapola
`default_nettype wire
113 2 acapola
 

powered by: WebSVN 2.1.0

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