x393  1.0
FPGAcodeforElphelNC393camera
timestamp_to_serial.v
Go to the documentation of this file.
1 
39 `timescale 1ns/1ps
40 
42  input clk, // clock that drives time counters
43  input stb, // serialize and send timestamp message
44  input [31:0] sec, // time seconds
45  input [19:0] usec, // time microseconds
46  output reg [7:0] tdata // byte-parallel timestamp data sent right after stb input
47 );
48  reg [2:0] cntr;
49  reg busy = 0;
50  wire [2:0] cntr_w;
51  assign cntr_w= stb? 3'b0 : cntr;
52  always @ (posedge clk) begin
53  if (stb) busy <= 1;
54  else if (&cntr_w[2:1]) busy <= 0;
55  if (stb) cntr <= 1;
56  else if (busy) cntr <= cntr + 1;
57 
58  case (cntr_w)
59  3'h0:tdata <= sec[ 7: 0];
60  3'h1:tdata <= sec[15: 8];
61  3'h2:tdata <= sec[23:16];
62  3'h3:tdata <= sec[31:24];
63  3'h4:tdata <= usec[ 7: 0];
64  3'h5:tdata <= usec[15: 8];
65  3'h6:tdata <= {4'h0,usec[19:16]};
66  3'h7:tdata <= 8'h0;
67  endcase
68  end
69 
70 endmodule
71