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

Subversion Repositories synchronous_reset_fifo

[/] [synchronous_reset_fifo/] [trunk/] [env/] [fifo_if.sv] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 madhu54321
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  File name "fifo_if.sv"                                          ////
4
////                                                              ////
5
////  This file is part of the "synchronous_reset_fifo" project   ////
6
//// http://opencores.com/project,synchronous_reset_fifo          ////
7
////                                                              ////
8
////  Author:                                                     ////
9
////     - Madhumangal Javanthieswaran (madhu54321@opencores.org) ////
10
////                                                              ////
11
//////////////////////////////////////////////////////////////////////
12
////                                                              ////
13
//// Copyright (C) 2008 AUTHORS. All rights reserved.             ////
14
////                                                              ////
15
//// This source file may be used and distributed without         ////
16
//// restriction provided that this copyright statement is not    ////
17
//// removed from the file and that any derivative work contains  ////
18
//// the original copyright notice and the associated disclaimer. ////
19
////                                                              ////
20
//// This source file is free software; you can redistribute it   ////
21
//// and/or modify it under the terms of the GNU Lesser General   ////
22
//// Public License as published by the Free Software Foundation; ////
23
//// either version 2.1 of the License, or (at your option) any   ////
24
//// later version.                                               ////
25
////                                                              ////
26
//// This source is distributed in the hope that it will be       ////
27
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
28
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
29
//// PURPOSE.  See the GNU Lesser General Public License for more ////
30
//// details.                                                     ////
31
////                                                              ////
32
//// You should have received a copy of the GNU Lesser General    ////
33
//// Public License along with this source; if not, download it   ////
34
//// from http://www.opencores.org/lgpl.shtml                     ////
35
////                                                              ////
36
//////////////////////////////////////////////////////////////////////
37
 
38
/************************************************************************
39
 Design Name : synchronous_reset_fifo
40
 Module Name : fifo_if.sv
41
 Description :
42
 Date        : 19/12/2011
43
 Author      : Madhumangal Javanthieswaran
44
 Email       : j.madhumangal@gmail.com
45
 Company     :
46
 Version     : 1.0
47
 Revision    : 0.0
48
************************************************************************/
49
interface fifo_if(input bit clock);
50
 
51
//Fifo size definitions
52
parameter WIDTH = 8;
53
parameter DEPTH = 16;
54
parameter POINTER_SIZE = 5;
55
 
56
 
57
//Inputs
58
logic resetn;
59
logic write_enb;
60
logic read_enb;
61
logic [WIDTH-1:0] data_in;
62
 
63
//Outputs
64
logic [WIDTH-1:0] data_out;
65
logic empty;
66
logic full;
67
 
68
clocking dr_cb @(posedge clock);
69
  output resetn;
70
  output write_enb;
71
  output read_enb;
72
  output data_in;
73
endclocking
74
 
75
clocking rcv_cb @(posedge clock);
76
  input data_out;
77
  input empty;
78
  input full;
79
endclocking
80
 
81
//modport DUV_IF(input clock,resetn,write_enb,read_enb,data_in, output data_out,empty,full);
82
 
83
modport DR_MP(clocking dr_cb);
84
modport RC_MP(clocking rcv_cb);
85
 
86
 
87
task sync_reset;
88
  begin
89
    dr_cb.resetn <= 0;
90
    dr_cb.read_enb <= 0;
91
    dr_cb.write_enb <= 0;
92
    //repeat(2)
93
    @(dr_cb);
94
    repeat(2)
95
    @(rcv_cb);
96
    if(rcv_cb.data_out == 8'd0)
97
      $display($time,"sync_reset works");
98
    else
99
      $display($time,"sync_reset error");
100
  end
101
endtask:sync_reset
102
 
103
task write;
104
 begin
105
    dr_cb.resetn <= 1;
106
    dr_cb.write_enb <= 1;
107
    dr_cb.data_in <= 8'd85;
108
    @(dr_cb);
109
    $display($time,"write works");
110
 end
111
 endtask:write
112
 
113
task read;
114
  begin
115
    dr_cb.resetn <= 1;
116
    dr_cb.read_enb <= 1;
117
    repeat(2)
118
    @(rcv_cb);
119
    if(rcv_cb.data_out == 8'd85)
120
      $display($time,"read works");
121
    else
122
      $display($time,"read error");
123
    //@(rcv_cb);
124
  end
125
endtask:read
126
 
127
 
128
task write_read;
129
  begin
130
    dr_cb.resetn <= 1;
131
    dr_cb.write_enb <= 1;
132
    dr_cb.data_in <= 8'd170;
133
    dr_cb.read_enb <= 1;
134
    repeat(2)
135
    @(dr_cb);
136
    repeat(2)
137
    @(rcv_cb);
138
    if(rcv_cb.data_out == 8'd170)
139
      $display($time,"write_read works");
140
    else
141
      $display($time,"write_read error");
142
  end
143
endtask:write_read
144
 
145
task fifo_full;
146
  begin
147
    dr_cb.resetn <= 1;
148
    dr_cb.write_enb <= 1;
149
    dr_cb.read_enb <= 0;
150
    dr_cb.data_in <= $random;
151
 
152
    repeat(16)
153
    @(dr_cb);
154
    //repeat(16)
155
    @(rcv_cb);
156
 
157
 
158
    if(rcv_cb.full == 1)
159
      $display($time,"fifo_full works");
160
    else
161
      $display($time,"fifo_full error");
162
  end
163
endtask
164
 
165
task fifo_empty;
166
  begin
167
    dr_cb.resetn <= 1;
168
    dr_cb.write_enb <= 0;
169
    dr_cb.read_enb <= 1;
170
    repeat(2)
171
    @(dr_cb);
172
    if(rcv_cb.empty == 1)
173
      $display($time,"fifo_empty works");
174
    else
175
      $display($time,"fifo_empty error");
176
  end
177
endtask
178
 
179
 
180
endinterface:fifo_if

powered by: WebSVN 2.1.0

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