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

Subversion Repositories systemverilog-uart16550

[/] [systemverilog-uart16550/] [trunk/] [bench/] [uart_interface_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_interface_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
interface wb_ext_bus() ;
38
   wire                     clk_i ;   // clock
39
   wire                     nrst_i ;  // reset
40
   wire [15:0]              adr_i ;   // address
41
   wire [31:0]              dat_i ;   // data input
42
   wire [31:0]              dat_o ;   // clk_rst_manager
43
   wire                     we_i  ;   // write enable
44
   wire [3:0]               sel_i ;   // select
45
   wire                     stb_i ;   //
46
   wire                     ack_o ;   // acknowledge accept
47
   wire                     cyc_i ;   // cycle assrted
48
   wire                     intr_o ;  //
49
 
50
   modport master_mp(
51
                     output  clk_i, nrst_i, adr_i, dat_i, we_i, sel_i, cyc_i, stb_i,
52
                     input  dat_o, ack_o, intr_o
53
                     ) ;
54
 
55
   modport slave_mp(
56
                    input  clk_i, nrst_i, adr_i, dat_i, we_i, sel_i, stb_i, cyc_i,
57
                    output dat_o, ack_o, intr_o) ;
58
 
59
 
60
   logic [31:0]            bw_data ;
61
   logic [4:0]             b_addr ;
62
   logic                   cs3, we ;
63
   logic [3:0]             be ;
64
 
65
   assign adr_i = b_addr ;
66
   assign dat_i = we == 1'b1 ? bw_data : 'hx ;
67
   assign stb_i = cs3 ;
68
   assign cyc_i = cs3 ;
69
   assign we_i  = we ;
70
   assign sel_i = be ;
71
   assign clk_b = clk_i ;
72
 
73
   initial begin
74
      bw_data = 0 ;
75
      b_addr  = 0;
76
      cs3  = 1'b0 ;
77
      we   = 1'b0 ;
78
      be   = 4'b0000 ;
79
   end
80
 
81
   task write(
82
              input logic [31:0] wdat,
83
              input logic [4:0] adr
84
              ) ;
85
      @(posedge clk_b) ;
86
      #(STEP*0.1) ;
87
      b_addr   = adr ;
88
      cs3  = 1'b1 ;
89
      @(posedge clk_b) ;
90
      #(STEP*0.1) ;
91
      bw_data   = wdat ;
92
      we  = 1'b1 ;
93
`ifdef ALIGN_4B
94
      be  = 4'b1111 ;
95
`else
96
      be[0]  = adr[1:0] == 2'b00 ;
97
      be[1]  = adr[1:0] == 2'b01 ;
98
      be[2]  = adr[1:0] == 2'b10 ;
99
      be[3]  = adr[1:0] == 2'b11 ;
100
`endif
101
      @(posedge clk_b) ;
102
      #(STEP*0.1) ;
103
      cs3  = 1'b0 ;
104
      we   = 1'b0 ;
105
      be   = 4'b0000 ;
106
      b_addr   = 'hx ;
107
      bw_data  = 'hx ;
108
   endtask
109
 
110
   task read(
111
             output logic [31:0] rdat,
112
             input logic [4:0] adr
113
             ) ;
114
      @(posedge clk_b) ;
115
      #(STEP*0.1) ;
116
      b_addr   = adr ;
117
      cs3  = 1'b1 ;
118
      we   = 1'b0 ;
119
      be   = 4'b0000 ;
120
      @(posedge clk_b) ;
121
      #(STEP*0.1) ;
122
      @(posedge clk_b) ;
123
      #(STEP*0.1) ;
124
      cs3  = 1'b1 ;
125
      we   = 1'b0 ;
126
`ifdef ALIGN_4B
127
      be  = 4'b1111 ;
128
`else
129
      be[0]  = adr[1:0] == 2'b00 ;
130
      be[1]  = adr[1:0] == 2'b01 ;
131
      be[2]  = adr[1:0] == 2'b10 ;
132
      be[3]  = adr[1:0] == 2'b11 ;
133
`endif
134
      @(posedge clk_b) ;
135
      rdat = dat_o ;
136
      #(STEP*0.1) ;
137
      cs3  = 1'b0 ;
138
      we   = 1'b0 ;
139
      be   = 4'b0000 ;
140
      b_addr   = 'hx ;
141
      bw_data  = 'hx ;
142
   endtask
143
 
144
   task nop() ;
145
      @(posedge clk_b) ;
146
      #(STEP*0.1) ;
147
      b_addr   = 'hx ;
148
      bw_data  = 'hx ;
149
      cs3 = 1'b0 ;
150
      we  = 1'b0 ;
151
      be  = 4'b0000 ;
152
   endtask
153
 
154
endinterface : wb_ext_bus
155
 

powered by: WebSVN 2.1.0

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