-1

I want to convert .bit file to .ace file using the command prompt. I try to create .bat file to do that. But when I execute the command, no files are added to the specified directory.

The batch file is named makeace and has this code:

@echo off
if "%1" == "" goto error
xmd -tcl ./genace.tcl -jprog -hw %1.bit -board ml505 -ace my_%1.ace
goto end
:error
echo Makeace - by FPGA Developer http://www.fpgadeveloper.com
echo.
echo Usage:   makeace bitfile (without .bit extension)
echo Example: makeace project
:end
echo.

The .bit file on my test was named comp.bit.

The command used for testing was:

makeace comp

It ran without errors, but no new file added.

What could be the mistake in batch code above?

Mofi
  • 46,139
  • 17
  • 80
  • 143
sepeee
  • 47
  • 1
  • 6
  • The code looks ok. Try removing `@echo off` and run again. Also try running the converter directly in the command prompt using the actual `comp` string instead of `%1` – wOxxOm Oct 25 '15 at 19:13
  • I try that ,the same result . is there specific place it stored in ?or in the same directory ? – sepeee Oct 25 '15 at 19:54
  • Well, your code looks for the file in current directory. – wOxxOm Oct 25 '15 at 20:03
  • the problem is still ,no files created – sepeee Oct 25 '15 at 20:07
  • If it doesn't work even if you run `xmd ....` line directly in the command prompt then the problem is with that xmd utility, maybe the parameters are wrong. – wOxxOm Oct 25 '15 at 22:22

1 Answers1

0

I suggest to use for your batch file:

@echo off
if "%~1" == "" goto ShowHelp
if "%~1" == "/?" goto ShowHelp

rem Get just file name without file extension and path.
set "BitFileName=%~n1"
rem Get drive and path of file ending with a backslash.
set "BitFilePath=%~dp1"

xmd.exe -tcl ./genace.tcl -jprog -hw "%BitFilePath%%BitFileName%.bit" -board ml505 -ace "%BitFilePath%my_%BitFileName%.ace"

set "BitFileName="
set "BitFilePath="
echo.
goto :EOF

:ShowHelp
echo Makeace - by FPGA Developer http://www.fpgadeveloper.com
echo.
echo Usage:   makeace bitfile
echo.
echo Example: makeace project
echo.
pause

Now it does not matter if the batch file is called with file name having .bit appended or not. And it works now also for file names with 1 or more spaces or other characters listed on last help page output by running cmd /? in a command prompt window.

:EOF is a predefined label which must not be explicitly defined in the batch file. goto :EOF is like exit /B, i.e. exit this batch file and continue with command processing in parent process which means exiting command processor if the parent process is the command process cmd.exe called without /K to keep command prompt window open after finishing batch processing.

For understanding the used commands and how they work, open a command prompt window, execute there the following commands, and read entirely all help pages displayed for each command very carefully.

  • call /? ... explains %~1, %~n1 and %~dp1.
  • echo /?
  • goto /?
  • if /?
  • pause /?
  • rem /?
  • set /?
Mofi
  • 46,139
  • 17
  • 80
  • 143
  • the same problem ,nothing changed :( – sepeee Oct 25 '15 at 20:04
  • @sepeee I agree with [wOxxOm](http://stackoverflow.com/users/3959875/woxxom). The batch file itself works. We don't have `xmd.exe` to check if this executable called without path is found at all by command processor and the parameters are right for this utility. Read the documentation of this tool or it's help. `./genace.tcl` could be the issue. It might be better to specify this file with full path in double quotes, i.e. `"Drive:\Path to File\genace.tcl"` as this file is perhaps not in current directory. – Mofi Oct 26 '15 at 09:39