Skip to content

Commit 5008999

Browse files
committed
up_adc_common: Add register data reading/writing functionality
1 parent 775a23e commit 5008999

File tree

1 file changed

+45
-6
lines changed

1 file changed

+45
-6
lines changed

library/common/up_adc_common.v

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,14 @@ module up_adc_common #(
101101
input up_drp_ready,
102102
input up_drp_locked,
103103

104+
// ADC custom read/write interface
105+
106+
output [31:0] adc_custom_wr,
107+
output adc_write_req,
108+
input [31:0] adc_custom_rd,
109+
input adc_read_valid,
110+
output adc_read_req,
111+
104112
// user channel control
105113

106114
output [ 7:0] up_usr_chanmax_out,
@@ -156,11 +164,15 @@ module up_adc_common #(
156164
reg [31:0] up_rdata_int = 'd0;
157165
reg [ 7:0] up_adc_custom_control = 'd0;
158166
reg up_adc_crc_enable = 'd0;
167+
reg [31:0] up_adc_custom_wr = 'd0;
159168

160169
// internal signals
161170

162171
wire up_wreq_s;
163172
wire up_rreq_s;
173+
wire up_rack_s;
174+
wire up_write_req;
175+
wire up_read_req;
164176
wire up_status_s;
165177
wire up_sync_status_s;
166178
wire up_status_ovf_s;
@@ -169,6 +181,8 @@ module up_adc_common #(
169181
wire up_drp_status_s;
170182
wire up_drp_rwn_s;
171183
wire [31:0] up_drp_rdata_hold_s;
184+
wire up_adc_read_valid;
185+
wire [31:0] up_adc_custom_rd;
172186

173187
wire adc_rst_n;
174188
wire adc_rst_s;
@@ -177,6 +191,9 @@ module up_adc_common #(
177191

178192
assign up_wreq_s = (up_waddr[13:7] == {COMMON_ID,1'b0}) ? up_wreq : 1'b0;
179193
assign up_rreq_s = (up_raddr[13:7] == {COMMON_ID,1'b0}) ? up_rreq : 1'b0;
194+
assign up_rack_s = (up_raddr[6:0] == 7'h21) ? up_adc_read_valid : up_rreq_s;
195+
assign up_write_req = (up_waddr[6:0] == 7'h20) ? up_wreq : 1'b0;
196+
assign up_read_req = (up_raddr[6:0] == 7'h21) ? up_rreq : 1'b0;
180197

181198
// processor write interface
182199

@@ -335,6 +352,16 @@ module up_adc_common #(
335352
end
336353
endgenerate
337354

355+
always @(posedge up_clk) begin
356+
if (up_rstn == 0) begin
357+
up_adc_custom_wr <= 'd0;
358+
end else begin
359+
if ((up_wreq_s == 1'b1) && (up_waddr[6:0] == 7'h20)) begin
360+
up_adc_custom_wr <= up_wdata;
361+
end
362+
end
363+
end
364+
338365
always @(posedge up_clk) begin
339366
if (up_rstn == 0) begin
340367
up_status_ovf <= 'd0;
@@ -429,8 +456,8 @@ module up_adc_common #(
429456
up_rack_int <= 'd0;
430457
up_rdata_int <= 'd0;
431458
end else begin
432-
up_rack_int <= up_rreq_s;
433-
if (up_rreq_s == 1'b1) begin
459+
up_rack_int <= up_rack_s;
460+
if (up_rack_s == 1'b1) begin
434461
case (up_raddr[6:0])
435462
7'h00: up_rdata_int <= VERSION;
436463
7'h01: up_rdata_int <= ID;
@@ -457,6 +484,8 @@ module up_adc_common #(
457484
7'h1d: up_rdata_int <= {14'd0, up_drp_locked, up_drp_status_s, 16'b0};
458485
7'h1e: up_rdata_int <= up_drp_wdata;
459486
7'h1f: up_rdata_int <= up_drp_rdata_hold_s;
487+
7'h20: up_rdata_int <= up_adc_custom_wr;
488+
7'h21: up_rdata_int <= up_adc_custom_rd;
460489
7'h22: up_rdata_int <= {29'd0, up_status_ovf, 2'b0};
461490
7'h23: up_rdata_int <= 32'd8;
462491
7'h28: up_rdata_int <= {24'd0, up_usr_chanmax_in};
@@ -491,7 +520,7 @@ module up_adc_common #(
491520
// adc control & status
492521

493522
up_xfer_cntrl #(
494-
.DATA_WIDTH(58)
523+
.DATA_WIDTH(92)
495524
) i_xfer_cntrl (
496525
.up_rstn (up_rstn),
497526
.up_clk (up_clk),
@@ -506,6 +535,9 @@ module up_adc_common #(
506535
up_adc_ext_sync_disarm,
507536
up_adc_ext_sync_manual_req,
508537
up_adc_sync,
538+
up_write_req,
539+
up_read_req,
540+
up_adc_custom_wr,
509541
up_adc_start_code,
510542
up_adc_r1_mode,
511543
up_adc_ddr_edgesel,
@@ -525,6 +557,9 @@ module up_adc_common #(
525557
adc_ext_sync_disarm,
526558
adc_ext_sync_manual_req,
527559
adc_sync,
560+
adc_write_req,
561+
adc_read_req,
562+
adc_custom_wr,
528563
adc_start_code,
529564
adc_r1_mode,
530565
adc_ddr_edgesel,
@@ -538,18 +573,22 @@ module up_adc_common #(
538573
assign adc_rst = ~adc_rst_n;
539574

540575
up_xfer_status #(
541-
.DATA_WIDTH(3)
576+
.DATA_WIDTH(36)
542577
) i_xfer_status (
543578
.up_rstn (up_rstn),
544579
.up_clk (up_clk),
545580
.up_data_status ({up_sync_status_s,
546581
up_status_s,
547-
up_status_ovf_s}),
582+
up_status_ovf_s,
583+
up_adc_read_valid,
584+
up_adc_custom_rd}),
548585
.d_rst (adc_rst_s),
549586
.d_clk (adc_clk),
550587
.d_data_status ({ adc_sync_status,
551588
adc_status,
552-
adc_status_ovf}));
589+
adc_status_ovf,
590+
adc_read_valid,
591+
adc_custom_rd}));
553592

554593
// adc clock monitor
555594

0 commit comments

Comments
 (0)