x393  1.0
FPGAcodeforElphelNC393camera
simul_axi_fifo_out.v
Go to the documentation of this file.
1 
39 
40 `timescale 1ns/1ps
41 
43 #(
44  parameter integer WIDTH= 64, // total number of output bits
45  parameter integer LATENCY=0, // minimal delay between inout and output ( 0 - next cycle)
46  parameter integer DEPTH=8, // maximal number of commands in FIFO
47 // parameter OUT_DELAY = 3.5,
48  parameter integer FIFO_DEPTH=LATENCY+DEPTH+1
49 // parameter integer DATA_2DEPTH=(1<<DATA_DEPTH)-1
50 )(
51  input clk,
52  input reset,
53  input [WIDTH-1:0] data_in,
54  input load,
55  output input_ready,
56  output [WIDTH-1:0] data_out,
57  output valid,
58  input ready);
59 
60  reg [WIDTH-1:0] fifo [0:FIFO_DEPTH-1];
61  integer in_address;
62  integer out_address;
63  integer in_count;
64  integer out_count;
66 
69  wire load_and_ready = load & input_ready_w; // Masked load with input_ready 07/06/2016
71 
72  assign data_out= fifo[out_address];
73  assign valid= out_count!=0;
74 
75  assign input_ready= input_ready_w;
76 // assign out_inc={
77 
78  always @ (posedge clk or posedge reset) begin
79  if (reset) latency_delay_r <= 0;
81 
82  if (reset) in_address <= 0;
84 
85  if (reset) out_address <= 0;
86  else if (valid && ready) out_address <= (out_address==(FIFO_DEPTH-1))?0:out_address+1;
87 
88  if (reset) in_count <= 0;
89  else if (!(valid && ready) && load_and_ready) in_count <= in_count+1;
90  else if (valid && ready && !load_and_ready) in_count <= in_count-1;
91 
92  if (reset) out_count <= 0;
93  else if (!(valid && ready) && out_inc) out_count <= out_count+1;
94  else if (valid && ready && !out_inc) out_count <= out_count-1;
95  end
96  always @ (posedge clk) begin
98  end
99 
100 endmodule
[0:FIFO_DEPTH-1] 8858fiforeg[WIDTH-1:0]
[WIDTH-1:0] 8852data_in
integer 8849FIFO_DEPTHLATENCY+DEPTH+1
[WIDTH-1:0] 8855data_out
8867latency_delaywire[LATENCY+1:0]
8863latency_delay_rreg[LATENCY:0]