File tree Expand file tree Collapse file tree 4 files changed +427
-0
lines changed
ascii_hex_writer_examples Expand file tree Collapse file tree 4 files changed +427
-0
lines changed Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env python
2
+ # coding: utf-8
3
+
4
+ # author: Konstantin Pavlov
5
+ # email: pavlovconst@gmail.com
6
+
7
+ # boilerplate script to generate ASCII hex files to initialize RAMs in Verilog
8
+
9
+ import math
10
+ import os
11
+
12
+ # settings =====================================================================
13
+ N = 128
14
+ tablename = "sin"
15
+ filename = tablename + ".hex"
16
+
17
+ # main =========================================================================
18
+ if os .path .exists (filename ):
19
+ os .remove (filename )
20
+ print ("Old file version removed" )
21
+
22
+ f = open (filename , "x" )
23
+ f .write ("// ascii hex file for " + tablename + " function\n \n " )
24
+
25
+ for i in range (0 , N ):
26
+ # computing and scaling
27
+ rad = math .pi / 4 / N * i
28
+ val = math .floor (math .sin (rad ) * 256 )
29
+ # formatting to HEX string of specified length
30
+ val_str = format (val , "#06x" )
31
+ # additional prefix
32
+ prefix_str = format (i , "#04x" )
33
+ # cutting '0x' prefix away
34
+ f .write (prefix_str [2 :] + "_" + val_str [2 :] + "\n " )
35
+
36
+ f .close ()
37
+
Original file line number Diff line number Diff line change
1
+ // ascii hex file for cos function
2
+
3
+ 00_0100
4
+ 01_00ff
5
+ 02_00ff
6
+ 03_00ff
7
+ 04_00ff
8
+ 05_00ff
9
+ 06_00ff
10
+ 07_00ff
11
+ 08_00ff
12
+ 09_00ff
13
+ 0a_00ff
14
+ 0b_00ff
15
+ 0c_00ff
16
+ 0d_00ff
17
+ 0e_00ff
18
+ 0f_00fe
19
+ 10_00fe
20
+ 11_00fe
21
+ 12_00fe
22
+ 13_00fe
23
+ 14_00fe
24
+ 15_00fd
25
+ 16_00fd
26
+ 17_00fd
27
+ 18_00fd
28
+ 19_00fc
29
+ 1a_00fc
30
+ 1b_00fc
31
+ 1c_00fc
32
+ 1d_00fb
33
+ 1e_00fb
34
+ 1f_00fb
35
+ 20_00fb
36
+ 21_00fa
37
+ 22_00fa
38
+ 23_00fa
39
+ 24_00f9
40
+ 25_00f9
41
+ 26_00f9
42
+ 27_00f8
43
+ 28_00f8
44
+ 29_00f7
45
+ 2a_00f7
46
+ 2b_00f7
47
+ 2c_00f6
48
+ 2d_00f6
49
+ 2e_00f5
50
+ 2f_00f5
51
+ 30_00f4
52
+ 31_00f4
53
+ 32_00f4
54
+ 33_00f3
55
+ 34_00f3
56
+ 35_00f2
57
+ 36_00f2
58
+ 37_00f1
59
+ 38_00f1
60
+ 39_00f0
61
+ 3a_00ef
62
+ 3b_00ef
63
+ 3c_00ee
64
+ 3d_00ee
65
+ 3e_00ed
66
+ 3f_00ed
67
+ 40_00ec
68
+ 41_00eb
69
+ 42_00eb
70
+ 43_00ea
71
+ 44_00ea
72
+ 45_00e9
73
+ 46_00e8
74
+ 47_00e8
75
+ 48_00e7
76
+ 49_00e6
77
+ 4a_00e6
78
+ 4b_00e5
79
+ 4c_00e4
80
+ 4d_00e3
81
+ 4e_00e3
82
+ 4f_00e2
83
+ 50_00e1
84
+ 51_00e1
85
+ 52_00e0
86
+ 53_00df
87
+ 54_00de
88
+ 55_00dd
89
+ 56_00dd
90
+ 57_00dc
91
+ 58_00db
92
+ 59_00da
93
+ 5a_00d9
94
+ 5b_00d9
95
+ 5c_00d8
96
+ 5d_00d7
97
+ 5e_00d6
98
+ 5f_00d5
99
+ 60_00d4
100
+ 61_00d3
101
+ 62_00d3
102
+ 63_00d2
103
+ 64_00d1
104
+ 65_00d0
105
+ 66_00cf
106
+ 67_00ce
107
+ 68_00cd
108
+ 69_00cc
109
+ 6a_00cb
110
+ 6b_00ca
111
+ 6c_00c9
112
+ 6d_00c8
113
+ 6e_00c7
114
+ 6f_00c6
115
+ 70_00c5
116
+ 71_00c4
117
+ 72_00c3
118
+ 73_00c2
119
+ 74_00c1
120
+ 75_00c0
121
+ 76_00bf
122
+ 77_00be
123
+ 78_00bd
124
+ 79_00bc
125
+ 7a_00bb
126
+ 7b_00ba
127
+ 7c_00b9
128
+ 7d_00b8
129
+ 7e_00b7
130
+ 7f_00b6
Original file line number Diff line number Diff line change
1
+ // ascii hex file for linear function
2
+
3
+ 00_0000
4
+ 01_0001
5
+ 02_0002
6
+ 03_0003
7
+ 04_0004
8
+ 05_0005
9
+ 06_0006
10
+ 07_0007
11
+ 08_0008
12
+ 09_0009
13
+ 0a_000a
14
+ 0b_000b
15
+ 0c_000c
16
+ 0d_000d
17
+ 0e_000e
18
+ 0f_000f
19
+ 10_0010
20
+ 11_0011
21
+ 12_0012
22
+ 13_0013
23
+ 14_0014
24
+ 15_0015
25
+ 16_0016
26
+ 17_0017
27
+ 18_0018
28
+ 19_0019
29
+ 1a_001a
30
+ 1b_001b
31
+ 1c_001c
32
+ 1d_001d
33
+ 1e_001e
34
+ 1f_001f
35
+ 20_0020
36
+ 21_0021
37
+ 22_0022
38
+ 23_0023
39
+ 24_0024
40
+ 25_0025
41
+ 26_0026
42
+ 27_0027
43
+ 28_0028
44
+ 29_0029
45
+ 2a_002a
46
+ 2b_002b
47
+ 2c_002c
48
+ 2d_002d
49
+ 2e_002e
50
+ 2f_002f
51
+ 30_0030
52
+ 31_0031
53
+ 32_0032
54
+ 33_0033
55
+ 34_0034
56
+ 35_0035
57
+ 36_0036
58
+ 37_0037
59
+ 38_0038
60
+ 39_0039
61
+ 3a_003a
62
+ 3b_003b
63
+ 3c_003c
64
+ 3d_003d
65
+ 3e_003e
66
+ 3f_003f
67
+ 40_0040
68
+ 41_0041
69
+ 42_0042
70
+ 43_0043
71
+ 44_0044
72
+ 45_0045
73
+ 46_0046
74
+ 47_0047
75
+ 48_0048
76
+ 49_0049
77
+ 4a_004a
78
+ 4b_004b
79
+ 4c_004c
80
+ 4d_004d
81
+ 4e_004e
82
+ 4f_004f
83
+ 50_0050
84
+ 51_0051
85
+ 52_0052
86
+ 53_0053
87
+ 54_0054
88
+ 55_0055
89
+ 56_0056
90
+ 57_0057
91
+ 58_0058
92
+ 59_0059
93
+ 5a_005a
94
+ 5b_005b
95
+ 5c_005c
96
+ 5d_005d
97
+ 5e_005e
98
+ 5f_005f
99
+ 60_0060
100
+ 61_0061
101
+ 62_0062
102
+ 63_0063
103
+ 64_0064
104
+ 65_0065
105
+ 66_0066
106
+ 67_0067
107
+ 68_0068
108
+ 69_0069
109
+ 6a_006a
110
+ 6b_006b
111
+ 6c_006c
112
+ 6d_006d
113
+ 6e_006e
114
+ 6f_006f
115
+ 70_0070
116
+ 71_0071
117
+ 72_0072
118
+ 73_0073
119
+ 74_0074
120
+ 75_0075
121
+ 76_0076
122
+ 77_0077
123
+ 78_0078
124
+ 79_0079
125
+ 7a_007a
126
+ 7b_007b
127
+ 7c_007c
128
+ 7d_007d
129
+ 7e_007e
130
+ 7f_007f
You can’t perform that action at this time.
0 commit comments