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

Subversion Repositories cryptosorter

[/] [cryptosorter/] [trunk/] [lib/] [bsv/] [BRAMFeeder/] [src/] [BRAMInitiator.v] - Blame information for rev 6

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 kfleming
/*
2
Copyright (c) 2007 MIT
3
 
4
Permission is hereby granted, free of charge, to any person
5
obtaining a copy of this software and associated documentation
6
files (the "Software"), to deal in the Software without
7
restriction, including without limitation the rights to use,
8
copy, modify, merge, publish, distribute, sublicense, and/or sell
9
copies of the Software, and to permit persons to whom the
10
Software is furnished to do so, subject to the following
11
conditions:
12
 
13
The above copyright notice and this permission notice shall be
14
included in all copies or substantial portions of the Software.
15
 
16
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23
OTHER DEALINGS IN THE SOFTWARE.
24
 
25
Author: Kermin Fleming
26
*/
27
 
28
module BRAMInitiator(CLK, RST_N,
29
            RD_ADDR, RD_RDY,   RD_EN,
30
            DOUT,    DOUT_RDY, DOUT_EN,
31
            WR_ADDR, WR_VAL,   WR_EN,
32
            BRAM_Addr, BRAM_Dout, BRAM_Din,BRAM_Dummy_Enable,
33
            BRAM_WEN, BRAM_EN, BRAM_RST,
34
            BRAM_CLK);
35
 
36
   // synopsys template   
37
   parameter                   addr_width = 1;
38
 
39
   input                       CLK;
40
   input                       RST_N;
41
 
42
   // Read Port
43
   // req
44
   input [addr_width -1 : 0]   RD_ADDR;
45
   input                       RD_EN;
46
   output                      RD_RDY;
47
   // resp
48
   output [31 : 0]             DOUT;
49
   output                      DOUT_RDY;
50
   input                       DOUT_EN;
51
 
52
   // Write Port
53
   // req
54
   input [addr_width - 1 : 0]  WR_ADDR;
55
   input [31 : 0]              WR_VAL;
56
   input                       WR_EN;
57
 
58
   // BRAM Wires
59
   output [addr_width - 1 : 0] BRAM_Addr;
60
   output [31 : 0]             BRAM_Dout;
61
   input  [31 : 0]             BRAM_Din;
62
   input                       BRAM_Dummy_Enable;
63
   output [3  : 0]             BRAM_WEN;
64
   output                      BRAM_EN;
65
   output                      BRAM_RST;
66
   output                      BRAM_CLK;
67
 
68
 
69
   // Assignments
70
   assign BRAM_CLK = CLK;
71
   assign BRAM_EN = RST_N; // disable the BRAM if we are in reset  
72
   assign BRAM_RST = 1'b0; // Never reset the BRAM.
73
   assign BRAM_Addr = (WR_EN)?(WR_ADDR):(RD_ADDR);
74
   assign BRAM_WEN  = {WR_EN,WR_EN,WR_EN,WR_EN};
75
   assign BRAM_Dout = WR_VAL;
76
 
77
   reg                         RD_REQ_MADE;
78
 
79
   reg  [1:0] CTR;
80
 
81
   /*always@(BRAM_Din)
82
     $display("BRAMInitiator.v BRAM_Din: %x",BRAM_Din);
83
   */
84
 
85
   FIFO2#(.width(32)) q(.RST_N(RST_N),
86
                        .CLK(CLK),
87
                        .D_IN(BRAM_Din),
88
                        .ENQ(RD_REQ_MADE),
89
                        .DEQ(DOUT_EN),
90
                        .CLR(1'b0),
91
                        .D_OUT(DOUT),
92
                        .FULL_N(),
93
                        .EMPTY_N(DOUT_RDY));
94
 
95
   assign RD_RDY = (CTR > 0);
96
 
97
   always@(posedge CLK)
98
     begin
99
       if (!RST_N)
100
         begin
101
           CTR <= 2;
102
         end
103
       else
104
         begin
105
           /*if(RD_EN)
106
             $display("BRAMInitiator: RD_EN");
107
           if(WR_EN)
108
             $display("BRAMInitiator: WR_EN");
109
           */
110
 
111
           RD_REQ_MADE <= RD_EN;
112
 
113
           CTR <= (RD_EN) ?
114
                    (DOUT_EN) ? CTR : CTR - 1 :
115
                    (DOUT_EN) ? CTR + 1 : CTR;
116
         end
117
     end // always@ (posedge CLK)
118
 
119
endmodule

powered by: WebSVN 2.1.0

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