-
Notifications
You must be signed in to change notification settings - Fork 3
/
DAC.v
78 lines (65 loc) · 2.16 KB
/
DAC.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
`timescale 1 ns / 1 ps
module axis_red_pitaya_dac #
(
parameter integer DAC_DATA_WIDTH = 14,
parameter integer AXIS_TDATA_WIDTH = 14
)
(
// PLL signals
input wire aclk,
input wire ddr_clk,
input wire locked,
// DAC signals
output wire dac_clk,
output wire dac_rst,
output wire dac_sel,
output wire dac_wrt,
output wire [DAC_DATA_WIDTH-1:0] dac_dat,
// Slave side
output wire s_axis_tready,
input wire [AXIS_TDATA_WIDTH-1:0] output_a,
input wire [AXIS_TDATA_WIDTH-1:0] output_b,
input wire s_axis_tvalid
);
reg [DAC_DATA_WIDTH-1:0] int_dat_a_reg;
reg [DAC_DATA_WIDTH-1:0] int_dat_b_reg;
reg int_rst_reg;
wire [DAC_DATA_WIDTH-1:0] int_dat_a_wire;
wire [DAC_DATA_WIDTH-1:0] int_dat_b_wire;
assign int_dat_a_wire = output_a;
assign int_dat_b_wire = output_b;
genvar j;
always @(posedge aclk)
begin
if(~locked | ~s_axis_tvalid)
begin
int_dat_a_reg <= {(DAC_DATA_WIDTH){1'b0}};
int_dat_b_reg <= {(DAC_DATA_WIDTH){1'b0}};
end
else
begin
int_dat_a_reg <= {int_dat_a_wire[DAC_DATA_WIDTH-1], ~int_dat_a_wire[DAC_DATA_WIDTH-2:0]};
int_dat_b_reg <= {int_dat_b_wire[DAC_DATA_WIDTH-1], ~int_dat_b_wire[DAC_DATA_WIDTH-2:0]};
end
int_rst_reg <= ~locked | ~s_axis_tvalid;
end
ODDR ODDR_rst(.Q(dac_rst), .D1(int_rst_reg), .D2(int_rst_reg), .C(aclk), .CE(1'b1), .R(1'b0), .S(1'b0));
ODDR ODDR_sel(.Q(dac_sel), .D1(1'b0), .D2(1'b1), .C(aclk), .CE(1'b1), .R(1'b0), .S(1'b0));
ODDR ODDR_wrt(.Q(dac_wrt), .D1(1'b0), .D2(1'b1), .C(ddr_clk), .CE(1'b1), .R(1'b0), .S(1'b0));
ODDR ODDR_clk(.Q(dac_clk), .D1(1'b0), .D2(1'b1), .C(ddr_clk), .CE(1'b1), .R(1'b0), .S(1'b0));
generate
for(j = 0; j < DAC_DATA_WIDTH; j = j + 1)
begin : DAC_DAT
ODDR ODDR_inst(
.Q(dac_dat[j]),
.D1(int_dat_a_reg[j]),
.D2(int_dat_b_reg[j]),
.C(aclk),
.CE(1'b1),
.R(1'b0),
.S(1'b0)
);
end
endgenerate
assign s_axis_tready = 1'b1;
endmodule