Improved rolled VHDL code generation. This is only active when using

GHDL as simulator. It's based on VHDL generators.

Using Icarus Verilog for VHDL synthesis is still in an early stage, and
the tool is not able to handle arrays. Thus, the generated VHDL code is
always completely unrolled
parent 5fd91c12
......@@ -163,6 +163,11 @@ class Filter():
btype = btype,
ftype = ftype)
elif filterMethod == 'Manual':
# TODO: Validator needed
b = np.fromstring(str(self.textManualCoeffB.toPlainText()), sep=',')
a = np.fromstring(str(self.textManualCoeffA.toPlainText()), sep=',')
else :
......@@ -182,6 +187,8 @@ class Filter():
if filterMethod == 'FIR 1':
flagManualCoeffA = False
flagManualCoeffB = False
flagFIRWindow = True
flagNumtaps = True
flagCutoff = True
......@@ -216,6 +223,8 @@ class Filter():
self.cbPassZero.setEnabled(True)
elif filterMethod == 'FIR 2':
flagManualCoeffA = False
flagManualCoeffB = False
flagFIRWindow = True
flagNumtaps = True
flagCutoff = False
......@@ -238,6 +247,8 @@ class Filter():
flagBType = False
elif filterMethod == 'IIR 1':
flagManualCoeffA = False
flagManualCoeffB = False
flagFIRWindow = False
flagNumtaps = False
flagCutoff = False
......@@ -260,6 +271,8 @@ class Filter():
flagBType = False
elif filterMethod == 'IIR 2':
flagManualCoeffA = False
flagManualCoeffB = False
flagFIRWindow = False
flagNumtaps = False
flagCutoff = False
......@@ -287,11 +300,43 @@ class Filter():
flagRs = False
flagBType = True
elif filterMethod == 'Manual':
flagManualCoeffA = True
flagManualCoeffB = True
flagFIRWindow = False
flagNumtaps = False
flagCutoff = False
flagWidth = False
flagPassZero = False
flagScale = False
flagFrequency = False
flagGain = False
flagAntisymmetric = False
flagIIRMethod = False
flagWp = False
flagWs = False
flagGpass = False
flagGstop = False
flagOrder = False
flagOrder = False
flagWn = False
flagRp = False
flagRs = False
flagBType = False
else :
print('Not recognized filter description method')
# TODO: this is ugly, should be compacted in a cleaner structure!!
self.labelManualCoeffB.setVisible(flagManualCoeffB)
self.textManualCoeffB.setVisible(flagManualCoeffB)
self.labelManualCoeffA.setVisible(flagManualCoeffA)
self.textManualCoeffA.setVisible(flagManualCoeffA)
self.labelFIRWindow.setVisible(flagFIRWindow)
self.comboFIRWindow.setVisible(flagFIRWindow)
......@@ -524,6 +569,7 @@ class Filter():
self.comboResponseType.addItem("IIR 1") # scipy.signal.iirdesign
# TODO: this IIR 2 filter causes undetected problems!! We disable this
self.comboResponseType.addItem("IIR 2") # scipy.signal.iirfilter
self.comboResponseType.addItem("Manual") # define the coeff by hand
self.comboResponseType.setEditable(True)
self.comboResponseType.lineEdit().setReadOnly(True)
self.comboResponseType.lineEdit().setAlignment(Qt.AlignRight)
......@@ -533,6 +579,19 @@ class Filter():
self.connect(self.comboResponseType, SIGNAL('currentIndexChanged(int)'), self.on_parameter_change)
# Manual configuration
self.labelManualCoeffB = QLabel('B Coeff:')
self.textManualCoeffB = QTextEdit()
self.textManualCoeffB.setText('1')
self.connect(self.textManualCoeffB, SIGNAL('textChanged()'), self.update_parameter_set)
self.connect(self.textManualCoeffB, SIGNAL('textChanged()'), self.on_parameter_change)
self.labelManualCoeffA = QLabel('A Coeff:')
self.textManualCoeffA = QTextEdit()
self.textManualCoeffA.setText('1')
self.connect(self.textManualCoeffA, SIGNAL('textChanged()'), self.update_parameter_set)
self.connect(self.textManualCoeffA, SIGNAL('textChanged()'), self.on_parameter_change)
# The Elements for filter configuration are:
......@@ -806,6 +865,18 @@ class Filter():
hboxResponseType.setStretch(0,1)
hboxResponseType.setStretch(1,1)
hboxManualCoeffB = QHBoxLayout()
hboxManualCoeffB.addWidget(self.labelManualCoeffB)
hboxManualCoeffB.addWidget(self.textManualCoeffB)
hboxManualCoeffB.setStretch(0,1)
hboxManualCoeffB.setStretch(1,1)
hboxManualCoeffA = QHBoxLayout()
hboxManualCoeffA.addWidget(self.labelManualCoeffA)
hboxManualCoeffA.addWidget(self.textManualCoeffA)
hboxManualCoeffA.setStretch(0,1)
hboxManualCoeffA.setStretch(1,1)
hboxFIRWindow = QHBoxLayout()
hboxFIRWindow.addWidget(self.labelFIRWindow)
hboxFIRWindow.addWidget(self.comboFIRWindow)
......@@ -929,6 +1000,7 @@ class Filter():
vboxFilterParameters = QVBoxLayout()
for parameterLayout in (hboxResponseType, hboxFIRWindow,
hboxManualCoeffB, hboxManualCoeffA,
hboxNumtaps, hboxCutoff,
hboxWidth, hboxPassZero, hboxScale,
hboxFrequency, hboxGain, hboxAntisymmetric,
......
# This file is part of librefdatool. librefdatool is free software: you can
# redistribute it and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation, version 2.
# This file is part of Libre-FDATool.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
# Libre-FDATool is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 51
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# Libre-FDATool is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Libre-FDATool. If not, see <http://www.gnu.org/licenses/>.
#
# Copyright (C) 2013 Javier D. Garcia-Lasheras
......@@ -76,6 +78,9 @@ class LibreFDATool(
self.simulatorBeginSignal.connect(self.on_simulator_begin)
self.simulatorEndSignal.connect(self.on_simulator_end)
# Choose GHDL as default
self.comboSimulatorEngine.setCurrentIndex(1)
self.runSimulator()
self.main_frame.setCurrentIndex(0)
......
......@@ -127,6 +127,13 @@ class Simcore:
structure = self.structure
name = self.name
# TODO: temporary assign of style depending on engine
if self.engine == 'GHDL':
style = 'rolled'
elif self.engine == 'Icarus Verilog':
style = 'unrolled'
# Code generation for a Transposed Direct Form FIR
hdlFile = open('{!s}.vhd'.format(name),'w')
......@@ -136,56 +143,56 @@ class Simcore:
hdlFile.write(hdl.entity(name, busX, busY))
hdlFile.write('\n')
hdlFile.write(hdl.architectureHeader(name, structure))
hdlFile.write(hdl.architectureHeader(name, structure, style=style))
hdlFile.write('\n')
# *** DECLARE INTERNAL SIGNALS ***
hdlFile.write(hdl.signalZ(self.M, self.N, busX, busY, busC, structure))
hdlFile.write(hdl.signalZ(self.M, self.N, busX, busY, busC, structure, style=style))
hdlFile.write('\n')
hdlFile.write(hdl.signalC(self.M, self.N, busC, structure))
hdlFile.write(hdl.signalC(self.M, self.N, busC, structure, style=style))
hdlFile.write('\n')
hdlFile.write(hdl.signalAdders(self.M, self.N, busX, busY, busC, structure))
hdlFile.write(hdl.signalAdders(self.M, self.N, busX, busY, busC, structure, style=style))
hdlFile.write('\n')
hdlFile.write(hdl.signalProducts(self.M, self.N, busX, busY, busC, structure))
hdlFile.write(hdl.signalProducts(self.M, self.N, busX, busY, busC, structure, style=style))
hdlFile.write('\n')
hdlFile.write(hdl.signalFeedback(self.M, self.N, busX, busY, busC, structure))
hdlFile.write(hdl.signalFeedback(self.M, self.N, busX, busY, busC, structure, style=style))
hdlFile.write('\n')
hdlFile.write("-- Begin Architecture\n")
hdlFile.write("begin\n\n")
hdlFile.write(hdl.sequentialBlock(M, N, clkEdge='posedge', rstActive='high'))
hdlFile.write("\n")
hdlFile.write('-- Arithmetics\n')
hdlFile.write(hdl.assignCoeff(M, N, self.icoefB, self.coefB,
self.icoefA, self.coefA, structure, style=style))
hdlFile.write("\n")
hdlFile.write(hdl.assignCoeff(M, N, self.icoefB, self.coefB,
self.icoefA, self.coefA, structure))
hdlFile.write(hdl.sequentialBlock(M, N, clkEdge='posedge', rstActive='high', style=style))
hdlFile.write("\n")
# Products
hdlFile.write(hdl.arithProduct(M, N,
busX, busY, busC,
structure))
structure, style=style))
hdlFile.write("\n")
# Sums
hdlFile.write(hdl.arithAdders(M, N, structure))
hdlFile.write(hdl.arithAdders(M, N,
self.busX, self.busY, self.busC,
structure, style=style))
hdlFile.write("\n")
hdlFile.write(hdl.connectBlocks(M, N,
self.busX, self.busY, self.busC,
structure))
hdlFile.write('\n')
structure, style=style))
hdlFile.write('end {!s};\n'.format(structure))
hdlFile.close()
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment