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

Subversion Repositories systemverilog-uart16550

[/] [systemverilog-uart16550/] [trunk/] [bench/] [uart_be.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_be.sv 108 2010-03-30 02:56:26Z hiroshi $         *
28
   ***************************************************************************** */
29
 
30
`ifdef SYN
31
/* empty */
32
`else
33
timeunit      1ps ;
34
timeprecision 1ps ;
35
`endif
36
import uart_top_package:: * ;
37
import uart_package:: * ;
38
module top ;
39
 
40
   u_reg_t UART_R ;
41
 
42
   logic        clk_sys ;
43
   logic        rst_p ;
44
   logic        intr_o, bench_intr_o ;
45
   logic [31:0] rdat, rdat1, rdat2, dat, wdat ;
46
   integer      i, j, k ;
47
   logic        ri, dcd ;
48
 
49
   logic [31:0] file_a ;
50
`ifdef ALIGN_4B
51
   localparam   UART_RXD               =  'h0 ;
52
   localparam   UART_TXD               =  'h0 ;
53
   localparam   UART_INTERRUPT_ENABLE  =  'h4 ;
54
   localparam   UART_INTERRUPT_IDENT   =  'h8 ;
55
   localparam   UART_FIFO_CONTROL      =  'hA ;
56
   localparam   UART_LINE_CONTROL      =  'hC ;
57
   localparam   UART_MODEM_CONTROL     =  'h10 ;
58
   localparam   UART_LINE_STATUS       =  'h14 ;
59
   localparam   UART_MODEM_STATUS      =  'h18 ;
60
   localparam   UART_SCRATCH           =  'h1C ;
61
   localparam   UART_BAUD              =  'h0 ;
62
`else
63
   localparam   UART_RXD               =  'h0 ;
64
   localparam   UART_TXD               =  'h0 ;
65
   localparam   UART_INTERRUPT_ENABLE  =  'h1 ;
66
   localparam   UART_INTERRUPT_IDENT   =  'h2 ;
67
   localparam   UART_FIFO_CONTROL      =  'h2 ;
68
   localparam   UART_LINE_CONTROL      =  'h3 ;
69
   localparam   UART_MODEM_CONTROL     =  'h4 ;
70
   localparam   UART_LINE_STATUS       =  'h5 ;
71
   localparam   UART_MODEM_STATUS      =  'h6 ;
72
   localparam   UART_SCRATCH           =  'h7 ;
73
   localparam   UART_BAUD              =  'h0 ;
74
`endif
75
   uart_bus    uart_bus_DUT() ;
76
   uart_bus    uart_bus_BENCH() ;
77
   wb_ext_bus  wb_DUT() ;
78
   wb_ext_bus  wb_BENCH() ;
79
 
80
   assign wb_DUT.clk_i    = clk_sys ;
81
   assign wb_DUT.nrst_i   = ~rst_p ;
82
   assign wb_BENCH.clk_i  = clk_sys ;
83
   assign wb_BENCH.nrst_i = ~rst_p ;
84
 
85
   // --------------
86
   // -  initial   -
87
   // --------------
88
   initial begin
89
      fork
90
         clock_sys ;
91
         test_pat(file_a) ;
92
      join
93
   end
94
 
95
   // ------------
96
   // -   task   -
97
   // ------------
98
   task test_pat(logic [31:0] file_a) ;
99
      integer i ;
100
      file_a = $fopen("uar_16550_rll.dump") ;
101
      ri = 1'b0 ;
102
      dcd = 1'b0 ;
103
 
104
      rst_p = 1'b1 ;
105
      #(STEP*20) ;
106
      rst_p = 1'b0 ;
107
 
108
 `include "uart_test.sv"
109
 
110
      $display(" ----------- happy end SIM !!!  --------------") ;
111
 
112
      $fclose(file_a) ;
113
 
114
      $stop ;
115
      //      $finish ;
116
   endtask
117
   task clock_sys ;
118
      clk_sys = 0 ;
119
      #(STEP) ;
120
      forever #(STEP/2) clk_sys = ~clk_sys ;
121
   endtask
122
 
123
   assign intr_o = wb_DUT.intr_o ;
124
   assign bench_intr_o = wb_BENCH.intr_o ;
125
 
126
   assign uart_bus_DUT.srx_i   = uart_bus_BENCH.stx_o ;
127
   assign uart_bus_BENCH.srx_i = uart_bus_DUT.stx_o ;
128
   assign uart_bus_DUT.cts_i   = uart_bus_BENCH.rts_o ;
129
   assign uart_bus_BENCH.cts_i = uart_bus_DUT.rts_o ;
130
   assign uart_bus_DUT.dsr_i   = uart_bus_BENCH.dtr_o ;
131
   assign uart_bus_BENCH.dsr_i = uart_bus_DUT.dtr_o ;
132
 
133
   assign uart_bus_DUT.ri_i    = ri ;
134
   assign uart_bus_DUT.dcd_i   = dcd ;
135
   assign uart_bus_BENCH.ri_i  = 1'b0 ;
136
   assign uart_bus_BENCH.dcd_i = 1'b0 ;
137
 
138
   // ----------
139
   // -   DUT  -
140
   // ----------
141
   uart_wrapper DUT(.wb_ext_bus(wb_DUT),
142
                    .uart_bus(uart_bus_DUT)) ;
143
 
144
   uart_wrapper BENCH(.uart_bus(uart_bus_BENCH),
145
                      .wb_ext_bus(wb_BENCH)) ;
146
endmodule

powered by: WebSVN 2.1.0

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