x393  1.0
FPGAcodeforElphelNC393camera
mcntrl_buf_wr.v
Go to the documentation of this file.
1 
40 `timescale 1ns/1ps
41 
42 module mcntrl_buf_wr #(
43  parameter integer LOG2WIDTH_WR = 5 // WIDTH= 1 << LOG2WIDTH
44  ) (
45  input ext_clk,
46  input [14-LOG2WIDTH_WR:0] ext_waddr, // external write address
47  input ext_we, // external write enable
48  input [(1 << LOG2WIDTH_WR)-1:0] ext_data_in, // data input
49 
50  input rclk, // mclk
51  input [1:0] rpage_in, // will register to wclk, input OK with mclk
52  input rpage_set, // set internal read page to rpage_in
53  input page_next, // advance to next page (and reset lower bits to 0)
54  output [1:0] page, // current internal page
55  input rd, // read buffer to memory, increment read address (regester enable will be delayed)
56  output [63:0] data_out // data out
57 
58 );
59  reg [1:0] page_r;
60  reg [6:0] raddr;
61  reg regen;
62  assign page=page_r;
63  always @ (posedge rclk) begin
64  regen <= rd;
65 
66  if (rpage_set) page_r <= rpage_in;
67  else if (page_next) page_r <= page_r+1;
68 
69  if (page_next || rpage_set) raddr <= 0;
70  else if (rd) raddr <= raddr+1;
71  end
72 
74  .REGISTERS(1),
76  .LOG2WIDTH_RD(6)
77  ) ram_var_w_var_r_i (
78  .rclk (rclk), // input
79  .raddr ({page_r,raddr}), // input[8:0]
80  .ren (rd), // input
81  .regen (regen), // input
82  .data_out (data_out), // output[63:0]
83  .wclk (ext_clk), // input
84  .waddr (ext_waddr), // input[9:0]
85  .we (ext_we), // input
86  .web (8'hff), // input[3:0]
87  .data_in (ext_data_in) // input[31:0]
88  );
89 endmodule
90 
[1:0] 5204rpage_in
Definition: mcntrl_buf_wr.v:51
[1 << LOG2WIDTH_WR-1:0] 11872data_in
[14-LOG2WIDTH_WR:0] 11869waddr
5211raddrreg[6:0]
Definition: mcntrl_buf_wr.v:60
[63:0] 5209data_out
Definition: mcntrl_buf_wr.v:56
[1 << LOG2WIDTH_RD-1:0] 11867data_out
[14-LOG2WIDTH_RD:0] 11864raddr
ram_var_w_var_r_i ram_var_w_var_r
Definition: mcntrl_buf_wr.v:73
5210page_rreg[1:0]
Definition: mcntrl_buf_wr.v:59
[1:0] 5207page
Definition: mcntrl_buf_wr.v:54
[1 << LOG2WIDTH_WR-1:0] 5202ext_data_in
Definition: mcntrl_buf_wr.v:48
integer 5198LOG2WIDTH_WR5
Definition: mcntrl_buf_wr.v:43
[14-LOG2WIDTH_WR:0] 5200ext_waddr
Definition: mcntrl_buf_wr.v:46