-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathcordic_wrap.v
More file actions
50 lines (42 loc) · 1.02 KB
/
cordic_wrap.v
File metadata and controls
50 lines (42 loc) · 1.02 KB
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
// Make a clean synthesis in the fabric, away from the I/O cells
`timescale 1ns / 1ns
module cordic_wrap(
input clk, // timespec 8.0 ns
input [18:0] data,
input [3:0] strobe,
input [1:0] osel,
output reg [18:0] d_out
);
// Just grab things at the IOB
reg [18:0] d1=0;
reg [3:0] s1=0;
reg [1:0] o1=0;
always @(posedge clk) begin
d1 <= data;
s1 <= strobe;
o1 <= osel;
end
// Set up input registers in the fabric
reg [17:0] xin=0, yin=0; reg [18:0] phasein=0; reg [1:0] opin=0;
always @(posedge clk) begin
if (s1[0]) opin <= d1;
if (s1[1]) xin <= d1;
if (s1[2]) yin <= d1;
if (s1[3]) phasein <= d1;
end
// Instantiate!
wire [17:0] xout, yout; wire[18:0] phaseout;
cordicg_b22 #(18) dut(
.clk(clk), .opin(opin), .xin(xin), .yin(yin), .phasein(phasein),
.xout(xout), .yout(yout), .phaseout(phaseout));
// collapse
reg [18:0] latch=0;
always @(posedge clk) case(o1)
2'b00: latch <= 0;
2'b01: latch <= phaseout;
2'b10: latch <= xout;
2'b11: latch <= yout;
endcase
// IOB again
always @(posedge clk) d_out <= latch;
endmodule