DDS module and test bench finished

This commit is contained in:
Imants Pulkstenis
2020-04-01 21:35:27 +03:00
parent c8581dbe68
commit 1598022c70
6 changed files with 246 additions and 67 deletions
+44 -22
View File
@@ -1,26 +1,48 @@
module lookuptable(
input [7 :0] in,
output reg [7 :0] out);
reg [7 :0] out = 8'h0;
module lookuptable #( parameter phase_width = 4, data_width = 8)(
input [phase_width - 1 :0] phase,
output reg [data_width - 1 :0] sin,
output reg [data_width - 1 :0] cos);
always@* begin
case (in)
8'd0 : out <= 8'b00000000;
8'd1 : out <= 8'b00011001;
8'd2 : out <= 8'b00101101;
8'd3 : out <= 8'b00111011;
8'd4 : out <= 8'b01000000;
8'd5 : out <= 8'b00111011;
8'd6 : out <= 8'b00101101;
8'd7 : out <= 8'b00011001;
8'd8 : out <= 8'b00000000;
8'd9 : out <= 8'b11101000;
8'd10 : out <= 8'b11010011;
8'd11 : out <= 8'b11000101;
8'd12 : out <= 8'b11000000;
8'd13 : out <= 8'b11000101;
8'd14 : out <= 8'b11010011;
8'd15 : out <= 8'b11101000;
default : out <= 8'b00000000;
case (phase[phase_width - 1 : 0])
4'd0 : sin[data_width - 1 : 0] <= 8'b00000000;
4'd1 : sin[data_width - 1 : 0] <= 8'b00011001;
4'd2 : sin[data_width - 1 : 0] <= 8'b00101101;
4'd3 : sin[data_width - 1 : 0] <= 8'b00111011;
4'd4 : sin[data_width - 1 : 0] <= 8'b01000000;
4'd5 : sin[data_width - 1 : 0] <= 8'b00111011;
4'd6 : sin[data_width - 1 : 0] <= 8'b00101101;
4'd7 : sin[data_width - 1 : 0] <= 8'b00011001;
4'd8 : sin[data_width - 1 : 0] <= 8'b00000000;
4'd9 : sin[data_width - 1 : 0] <= 8'b11101000;
4'd10 : sin[data_width - 1 : 0] <= 8'b11010011;
4'd11 : sin[data_width - 1 : 0] <= 8'b11000101;
4'd12 : sin[data_width - 1 : 0] <= 8'b11000000;
4'd13 : sin[data_width - 1 : 0] <= 8'b11000101;
4'd14 : sin[data_width - 1 : 0] <= 8'b11010011;
4'd15 : sin[data_width - 1 : 0] <= 8'b11101000;
default : sin[data_width - 1 : 0] <= 8'b00000000;
endcase
end
always@* begin
case (phase[phase_width - 1 : 0])
4'd0 : cos[data_width - 1 : 0] <= 8'b01000000;
4'd1 : cos[data_width - 1 : 0] <= 8'b00111011;
4'd2 : cos[data_width - 1 : 0] <= 8'b00101101;
4'd3 : cos[data_width - 1 : 0] <= 8'b00011001;
4'd4 : cos[data_width - 1 : 0] <= 8'b00000000;
4'd5 : cos[data_width - 1 : 0] <= 8'b11101000;
4'd6 : cos[data_width - 1 : 0] <= 8'b11010011;
4'd7 : cos[data_width - 1 : 0] <= 8'b11000101;
4'd8 : cos[data_width - 1 : 0] <= 8'b11000000;
4'd9 : cos[data_width - 1 : 0] <= 8'b11000101;
4'd10 : cos[data_width - 1 : 0] <= 8'b11010011;
4'd11 : cos[data_width - 1 : 0] <= 8'b11101000;
4'd12 : cos[data_width - 1 : 0] <= 8'b00000000;
4'd13 : cos[data_width - 1 : 0] <= 8'b00011001;
4'd14 : cos[data_width - 1 : 0] <= 8'b00101101;
4'd15 : cos[data_width - 1 : 0] <= 8'b00111011;
default : cos[data_width - 1 : 0] <= 8'b01000000;
endcase
end
endmodule