URL
https://opencores.org/ocsvn/eco32/eco32/trunk
Go to most recent revision |
Only display areas with differences |
Details |
Blame |
View Log
Rev 288 |
Rev 290 |
//
|
//
|
// dac.v -- DAC control circuit
|
// dac.v -- DAC control circuit
|
//
|
//
|
|
|
|
|
`timescale 1ns/1ns
|
`timescale 1ns/1ns
|
|
`default_nettype none
|
|
|
|
|
module dac(clk, reset,
|
module dac(clk, reset,
|
sample_l, sample_r, next,
|
sample_l, sample_r, next,
|
mclk, sclk, lrck, sdti);
|
mclk, sclk, lrck, sdti);
|
input clk;
|
input clk;
|
input reset;
|
input reset;
|
input [15:0] sample_l;
|
input [15:0] sample_l;
|
input [15:0] sample_r;
|
input [15:0] sample_r;
|
output next;
|
output next;
|
output mclk;
|
output mclk;
|
output sclk;
|
output sclk;
|
output lrck;
|
output lrck;
|
output sdti;
|
output sdti;
|
|
|
reg [9:0] timing;
|
reg [9:0] timing;
|
reg [63:0] sr;
|
reg [63:0] sr;
|
wire shift;
|
wire shift;
|
|
|
always @(posedge clk) begin
|
always @(posedge clk) begin
|
if (reset) begin
|
if (reset) begin
|
timing <= 10'h0;
|
timing <= 10'h0;
|
end else begin
|
end else begin
|
timing <= timing + 1;
|
timing <= timing + 1;
|
end
|
end
|
end
|
end
|
|
|
assign mclk = timing[1];
|
assign mclk = timing[1];
|
assign sclk = timing[3];
|
assign sclk = timing[3];
|
assign lrck = timing[9];
|
assign lrck = timing[9];
|
|
|
assign next = (timing[9:0] == 10'h1FF) ? 1 : 0;
|
assign next = (timing[9:0] == 10'h1FF) ? 1 : 0;
|
assign shift = (timing[3:0] == 4'hF) ? 1 : 0;
|
assign shift = (timing[3:0] == 4'hF) ? 1 : 0;
|
|
|
always @(posedge clk) begin
|
always @(posedge clk) begin
|
if (reset) begin
|
if (reset) begin
|
sr <= 64'h0;
|
sr <= 64'h0;
|
end else begin
|
end else begin
|
if (next) begin
|
if (next) begin
|
sr[63:52] <= 12'h000;
|
sr[63:52] <= 12'h000;
|
sr[51:32] <= { sample_l[15:0], 4'h0 };
|
sr[51:32] <= { sample_l[15:0], 4'h0 };
|
sr[31:20] <= 12'h000;
|
sr[31:20] <= 12'h000;
|
sr[19: 0] <= { sample_r[15:0], 4'h0 };
|
sr[19: 0] <= { sample_r[15:0], 4'h0 };
|
end else begin
|
end else begin
|
if (shift) begin
|
if (shift) begin
|
sr[63:1] <= sr[62:0];
|
sr[63:1] <= sr[62:0];
|
sr[0] <= 1'b0;
|
sr[0] <= 1'b0;
|
end
|
end
|
end
|
end
|
end
|
end
|
end
|
end
|
|
|
assign sdti = sr[63];
|
assign sdti = sr[63];
|
|
|
endmodule
|
endmodule
|
|
|
© copyright 1999-2024
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.