URL
https://opencores.org/ocsvn/minsoc/minsoc/trunk
Subversion Repositories minsoc
Compare Revisions
- This comparison shows the changes necessary to convert path
/minsoc/branches/rc-1.0
- from Rev 133 to Rev 132
- ↔ Reverse comparison
Rev 133 → Rev 132
/sim/modelsim/run_sim.bat
1,8 → 1,7
@echo off |
set /p target_firmware=Input the target firmware hex file along with its path. Ex: "..\..\sw\uart\uart-nocache.hex": |
if EXIST %target_firmware% ( |
set firmware_size=find /c /v "NOTTHISSTRING" |
vsim -lib minsoc minsoc_bench -pli ../../bench/verilog/vpi/jp-io-vpi.dll +file_name=%target_firmware% +firmware_size=%firmware_size% |
vsim -lib minsoc minsoc_bench_clock -pli ../../bench/verilog/vpi/jp-io-vpi.dll +file_name=%target_firmware% |
) else ( |
echo %target_firmware% could not be found. |
set /p exit=Press ENTER to close this window... |
/sim/modelsim/run_sim.sh
1,13 → 1,3
#!/bin/bash |
|
set -o errexit |
set -o nounset |
set -o pipefail |
set -o posix # Make command substitution subshells inherit the errexit option. |
# Otherwise, the 'command' in this example will not fail for non-zero exit codes: echo "$(command)" |
|
# A word count should always deliver the number of bytes in the hex file, |
# regardless of the number of hex bytes per line. |
FIRMWARE_SIZE_IN_BYTES="$(wc -w <"$1")" |
|
vsim -lib minsoc minsoc_bench -pli ../../bench/verilog/vpi/jp-io-vpi.so +file_name=$1 +firmware_size="$FIRMWARE_SIZE_IN_BYTES" |
vsim -lib minsoc minsoc_bench_clock -pli ../../bench/verilog/vpi/jp-io-vpi.so +file_name=$1 |
/sim/run/run_bench
1,13 → 1,2
#!/bin/bash |
|
set -o errexit |
set -o nounset |
set -o pipefail |
set -o posix # Make command substitution subshells inherit the errexit option. |
# Otherwise, the 'command' in this example will not fail for non-zero exit codes: echo "$(command)" |
|
# A word count should always deliver the number of bytes in the hex file, |
# regardless of the number of hex bytes per line. |
FIRMWARE_SIZE_IN_BYTES="$(wc -w <"$1")" |
|
vvp -M ../../bench/verilog/vpi/ -mjp-io-vpi minsoc_bench +file_name="$1" +firmware_size="$FIRMWARE_SIZE_IN_BYTES" |
#!/bin/sh |
vvp -M ../../bench/verilog/vpi/ -mjp-io-vpi minsoc_bench +file_name=$1 |
/bench/verilog/minsoc_bench.v
File deleted
/bench/verilog/minsoc_bench_core.v
68,10 → 68,8
// Testbench mechanics |
// |
reg [7:0] program_mem[(1<<(`MEMORY_ADR_WIDTH+2))-1:0]; |
integer initialize, ptr; |
integer initialize, firmware_size, ptr; |
reg [8*64:0] file_name; |
integer firmware_size; // Note that the .hex file size is greater than this, as each byte in the file needs 2 hex characters. |
integer firmware_size_in_header; |
reg load_file; |
|
initial begin |
107,31 → 105,12
//get firmware hex file from command line input |
if ( load_file ) begin |
if ( ! $value$plusargs("file_name=%s", file_name) || file_name == 0 ) begin |
$display("ERROR: Please specify the name of the firmware file to load on start-up."); |
$display("ERROR: please specify an input file to start."); |
$finish; |
end |
|
// We are passing the firmware size separately as a command-line argument in order |
// to avoid this kind of Icarus Verilog warnings: |
// WARNING: minsoc_bench_core.v:111: $readmemh: Standard inconsistency, following 1364-2005. |
// WARNING: minsoc_bench_core.v:111: $readmemh(../../sw/uart/uart.hex): Not enough words in the file for the requested range [0:32767]. |
// Apparently, some of the $readmemh() warnigns are even required by the standard. The trouble is, |
// Verilog's $fread() is not widely implemented in the simulators, so from Verilog alone |
// it's not easy to read the firmware file header without getting such warnings. |
if ( ! $value$plusargs("firmware_size=%d", firmware_size) ) begin |
$display("ERROR: Please specify the size of the firmware (in bytes) contained in the hex firmware file."); |
$finish; |
end |
|
$readmemh(file_name, program_mem, 0, firmware_size - 1); |
|
firmware_size_in_header = { program_mem[0] , program_mem[1] , program_mem[2] , program_mem[3] }; |
|
if ( firmware_size != firmware_size_in_header ) begin |
$display("ERROR: The firmware size in the file header does not match the firmware size given as command-line argument. Did you forget bin2hex's -size_word flag when generating the firmware file?"); |
$finish; |
end |
|
$readmemh(file_name, program_mem); |
// First word comprehends size of program |
firmware_size = { program_mem[0] , program_mem[1] , program_mem[2] , program_mem[3] }; |
end |
|
`ifdef INITIALIZE_MEMORY_MODEL |
/prj/src/minsoc_bench.prj
1,6 → 1,7
PROJECT_DIR=(backend bench/verilog bench/verilog/vpi bench/verilog/sim_lib rtl/verilog) |
PROJECT_SRC=(minsoc_bench_defines.v |
minsoc_bench.v |
minsoc_bench_clock.v |
minsoc_bench_core.v |
minsoc_memory_model.v |
dbg_comm_vpi.v |
fpga_memory_primitives.v |
/sw/utils/bin2hex.c
43,9 → 43,6
// Generates basic ASCII hex output to stdout from binary file input |
// Compile and run the program with no options for usage. |
// |
// Modified by R. Diez in 2011 so that, when using option -size_word, |
// padding zeroes are eventually appended, so that the length of |
// the resulting file matches the length written in the header. |
|
#include <stdio.h> |
#include <stdlib.h> |
67,18 → 64,16
int filename_index=1; |
int bytes_per_line=1; |
int bytes_per_line_index=2; |
unsigned int padding_size = 0; |
unsigned int image_size; |
|
if(argc < 3) { |
fprintf(stderr,"\n\tInsufficient options.\n"); |
fprintf(stderr,"\tPlease specify, in this order: a binary file to\n"); |
fprintf(stderr,"\tconvert and the number of bytes of data to output\n"); |
fprintf(stderr,"\tconvert and the number of bytes of data to putput\n"); |
fprintf(stderr,"\tper line.\n"); |
fprintf(stderr,"\tOptionally specify the option -size_word to output\n"); |
fprintf(stderr,"\tOptionally specify the option -size_word to output,\n"); |
fprintf(stderr,"\tthe size of the image in the first 4 bytes. This is\n"); |
fprintf(stderr,"\tused by some of the new OR1k bootloaders. Note that\n"); |
fprintf(stderr,"\tpadding zeroes will be appended so that the image size\n"); |
fprintf(stderr,"\tis a multiple of 4.\n\n"); |
fprintf(stderr,"\tused by some of the new OR1k bootloaders.\n\n"); |
exit(1); |
} |
|
110,8 → 105,6
|
if (write_size_word) |
{ |
unsigned int image_size; |
|
// or1200 startup method of determining size of boot image we're copying by reading out |
// the very first word in flash is used. Determine the length of this file |
fseek(fd, 0, SEEK_END); |
119,8 → 112,8
fseek(fd,0,SEEK_SET); |
|
// Now we should have the size of the file in bytes. Let's ensure it's a word multiple |
padding_size = ( 4 - (image_size % 4) ) % 4; |
image_size += padding_size; |
image_size+=3; |
image_size &= 0xfffffffc; |
|
// Sanity check on image size |
if (image_size < 8){ |
155,15 → 148,5
} |
} |
|
unsigned j; |
for ( j = 0; j < padding_size; ++j ) { |
// printf("Adding one padding byte.\n"); |
printf("%.2x", 0); |
if (++i == bytes_per_line) { |
printf("\n"); |
i = 0; |
} |
} |
|
return 0; |
} |