Skip to content

Commit 23a39f0

Browse files
committed
update spram template
1 parent 96c2918 commit 23a39f0

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

lambdalib/utils/__init__.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
11
from jinja2 import Template
22
import os
3-
import math
43
from collections import OrderedDict
54

65

7-
def write_la_spram(fout, memories, control_signals=None, la_type='ram', minbits=None):
6+
def write_la_ram(fout,
7+
memories,
8+
control_signals=None,
9+
la_type='la_spram',
10+
minsize=None):
811
template_path = os.path.abspath(os.path.join(os.path.dirname(__file__),
912
'templates',
10-
'la_spmemory.v'))
13+
f'{la_type}memory.v'))
1114

1215
widths_table = []
1316
depths_table = []
1417
memory_port_map = {}
1518
selection_table = {}
1619
memory_inst_map = {}
1720

21+
if minsize is None:
22+
minsize = 0
23+
1824
for memory, info in memories.items():
1925
widths_table.append(
2026
(memory, info['DW'])
@@ -35,12 +41,6 @@ def write_la_spram(fout, memories, control_signals=None, la_type='ram', minbits=
3541
for aw, items in selection_table.items():
3642
selection_table[aw] = OrderedDict(sorted(items.items(), reverse=True))
3743

38-
if minbits is not None:
39-
depth = 2**aw
40-
dw = int(math.floor(minbits / depth))
41-
if dw > 0:
42-
selection_table[aw][dw] = "SOFT"
43-
selection_table[min(selection_table.keys()) - 1] = {0: "SOFT"}
4444
widths_table.sort()
4545
depths_table.sort()
4646

@@ -54,4 +54,5 @@ def write_la_spram(fout, memories, control_signals=None, la_type='ram', minbits=
5454
selection_table=selection_table,
5555
inst_map=memory_inst_map,
5656
port_mapping=memory_port_map,
57-
control_signals=control_signals))
57+
control_signals=control_signals,
58+
minsize=minsize))

lambdalib/utils/templates/la_spmemory.v renamed to lambdalib/utils/templates/la_sprammemory.v

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*****************************************************************************
2-
* Function: Single Port {{ type }}
2+
* Function: Single Port Memory ({{ type }})
33
* Copyright: Lambda Project Authors. All rights Reserved.
44
* License: MIT (see LICENSE file in Lambda repository)
55
*
@@ -13,14 +13,14 @@
1313
* Advanced ASIC development should rely on complete functional models
1414
* supplied on a per macro basis.
1515
*
16-
* Technologoy specific implementations of "la_sp{{ type }}" would generally include
16+
* Technologoy specific implementations of "{{ type }}" would generally include
1717
* one or more hardcoded instantiations of {{ type }} modules with a generate
1818
* statement relying on the "PROP" to select between the list of modules
1919
* at build time.
2020
*
2121
****************************************************************************/
2222

23-
module la_sp{{ type }}
23+
module {{ type }}
2424
#(parameter DW = 32, // Memory width
2525
parameter AW = 10, // Address width (derived)
2626
parameter PROP = "DEFAULT", // Pass through variable for hard macro
@@ -44,8 +44,11 @@ module la_sp{{ type }}
4444
input [TESTW-1:0] test // pass through ASIC test interface
4545
);
4646

47+
// Total number of bits
48+
localparam TOTAL_BITS = (2 ** AW) * DW;
49+
4750
// Determine which memory to select
48-
localparam MEM_PROP = (PROP != "DEFAULT") ? PROP :{% for aw, dw_select in selection_table.items() %}
51+
localparam MEM_PROP = (PROP != "DEFAULT") ? PROP :{% if minsize > 0 %} ({{ minsize }} >= TOTAL_BITS) ? "SOFT" :{% endif %}{% for aw, dw_select in selection_table.items() %}
4952
{% if loop.nextitem is defined %}(AW >= {{ aw }}) ? {% endif %}{% for dw, memory in dw_select.items() %}{% if loop.nextitem is defined %}(DW >= {{dw}}) ? {% endif %}"{{ memory}}"{% if loop.nextitem is defined %} : {% endif%}{% endfor %}{% if loop.nextitem is defined %} :{% else %};{% endif %}{% endfor %}
5053

5154
localparam MEM_WIDTH = {% for memory, width in width_table %}

0 commit comments

Comments
 (0)