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

Subversion Repositories m16c5x

[/] [m16c5x/] [trunk/] [RTL/] [Sim/] [tb_UART_BRG.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 MichaelA
////////////////////////////////////////////////////////////////////////////////
2
//
3
//  Copyright 2008-2013 by Michael A. Morris, dba M. A. Morris & Associates
4
//
5
//  All rights reserved. The source code contained herein is publicly released
6
//  under the terms and conditions of the GNU Lesser Public License. No part of
7
//  this source code may be reproduced or transmitted in any form or by any
8
//  means, electronic or mechanical, including photocopying, recording, or any
9
//  information storage and retrieval system in violation of the license under
10
//  which the source code is released.
11
//
12
//  The source code contained herein is free; it may be redistributed and/or
13
//  modified in accordance with the terms of the GNU Lesser General Public
14
//  License as published by the Free Software Foundation; either version 2.1 of
15
//  the GNU Lesser General Public License, or any later version.
16
//
17
//  The source code contained herein is freely released WITHOUT ANY WARRANTY;
18
//  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
19
//  PARTICULAR PURPOSE. (Refer to the GNU Lesser General Public License for
20
//  more details.)
21
//
22
//  A copy of the GNU Lesser General Public License should have been received
23
//  along with the source code contained herein; if not, a copy can be obtained
24
//  by writing to:
25
//
26
//  Free Software Foundation, Inc.
27
//  51 Franklin Street, Fifth Floor
28
//  Boston, MA  02110-1301 USA
29
//
30
//  Further, no use of this source code is permitted in any form or means
31
//  without inclusion of this banner prominently in any derived works.
32
//
33
//  Michael A. Morris
34
//  Huntsville, AL
35
//
36
////////////////////////////////////////////////////////////////////////////////
37
 
38
`timescale 1ns / 1ps
39
 
40
///////////////////////////////////////////////////////////////////////////////
41
// Company:         M. A. Morris & Associates
42
// Engineer:        Michael A. Morris
43
//
44
// Create Date:     19:16:35 05/10/2008
45
// Design Name:     Synchronous Serial Peripheral (SSP) Interface UART 
46
// Module Name:     ../VerilogCoponentsLib/SSP_UART/tb_UART_BRG.v
47
// Project Name:    Verilog Components Library
48
// Target Devices:  XC3S50A-4VQG100I, XC3S20A-4VQG100I, XC3S700AN-4FFG484I 
49
// Tool versions:   ISE 10.1i SP3 
50
//
51
// Description: This test bench is intended to test the BRG module for the SSP 
52
//              UART.
53
//
54
// Verilog Test Fixture created by ISE for module: UART_BRG
55
//
56
// Dependencies:
57
// 
58
// Revision History:
59
//
60
//  0.01    08E10   MAM     File Created
61
//
62
// Additional Comments: 
63
//
64
////////////////////////////////////////////////////////////////////////////////
65
 
66
module tb_UART_BRG_v;
67
 
68
// Inputs
69
reg     Rst;
70
reg     Clk;
71
reg     [3:0] PS;
72
reg     [7:0] Div;
73
 
74
reg     [3:0] Baud;
75
 
76
// Outputs
77
wire    CE_16x;
78
 
79
// Instantiate the Unit Under Test (UUT)
80
 
81
UART_BRG    uut (
82
                .Rst(Rst),
83
                .Clk(Clk),
84
 
85
                .PS(PS),
86
                .Div(Div),
87
 
88
                .CE_16x(CE_16x)
89
            );
90
 
91
initial begin
92
    // Initialize Inputs
93
    Rst  = 1;
94
    Clk  = 0;
95
    Baud = 0;
96
 
97
    // Wait 100 ns for global reset to finish
98
    #101;
99
 
100
    Rst = 0;
101
 
102
    // Add stimulus here
103
 
104
 
105
    @(posedge Clk);
106
    @(posedge Clk);
107
    @(posedge Clk);
108
    @(posedge Clk);
109
    @(posedge Clk);
110
    @(posedge Clk);
111
    @(posedge Clk);
112
    @(posedge Clk);
113
 
114
    @(posedge Clk)    #1 Baud = 1;
115
    @(negedge CE_16x) #1 Baud = 2;
116
    @(negedge CE_16x) #1 Baud = 3;
117
    @(negedge CE_16x);
118
 
119
    @(negedge CE_16x) #1 Baud = 4;
120
    @(negedge CE_16x) #1 Baud = 5;
121
    @(negedge CE_16x) #1 Baud = 6;
122
    @(negedge CE_16x) #1 Baud = 7;
123
    @(negedge CE_16x) #1 Baud = 8;
124
    @(negedge CE_16x) #1 Baud = 9;
125
    @(negedge CE_16x) #1 Baud = 10;
126
    @(negedge CE_16x) #1 Baud = 11;
127
    @(negedge CE_16x) #1 Baud = 12;
128
    @(negedge CE_16x) #1 Baud = 13;
129
    @(negedge CE_16x) #1 Baud = 14;
130
    @(negedge CE_16x) #1 Baud = 15;
131
    @(negedge CE_16x)
132
 
133
    @(negedge CE_16x) Baud = 0;
134
 
135
end
136
 
137
///////////////////////////////////////////////////////////////////////////////
138
//
139
//  Clocks
140
//
141
 
142
always #10.416 Clk = ~Clk;
143
 
144
///////////////////////////////////////////////////////////////////////////////
145
//
146
//  Simulation Drivers/Models
147
//
148
 
149
//  Baud Rate Generator's PS and Div for defined Baud Rates (48 MHz Oscillator)
150
 
151
always @(Baud)
152
begin
153
    case(Baud)
154
        4'b0000 : {Div, PS} <= 12'b0000_0000_0000; // Div =   1; PS =  1
155
        4'b0001 : {Div, PS} <= 12'b0000_0001_0000; // Div =   2; PS =  1
156
        4'b0010 : {Div, PS} <= 12'b0000_0101_0000; // Div =   6; PS =  1
157
        4'b0011 : {Div, PS} <= 12'b0000_1111_0000; // Div =  16; PS =  1
158
        4'b0100 : {Div, PS} <= 12'b0000_0000_1100; // Div =   1; PS = 13
159
        4'b0101 : {Div, PS} <= 12'b0000_0001_1100; // Div =   2; PS = 13
160
        4'b0110 : {Div, PS} <= 12'b0000_0010_1100; // Div =   3; PS = 13
161
        4'b0111 : {Div, PS} <= 12'b0000_0011_1100; // Div =   4; PS = 13
162
        4'b1000 : {Div, PS} <= 12'b0000_0101_1100; // Div =   6; PS = 13
163
        4'b1001 : {Div, PS} <= 12'b0000_1011_1100; // Div =  12; PS = 13
164
        4'b1010 : {Div, PS} <= 12'b0001_0111_1100; // Div =  24; PS = 13
165
        4'b1011 : {Div, PS} <= 12'b0010_1111_1100; // Div =  48; PS = 13
166
        4'b1100 : {Div, PS} <= 12'b0101_1111_1100; // Div =  96; PS = 13
167
        4'b1101 : {Div, PS} <= 12'b1011_1111_1100; // Div = 192; PS = 13
168
        4'b1110 : {Div, PS} <= 12'b0111_1111_1100; // Div = 128; PS = 13
169
        4'b1111 : {Div, PS} <= 12'b1111_1111_1100; // Div = 256; PS = 13
170
    endcase
171
end
172
 
173
endmodule
174
 

powered by: WebSVN 2.1.0

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