OpenCores
URL https://opencores.org/ocsvn/softavrcore/softavrcore/trunk

Subversion Repositories softavrcore

[/] [softavrcore/] [trunk/] [util/] [progmem-generic.sh] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 apal
#!/bin/bash
2
 
3
infile=""
4
 
5
depth=8
6
 
7
name=rom_16bit
8
 
9
while [ -n "$1" ]; do
10
        case "$1" in
11
                -h|--help)
12
                        echo -e "Usage:\t$0 [-h|--help] [-w|--width <width>] <16-bit-image.bin>"
13
                        exit    0
14
                        ;;
15
                -w|--width|-d|--depth)
16
                        depth="$2"
17
                        shift
18
                        ;;
19
                -n|--name)
20
                        name="$2"
21
                        shift
22
                        ;;
23
                -*)
24
                        echo -e "$0: error: invalid command line argument near '$1'." >> /dev/stderr
25
                        exit    1
26
                        ;;
27
                *)
28
                        infile="$1"
29
                        ;;
30
        esac; shift
31
done
32
 
33
if ! [ -n "$infile" ] || ! [ -f "$infile" ]; then
34
        echo "$0: error: input file is missing or not found." >> /dev/stderr
35
        exit    1
36
fi
37
 
38
nword=$((1<<depth))
39
 
40
cat "$infile" /dev/zero | \
41
head -c $((2*nword)) | \
42
hexdump -v -e '/2 "%.4x\n"' | \
43
awk -v f=0 -v i=0 -v n=0 -v nword=$nword -v depth=$depth -v name=$name \
44
 'BEGIN \
45
  {     printf("module %s\n",name);
46
        printf("#(      parameter       flash_width = %d\n",depth);
47
        printf(" )\n");
48
        printf(" (      input           clk,\n");
49
        printf("        input           mem_ce,\n");
50
        printf("        input   [flash_width-1:0] mem_a,\n");
51
        printf("        output  [15:0]  mem_d\n");
52
        printf(" );\n");
53
        printf("reg [15:0] flash_array [0:2**flash_width-1];\n");
54
        printf("reg [15:0] data_read;\n");
55
        printf("assign mem_d = data_read;\n");
56
        printf("always @(posedge clk) begin\n");
57
        printf("        if (mem_ce) data_read <= flash_array[mem_a];\n");
58
        printf("end\n");
59
        printf("initial begin\n");
60
  } \
61
  {     printf("        flash_array[%d]=16%ch%s;\n",n,39,$1);n++;
62
  } \
63
 END \
64
  {     printf("end\n");
65
        printf("endmodule\n");
66
  }'
67
 

powered by: WebSVN 2.1.0

© copyright 1999-2022 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.