-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathExtendedWireToParallel.v
More file actions
94 lines (87 loc) · 2.51 KB
/
ExtendedWireToParallel.v
File metadata and controls
94 lines (87 loc) · 2.51 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
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////
// IonControl 1.0: Copyright 2016 Sandia Corporation
// This Software is released under the GPL license detailed
// in the file "license.txt" in the top-level pyGSTi directory
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
// A way to implement 64 bit wire ins. Transmitted are 5 words with 16 bits each.
// The first word is the address, the remaining 4 words are the data LSW first
//
///////////////////////
module ExtendedWireToParallel(
input wire [15:0] data_in,
input wire clk_in,
input wire write,
output reg [15:0] address = 0,
output reg [63:0] data_out = 0,
output reg data_available = 0,
output reg apply_immediately = 0,
input wire [63:0] wide_in,
input wire wide_update,
input wire wide_clk,
input wire [15:0] wide_address
);
reg [2:0] state = 0;
reg [63:0] wide_buffer = 0;
reg [63:0] receiver_buffer = 0;
reg [63:0] receiver_double_buffer = 0;
reg wide_available;
reg receiver_available;
reg [15:0] external_address = 0;
reg [15:0] external_address_buffer = 0;
wire receiver_available_sync;
monoflop_sync external_mf( .clock(wide_clk), .enable(1'b1), .trigger(receiver_available), .q(receiver_available_sync) );
always @(posedge wide_clk) begin
if (data_available) begin
data_available <= 1'b0;
end else if (wide_update) begin
data_out <= wide_in;
data_available <= 1'b1;
address <= wide_address;
apply_immediately <= 1'b0;
end else if (receiver_available_sync) begin
data_out <= receiver_buffer;
data_available <= 1'b1;
address <= external_address;
apply_immediately <= 1'b1;
end
end
always @(posedge clk_in) begin
receiver_available <= 1'b0; // default
case (state)
3'h0: begin
if (write) begin
external_address_buffer <= data_in;
state <= 3'h1;
end
end
3'h1: begin
if (write) begin
receiver_double_buffer[15:0] <= data_in[15:0];
state <= 3'h2;
end
end
3'h2: begin
if (write) begin
receiver_double_buffer[31:16] <= data_in[15:0];
state <= 3'h3;
end
end
3'h3: begin
if (write) begin
receiver_double_buffer[47:32] <= data_in[15:0];
state <= 3'h4;
end
end
3'h4: begin
if (write) begin
receiver_buffer[63:0] <= {data_in[15:0], receiver_double_buffer[47:0]};
external_address <= external_address_buffer;
receiver_available <= 1'b1;
state <= 3'h0;
end
end
endcase
end
endmodule