OpenCores
URL https://opencores.org/ocsvn/systemverilog-uart16550/systemverilog-uart16550/trunk

Subversion Repositories systemverilog-uart16550

[/] [systemverilog-uart16550/] [trunk/] [sim/] [uart_test.sv] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 hiroshi
/* *****************************************************************************
2
   * title:         uart_16550_rll module                                      *
3
   * description:   RS232 Protocol 16550D uart (mostly supported)              *
4
   * languages:     systemVerilog                                              *
5
   *                                                                           *
6
   * Copyright (C) 2010 miyagi.hiroshi                                         *
7
   *                                                                           *
8
   * This library is free software; you can redistribute it and/or             *
9
   * modify it under the terms of the GNU Lesser General Public                *
10
   * License as published by the Free Software Foundation; either              *
11
   * version 2.1 of the License, or (at your option) any later version.        *
12
   *                                                                           *
13
   * This library is distributed in the hope that it will be useful,           *
14
   * but WITHOUT ANY WARRANTY; without even the implied warranty of            *
15
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         *
16
   * Lesser General Public License for more details.                           *
17
   *                                                                           *
18
   * You should have received a copy of the GNU Lesser General Public          *
19
   * License along with this library; if not, write to the Free Software       *
20
   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111*1307  USA *
21
   *                                                                           *
22
   *         ***  GNU LESSER GENERAL PUBLIC LICENSE  ***                       *
23
   *           from http://www.gnu.org/licenses/lgpl.txt                       *
24
   *****************************************************************************
25
   *                            redleaflogic,ltd                               *
26
   *                    miyagi.hiroshi@redleaflogic.biz                        *
27
   *          $Id: uart_test.sv 112 2010-03-30 04:37:33Z hiroshi $         *
28
   ***************************************************************************** */
29
 
30
#(STEP*100) ;
31
$display("char7 pari non, buad rate setup 19200bps") ;
32
$fdisplay(file_a, "char7 pari non, buad rate setup 19200bps") ;
33
 
34
UART_R = 0 ; // all cleaer register
35
 
36
$display("fifo trigger level 14byte") ;
37
$fdisplay(file_a, "fifo trigger level 14byte") ;
38
UART_R.fifo_control_reg.define_fifo_trigger_level = BYTE_14  ;
39
wb_DUT.write( UART_R.fifo_control_reg, UART_FIFO_CONTROL) ;
40
wb_BENCH.write(UART_R.fifo_control_reg, UART_FIFO_CONTROL) ;
41
 
42
 
43
UART_R.line_control_reg.divisor_access = 1'b1 ;
44
UART_R.baud_reg = 8'd64 ; // 19200bps
45
wb_BENCH.write(UART_R.line_control_reg,  UART_LINE_CONTROL) ;
46
wb_BENCH.write(UART_R.baud_reg,  UART_BAUD) ;
47
wb_DUT.write(UART_R.line_control_reg,  UART_LINE_CONTROL) ;
48
wb_DUT.write(UART_R.baud_reg,  UART_BAUD) ;
49
// --
50
UART_R.line_control_reg.divisor_access = 1'b0 ;
51
UART_R.line_control_reg.char_length = CHAR_7_BIT ;
52
UART_R.line_control_reg.parity_enable   = 1'b0 ;
53
UART_R.line_control_reg.even_parity = 1'b1 ;
54
wb_BENCH.write(UART_R.line_control_reg,  UART_LINE_CONTROL) ;
55
wb_DUT.write(  UART_R.line_control_reg,  UART_LINE_CONTROL) ;
56
 
57
UART_R.interrupt_enable_reg.trans_holding_reg_empty = 1'b1 ;
58
wb_DUT.write(UART_R.interrupt_enable_reg, UART_INTERRUPT_ENABLE) ;
59
wb_DUT.nop() ;
60
wdat = 1 ;
61
 
62
for(i=0;i<8;i+=1) begin
63
   wb_DUT.write(wdat<
64
end
65
 
66
@(posedge intr_o) ;
67
#(STEP*13000) ;
68
 
69
for(i=0;i<8;i+=1) begin
70
   wb_BENCH.read(rdat, UART_RXD) ;
71
   $display("read data = %x", rdat) ;
72
   $fdisplay(file_a, "read data = %x", rdat) ;
73
end
74
 
75
$display("fifo clear") ;
76
$fdisplay(file_a, "fifo clear") ;
77
UART_R.fifo_control_reg.transmitter_fifo_reset = 1'b1 ;
78
UART_R.fifo_control_reg.receiver_fifo_reset = 1'b1 ;
79
wb_DUT.write( UART_R.fifo_control_reg, UART_FIFO_CONTROL) ;
80
wb_BENCH.write(UART_R.fifo_control_reg, UART_FIFO_CONTROL) ;
81
 
82
 
83
$display("char7 pari even") ;
84
$fdisplay(file_a, "char7 pari even") ;
85
UART_R.line_control_reg.parity_enable   = 1'b1 ;
86
UART_R.line_control_reg.even_parity = 1'b1 ;
87
wb_BENCH.write(UART_R.line_control_reg,  UART_LINE_CONTROL) ;
88
wb_DUT.write(  UART_R.line_control_reg,  UART_LINE_CONTROL) ;
89
 
90
 
91
wb_DUT.nop() ;
92
wdat = 1 ;
93
for(i=0;i<8;i+=1) begin
94
   wb_DUT.write(wdat<
95
end
96
 
97
@(posedge intr_o) ;
98
#(STEP*13000) ;
99
 
100
$display("char7 pari odd") ;
101
$fdisplay(file_a, "char7 pari odd") ;
102
 
103
UART_R.line_control_reg.even_parity = 1'b0 ;
104
wb_BENCH.write(UART_R.line_control_reg,  UART_LINE_CONTROL) ;
105
wb_DUT.write(  UART_R.line_control_reg,  UART_LINE_CONTROL) ;
106
wb_DUT.nop() ;
107
wdat = 1 ;
108
for(i=0;i<8;i+=1) begin
109
   wb_DUT.write(wdat<
110
end
111
 
112
@(posedge intr_o) ;
113
#(STEP*13000) ;
114
 
115
for(i=0;i<16;i+=1) begin
116
   wb_BENCH.read(rdat, UART_RXD) ;
117
   $display("read data = %x", rdat) ;
118
   $fdisplay(file_a, "read data = %x", rdat) ;
119
end
120
 
121
#(STEP*300) ;
122
 
123
$display("fifo clear") ;
124
$fdisplay(file_a, "fifo clear") ;
125
UART_R.fifo_control_reg.transmitter_fifo_reset = 1'b1 ;
126
UART_R.fifo_control_reg.receiver_fifo_reset = 1'b1 ;
127
wb_DUT.write(  UART_R.fifo_control_reg, UART_FIFO_CONTROL) ;
128
wb_BENCH.write(UART_R.fifo_control_reg, UART_FIFO_CONTROL) ;
129
 
130
 
131
UART_R.interrupt_enable_reg.trans_holding_reg_empty = 1'b1 ;
132
wb_BENCH.write(UART_R.interrupt_enable_reg, UART_INTERRUPT_ENABLE) ;
133
 
134
UART_R.interrupt_enable_reg.trans_holding_reg_empty = 1'b0 ;
135
UART_R.interrupt_enable_reg.rec_data_available = 1'b1 ;
136
wb_DUT.write(UART_R.interrupt_enable_reg, UART_INTERRUPT_ENABLE) ;
137
 
138
 
139
wb_DUT.read(rdat, UART_INTERRUPT_IDENT) ;
140
 
141
 
142
wb_DUT.nop() ;
143
 
144
for(i=0;i<4;i+=1) begin
145
   wb_BENCH.write(wdat<
146
end
147
 
148
 
149
@(posedge intr_o) ;
150
 
151
$display("timeout intr -> accept") ;
152
$fdisplay(file_a, "timeout intr -> accept") ;
153
wb_DUT.read(rdat, UART_LINE_STATUS) ;
154
$display("line_status = %b", rdat) ;
155
$fdisplay(file_a, "line_status = %b", rdat) ;
156
 
157
wb_DUT.read(rdat, UART_INTERRUPT_IDENT) ;
158
$display("interrupt_ident = %b", rdat) ;
159
$fdisplay(file_a, "interrupt_ident = %b", rdat) ;
160
 
161
wb_DUT.read(rdat, UART_RXD) ;
162
wb_DUT.read(rdat, UART_INTERRUPT_IDENT) ;
163
$display("interrupt_ident = %b", rdat) ;
164
$fdisplay(file_a, "interrupt_ident = %b", rdat) ;
165
 
166
#(STEP*500) ;
167
 
168
 

powered by: WebSVN 2.1.0

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