x393  1.0
FPGAcodeforElphelNC393camera
table_ad_transmit.v
Go to the documentation of this file.
1 
41 `timescale 1ns/1ps
42 
44  parameter NUM_CHANNELS = 1,
45  parameter ADDR_BITS=4
46 )(
47  input clk, // posedge mclk
48  input srst, // reset @posedge clk
49  input a_not_d_in, // address/not data input (valid @ we)
50  input we, // write address/data (single cycle) with at least 5 inactive between
51  input [31:0] din, // 32 bit data to send or 8-bit channel select concatenated with 24-bit byte address (@we)
52  output [ 7:0] ser_d, // 8-bit address/data to be sent to submodules that have table write port(s), LSB first
53  output reg a_not_d, // sending adderass / not data - valid during all bytes
54  output reg [NUM_CHANNELS-1:0] chn_en // sending address or data
55 );
56  wire [NUM_CHANNELS-1:0] sel;
57  reg [31:0] d_r;
58  reg any_en;
59  reg [ADDR_BITS-1:0] sel_a;
60  reg we_r;
61  wire we3;
62 
63  assign ser_d = d_r[7:0];
64 
65  always @ (posedge clk) begin
66  if (we) d_r <= din;
67  else if (any_en) d_r <= d_r >> 8;
68 
69  if (we) a_not_d <= a_not_d_in;
70 
71  we_r <= we && a_not_d_in;
72 
73  if (srst) any_en <= 0;
74  else if ((we && !a_not_d_in) || we_r) any_en <= 1;
75  else if (we3) any_en <= 0;
76 
77  if (srst) chn_en <= 0;
78  else if ((we && !a_not_d_in) || we_r) chn_en <= sel;
79  else if (we3) chn_en <= 0;
80 
81  if (we && a_not_d_in) sel_a <= din[24+:ADDR_BITS];
82 
83  end
84 // dly_16 #(.WIDTH(1)) i_end_burst(.clk(clk),.rst(1'b0), .dly(4'd2), .din(we), .dout(we3)); // dly=2+1=3
85  dly_16 #(.WIDTH(1)) i_end_burst(.clk(clk),.rst(1'b0), .dly(4'd3), .din(we), .dout(we3)); // dly=3+1=4
86 
87  genvar i;
88  generate
89  for (i = 0; i < NUM_CHANNELS; i = i + 1) begin : gsel
90  assign sel[i] = sel_a == i;
91  end
92  endgenerate
93 
94 endmodule
95 
10332clk
Definition: dly_16.v:44
11068selwire[NUM_CHANNELS-1:0]
11071sel_areg[ADDR_BITS-1:0]
[WIDTH-1:0] 10336dout
Definition: dly_16.v:48
[WIDTH-1:0] 10335din
Definition: dly_16.v:47
reg [NUM_CHANNELS-1:0] 11067chn_en
10333rst
Definition: dly_16.v:45
[3:0] 10334dly
Definition: dly_16.v:46