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

Subversion Repositories cryptosorter

[/] [cryptosorter/] [trunk/] [memocodeDesignContest2008/] [sort/] [BRAM_v/] [BRAMFIFO.bsv] - Blame information for rev 6

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 kfleming
//----------------------------------------------------------------------//
2
// The MIT License
3
//
4
// Copyright (c) 2008 Alfred Man Cheuk Ng, mcn02@mit.edu
5
//
6
// Permission is hereby granted, free of charge, to any person
7
// obtaining a copy of this software and associated documentation
8
// files (the "Software"), to deal in the Software without
9
// restriction, including without limitation the rights to use,
10
// copy, modify, merge, publish, distribute, sublicense, and/or sell
11
// copies of the Software, and to permit persons to whom the
12
// Software is furnished to do so, subject to the following conditions:
13
//
14
// The above copyright notice and this permission notice shall be
15
// included in all copies or substantial portions of the Software.
16
//
17
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24
// OTHER DEALINGS IN THE SOFTWARE.
25
//----------------------------------------------------------------------//
26
 
27
import FIFO::*;
28
import FIFOF::*;
29
import FIFOF_::*;
30
 
31
/***
32
 *
33
 * This module serves as a simple bluespec wrapper for
34
 * the verilog based BRAMFIFO.  The imported methods support
35
 * the standard FIFOF and FIFO classes.  It should be noted that
36
 * the underlying verilog implementation is gaurded.
37
 *
38
 ***/
39
 
40
 
41
module mkBRAMFIFO#(Integer count) (FIFO#(fifo_type))
42
  provisos
43
          (Bits#(fifo_type, fifo_size));
44
  FIFOF#(fifo_type) fifo <- mkBRAMFIFOF(count);
45
 
46
  method Action enq(fifo_type data);
47
    fifo.enq(data);
48
  endmethod
49
 
50
  method Action deq();
51
    fifo.deq();
52
  endmethod
53
 
54
  method fifo_type first();
55
    return fifo.first();
56
  endmethod
57
 
58
  method Action clear();
59
    fifo.clear();
60
  endmethod
61
 
62
endmodule
63
 
64
module mkBRAMFIFOF#(Integer count) (FIFOF#(fifo_type))
65
  provisos
66
          (Bits#(fifo_type, fifo_size));
67
  FIFOF_#(fifo_type) fifo <- mkBRAMFIFOF_(count);
68
 
69
  method Action enq(fifo_type data) if(fifo.i_notFull);
70
    fifo.enq(data);
71
  endmethod
72
 
73
  method Action deq() if(fifo.i_notEmpty);
74
    fifo.deq();
75
  endmethod
76
 
77
  method fifo_type first() if(fifo.i_notEmpty);
78
    return fifo.first();
79
  endmethod
80
 
81
  method Bool notFull;
82
    return fifo.notFull;
83
  endmethod
84
 
85
  method Bool notEmpty;
86
    return fifo.notEmpty;
87
  endmethod
88
 
89
  method Action clear();
90
    fifo.clear();
91
  endmethod
92
 
93
 
94
endmodule
95
 
96
 
97
import "BVI" BRAMFIFOF = module mkBRAMFIFOF_#(Integer count)
98
  //interface:
99
              (FIFOF_#(fifo_type))
100
  provisos
101
          (Bits#(fifo_type, fifo_size));
102
 
103
  default_clock clk(CLK);
104
 
105
  parameter                   log_data_count = log2(count);
106
  parameter                   data_count = count;
107
  parameter                   data_width = valueOf(fifo_size);
108
 
109
  method enq((* reg *)D_IN) enable(ENQ);
110
  method deq() enable(DEQ);
111
  method (* reg *)D_OUT first;
112
  method FULL_N   notFull;
113
  method FULL_N i_notFull;
114
  method (* reg *)EMPTY_N   notEmpty;
115
  method (* reg *)EMPTY_N i_notEmpty;
116
  method clear() enable(CLR);
117
 
118
  schedule deq CF (enq, i_notEmpty, i_notFull) ;
119
  schedule enq CF (deq, first, i_notEmpty, i_notFull) ;
120
  schedule (first, notEmpty, notFull) CF
121
             (first, i_notEmpty, i_notFull, notEmpty, notFull) ;
122
  schedule (i_notEmpty, i_notFull) CF
123
              (clear, first, i_notEmpty, i_notFull, notEmpty, notFull) ;
124
  schedule (clear, deq, enq) SBR clear ;
125
  schedule first SB (clear, deq) ;
126
  schedule (notEmpty, notFull) SB (clear, deq, enq) ;
127
 
128
 
129
  /*schedule first SB (deq,enq,clear);
130
  schedule first CF (first,notFull,notEmpty);
131
 
132
  schedule notFull SB (deq,enq,clear);
133
  schedule notFull CF (first,notFull,notEmpty);
134
 
135
  schedule notEmpty SB (deq,enq,clear);
136
  schedule notEmpty CF (first,notFull,notEmpty);
137
 
138
  schedule deq CF enq;
139
  schedule deq SB clear;
140
  schedule deq C  deq;
141
 
142
  schedule enq CF deq;
143
  schedule enq SB clear;
144
  schedule enq C  enq;
145
 
146
  schedule clear C clear;*/
147
 
148
endmodule
149
 
150
 

powered by: WebSVN 2.1.0

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