enso wrote:
fpgasm takes a file that looks like the usual BRAM init string, something like:
INIT_00::E9E9E9E9E9E9E9E9E9E9E9E9E9E9E9E9E9E9E9E9E900084CE9E9E9E9E9E9E9E9
INIT_01::E9E9E9E9E9E9E9E9E9E9E9E9E9E9E9E9E9E9E9E9E9E9E9E9E9E9E9E9E9E9E9E9
In Verilog the init string looks very similar. If it is exactly the same format, you'll need to watch the bit order. The byte on the right hand side of the string is the first byte in the memory.
Here's a simple C program I've used before to do the conversion from a binary to Verilog init strings. It should be easy to modify for the slightly different syntax.
Code:
#include <stdio.h>
#include <string.h>
static char *name;
static unsigned char row[32];
static int rows;
static int n;
static void flush( void )
{
int i;
printf( "defparam %s.INIT_%02X=256'h", name, rows++ );
for( i = sizeof(row) - 1; i >= 0; i-- )
printf( "%02x", row[i] );
printf( ";\n" );
n = 0;
memset( row, 0, sizeof(row) );
}
int main( int argc, char **argv )
{
int c;
if( argc < 2 )
{
fprintf( stderr, "%s: missing name\n", argv[0] );
return 1;
}
name = argv[1];
while( (c = getchar()) >= 0 )
{
row[n] = c;
if( ++n == sizeof(row) )
flush( );
}
if( n )
flush( );
return 0;
}
Of course, this only works for 8 bit wide memories.