1 // ==================================================================
2 // >>>>>>>>>>>>>>>>>>>>>>> COPYRIGHT NOTICE <<<<<<<<<<<<<<<<<<<<<<<<<
3 // ------------------------------------------------------------------
4 // Copyright (c) 2006-2011 by Lattice Semiconductor Corporation
6 // ------------------------------------------------------------------
8 // IMPORTANT: THIS FILE IS AUTO-GENERATED BY THE LATTICEMICO SYSTEM.
12 // Lattice Semiconductor grants permission to use this code
13 // pursuant to the terms of the Lattice Semiconductor Corporation
14 // Open Source License Agreement.
18 // Lattice Semiconductor provides no warranty regarding the use or
19 // functionality of this code. It is the user's responsibility to
20 // verify the user's design for consistency and functionality through
21 // the use of formal verification methods.
23 // --------------------------------------------------------------------
25 // Lattice Semiconductor Corporation
26 // 5555 NE Moore Court
27 // Hillsboro, OR 97214
30 // TEL: 1-800-Lattice (USA and Canada)
31 // 503-286-8001 (other locations)
33 // web: http://www.latticesemi.com/
34 // email: techsupport@latticesemi.com
36 // --------------------------------------------------------------------
38 // Project : LatticeMico32
40 // Title : Pseudo dual-port RAM.
43 // Version : 7.0SP2, 3.0
46 // : Options added to select EBRs (True-DP, Psuedo-DP, DQ, or
47 // : Distributed RAM).
49 // : EBRs use SYNC resets instead of ASYNC resets.
51 // : Added read-after-write hazard resolution when using true
53 // =============================================================================
55 `include "lm32_include.v"
57 /////////////////////////////////////////////////////
59 /////////////////////////////////////////////////////
63 // ----- Inputs -------
73 // ----- Outputs -------
77 /*----------------------------------------------------------------------
79 ----------------------------------------------------------------------*/
80 parameter data_width = 1; // Width of the data ports
81 parameter address_width = 1; // Width of the address ports
83 /*----------------------------------------------------------------------
85 ----------------------------------------------------------------------*/
86 input read_clk; // Read clock
87 input write_clk; // Write clock
90 input enable_read; // Access enable
91 input [address_width-1:0] read_address; // Read/write address
92 input enable_write; // Access enable
93 input [address_width-1:0] write_address;// Read/write address
94 input [data_width-1:0] write_data; // Data to write to specified address
95 input write_enable; // Write enable
97 /*----------------------------------------------------------------------
99 ----------------------------------------------------------------------*/
100 output [data_width-1:0] read_data; // Data read from specified addess
101 wire [data_width-1:0] read_data;
103 /*----------------------------------------------------------------------
104 Internal nets and registers
105 ----------------------------------------------------------------------*/
106 reg [data_width-1:0] mem[0:(1<<address_width)-1]; // The RAM
107 reg [address_width-1:0] ra; // Registered read address
109 /*----------------------------------------------------------------------
111 ----------------------------------------------------------------------*/
113 assign read_data = mem[ra];
115 /*----------------------------------------------------------------------
117 ----------------------------------------------------------------------*/
119 always @(posedge write_clk)
120 if ((write_enable == `TRUE) && (enable_write == `TRUE))
121 mem[write_address] <= write_data;
123 // Register read address for use on next cycle
124 always @(posedge read_clk)