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

Subversion Repositories cryptosorter

[/] [cryptosorter/] [trunk/] [memocodeDesignContest2008/] [sort/] [BRAM_v/] [UGBRAM.v] - 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
// unguarded bram
28
// When synthesized, one basic BRAM instance  = 4096 bits, 
29
// the maximum width = 16, depth = 256
30
module UGBRAM (CLK,
31
               RST_N,
32
               READ_A_ADDR_EN,
33
               READ_A_ADDR,
34
               READ_A_DATA,
35
               READ_A_DATA_RDY,
36
               WRITE_B_EN,
37
               WRITE_B_ADDR,
38
               WRITE_B_DATA
39
               );
40
   parameter addr_width = 1;
41
   parameter  data_width = 1;
42
   parameter  lo = 0;
43
   parameter  hi = 1;
44
 
45
   input                    CLK;
46
   input                    RST_N;
47
 
48
   // read port
49
   // req, always ready
50
   input                    READ_A_ADDR_EN;
51
   input [addr_width-1:0]   READ_A_ADDR;
52
 
53
   // resp
54
   output [data_width-1:0]  READ_A_DATA;
55
   output                   READ_A_DATA_RDY;
56
 
57
   // write port, always ready
58
   input                    WRITE_B_EN;
59
   input [addr_width-1:0]   WRITE_B_ADDR;
60
   input [data_width-1:0]   WRITE_B_DATA;
61
 
62
   reg [addr_width-1:0]     READ_ADDR; // read addr need to be registered for block ram to be inferred
63
   reg                      READ_A_DATA_RDY;
64
 
65
   reg [data_width-1:0]     RAM [hi:lo]; /*synthesis syn_ramstyle = "block_ram"*/
66
 
67
   assign READ_A_DATA = RAM[READ_ADDR];
68
 
69
   always@(posedge CLK)
70
      begin
71
         if (!RST_N)
72
           READ_A_DATA_RDY <= 0;
73
         else
74
           begin
75
              if(WRITE_B_EN)
76
                RAM[WRITE_B_ADDR] <= WRITE_B_DATA;
77
 
78
              READ_ADDR <= READ_A_ADDR;
79
              READ_A_DATA_RDY <= (READ_A_ADDR_EN) ? 1 : 0;
80
           end
81
      end // always@ (posedge CLK)
82
 
83
endmodule

powered by: WebSVN 2.1.0

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