x393  1.0
FPGAcodeforElphelNC393camera
table_ad_receive.v
Go to the documentation of this file.
1 
39 `timescale 1ns/1ps
40 
42  parameter MODE_16_BITS = 1,
43  parameter NUM_CHN = 1
44 )(
45  input clk, // posedge mclk
46  input a_not_d, // receiving adderass / not data - valid during all bytes
47  input [7:0] ser_d, // byte-wide address/data
48  input [NUM_CHN-1:0] dv, // data valid - active for each address or data bytes
49  output [23-MODE_16_BITS:0] ta, // table address
50  output [(MODE_16_BITS?15:7):0] td, // 8/16 bit table data, LSB first
51  output [NUM_CHN-1:0] twe // table write enable
52 );
53  reg [23:0] addr_r;
54  reg [NUM_CHN-1:0] twe_r;
55  reg [(MODE_16_BITS?15:7):0] td_r;
56 
57  assign td = td_r;
58  assign ta = MODE_16_BITS ? addr_r[23:1] : addr_r[23:0];
59 // assign twe = twe_r && (MODE_16_BITS ? addr_r[0]: 1'b1);
60  assign twe = (MODE_16_BITS ? addr_r[0]: 1'b1)? twe_r : {NUM_CHN{1'b0}} ;
61 
62  always @(posedge clk) begin
63 // twe_r <= en && !a_not_d;
64  twe_r <= a_not_d ? 0 : dv;
65  if ((|dv) && a_not_d) addr_r[23:0] <= {ser_d,addr_r[23:8]};
66  else if (|twe_r) addr_r[23:0] <= addr_r[23:0] + 1;
67  end
68  generate
69  if (MODE_16_BITS) always @ (posedge clk) td_r[15:0] <= {ser_d[7:0],td_r[15:8]}; //LSB received first
70  else always @ (posedge clk) td_r[ 7:0] <= ser_d[7:0];
71  endgenerate
72 
73 endmodule
74 
11057td_rreg[MODE_16_BITS?15:7:0]
[NUM_CHN-1:0] 11054twe
[MODE_16_BITS?15:7:0] 11053td
[23-MODE_16_BITS:0] 11052ta
11056twe_rreg[NUM_CHN-1:0]
[NUM_CHN-1:0] 11051dv