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
...@@ -162,6 +162,11 @@ class Filter(): ...@@ -162,6 +162,11 @@ class Filter():
rp = rp, rs = rs, rp = rp, rs = rs,
btype = btype, btype = btype,
ftype = ftype) ftype = ftype)
elif filterMethod == 'Manual':
# TODO: Validator needed
b = np.fromstring(str(self.textManualCoeffB.toPlainText()), sep=',')
a = np.fromstring(str(self.textManualCoeffA.toPlainText()), sep=',')
...@@ -182,6 +187,8 @@ class Filter(): ...@@ -182,6 +187,8 @@ class Filter():
if filterMethod == 'FIR 1': if filterMethod == 'FIR 1':
flagManualCoeffA = False
flagManualCoeffB = False
flagFIRWindow = True flagFIRWindow = True
flagNumtaps = True flagNumtaps = True
flagCutoff = True flagCutoff = True
...@@ -216,6 +223,8 @@ class Filter(): ...@@ -216,6 +223,8 @@ class Filter():
self.cbPassZero.setEnabled(True) self.cbPassZero.setEnabled(True)
elif filterMethod == 'FIR 2': elif filterMethod == 'FIR 2':
flagManualCoeffA = False
flagManualCoeffB = False
flagFIRWindow = True flagFIRWindow = True
flagNumtaps = True flagNumtaps = True
flagCutoff = False flagCutoff = False
...@@ -238,6 +247,8 @@ class Filter(): ...@@ -238,6 +247,8 @@ class Filter():
flagBType = False flagBType = False
elif filterMethod == 'IIR 1': elif filterMethod == 'IIR 1':
flagManualCoeffA = False
flagManualCoeffB = False
flagFIRWindow = False flagFIRWindow = False
flagNumtaps = False flagNumtaps = False
flagCutoff = False flagCutoff = False
...@@ -260,6 +271,8 @@ class Filter(): ...@@ -260,6 +271,8 @@ class Filter():
flagBType = False flagBType = False
elif filterMethod == 'IIR 2': elif filterMethod == 'IIR 2':
flagManualCoeffA = False
flagManualCoeffB = False
flagFIRWindow = False flagFIRWindow = False
flagNumtaps = False flagNumtaps = False
flagCutoff = False flagCutoff = False
...@@ -286,12 +299,44 @@ class Filter(): ...@@ -286,12 +299,44 @@ class Filter():
flagRp = False flagRp = False
flagRs = False flagRs = False
flagBType = True 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 : else :
print('Not recognized filter description method') print('Not recognized filter description method')
# TODO: this is ugly, should be compacted in a cleaner structure!! # 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.labelFIRWindow.setVisible(flagFIRWindow)
self.comboFIRWindow.setVisible(flagFIRWindow) self.comboFIRWindow.setVisible(flagFIRWindow)
...@@ -524,6 +569,7 @@ class Filter(): ...@@ -524,6 +569,7 @@ class Filter():
self.comboResponseType.addItem("IIR 1") # scipy.signal.iirdesign self.comboResponseType.addItem("IIR 1") # scipy.signal.iirdesign
# TODO: this IIR 2 filter causes undetected problems!! We disable this # TODO: this IIR 2 filter causes undetected problems!! We disable this
self.comboResponseType.addItem("IIR 2") # scipy.signal.iirfilter self.comboResponseType.addItem("IIR 2") # scipy.signal.iirfilter
self.comboResponseType.addItem("Manual") # define the coeff by hand
self.comboResponseType.setEditable(True) self.comboResponseType.setEditable(True)
self.comboResponseType.lineEdit().setReadOnly(True) self.comboResponseType.lineEdit().setReadOnly(True)
self.comboResponseType.lineEdit().setAlignment(Qt.AlignRight) self.comboResponseType.lineEdit().setAlignment(Qt.AlignRight)
...@@ -533,6 +579,19 @@ class Filter(): ...@@ -533,6 +579,19 @@ class Filter():
self.connect(self.comboResponseType, SIGNAL('currentIndexChanged(int)'), self.on_parameter_change) 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: # The Elements for filter configuration are:
...@@ -805,6 +864,18 @@ class Filter(): ...@@ -805,6 +864,18 @@ class Filter():
hboxResponseType.addWidget(self.comboResponseType) hboxResponseType.addWidget(self.comboResponseType)
hboxResponseType.setStretch(0,1) hboxResponseType.setStretch(0,1)
hboxResponseType.setStretch(1,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 = QHBoxLayout()
hboxFIRWindow.addWidget(self.labelFIRWindow) hboxFIRWindow.addWidget(self.labelFIRWindow)
...@@ -928,7 +999,8 @@ class Filter(): ...@@ -928,7 +999,8 @@ class Filter():
vboxFilterParameters = QVBoxLayout() vboxFilterParameters = QVBoxLayout()
for parameterLayout in (hboxResponseType, hboxFIRWindow, for parameterLayout in (hboxResponseType, hboxFIRWindow,
hboxManualCoeffB, hboxManualCoeffA,
hboxNumtaps, hboxCutoff, hboxNumtaps, hboxCutoff,
hboxWidth, hboxPassZero, hboxScale, hboxWidth, hboxPassZero, hboxScale,
hboxFrequency, hboxGain, hboxAntisymmetric, hboxFrequency, hboxGain, hboxAntisymmetric,
......
# This file is part of librefdatool. librefdatool is free software: you can # This file is part of Libre-FDATool.
# 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 program is distributed in the hope that it will be useful, but WITHOUT # Libre-FDATool is free software: you can redistribute it and/or modify
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # it under the terms of the GNU General Public License as published by
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more # the Free Software Foundation, either version 3 of the License, or
# details. # (at your option) any later version.
# #
# You should have received a copy of the GNU General Public License along with # Libre-FDATool is distributed in the hope that it will be useful,
# this program; if not, write to the Free Software Foundation, Inc., 51 # but WITHOUT ANY WARRANTY; without even the implied warranty of
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # 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 # Copyright (C) 2013 Javier D. Garcia-Lasheras
...@@ -76,6 +78,9 @@ class LibreFDATool( ...@@ -76,6 +78,9 @@ class LibreFDATool(
self.simulatorBeginSignal.connect(self.on_simulator_begin) self.simulatorBeginSignal.connect(self.on_simulator_begin)
self.simulatorEndSignal.connect(self.on_simulator_end) self.simulatorEndSignal.connect(self.on_simulator_end)
# Choose GHDL as default
self.comboSimulatorEngine.setCurrentIndex(1)
self.runSimulator() self.runSimulator()
self.main_frame.setCurrentIndex(0) self.main_frame.setCurrentIndex(0)
......
...@@ -126,6 +126,13 @@ class Simcore: ...@@ -126,6 +126,13 @@ class Simcore:
structure = self.structure structure = self.structure
name = self.name 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 # Code generation for a Transposed Direct Form FIR
hdlFile = open('{!s}.vhd'.format(name),'w') hdlFile = open('{!s}.vhd'.format(name),'w')
...@@ -136,56 +143,56 @@ class Simcore: ...@@ -136,56 +143,56 @@ class Simcore:
hdlFile.write(hdl.entity(name, busX, busY)) hdlFile.write(hdl.entity(name, busX, busY))
hdlFile.write('\n') hdlFile.write('\n')
hdlFile.write(hdl.architectureHeader(name, structure)) hdlFile.write(hdl.architectureHeader(name, structure, style=style))
hdlFile.write('\n') hdlFile.write('\n')
# *** DECLARE INTERNAL SIGNALS *** # *** 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('\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('\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('\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('\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('\n')
hdlFile.write("-- Begin Architecture\n") hdlFile.write("-- Begin Architecture\n")
hdlFile.write("begin\n\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("\n")
hdlFile.write(hdl.assignCoeff(M, N, self.icoefB, self.coefB, hdlFile.write(hdl.assignCoeff(M, N, self.icoefB, self.coefB,
self.icoefA, self.coefA, structure)) self.icoefA, self.coefA, structure, style=style))
hdlFile.write("\n")
hdlFile.write(hdl.sequentialBlock(M, N, clkEdge='posedge', rstActive='high', style=style))
hdlFile.write("\n") hdlFile.write("\n")
# Products # Products
hdlFile.write(hdl.arithProduct(M, N, hdlFile.write(hdl.arithProduct(M, N,
busX, busY, busC, busX, busY, busC,
structure)) structure, style=style))
hdlFile.write("\n") hdlFile.write("\n")
# Sums # 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("\n")
hdlFile.write(hdl.connectBlocks(M, N, hdlFile.write(hdl.connectBlocks(M, N,
self.busX, self.busY, self.busC, self.busX, self.busY, self.busC,
structure)) structure, style=style))
hdlFile.write('\n')
hdlFile.write('end {!s};\n'.format(structure)) hdlFile.write('end {!s};\n'.format(structure))
hdlFile.close() 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