Commit 30234393 authored by Andrey Filippov's avatar Andrey Filippov

More on cocotb integration

parent 17be1363
......@@ -34,13 +34,6 @@ import java.util.regex.PatternSyntaxException;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
//import com.elphel.vdt.VDT;
import com.elphel.vdt.VerilogUtils;
import com.elphel.vdt.core.tools.params.FormatProcessor;
......@@ -98,12 +91,24 @@ public class FilteredIncludesListGenerator extends AbstractGenerator {
String[] file_names = null;
IResource resource = SelectedResourceManager.getDefault().getChosenVerilogFile();
if ((topFile != null) && (!topFile.equals("")) && (resource !=null)) {
// If topFile is absolute, try to convert top file to project resource
if (topFile.startsWith("/")){
String aPojectStr=resource.getProject().getLocation().toOSString();
if (topFile.startsWith(aPojectStr)){
topFile = topFile.substring(aPojectStr.length()+1);
}
}
// Only apply if topFile is not absolute anymore
if (!topFile.startsWith("/")){
IResource resource1 = resource.getProject().getFile(topFile);
if ((resource1 != null) && (resource1.getType() == IResource.FILE)){
resource = resource1;
// System.out.println("resource1="+resource1);
// System.out.println("resource1="+resource1);
}
}
}
Pattern ignorePattern = null;
if (ignoreFilter!=null){
try {
......
......@@ -34,14 +34,6 @@ import java.util.regex.PatternSyntaxException;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
//import com.elphel.vdt.VDT;
import com.elphel.vdt.VerilogUtils;
import com.elphel.vdt.core.tools.params.FormatProcessor;
......@@ -91,7 +83,7 @@ public class FilteredSourceListGenerator extends AbstractGenerator {
System.out.println("FilteredSourceListGenerator().getStringValue(): tool="+tool.getName()+", ignoreFilter="+ignoreFilter);
}
topFile = tool.getTopFile();
toolDefine = tool.getDefine();
toolDefine = tool.getDefine(); // correct absolute
if ((toolDefine == null) || (toolDefine == "")) {
if ((topFile == null ) || (topFile == "")) toolDefine = null; // no need to reparse tree for this tool
else toolDefine = ""; // reparse for this tool - top file may have different defines
......@@ -109,10 +101,20 @@ public class FilteredSourceListGenerator extends AbstractGenerator {
String[] file_names = null;
IResource resource = SelectedResourceManager.getDefault().getChosenVerilogFile();
if ((topFile != null) && (!topFile.equals("")) && (resource !=null)) {
// If topFile is absolute, try to convert top file to project resource
if (topFile.startsWith("/")){
String aPojectStr=resource.getProject().getLocation().toOSString();
if (topFile.startsWith(aPojectStr)){
topFile = topFile.substring(aPojectStr.length()+1);
}
}
// Only apply if topFile is not absolute anymore
if (!topFile.startsWith("/")){
IResource resource1 = resource.getProject().getFile(topFile);
if ((resource1 != null) && (resource1.getType() == IResource.FILE)){
resource = resource1;
// System.out.println("resource1="+resource1);
// System.out.println("resource1="+resource1);
}
}
}
Pattern ignorePattern = null;
......
......@@ -26,6 +26,7 @@
*******************************************************************************/
package com.elphel.vdt.ui.options.component;
import org.eclipse.core.resources.IProject;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Composite;
......@@ -33,6 +34,7 @@ import org.eclipse.swt.widgets.FileDialog;
import com.elphel.vdt.core.tools.params.Parameter;
import com.elphel.vdt.core.tools.params.types.ParamTypeString;
import com.elphel.vdt.ui.variables.SelectedResourceManager;
public class FileComponent extends BrowsableComponent {
......@@ -61,8 +63,25 @@ public class FileComponent extends BrowsableComponent {
FileDialog dialog = (FileDialog)locationField.getBrowseDialog();
String selectedFile = dialog.open();
if(selectedFile != null)
if(selectedFile != null) {
// try to convert to project-relative
IProject project = SelectedResourceManager.getDefault().getSelectedProject();
String projectPath=null;
if (project!=null) {
projectPath=project.getLocation().toString();
if ((selectedFile!=null) && selectedFile.startsWith(projectPath)) {
if (selectedFile.equals(projectPath)){
System.out.println("FileListPromptDialog(): Path equals to project path = \""+selectedFile+"\", returning \".\"");
selectedFile = ".";
}
selectedFile = selectedFile.substring(projectPath.length()+1);
}
}
locationField.getBrowsedNameField().setText(selectedFile);
}
}
});
......
......@@ -41,7 +41,7 @@
<menuitem name="cocotb"
label="Cocotb Python Verification"
icon="pv_logo_32x32.png"
icon="pv_hc.png"
call="cocotb"/>
<menuitem name="GTKWave"
......
......@@ -45,19 +45,19 @@
</typedef>
<syntax name="ListEqMultiline" format="%%ParamName = %(%%ParamValue%| \\n%)" />
<syntax name="ListEqMultilineAbs" format="%%ParamName = %($(PROJECT_ROOT)/%%ParamValue%| \\n%)" />
<syntax name="ListEqMultilineAbsExtra" format="%%ParamName += %($(PROJECT_ROOT)/%%ParamValue%| \\n%)" />
<syntax name="MakeCleanItems" format="clean::\n%(\t-@rm -f %%ParamValue%|\n%)"/>
<syntax name="ListEqComma" format="%%ParamName = %(%%ParamValue%|,%)" />
<syntax name="CocotbIncludeDirSyntax" format="%%ParamName += %(-I%%ParamValue%| %)" />
<syntax name="CocotbTopModulesOtherSyntax" format="%%ParamName += %(-s%%ParamValue%| %)" />
<syntax name="CocotbModuleLibrarySyntax" format="%%ParamName += %(-y%%ParamValue%| %)" />
<syntax name="D_ParamSyntax" format="-D%%ParamName" />
<syntax name="g_ParamSyntax" format="-g%%ParamName" />
<syntax name="NospecifySyntax" format="-gno-specify" />
<syntax name="TopModuleSyntax" format="-s%%TopModule" />
<syntax name="TopModulesOtherSyntax" format="%(-s%%ParamValue%| %)" />
<syntax name="ModuleLibrarySyntax" format="%(-y%%ParamValue%| %)" />
<syntax name="IncludeDirSyntax" format="%(-I%%ParamValue%| %)" />
<syntax name="ExtraFilesSyntax" format="%(%%ParamValue%| %)" />
<syntax name="SwitchSyntax" format="-%%ParamName" />
<syntax name="GrepFindSyntax"
format="| { grep --line-buffered -E &quot;%%ParamValue&quot; || true; }" />
......@@ -174,8 +174,8 @@
<!-- <parameter id="CocotbMakefileDir" type="Pathname" label="Makefile directory" tooltip="Cocotb project Makefile directory"
format="CopyValue" default="%CocotbFilesDir" readonly="false" visible="true" />-->
<parameter id="CocotbRoot" outid="COCOTB" type="Pathname" label="Cocotb installation" tooltip="Cocotb installation root directory"
format="NameEqValue" default="%%PluginRoot/cocotb" readonly="false" visible="true" />
<parameter id="CocotbRootRel" type="String" label="Cocotb installation" tooltip="Cocotb installation root directory relative to VDT plugin root"
format="CopyValue" default="cocotb" readonly="false" visible="true" />
<parameter id="ProjectAbsolutePath" outid="PROJECT_ROOT" default="%%ProjectPath" label = "Project absolute path"
type="Pathname" format="NameEqValue" visible="true" />
......@@ -195,10 +195,22 @@
<parameter id="ShowWaves" type="BoolYesNo" format="None"
default="true" label="Show simulation result in waveform viewer" />
<parameter id="IcarusTopFile"
label="Simulation top file" tooltip="IVerilog simulator top file"
default="%SimulationTopFile"
type="String" format="CopyValue" />
<parameter id="CocotbTopModulesOther" outid="COMPILE_ARGS" type="Stringlist"
format="CocotbTopModulesOtherSyntax" default="" omit=""
label="Select top modules not referenced by the chosen target"
readonly="false" visible="true" />
<parameter id="CocotbModuleLibrary" outid="COMPILE_ARGS" type="ModuleLibraryType"
format="CocotbModuleLibrarySyntax" default="" label="Select additional libraries to include"
omit="" readonly="false" visible="true" />
<parameter id="CocotbExtraFiles" outid="VERILOG_SOURCES" type="Filelist" format="ListEqMultilineAbsExtra"
default="" label="Select additional Verilog files to include" omit="" readonly="false"
visible="true" />
<parameter id="Param_Shell_Options" label="Param_Shell_Options"
......@@ -224,28 +236,6 @@
format="CopyValue" default="gtkwave" readonly="false"
visible="true" />
<parameter id="Param_TopModule" label="Top module extracted from the chosen target file"
type="String" format="TopModuleSyntax" default="%%TopModule"
readonly="true" visible="true" />
<parameter id="TopModulesOther" type="Stringlist"
format="TopModulesOtherSyntax" default="" omit=""
label="Select top modules not referenced by the chosen target"
readonly="false" visible="true" />
<parameter id="ModuleLibrary" type="ModuleLibraryType"
format="ModuleLibrarySyntax" default="" label="Select additional libraries to include"
omit="" readonly="false" visible="true" />
<parameter id="ExtraFiles" type="Filelist" format="ExtraFilesSyntax"
default="" label="Select additional files to include" readonly="false"
visible="true" />
<parameter id="IncludeDir" type="IncludeDirType"
format="IncludeDirSyntax" default="" label="Select include file directories"
omit="" readonly="false" visible="true" />
<parameter id="legacy_model" outid="legacy_model" type="D_ParamType"
format="D_ParamSyntax" default="true" label="Use legacy model" />
......@@ -371,45 +361,36 @@
<parameter id="cocotbInstallDir" default="%CocotbRoot"
type="String" format="CopyValue" visible="false" /> -->
<parameter id="CocotbRoot" outid="COCOTB" type="String"
format="NameEqValue" default="%%PluginRoot/%CocotbRootRel" visible="false" />
<input>
<group name="cocotb" label="Cocotb">
"CocotbMODULE"
"CocotbTESTCASE"
"CocotbDutTopFile"
"CocotbDutTopModule"
"ShowWaves"
"CocotbVERILOG_SOURCES"
"CocotbExtraFiles"
"CocotbTopModulesOther"
"GTKWaveSavFile"
"CocotbIncludeDir"
"IncludeParametersList"
"---"
"CocotbGUI"
"CocotbSIM"
"CocotbVERILOG_SOURCES"
"CocotbVHDL_SOURCES"
"CocotbCOMPILE_ARGS"
"CocotbSIM_ARGS"
"CocotbEXTRA_ARGS"
"CocotbCUSTOM_COMPILE_DEPS"
"CocotbCUSTOM_SIM_DEPS"
"CocotbDutTopFile"
"CocotbDutTopModule"
"CocotbRANDOM_SEED"
"COCOTB_ANSI_OUTPUT"
"CocotbMODULE"
"CocotbTESTCASE"
"CocotbRoot"
"CocotbFilesDir"
"CocotbIncludeDir"
"CocotbRootRel"
"MakeCleanPatterns"
"ShowWaves"
"GTKWaveSavFile"
<!-- "CocotbMakefileDir" -->
"ParsersRoot"
"ProjectAbsolutePath"
</group>
<group name="files" label="Files">
<!-- "SimulationTopFile" -->
"IcarusTopFile"
"Param_TopModule"
"TopModulesOther"
"ExtraFiles"
"ModuleLibrary"
"IncludeDir"
"IncludeParametersList"
"CocotbModuleLibrary"
</group>
<group name="options" label="Options">
<!--"ShowWaves" -->
......@@ -460,29 +441,13 @@
"exit 0;"
- "else echo 'FAILURE';"
"fi"
<!--
"%Param_Shell_Options"
"while true; do"
" read -p 'Do you wish to install this program? ' yn;"
" case $yn in"
" [Yy]* ) echo 'Installing...'; break;;"
" [Nn]* ) exit;;"
" * ) echo 'Please answer yes or no.';;"
" esac"
"done"
-->
</line>
<!-- 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=" "
success = "SIMULATION FINISHED SUCCESSFULLY"
failure = "recipe for target '[^']*' failed"
>
<!-- success="SIMULATION FINISHED SUCCESSFULLY" -->
"%Param_Shell_Options"
"%Param_PreExe"
<!-- MKDIR - ALWAYS -->
......@@ -529,18 +494,26 @@
"%CocotbMODULE"
"%CocotbTESTCASE"
"%CocotbVERILOG_SOURCES"
"%CocotbExtraFiles"
"%CocotbVHDL_SOURCES"
"%CocotbGUI"
"%CocotbSIM"
"%CocotbCOMPILE_ARGS"
<!-- Always include top project dir (where IVERILOG_INCLUDE.v is) -->
"COMPILE_ARGS += -I/$(PROJECT_ROOT)"
<if ShowWaves="true">
"COMPILE_ARGS += -DTRACE"
</if>
"%CocotbTopModulesOther"
"%CocotbModuleLibrary"
"%CocotbIncludeDir"
"%CocotbSIM_ARGS"
"%CocotbEXTRA_ARGS"
"%CocotbCUSTOM_COMPILE_DEPS"
<!--"CUSTOM_COMPILE_DEPS += %%ProjectPath/IVERILOG_INCLUDE.v"-->
""CUSTOM_COMPILE_DEPS += $(PROJECT_ROOT)/IVERILOG_INCLUDE.v
"CUSTOM_COMPILE_DEPS += $(PROJECT_ROOT)/IVERILOG_INCLUDE.v"
"%CocotbCUSTOM_SIM_DEPS"
"%CocotbRANDOM_SEED"
"%COCOTB_ANSI_OUTPUT"
......@@ -548,10 +521,6 @@
"include $(COCOTB)/makefiles/Makefile.inc"
"include $(COCOTB)/makefiles/Makefile.sim"
"%MakeCleanPatterns"
<!-- "clean::"
"\t-@rm -f *.pyc"
"\t-@rm -f *.jpg"
"\t-@rm -f results.xml" -->
</line>
</output>
......
......@@ -341,6 +341,7 @@
<line name="command_line"
sep=" "
success = "SIMULATION FINISHED SUCCESSFULLY"
failure = "invalid option"
>
"%Param_Shell_Options"
"%Param_PreExe"
......
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