mirror of https://github.com/VLSIDA/OpenRAM.git
Fixed write_size checks for characterizer
This commit is contained in:
parent
a361d9f7bb
commit
8f955207d3
|
|
@ -24,7 +24,7 @@ class cacti(simulation):
|
||||||
# self.targ_read_ports = []
|
# self.targ_read_ports = []
|
||||||
# self.targ_write_ports = []
|
# self.targ_write_ports = []
|
||||||
# self.period = 0
|
# self.period = 0
|
||||||
# if self.write_size:
|
# if self.write_size != self.word_size:
|
||||||
# self.num_wmasks = int(math.ceil(self.word_size / self.write_size))
|
# self.num_wmasks = int(math.ceil(self.word_size / self.write_size))
|
||||||
# else:
|
# else:
|
||||||
# self.num_wmasks = 0
|
# self.num_wmasks = 0
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ class delay(simulation):
|
||||||
self.targ_read_ports = []
|
self.targ_read_ports = []
|
||||||
self.targ_write_ports = []
|
self.targ_write_ports = []
|
||||||
self.period = 0
|
self.period = 0
|
||||||
if self.write_size:
|
if self.write_size != self.word_size:
|
||||||
self.num_wmasks = int(math.ceil(self.word_size / self.write_size))
|
self.num_wmasks = int(math.ceil(self.word_size / self.write_size))
|
||||||
else:
|
else:
|
||||||
self.num_wmasks = 0
|
self.num_wmasks = 0
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ class elmore(simulation):
|
||||||
# self.targ_read_ports = []
|
# self.targ_read_ports = []
|
||||||
# self.targ_write_ports = []
|
# self.targ_write_ports = []
|
||||||
# self.period = 0
|
# self.period = 0
|
||||||
# if self.write_size:
|
# if self.write_size != self.word_size:
|
||||||
# self.num_wmasks = int(math.ceil(self.word_size / self.write_size))
|
# self.num_wmasks = int(math.ceil(self.word_size / self.write_size))
|
||||||
# else:
|
# else:
|
||||||
# self.num_wmasks = 0
|
# self.num_wmasks = 0
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ class functional(simulation):
|
||||||
else:
|
else:
|
||||||
self.output_path = output_path
|
self.output_path = output_path
|
||||||
|
|
||||||
if self.write_size:
|
if self.write_size != self.word_size:
|
||||||
self.num_wmasks = int(math.ceil(self.word_size / self.write_size))
|
self.num_wmasks = int(math.ceil(self.word_size / self.write_size))
|
||||||
else:
|
else:
|
||||||
self.num_wmasks = 0
|
self.num_wmasks = 0
|
||||||
|
|
@ -133,7 +133,7 @@ class functional(simulation):
|
||||||
|
|
||||||
def create_random_memory_sequence(self):
|
def create_random_memory_sequence(self):
|
||||||
# Select randomly, but have 3x more reads to increase probability
|
# Select randomly, but have 3x more reads to increase probability
|
||||||
if self.write_size:
|
if self.write_size != self.word_size:
|
||||||
rw_ops = ["noop", "write", "partial_write", "read", "read"]
|
rw_ops = ["noop", "write", "partial_write", "read", "read"]
|
||||||
w_ops = ["noop", "write", "partial_write"]
|
w_ops = ["noop", "write", "partial_write"]
|
||||||
else:
|
else:
|
||||||
|
|
@ -440,7 +440,7 @@ class functional(simulation):
|
||||||
|
|
||||||
# Generate wmask bits
|
# Generate wmask bits
|
||||||
for port in self.write_ports:
|
for port in self.write_ports:
|
||||||
if self.write_size:
|
if self.write_size != self.word_size:
|
||||||
self.sf.write("\n* Generation of wmask signals\n")
|
self.sf.write("\n* Generation of wmask signals\n")
|
||||||
for bit in range(self.num_wmasks):
|
for bit in range(self.num_wmasks):
|
||||||
sig_name = "WMASK{0}_{1} ".format(port, bit)
|
sig_name = "WMASK{0}_{1} ".format(port, bit)
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ class simulation():
|
||||||
self.words_per_row = self.sram.words_per_row
|
self.words_per_row = self.sram.words_per_row
|
||||||
self.num_rows = self.sram.num_rows
|
self.num_rows = self.sram.num_rows
|
||||||
self.num_cols = self.sram.num_cols
|
self.num_cols = self.sram.num_cols
|
||||||
if self.write_size:
|
if self.write_size != self.word_size:
|
||||||
self.num_wmasks = int(math.ceil(self.word_size / self.write_size))
|
self.num_wmasks = int(math.ceil(self.word_size / self.write_size))
|
||||||
else:
|
else:
|
||||||
self.num_wmasks = 0
|
self.num_wmasks = 0
|
||||||
|
|
@ -464,7 +464,7 @@ class simulation():
|
||||||
for port in range(total_ports):
|
for port in range(total_ports):
|
||||||
pin_names.append("{0}{1}".format("clk", port))
|
pin_names.append("{0}{1}".format("clk", port))
|
||||||
|
|
||||||
if self.write_size:
|
if self.write_size != self.word_size:
|
||||||
for port in write_index:
|
for port in write_index:
|
||||||
for bit in range(self.num_wmasks):
|
for bit in range(self.num_wmasks):
|
||||||
pin_names.append("WMASK{0}_{1}".format(port, bit))
|
pin_names.append("WMASK{0}_{1}".format(port, bit))
|
||||||
|
|
|
||||||
|
|
@ -1,120 +0,0 @@
|
||||||
# See LICENSE for licensing information.
|
|
||||||
#
|
|
||||||
# Copyright (c) 2016-2021 Regents of the University of California
|
|
||||||
# Santa Cruz
|
|
||||||
# All rights reserved.
|
|
||||||
#
|
|
||||||
import re
|
|
||||||
|
|
||||||
|
|
||||||
class baseSection:
|
|
||||||
"""
|
|
||||||
This is the base section class for other section classes to inherit.
|
|
||||||
It is also used as the top most section.
|
|
||||||
"""
|
|
||||||
def __init__(self):
|
|
||||||
self.children = []
|
|
||||||
|
|
||||||
def expand(self, dict, fd):
|
|
||||||
for c in self.children:
|
|
||||||
c.expand(dict, fd)
|
|
||||||
|
|
||||||
|
|
||||||
class loopSection(baseSection):
|
|
||||||
"""
|
|
||||||
This section is for looping elements. It will repeat the children
|
|
||||||
sections based on the key list.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, var, key):
|
|
||||||
baseSection.__init__(self)
|
|
||||||
self.var = var
|
|
||||||
self.key = key
|
|
||||||
|
|
||||||
def expand(self, dict, fd):
|
|
||||||
for ind in dict[self.key]:
|
|
||||||
dict[self.var] = ind
|
|
||||||
for c in self.children:
|
|
||||||
c.expand(dict, fd)
|
|
||||||
if self.var in dict:
|
|
||||||
del dict[self.var]
|
|
||||||
|
|
||||||
|
|
||||||
class conditionalSection(baseSection):
|
|
||||||
"""
|
|
||||||
This class will conditionally print it's children based on the 'cond'
|
|
||||||
element.
|
|
||||||
"""
|
|
||||||
def __init__(self, cond):
|
|
||||||
baseSection.__init__(self)
|
|
||||||
self.cond = cond
|
|
||||||
|
|
||||||
def expand(self, dict, fd):
|
|
||||||
run = eval(self.cond, dict)
|
|
||||||
if run:
|
|
||||||
for c in self.children:
|
|
||||||
c.expand(dict, fd)
|
|
||||||
|
|
||||||
|
|
||||||
class textSection(baseSection):
|
|
||||||
"""
|
|
||||||
This is plain text section. It can contain parameters that can be
|
|
||||||
replaced based on the dictionary.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, text):
|
|
||||||
self.text = text
|
|
||||||
|
|
||||||
def expand(self, dict, fd):
|
|
||||||
varRE = re.compile('\{\{ (\S*) \}\}')
|
|
||||||
vars = varRE.finditer(self.text)
|
|
||||||
newText = self.text
|
|
||||||
for var in vars:
|
|
||||||
newText = newText.replace('{{ ' + var.group(1) + ' }}', str(dict[var.group(1)]))
|
|
||||||
print(newText, end='', file=fd)
|
|
||||||
|
|
||||||
|
|
||||||
class template:
|
|
||||||
"""
|
|
||||||
The template class will read a template and generate an output file
|
|
||||||
based on the template and the given dictionary.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, template, dict):
|
|
||||||
self.template = template
|
|
||||||
self.dict = dict
|
|
||||||
|
|
||||||
def readTemplate(self):
|
|
||||||
lines = []
|
|
||||||
with open(self.template, 'r') as f:
|
|
||||||
lines = f.readlines()
|
|
||||||
|
|
||||||
self.baseSectionSection = baseSection()
|
|
||||||
context = [self.baseSectionSection]
|
|
||||||
forRE = re.compile('\s*\{% for (\S*) in (\S*) %\}')
|
|
||||||
endforRE = re.compile('\s*\{% endfor %\}')
|
|
||||||
ifRE = re.compile('\s*{% if (.*) %\}')
|
|
||||||
endifRE = re.compile('\s*\{% endif %\}')
|
|
||||||
for line in lines:
|
|
||||||
m = forRE.match(line)
|
|
||||||
if m:
|
|
||||||
section = loopSection(m.group(1), m.group(2))
|
|
||||||
context[-1].children.append(section)
|
|
||||||
context.append(section)
|
|
||||||
continue
|
|
||||||
m = ifRE.match(line)
|
|
||||||
if m:
|
|
||||||
section = conditionalSection(m.group(1))
|
|
||||||
context[-1].children.append(section)
|
|
||||||
context.append(section)
|
|
||||||
continue
|
|
||||||
if endforRE.match(line) or endifRE.match(line):
|
|
||||||
context.pop()
|
|
||||||
else:
|
|
||||||
context[-1].children.append(textSection(line))
|
|
||||||
|
|
||||||
def write(self, filename):
|
|
||||||
fd = open(filename, 'w')
|
|
||||||
self.readTemplate()
|
|
||||||
self.baseSectionSection.expand(self.dict, fd)
|
|
||||||
fd.close()
|
|
||||||
Loading…
Reference in New Issue