User`s manual

236 end
237 X_READ: begin
238 pts_start = (count == 5’d1) ? 1 : 0;
239 par_in = (count == 5’d1) ? 8’hF2 : 0; // 1 for R, 1 for MB
240 ma_x_in_ready = (count == 5’d25) ? 1 : 0;
241 ma_x_in = (count == 5’d25) ? {par_out, x_low_bits} : 0;
242 ma_y_in_ready = 0; ma_y_in = 0;
243 ncs_reg = (count == 5’d25) ? 1 : 0;
244 end
245 Y_READ: begin
246 pts_start = (count == 5’d1) ? 1 : 0;
247 par_in = (count == 5’d1) ? 8’hF4 : 0; // 1 for R, 1 for MB
248 ma_y_in_ready = (count == 5’d25) ? 1 : 0;
249 ma_y_in = (count == 5’d25) ? {par_out, y_low_bits} : 0;
250 ma_x_in_ready = 0; ma_x_in = 0;
251 ncs_reg = (count == 5’d25) ? 1 : 0;
252 end
253 endcase
254 end
255
256
257 assign scl = (ncs_reg == 1 || (state == MEASURE_INIT && count == 5’d1
258 || state != MEASURE_INIT && count == 5’d0)) ? 1 : dev_clk;
259 assign ncs = ncs_reg;
260 assign ready = ma_x_avg_ready && ma_y_avg_ready;
261 assign x = ma_x_avg;
262 assign y = ma_y_avg;
263 endmodule
A.3.2 accel lut.v
1 ////////////////////////////////////////////////////////////////////////////////
2 //This file was autogenerated by accel_lut.jl.
3 //DO NOT MANUALLY EDIT THIS FILE!!!
4
5 //This file implements accel_lut rom for lookup of quadrilateral corners
6 //based on accelerometer readings
7 ////////////////////////////////////////////////////////////////////////////////
8
9 module accel_lut(input clk, input[11:0] accel_val, output reg[75:0] quad_corners);
10 always @(posedge clk) begin
11 case (accel_val)
12 12’d0: quad_corners = 76’d166903815503556664320;
13 12’d1: quad_corners = 76’d166903815503556664320;
14 12’d2: quad_corners = 76’d166903815503556664320;
15 12’d3: quad_corners = 76’d166903815503556664320;
126