Commit 17be1363 authored by Andrey Filippov's avatar Andrey Filippov

Added support for Cocotb

parent 8ac01d33
......@@ -7,3 +7,4 @@ tmp
about_veditor.html
ChangeLogVeditor.txt
CONTRIBUTORS_VEDITOR.txt
cocotb
......@@ -169,6 +169,7 @@ public class VDT {
public static final String GENERATOR_ID_STATE_FILE = "StateFile";
public static final String GENERATOR_PARSERS_PATH = "ParsersPath";
public static final String GENERATOR_PLUGIN_ROOT = "PluginRoot";
public static final String PATH_TO_PARSERS = "parsers";
public static final String TIME_STAMP_FORMAT = "yyyyMMddHHmmssSSS";
......
......@@ -38,7 +38,8 @@ import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.ui.console.IConsole;
import org.eclipse.ui.console.ConsolePlugin;
import org.eclipse.ui.console.IConsoleManager;
import org.eclipse.ui.console.TextConsole;
import org.eclipse.debug.internal.ui.views.console.ProcessConsole;
import com.elphel.vdt.core.tools.ToolsCore;
import com.elphel.vdt.core.tools.params.Tool;
import com.elphel.vdt.core.tools.params.Tool.TOOL_MODE;
......@@ -82,9 +83,9 @@ public class RunningBuilds {
parserListeners= new ConcurrentHashMap<IConsole,MonListener>();
unfinishedBuilds = new ConcurrentHashMap<String, VDTRunnerConfiguration>();
IConsoleManager manager = ConsolePlugin.getDefault().getConsoleManager();
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) {
System.out.println("***Addded console listeners");
}
// if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) {
// System.out.println("***Addded console listeners");
// }
manager.addConsoleListener(new IConsoleListener(){
public void consolesAdded(IConsole[] consoles){
for (int i=0;i<consoles.length;i++){
......@@ -101,10 +102,14 @@ public class RunningBuilds {
}
// unfinishedBuilds.remove(consoles[i]);
removeMonListener(consoles[i]); // remove listeners that provided input data for parsers
removeConsole(consoles[i]);
removeConsole(consoles[i], null);
}
}
});
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) {
System.out.println("***Addded console listeners");
}
}
public void addMonListener(IConsole parserConsole, IStreamMonitor monitor, IStreamListener listener){
......@@ -165,18 +170,6 @@ public class RunningBuilds {
String consoleName=findConsoleParent(console);
if (consoleName!=null){
VDTRunnerConfiguration runConfig=unfinishedBuilds.get(consoleName);
/*
runConfig.removeConsole(console);
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) {
System.out.println("Removing console "+console.getName()+" from runConfig for "+consoleName);
}
if (runConfig.noConsoles()){
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) {
System.out.println("No consoles left in unfinished "+consoleName+" - removing it too");
}
unfinishedBuilds.remove(consoleName);
}
*/
} else {
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) {
System.out.println("Console "+console.getName()+" did not belong here");
......@@ -263,12 +256,22 @@ public class RunningBuilds {
final String fConsoleName=fIconsole.getName();
final IPropertyChangeListener fListener =new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
// ProcessConsole console = (ProcessConsole) event.getSource();
// TextConsole console = (TextConsole) event.getSource();
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) {
String txt = ((TextConsole) event.getSource()).getDocument().get();
System.out.println("==== Console contents at "+event.getProperty()+" ====");
System.out.println("fConsoleName="+fConsoleName+" fIconsole.getName()="+fIconsole.getName());
System.out.println(txt);
System.out.println("==== End of console contents at "+event.getProperty()+" ====");
}
if (!fConsoleName.equals(fIconsole.getName())){
fIconsole.removePropertyChangeListener(this);
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) {
System.out.println(">>> "+fConsoleName+" -> "+fIconsole.getName());
}
removeConsole(fIconsole); // changed name means "<terminated>..."
String ctxt = ((TextConsole) event.getSource()).getDocument().get(); // To search for good/bad completion
removeConsole(fIconsole, ctxt); // changed name means "<terminated>..."
}
}
};
......@@ -283,12 +286,25 @@ public class RunningBuilds {
}
// Only for closing consoles
public boolean removeConsole(IConsole iConsole){ // from add console;
public boolean removeConsole(IConsole iConsole, String consoleText){ // from add console;
Iterator<String> iter=unfinishedBuilds.keySet().iterator();
while (iter.hasNext()) {
String consoleName=iter.next();
VDTRunnerConfiguration runConfig=unfinishedBuilds.get(consoleName);
if (runConfig.getIConsole()==iConsole){ // same instance
boolean hasGood = false;
boolean hasBad = false;
boolean goodSet = false;
boolean badSet = false;
if (consoleText != null){
goodSet = runConfig.isSetGood();
badSet = runConfig.isSetBad();
if (goodSet || badSet) {
runConfig.addConsoleText(consoleText);
hasGood = runConfig.gotGood();
hasBad = runConfig.gotBad();
}
}
runConfig.setIConsole(null);
Tool tool=ToolsCore.getTool(runConfig.getToolName());
if (tool.getState()==TOOL_STATE.KEPT_OPEN) {
......@@ -297,6 +313,10 @@ public class RunningBuilds {
removeConfiguration(consoleName);
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) System.out.print("Killed open console");
return true;
} else {
if (hasBad) tool.setState(TOOL_STATE.FAILURE);
else if (hasGood) tool.setState(TOOL_STATE.SUCCESS);
else if (goodSet) tool.setState(TOOL_STATE.FAILURE);
}
}
}
......
......@@ -148,6 +148,12 @@ public class VDTProgramRunner {
}
}
// AF2016
// Adding good/bad console messages - same as for VDTConsoleRunner
runConfig.setConsoleFinish(buildParamsItem.getPrompt());
runConfig.setConsoleBad(buildParamsItem.getFailureString());
runConfig.setConsoleGood(buildParamsItem.getSuccessString());
String[] cmdLine;
if (isShell && (arguments != null) && (arguments.length > 0)){ /* first argument is passed as a parameter to shell*/
StringBuilder builder = new StringBuilder();
......
......@@ -245,12 +245,12 @@ public class VDTRunner {
if (debugPrint) System.out.println("Fire!");
fiCons.firePropertyChange(fiCons,"org.eclipse.jface.text", consoleName, fConsoleName);
}
if (debugPrint) System.out.println("return - waiting to be awaken");
int timeout=argumentsItemsArray[numItem].getTimeout();
//keepOpen()
final boolean fKeepOpen=argumentsItemsArray[numItem].keepOpen();
if (fKeepOpen) runConfig.setKeptOpen(true);
if (fKeepOpen && (timeout<1)) timeout=1; // some minimal timeout
if (debugPrint) System.out.println("return - waiting to be awaken, timeout = "+timeout);
if (timeout>0){
if (debugPrint) System.out.println ("timeout="+timeout+"s, keep-open="+ fKeepOpen);
// implementation will require keeping track of it and canceling if program terminated earlier.
......
......@@ -273,20 +273,7 @@ public class VDTRunnerConfiguration {
public VDTProgramRunner getProgramRunner(){
return this.programRunner;
}
/*
public void addConsole(IConsole console){ // not used
consoles.add(console);
}
public void removeConsole(IConsole console){ // from VDTRunnerConfiguration
consoles.remove(console);
}
public boolean noConsoles(){
return consoles.isEmpty();
}
public boolean hasConsole(IConsole console){
return consoles.contains(console);
}
*/
public void setConsoleFinish(String consoleFinish){
this.consoleFinish=consoleFinish;
if ((this.consoleFinish!=null) && ((this.consoleFinish.length()+extraChars) > maxLength)){
......@@ -357,6 +344,15 @@ public class VDTRunnerConfiguration {
public boolean gotGood(){
return hasGood;
}
public boolean isSetGood(){
return consoleGood != null;
}
public boolean isSetBad(){
return consoleBad != null;
}
public String getConsoluBuffer(){
return consoleBuffer; // just for debugging
}
......
......@@ -97,7 +97,7 @@ public class FilteredIncludesListGenerator extends AbstractGenerator {
}
String[] file_names = null;
IResource resource = SelectedResourceManager.getDefault().getChosenVerilogFile();
if ((topFile != null) && (topFile !="") && (resource !=null)) {
if ((topFile != null) && (!topFile.equals("")) && (resource !=null)) {
IResource resource1 = resource.getProject().getFile(topFile);
if ((resource1 != null) && (resource1.getType() == IResource.FILE)){
resource = resource1;
......
......@@ -108,7 +108,7 @@ public class FilteredSourceListGenerator extends AbstractGenerator {
}
String[] file_names = null;
IResource resource = SelectedResourceManager.getDefault().getChosenVerilogFile();
if ((topFile != null) && (topFile !="") && (resource !=null)) {
if ((topFile != null) && (!topFile.equals("")) && (resource !=null)) {
IResource resource1 = resource.getProject().getFile(topFile);
if ((resource1 != null) && (resource1.getType() == IResource.FILE)){
resource = resource1;
......
......@@ -53,7 +53,8 @@ public class ParsersPathGenerator extends AbstractGenerator {
if(url != null) {
URI uri=FileLocator.resolve(url).toURI();
// System.out.println("ParsersPathGenerator()->"+uri.getRawPath()+" : "+uri.toString());
return new String[]{uri.getRawPath()};
// return new String[]{uri.getRawPath()};
return new String[]{uri.normalize().getPath()};
}
return null;
} catch (Exception e){
......
/*******************************************************************************
* Copyright (c) 2014 Elphel, Inc.
* This file is a part of VDT plug-in.
* VDT plug-in 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.
*
* VDT plug-in 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 this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional permission under GNU GPL version 3 section 7:
* If you modify this Program, or any covered work, by linking or combining it
* with Eclipse or Eclipse plugins (or a modified version of those libraries),
* containing parts covered by the terms of EPL/CPL, the licensors of this
* Program grant you additional permission to convey the resulting work.
* {Corresponding Source for a non-source form of such a combination shall
* include the source code for the parts of Eclipse or Eclipse plugins used
* as well as that of the covered work.}
*******************************************************************************/
package com.elphel.vdt.core.tools.generators;
import java.io.File;
import java.net.URI;
import org.eclipse.core.runtime.FileLocator;
import com.elphel.vdt.VDT;
import com.elphel.vdt.veditor.VerilogPlugin;
public class PluginPathGenerator extends AbstractGenerator {
public static final String NAME = VDT.GENERATOR_PLUGIN_ROOT;
public String getName() {
return NAME;
}
public PluginPathGenerator()
{
super(null); // null for topFormatProcessor - this generator can not reference other parameters
}
protected String[] getStringValues() {
try {
File path=FileLocator.getBundleFile(VerilogPlugin.getDefault().getBundle());
String normalized = new URI(path.getAbsolutePath()).normalize().getPath();
return new String[]{normalized};
} catch (Exception e){
return null;
}
}
}
......@@ -28,8 +28,10 @@ package com.elphel.vdt.core.tools.generators;
import java.io.File;
import java.nio.file.Paths;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
import com.elphel.vdt.VDT;
import com.elphel.vdt.ui.variables.SelectedResourceManager;
......@@ -56,9 +58,18 @@ public class ProjectPathGenerator extends AbstractGenerator {
String[] value = null;
IResource resource = SelectedResourceManager.getDefault().getSelectedResource();
if (resource != null) {
/*
String workspaceRoot=resource.getWorkspace().getRoot().getLocation().toString();
String project_name = workspaceRoot+resource.getProject().getFullPath().toString()+File.separator;
String projectRoot=resource.getWorkspace().getRoot().getLocation().toString();
IPath apath = resource.getProject().getRawLocation().makeAbsolute();
value = new String[]{project_name};
*/
try {
value = new String[]{resource.getProject().getRawLocation().makeAbsolute().toString()};
} catch (NullPointerException npe){
return new String[] {""};
}
} else {
// fault("There is no selected project");
System.out.println(getName()+": no project selected");
......
......@@ -61,7 +61,7 @@ public class TopModuleNameGenerator extends AbstractGenerator {
} else {
System.out.println("ToolNameGenerator(): topProcessor.getCurrentTool() is null");
}
if ((topFile != null) && (topFile !="") && (resource !=null)) {
if ((topFile != null) && (!topFile.equals("")) && (resource !=null)) {
IResource resource1 = resource.getProject().getFile(topFile);
if ((resource1 != null) && (resource1.getType() == IResource.FILE)){
resource = resource1;
......
......@@ -65,7 +65,7 @@ public class TopModulesNameGenerator extends AbstractGenerator {
} else {
System.out.println("ToolNameGenerator(): topProcessor.getCurrentTool() is null");
}
if ((topFile != null) && (topFile !="") && (resource !=null)) {
if ((topFile != null) && (!topFile.equals("")) && (resource !=null)) {
IResource resource1 = resource.getProject().getFile(topFile);
if ((resource1 != null) && (resource1.getType() == IResource.FILE)){
resource = resource1;
......
......@@ -55,7 +55,8 @@ public class SimpleGeneratorRecognizer implements Recognizer {
new StateFileGenerator(processor),
new StateBaseGenerator(processor),
new ToolNameGenerator(),
new ParsersPathGenerator()
new ParsersPathGenerator(),
new PluginPathGenerator()
// new SourceListGenerator("","",""),
// new FilteredSourceListGenerator("","","")
};
......
......@@ -42,6 +42,7 @@ import org.eclipse.jface.window.Window;
import org.eclipse.swt.graphics.Image;
//import org.eclipse.swt.graphics.ImageData;
import org.eclipse.jface.action.*;
import org.eclipse.jface.text.IDocument;
import org.eclipse.ui.*;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.SWT;
......@@ -72,6 +73,8 @@ import com.elphel.vdt.Txt;
import com.elphel.vdt.VDT;
import com.elphel.vdt.VerilogUtils;
import com.elphel.vdt.veditor.VerilogPlugin;
import com.elphel.vdt.veditor.document.HdlDocument;
import com.elphel.vdt.veditor.editor.HdlEditor;
import com.elphel.vdt.veditor.preference.PreferenceStrings;
import com.elphel.vdt.ui.MessageUI;
import com.elphel.vdt.ui.VDTPluginImages;
......@@ -362,7 +365,7 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
manager.add(clearProjectPropertiesAction);
manager.add(clearToolPropertiesAction);
manager.add(new Separator());
manager.add(selectDesignMenuAction);
manager.add(selectDesignMenuAction); // got null
manager.add(new Separator());
manager.add(clearStateFilesAction);
manager.add(clearLogFilesAction);
......@@ -577,6 +580,14 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
clearToolPropertiesAction.setImageDescriptor(VDTPluginImages.DESC_TOOL_PROPERTIES);
selectDesignMenuAction = new Action() {
public void run() {
if (selectedResource == null){
HdlEditor editor = HdlEditor.current();
if ((editor != null) && (editor.getDocument() != null) && (editor.getDocument() instanceof HdlDocument) ){
selectedResource = ((HdlDocument)editor.getDocument()).getFile();
} else {
return;
}
}
openDesignMenuSelectionDialog(selectedResource.getProject());
}
};
......
......@@ -52,6 +52,10 @@
<paramtype kind="bool" formatTrue="on" formatFalse="off" />
</typedef>
<typedef name = "Bool_1_0">
<paramtype kind="bool" formatTrue="1" formatFalse="0" />
</typedef>
<typedef name = "Cardinal">
<paramtype kind="number" lo="0" hi="65535" format="%d" />
</typedef>
......@@ -125,6 +129,7 @@
<syntax name="NameValue" format=" %%ParamName %%ParamValue" />
<syntax name="DoubleDash" format="--%%ParamName=%%ParamValue" />
<syntax name="DoubleDashName" format="--%%ParamName" />
<syntax name="NameEqValue" format="%%ParamName=%%ParamValue" />
<!--
Does not work according to 2.2.1. "Inside text-repetitor, one and only one pattern-generator is mandatory".
......
......@@ -39,6 +39,11 @@
icon="iverilog.ico"
call="iverilog"/>
<menuitem name="cocotb"
label="Cocotb Python Verification"
icon="pv_logo_32x32.png"
call="cocotb"/>
<menuitem name="GTKWave"
label="GTKWave (Waves viewer)"
icon="gtkwave.ico"
......
......@@ -243,12 +243,19 @@
readonly="false" />
<parameter id="SimulationTopModule" label="Simulation top module" tooltip="Project top simulation module"
type="String" default="" format="CopyValue" readonly="false" />
<parameter id="DUTTopFile" label="DUT top file" tooltip="Cocotb DUT top Veilog file"
type="Filename" default="" format="CopyValue"
readonly="false" />
<parameter id="DUTTopModule" label="DUT top module" tooltip="Cocotb DUT top simulation module"
type="String" default="" format="CopyValue" readonly="false" />
<parameter id="ImplementationTopFile" label="Implementation top file" tooltip="Project file with top implementation module"
type="Filename" default="" format="CopyValue" readonly="false" />
<parameter id="ImplementationTopModule" label="Implementation top module" tooltip="Project top implementation module"
type="String" default="" format="CopyValue" readonly="false" />
<parameter id="SimulDir" label="Simulation directory" tooltip="Project simulation directory"
type="Pathname" default="simulation" format="CopyValue" readonly="false" />
<parameter id="CocotbFilesDir" label="Cocotb Simulation directory" tooltip="Cocotb simulation files directory for the project"
type="Pathname" default="cocotb" format="CopyValue" readonly="false" />
<!-- Vivado parameters -->
<parameter id="part" label="Device" tooltip= "FPGA part number (device) to use"
default="" visible="true" omit="" type="String" format="CopyValue"/>
......@@ -481,6 +488,9 @@
<group name="Simulation" label="Simulation properties">
"SimulationTopFile"
"SimulationTopModule"
"DUTTopFile"
"DUTTopModule"
"CocotbFilesDir"
"SimulDir"
</group>
......
This diff is collapsed.
......@@ -93,7 +93,8 @@
<tool name="iverilog" project="FPGA_project" label="Icarus Verilog compiler"
shell="bash"
package="FPGA_package"
interface="IVerilog" errors="(.*):([0-9]+): [a-z_\- ]*error: (.*)"
interface="IVerilog"
errors="(.*):([0-9]+): [a-z_\- ]*error[: ]?(.*)"
warnings="(.*):([0-9]+): [a-z_\- ]*warning: (.*)"
info="(.*):([0-9]+): [a-z_\- ]*sorry: (.*)"
top-file="%IcarusTopFile"
......@@ -290,6 +291,7 @@
<parameter id="FstDumpFileFull" default="%SimulDir/%FstDumpFile"
visible="false" type="String" format="FstFileSyntax"/>
<input>
<group name="files" label="Files">
<!-- "SimulationTopFile" -->
......@@ -336,13 +338,17 @@
<output>
<!-- TODO: watch for new lines inserted inside quoted tokens during autoformat - they break output
Maybe add filter to the code to transform white spaces -->
<line name="command_line" sep=" ">
<line name="command_line"
sep=" "
success = "SIMULATION FINISHED SUCCESSFULLY"
>
"%Param_Shell_Options"
"%Param_PreExe"
<!-- MKDIR - ALWAYS -->
"mkdir -p"
"%SimulDir"
";"
<!-- "(&gt;&amp;2 echo 'unisims/RAMB36E1.v:100: warning: choosing typ expression.');" -->
<if SaveLogsPreprocessor="true"
SaveLogsSimulator="true">
"touch"
......@@ -366,6 +372,8 @@
"%Param_TopModule"
"%TopModulesOther"
"%ModuleLibrary"
<!-- Always include top project dir (where IVERILOG_INCLUDE.v is) -->
"-I%%ProjectPath"
"%IncludeDir"
"%legacy_model"
"%no_specify"
......@@ -416,10 +424,14 @@
"%GtkWave_Exe"
"%FstDumpFileFull"
"%GTKWaveSavFile"
"&lt;/dev/null &amp;&gt;/dev/null"
"&amp; "
</if>
"%Param_4"
</if-not>
"if [ $? -eq 0 ]; then echo 'SIMULATION FINISHED SUCCESSFULLY'; else echo 'SIMULATION FAILED'; fi;"
"sleep 1"
</line>
<line name="IverilogIncludeFile" dest="iverilog_include_file"
sep="\n">
......
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