~ubuntu-branches/ubuntu/trusty/gnuradio/trusty-updates

« back to all changes in this revision

Viewing changes to gr-radar-mono/src/fpga/models/fifo_1clk.v

  • Committer: Package Import Robot
  • Author(s): A. Maitland Bottoms
  • Date: 2012-02-26 21:26:16 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20120226212616-vsfkbi1158xshdql
Tags: 3.5.1-1
* new upstream version, re-packaged from scratch with modern tools
    closes: #642716, #645332, #394849, #616832, #590048, #642580,
    #647018, #557050, #559640, #631863
* CMake build

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- verilog -*- */
2
 
/*
3
 
 * Copyright (C) 2003 Matt Ettus
4
 
 * Copyright (C) 2007 Corgan Enterprises LLC
5
 
 * 
6
 
 * GNU Radio is free software; you can redistribute it and/or modify
7
 
 * it under the terms of the GNU General Public License as published by
8
 
 * the Free Software Foundation; either version 3, or (at your option)
9
 
 * any later version.
10
 
 * 
11
 
 * GNU Radio is distributed in the hope that it will be useful,
12
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
 * GNU General Public License for more details.
15
 
 * 
16
 
 * You should have received a copy of the GNU General Public License
17
 
 * along with GNU Radio; see the file COPYING.  If not, write to
18
 
 * the Free Software Foundation, Inc., 51 Franklin Street,
19
 
 * Boston, MA 02110-1301, USA.
20
 
 */
21
 
 
22
 
// Model of Altera FIFO with common clock domain
23
 
 
24
 
module fifo_1clk(data, wrreq, rdreq, clock, sclr, q,
25
 
                 full, empty, usedw);
26
 
 
27
 
   parameter width = 32;
28
 
   parameter depth = 4096;
29
 
   //`define rd_req 0;  // Set this to 0 for rd_ack, 1 for rd_req
30
 
      
31
 
   input [31:0]  data;
32
 
   input         wrreq;
33
 
   input         rdreq;
34
 
   input         clock;
35
 
   input         sclr;
36
 
   output [31:0] q;
37
 
   output        full;
38
 
   output        empty;
39
 
   output [11:0] usedw;
40
 
   
41
 
   reg [width-1:0] mem [0:depth-1];
42
 
   reg [7:0]       rdptr;
43
 
   reg [7:0]       wrptr;
44
 
   
45
 
`ifdef rd_req
46
 
   reg [width-1:0] q;
47
 
`else
48
 
   wire [width-1:0] q;
49
 
`endif
50
 
   
51
 
   reg [11:0]     usedw;
52
 
   
53
 
   integer          i;
54
 
   
55
 
   always @( sclr)
56
 
     begin
57
 
        wrptr <= #1 0;
58
 
        rdptr <= #1 0;
59
 
        for(i=0;i<depth;i=i+1)
60
 
          mem[i] <= #1 0;
61
 
     end
62
 
   
63
 
   always @(posedge clock)
64
 
     if(wrreq)
65
 
       begin
66
 
          wrptr <= #1 wrptr+1;
67
 
          mem[wrptr] <= #1 data;
68
 
       end
69
 
   
70
 
   always @(posedge clock)
71
 
     if(rdreq)
72
 
       begin
73
 
          rdptr <= #1 rdptr+1;
74
 
`ifdef rd_req
75
 
          q <= #1 mem[rdptr];
76
 
`endif
77
 
       end
78
 
   
79
 
`ifdef rd_req
80
 
`else
81
 
   assign q = mem[rdptr];
82
 
`endif
83
 
   
84
 
   always @(posedge clock)
85
 
     usedw <= #1 wrptr - rdptr;
86
 
   
87
 
   assign empty = (wrptr == rdptr);
88
 
endmodule