-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAddres_controller.v
More file actions
110 lines (104 loc) · 2.34 KB
/
Copy pathAddres_controller.v
File metadata and controls
110 lines (104 loc) · 2.34 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer: chandula
//
// Create Date: 20:06:48 04/07/2018
// Design Name:
// Module Name: Address_controller
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module Address_controller(
input rx_done,tx_done,Pro_over,
input [7:0] RxD,
input Pro_wea,
input [7:0] Pro_Dout,
input [17:0] ProAddress,
output reg [17:0] MemAddress,
output reg [7:0] MemData,
output reg Pro_rst,
output reg wea,
output reg Tx_start,
output reg Rx_finish=1'b0,
output reg Tx_finish=1'b0
);
localparam iba= 18'd7; //in begin address
localparam oba= 18'd7; //out begin address
localparam size= 18'd65536;
localparam out_size= 18'd16257;
reg u_wea=1'b1;
reg [17:0] Rcounter= 18'd1;
reg [17:0] Tcounter= 18'd1;
reg [17:0] Rxaddress=18'd7;
reg [17:0] Txaddress=18'd65543;
//Receiver addressing
always @(posedge rx_done)
begin
if (~Rx_finish) begin
if (size>Rcounter) begin
u_wea=1'b1;
Rxaddress=Rxaddress+1;
Rcounter=Rcounter+1; end
else if (size==Rcounter) begin
Rx_finish=1'b1;
u_wea=1'b0; end
end
end
//Transmitter addressing
always @(posedge tx_done)
begin
if (~Tx_finish) begin
if (out_size>Tcounter) begin
Txaddress=Txaddress+1;
Tcounter=Tcounter+1; end
else if (out_size==Tcounter)
Tx_finish=1'b1;
end
end
//Final assignments
always@(Rx_finish or Tx_finish or Pro_over or Rxaddress or RxD or u_wea or ProAddress or Pro_Dout or Pro_wea or Txaddress)
begin
if(~Rx_finish) //Recieving img
begin
MemAddress=Rxaddress;
MemData=RxD;
wea=u_wea;
Tx_start=0;
Pro_rst=1;
end
else if(~Pro_over) //Processing
begin
MemAddress=ProAddress;
MemData=Pro_Dout;
wea=Pro_wea;
Tx_start=0;
Pro_rst=0;
end
else if(~Tx_finish) //Transmitting
begin
MemAddress=Txaddress;
MemData=RxD;
wea=u_wea;
Tx_start=1;
Pro_rst=0;
end
else //Over
begin
MemAddress=Txaddress;
MemData=RxD;
wea=u_wea;
Tx_start=0;
Pro_rst=0;
end
end
endmodule