Skip to content
Snippets Groups Projects
Commit 6f2697be authored by Eric Kooistra's avatar Eric Kooistra
Browse files

Import common.py as cm. This also means that in the peripheral YAML files...

Import common.py as cm. This also means that in the peripheral YAML files cm.c_nof_complex and cm.celi_log2() habe to be used.
parent cf17d377
No related branches found
No related tags found
No related merge requests found
############################################################################### ###############################################################################
# #
# Copyright (C) 2012 # Copyright (C) 2016
# ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/> # ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands # P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
# #
...@@ -17,14 +17,19 @@ ...@@ -17,14 +17,19 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
# Author Date
# HJ jan 2017 Original
# EK feb 2017
#
############################################################################### ###############################################################################
############################################################################### ###############################################################################
import os
import copy import copy
import yaml import yaml
from common import * import common as cm
field_modes = ["RO", "WO", "RW", "WP", "RR"] field_modes = ["RO", "WO", "RW", "WP", "RR"]
...@@ -47,14 +52,14 @@ class Register: ...@@ -47,14 +52,14 @@ class Register:
self.name = name self.name = name
self.fields = fields self.fields = fields
self.nof_inst = nof_inst self.nof_inst = nof_inst
self.depth = self.nof_inst*2**ceil_log2(len(fields)) self.depth = self.nof_inst * cm.ceil_pow2(len(fields))
def addField(self, name, width, mode, offset, default, descr): def addField(self, name, width, mode, offset, default, descr):
self.fields.append(Field(name, width, mode, offset, default, descr)) self.fields.append(Field(name, width, mode, offset, default, descr))
self.depth = self.nof_inst*2**ceil_log2(len(fields)) self.depth = self.nof_inst * cm.ceil_pow2(len(fields))
def setDepth(self): def setDepth(self):
self.depth = self.nof_inst*2**ceil_log2(len(self.fields)) self.depth = self.nof_inst * cm.ceil_pow2(len(self.fields))
def setNof_inst(self, nof_inst): def setNof_inst(self, nof_inst):
self.nof_inst = nof_inst self.nof_inst = nof_inst
...@@ -119,9 +124,12 @@ class Peripheral: ...@@ -119,9 +124,12 @@ class Peripheral:
exec("%s = %d" % (parameter, self.parameters[parameter])) # Here the parameters of the peripheral are promoted to real python variables exec("%s = %d" % (parameter, self.parameters[parameter])) # Here the parameters of the peripheral are promoted to real python variables
for ram in self.rams: for ram in self.rams:
ram.name = ram.name + self.postfix ram.name = ram.name + self.postfix
ram.depth = self.nof_inst * 2 ** ceil_log2(eval(str(ram.depth))) # Here the variables are used to evaluate the true value for the depth parameter(taking int account the nof_inst as well) print ram.depth
ram.depth = self.nof_inst * cm.ceil_pow2(eval(str(ram.depth))) # Here the variables are used to evaluate the true value for the depth parameter(taking int account the nof_inst as well)
print ram.depth
print ram.width print ram.width
ram.width = eval(str(ram.width)) # Here the variables are used to evaluate the true value for the width parameter. ram.width = eval(str(ram.width)) # Here the variables are used to evaluate the true value for the width parameter.
print ram.width
print " " + ram.name + " " + "depth: " + str(ram.depth) print " " + ram.name + " " + "depth: " + str(ram.depth)
print " " + ram.name + " " + "width: " + str(ram.width) print " " + ram.name + " " + "width: " + str(ram.width)
...@@ -163,7 +171,7 @@ class PeripheralLibrary: ...@@ -163,7 +171,7 @@ class PeripheralLibrary:
"""Store the dictionaries from all fileName files in rootDir.""" """Store the dictionaries from all fileName files in rootDir."""
self.rootDir = rootDir self.rootDir = rootDir
self.fileName = fileName # all peripheral files have the same fileName self.fileName = fileName # all peripheral files have the same fileName
self.filePaths = find_all_file_paths(rootDir, fileName) # list of all directory paths of peripheral files that are available in the rootDir tree self.filePaths = cm.find_all_file_paths(rootDir, fileName) # list of all directory paths of peripheral files that are available in the rootDir tree
if len(self.filePaths)==0: if len(self.filePaths)==0:
sys.exit('Error : No %s file found in %s directory tree.' % (fileName, rootDir)) sys.exit('Error : No %s file found in %s directory tree.' % (fileName, rootDir))
self.filePathNames = [] # list of all directory paths + fileName of the available peripheral files self.filePathNames = [] # list of all directory paths + fileName of the available peripheral files
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment