User`s manual

4110 endmodule
A.3.3 accel lut.jl
1 #=
2 This script generates an accel_lut.v file.
3 accel_lut.v contains a verilog implementation of a lookup table,
4 which takes in an accelerometer reading (6 bit x dir, 6 bit y dir),
5 and looks up a 76 bit value (4 corners of quadrilateral)
6 This script requires a input file accel_lut.txt containing data points.
7 It then interpolates the data points using 2D splines,
8 and creates the desired lookup table.
9
10 Format of accel_lut.txt:
11 x_accel, y_accel, x1, y1, x2, y2, x3, y3, x4, y4
12
13 i.e it is a csv file, each line denoting a reading
14 for ease of entry, all values are hex (just read off hex display)
15 leading zeros don’t have to be specified, but can be if desired
16
17 NOTE: accel_lut.v and accel_lut.txt are suggested names
18 General installation:
19 1) Install julia
20 2) open Julia interpreter, i.e julia at cmd line
21 3) install gfortran (gcc frontend for fortran), needed to compile interpolation package
22 4) install Dierckx (for the spline interpolation) by ‘Pkg.add("Dierckx")’ at julia prompt
23 5) Dierckx details (docs, installation help, etc): https://github.com/kbarbary/Dierckx.jl
24
25 General usage:
26 accel_lut(input_path, output_path) at julia prompt
27
28 input_path is path to the csv file, and output_path is path to the desired .v file
29 NOTE: in order to run the command, you first need to include this file, so type:
30 include("accel_lut.jl") at the julia prompt prior to running the above
31 NOTE: THIS CODE WILL OVERWRITE THE FILE AT OUTPUT_PATH!!!
32
33 Suggested usage:
34 accel_lut("./accel_lut.txt", "./accel_lut.v")
35 =#
36
37 using Dierckx # interpolation package
38
39 function read_file(path)
40 return readcsv(path, String)
41 end
42
216