mirror of
https://github.com/pConst/basic_verilog.git
synced 2025-01-14 06:42:54 +08:00
Added Intel HLS scripts and boilerplate
This commit is contained in:
parent
6c5ef366e7
commit
2499f3a2ea
198
scripts_for_intel_hls/b.bat
Executable file
198
scripts_for_intel_hls/b.bat
Executable file
@ -0,0 +1,198 @@
|
||||
@echo off
|
||||
rem ----------------------------------------------------------------------------
|
||||
rem b.bat
|
||||
rem build script for Intel High Level Synthesis projects for Windows
|
||||
rem Konstantin Pavlov, pavlovconst@gmail.com
|
||||
rem ----------------------------------------------------------------------------
|
||||
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
|
||||
set "COMPONENT=test"
|
||||
|
||||
set "FPGA_SERIES=CycloneV"
|
||||
set "FPGA_CLOCK=100MHz"
|
||||
|
||||
set "SOURCE_FILES=test.cpp"
|
||||
set "HLS_CXX_FLAGS=-v --debug-log"
|
||||
|
||||
|
||||
for /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set Z_DATE=%%c-%%a-%%b)
|
||||
for /f "tokens=1-2 delims=/:" %%a in ('time /t') do (set Z_TIME=%%a-%%b)
|
||||
echo DBG: start timestamp is %Z_DATE%_%Z_TIME%
|
||||
set "Z_PATH="C:\Program Files\7-Zip\7z.exe""
|
||||
echo DBG: 7z.exe path is %Z_PATH%
|
||||
|
||||
:: Accept the user's target, else default to e[mulation]
|
||||
if not "%1"=="" (
|
||||
set "TARGET=%1"
|
||||
) else (
|
||||
set "TARGET=e"
|
||||
echo No target specified, defaulting to !TARGET!
|
||||
echo Available targets: e[mulation], s[imulation], m[svc], c[lean], r[eport], v[sim], q[uartus]
|
||||
)
|
||||
echo DBG: target is !TARGET!
|
||||
|
||||
:: Any tools installed with HLS can be found relative to the location of i++
|
||||
for %%I in (i++.exe) do (
|
||||
set "HLS_INSTALL_DIR=%%~dp$PATH:I"
|
||||
)
|
||||
set "HLS_INSTALL_DIR=%HLS_INSTALL_DIR%.."
|
||||
echo DBG: HLS_INSTALL_DIR is %HLS_INSTALL_DIR%
|
||||
|
||||
set "TARGET_INIT=!TARGET!"
|
||||
|
||||
:: Set up the compile variables
|
||||
if "!TARGET!" == "e" (
|
||||
:: Dont gesitate that FPGA_FAMILY is shown as Arria 10 here.
|
||||
:: This is just an emulation anyway
|
||||
call :clean_e_subroutine
|
||||
|
||||
set "CXX=i++"
|
||||
set "CXXFLAGS=%HLS_CXX_FLAGS% -march=x86-64"
|
||||
set "LFLAGS=-o !TARGET!.exe"
|
||||
)
|
||||
|
||||
if "!TARGET!" == "s" (
|
||||
call :clean_s_subroutine
|
||||
|
||||
set "CXX=i++"
|
||||
set "CXXFLAGS=%HLS_CXX_FLAGS% --clock %FPGA_CLOCK% -ghdl -march=%FPGA_SERIES%
|
||||
set "LFLAGS=-o !TARGET!.exe"
|
||||
)
|
||||
|
||||
if "!TARGET!" == "q" (
|
||||
::Dont make special project folder for Quartus
|
||||
set "INIT_TARGET=q"
|
||||
set "TARGET=s"
|
||||
echo DBG: target is !TARGET!
|
||||
|
||||
call :clean_s_subroutine
|
||||
|
||||
set "CXX=i++"
|
||||
set "CXXFLAGS=%HLS_CXX_FLAGS% --clock %FPGA_CLOCK% --quartus-compile -ghdl -march=%FPGA_SERIES%
|
||||
set "LFLAGS=-o !TARGET!.exe"
|
||||
)
|
||||
|
||||
if "!TARGET!" == "m" (
|
||||
::Dont make special project folder for VC
|
||||
set "TARGET=s"
|
||||
echo DBG: target is !TARGET!
|
||||
|
||||
call :clean_s_subroutine
|
||||
|
||||
set "CXX=cl"
|
||||
set "CXXFLAGS=/I ""%HLS_INSTALL_DIR%\include"" /nologo /EHsc /wd4068 /DWIN32 /MD"
|
||||
set "LFLAGS=/link ""/libpath:%HLS_INSTALL_DIR%\host\windows64\lib"" hls_emul.lib /out:!TARGET!.exe"
|
||||
)
|
||||
|
||||
if "!TARGET!" == "c" (
|
||||
call :clean_all_subroutine
|
||||
goto:eof
|
||||
)
|
||||
|
||||
if "!TARGET!" == "r" (
|
||||
call :open_report_subroutine
|
||||
goto:eof
|
||||
)
|
||||
|
||||
if "!TARGET!" == "v" (
|
||||
if exist ".\s.prj\verification\vsim.wlf" (
|
||||
echo:
|
||||
echo DBG: vsim.wlf file - open in Mdelsim
|
||||
modelsim.exe -view ".\s.prj\verification\vsim.wlf" -do "add wave -position insertpoint vsim:/tb/%COMPONENT%_inst/*"
|
||||
rem @pause
|
||||
) else (
|
||||
echo:
|
||||
echo ERR: =================================
|
||||
echo ERR: vsim.wlf file - doesn`t exist !
|
||||
echo ERR: =================================
|
||||
)
|
||||
goto:eof
|
||||
)
|
||||
|
||||
::set "OBJ=%SOURCE_FILES:cpp=o%"
|
||||
|
||||
:: Replace "" with " in the flags
|
||||
set "CXXFLAGS=%CXXFLAGS:""="%"
|
||||
set "LFLAGS=%LFLAGS:""="%"
|
||||
|
||||
:: Kick off the compile
|
||||
echo DBG: executing %CXX% %CXXFLAGS% %SOURCE_FILES% %LFLAGS%
|
||||
%CXX% %CXXFLAGS% %SOURCE_FILES% %LFLAGS%
|
||||
if not ERRORLEVEL 0 (
|
||||
echo:
|
||||
echo ERR: ======================
|
||||
echo ERR: COMPILATION FAILED !
|
||||
echo ERR: ======================
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
::echo %CXX% %CXXFLAGS% --x86-only %SOURCE_FILES% %LFLAGS%
|
||||
::%CXX% %CXXFLAGS% --x86-only -c %SOURCE_FILES% %LFLAGS%
|
||||
|
||||
::echo %CXX% %CXXFLAGS% --fpga-only -c %SOURCE_FILES% %LFLAGS%
|
||||
::%CXX% %CXXFLAGS% --fpga-only -c %SOURCE_FILES% %LFLAGS%
|
||||
|
||||
:: Execute the test
|
||||
echo:
|
||||
echo DBG: Executing the test
|
||||
call !TARGET!.exe
|
||||
if not ERRORLEVEL 0 (
|
||||
echo:
|
||||
echo ERR: ==============
|
||||
echo ERR: RUN FAILED !
|
||||
echo ERR: ==============
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
if "%TARGET_INIT%" == "q" (
|
||||
echo:
|
||||
echo DBG: Quartus timing
|
||||
findstr /r /c:"Analysis & Synthesis ; 0" %~dp0s.prj\quartus\quartus_compile.flow.rpt
|
||||
findstr /r /c:"Partition Merge ; 0" %~dp0s.prj\quartus\quartus_compile.flow.rpt
|
||||
findstr /r /c:"Fitter ; 0" %~dp0s.prj\quartus\quartus_compile.flow.rpt
|
||||
findstr /r /c:"Fitter ; 0" %~dp0s.prj\quartus\quartus_compile.flow.rpt
|
||||
findstr /r /c:"Timing Analyzer ; 0" %~dp0s.prj\quartus\quartus_compile.flow.rpt
|
||||
findstr /r /c:"Total ; 0" %~dp0s.prj\quartus\quartus_compile.flow.rpt
|
||||
|
||||
echo:
|
||||
call :open_report_subroutine
|
||||
)
|
||||
|
||||
:: Make a backup
|
||||
echo:
|
||||
echo DBG: Making a backup
|
||||
:: enabledelayedexpansion turned on. With this mode, ! symbols have special
|
||||
:: meaning, and to make matters more interesting, there are two parse passes
|
||||
:: on each line, meaning you'll need to double escape them to have the symbol
|
||||
:: pass through to the target application
|
||||
%Z_PATH% a -t7z .\backup\%Z_DATE%_%Z_TIME%.7z *.* -x^^!backup | findstr /I "Add"
|
||||
for /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set Z_DATE=%%c-%%a-%%b)
|
||||
for /f "tokens=1-2 delims=/:" %%a in ('time /t') do (set Z_TIME=%%a-%%b)
|
||||
echo DBG: end timestamp is %Z_DATE%_%Z_TIME%
|
||||
echo DBG: Recipe done
|
||||
goto:eof
|
||||
|
||||
|
||||
:clean_all_subroutine
|
||||
call :clean_e_subroutine
|
||||
call :clean_s_subroutine
|
||||
exit /b
|
||||
|
||||
:clean_e_subroutine
|
||||
del /S /F /Q e.exe > NUL
|
||||
echo DBG: Cleaning emulation done
|
||||
exit /b
|
||||
|
||||
:clean_s_subroutine
|
||||
del /S /F /Q m.exe s.exe s.prj > NUL
|
||||
rmdir /S /Q s.prj > NUL
|
||||
echo DBG: Cleaning simulation done
|
||||
exit /b
|
||||
|
||||
:open_report_subroutine
|
||||
echo DBG: Opening the report
|
||||
start "" .\s.prj\reports\report.html
|
||||
exit /b
|
||||
|
29
scripts_for_intel_hls/hls_type_size_win64.txt
Executable file
29
scripts_for_intel_hls/hls_type_size_win64.txt
Executable file
@ -0,0 +1,29 @@
|
||||
char 1
|
||||
signed char 1
|
||||
unsigned char 1
|
||||
short 2
|
||||
short int 2
|
||||
signed short 2
|
||||
signed short int 2
|
||||
unsigned short 2
|
||||
unsigned short int 2
|
||||
int 4
|
||||
signed 4
|
||||
signed int 4
|
||||
unsigned 4
|
||||
unsigned int 4
|
||||
long 4
|
||||
long int 4
|
||||
signed long 4
|
||||
signed long int 4
|
||||
unsigned long 4
|
||||
unsigned long int 4
|
||||
long long 8
|
||||
long long int 8
|
||||
signed long long 8
|
||||
signed long long int 8
|
||||
unsigned long long 8
|
||||
unsigned long long int 8
|
||||
float 4
|
||||
double 8
|
||||
long double 8
|
10
scripts_for_intel_hls/i.bat
Executable file
10
scripts_for_intel_hls/i.bat
Executable file
@ -0,0 +1,10 @@
|
||||
:: 1. Place this file into:
|
||||
:: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\
|
||||
:: 2. Find link with this name in Start menu
|
||||
:: "Visual Studio x64 Win64 Command Prompt (2010)"
|
||||
:: 3. Copy the link to the desktop. Launch. Execute following command
|
||||
:: i.bat[Enter]
|
||||
:: 4. Intel HLS should be initialized now
|
||||
|
||||
cd "C:\intelFPGA\18.0\hls\"
|
||||
call "init_hls.bat"
|
40
scripts_for_intel_hls/test.cpp
Executable file
40
scripts_for_intel_hls/test.cpp
Executable file
@ -0,0 +1,40 @@
|
||||
#include "HLS/hls.h"
|
||||
#include <HLS/stdio.h>
|
||||
#include <HLS/math.h>
|
||||
#include <stdint.h>
|
||||
|
||||
using namespace ihc;
|
||||
|
||||
//component unsigned int test() {
|
||||
// static unsigned int cnt = 0;
|
||||
// return cnt++;
|
||||
//}
|
||||
|
||||
component int dut(int a, int b) {
|
||||
return a*b;
|
||||
}
|
||||
|
||||
int main (void) {
|
||||
//int x1, x2, x3;
|
||||
int x[3];
|
||||
|
||||
for (int i = 0; i < 3; i++) x[i]=1;
|
||||
printf("1: x1 = %d, x2 = %d, x3 = %d\n", x[0], x[1], x[2]);
|
||||
|
||||
x[0] = dut(7, 8);
|
||||
x[1] = dut(9, 10);
|
||||
x[2] = dut(11, 12);
|
||||
printf("2: x1 = %d, x2 = %d, x3 = %d\n", x[0], x[1], x[2]);
|
||||
|
||||
|
||||
for (int i = 0; i < 3; i++) x[i]=2;
|
||||
printf("3: x1 = %d, x2 = %d, x3 = %d\n", x[0], x[1], x[2]);
|
||||
|
||||
ihc_hls_enqueue((int*)(x+0), &dut, 7, 8);
|
||||
ihc_hls_enqueue((int*)(x+1), &dut, 9, 10);
|
||||
ihc_hls_enqueue((int*)(x+2), &dut, 11, 12);
|
||||
ihc_hls_component_run_all(dut);
|
||||
printf("4: x1 = %d, x2 = %d, x3 = %d\n", x[0], x[1], x[2]);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user