x393  1.0
FPGAcodeforElphelNC393camera
cmd_encod_tiled_rw.v
Go to the documentation of this file.
1 
39 `timescale 1ns/1ps
40 
42  parameter ADDRESS_NUMBER= 15,
43  parameter COLADDR_NUMBER= 10,
44  parameter CMD_PAUSE_BITS= 10,
45  parameter CMD_DONE_BIT= 10, // VDT BUG: CMD_DONE_BIT is used in a function call parameter!
46  parameter FRAME_WIDTH_BITS= 13, // Maximal frame width - 8-word (16 bytes) bursts
47  parameter RSEL= 1'b1, // late/early READ commands (to adjust timing by 1 SDCLK period)
48  parameter WSEL= 1'b0 // late/early WRITE commands (to adjust timing by 1 SDCLK period)
49 ) (
50  input mrst,
51  input clk,
52 // programming interface
53  input [2:0] start_bank, // bank address
54  input [ADDRESS_NUMBER-1:0] start_row, // memory row
55  input [COLADDR_NUMBER-4:0] start_col, // start memory column in 8-bit bursts
56  input [FRAME_WIDTH_BITS:0] rowcol_inc_in, // increment {row.col} when bank rolls over, removed 3 LSBs (in 8-bursts)
57  input [5:0] num_rows_in_m1, // number of rows to read minus 1
58  input [5:0] num_cols_in_m1, // number of 16-pixel columns to read (rows first, then columns) - 1
59  input keep_open_in, // keep banks open (for <=8 banks only
60  input skip_next_page_in, // do not reset external buffer (continue)
61  input start_rd, // start generating commands by cmd_encod_linear_rd
62  input start_wr, // start generating commands by cmd_encod_linear_wr
63  output reg start, // this channel was started (1 clk from start_rd || start_wr
64  output reg [31:0] enc_cmd, // encoded command
65  output reg enc_wr, // write encoded command
66  output reg enc_done // encoding finished
67 );
68  wire [31:0] enc_cmd_rd; // encoded command
69  wire enc_wr_rd; // write encoded command
70  wire enc_done_rd; // encoding finished
71  wire [31:0] enc_cmd_wr; // encoded command
72  wire enc_wr_wr; // write encoded command
73  wire enc_done_wr; // encoding finished
74  reg select_wr;
75 
81  .RSEL (RSEL)
82  ) cmd_encod_tiled_rd_i (
83  .mrst (mrst), // input
84  .clk (clk), // input
85  .start_bank (start_bank), // input[2:0]
86  .start_row (start_row), // input[14:0]
87  .start_col (start_col), // input[6:0]
88  .rowcol_inc_in (rowcol_inc_in), // input[13:0] // [21:0]
89  .num_rows_in_m1 (num_rows_in_m1), // input[5:0]
90  .num_cols_in_m1 (num_cols_in_m1), // input[5:0]
91  .keep_open_in (keep_open_in), // input
93 
94  .start (start_rd), // input
95  .enc_cmd (enc_cmd_rd), // output[31:0] reg
96  .enc_wr (enc_wr_rd), // output reg
97  .enc_done (enc_done_rd) // output reg
98  );
99 
105  .WSEL (WSEL)
106  ) cmd_encod_tiled_wr_i (
107  .mrst (mrst), // input
108  .clk (clk), // input
109  .start_bank (start_bank), // input[2:0]
110  .start_row (start_row), // input[14:0]
111  .start_col (start_col), // input[6:0]
112  .rowcol_inc_in (rowcol_inc_in), // input[13:0] // [21:0]
113  .num_rows_in_m1 (num_rows_in_m1), // input[5:0]
114  .num_cols_in_m1 (num_cols_in_m1), // input[5:0]
115  .keep_open_in (keep_open_in), // input
117 
118  .start (start_wr), // input
119  .enc_cmd (enc_cmd_wr), // output[31:0] reg
120  .enc_wr (enc_wr_wr), // output reg
121  .enc_done (enc_done_wr) // output reg
122  );
123 
124  always @(posedge clk) begin
125  if (mrst) start <= 0;
126  else start <= start_rd || start_wr;
127 
128  if (mrst) select_wr <= 0;
129  else if (start_rd) select_wr <= 0;
130  else if (start_wr) select_wr <= 1;
131  end
132  always @(posedge clk) begin
136  end
137 
138 endmodule
139 
[ADDRESS_NUMBER-1:0] 4477start_row
[ADDRESS_NUMBER-1:0] 4448start_row
cmd_encod_tiled_wr_i cmd_encod_tiled_wr
cmd_encod_tiled_rd_i cmd_encod_tiled_rd
[FRAME_WIDTH_BITS:0] 4378rowcol_inc_in
[COLADDR_NUMBER-4:0] 4449start_col
[COLADDR_NUMBER-4:0] 4377start_col
[FRAME_WIDTH_BITS:0] 4479rowcol_inc_in
[FRAME_WIDTH_BITS:0] 4450rowcol_inc_in
[ADDRESS_NUMBER-1:0] 4376start_row
[COLADDR_NUMBER-4:0] 4478start_col