forked from JoseIuri/axi4lite2uart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
axi4LiteReg.sv
74 lines (64 loc) · 2.26 KB
/
axi4LiteReg.sv
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
// ============================================================================= //
// Designer: Jose Iuri B. de Brito - [email protected] // //
// Rubbens Fernandes Roux - [email protected] //
//
// Design Name: AXI4LIte Registers Bank //
// Module Name: axi4LiteReg //
// //
// ============================================================================= //
//
// This file contains the AXI4Lite Registers, used to comunnicate with the FIFO for
// bridge btween peripheals.
//
module axi4LiteReg
(
input logic clk,
input logic rst,
//interface start
input logic wr_amba,
input logic [31:0] addr_rc,
input logic [31:0] addr_wc,
output logic [31:0] data_out, // 2Interface
input logic [3:0] strb,
input logic [31:0] data_in, // 4Interface
//interface end
input logic [31:0] rx_data,
output logic [31:0] tx_data,
output logic rxReady,
input logic rxValid,
output logic txValid,
input logic txReady
);
logic [31:0] regs [2];
assign data_out = regs[addr_rc[2]];
assign rxReady = 1'b1; // always ready.
assign tx_data = regs[0];
always_ff @ (posedge clk our negedge rst)
begin
if(!rst)
begin
regs[0] <= 0;
regs[1] <= 0;
txValid <= 0;
end
else
begin
if(wr_amba)
begin
regs[addr_wc[2]] <= (strb == 0) ? data_in : {(strb[3]) ? data_in[31:24] : regs[addr_wc[2]][31:24],
(strb[2]) ? data_in[23:16] : regs[addr_wc[2]][23:16],
(strb[1]) ? data_in[15: 8] : regs[addr_wc[2]][15: 8],
(strb[0]) ? data_in[ 7: 0] : regs[addr_wc[2]][ 7: 0]};
txValid <= 1'b1;
end
if(txReady && txValid)
begin
txValid <= 1'b0;
end
if(rxValid)
begin
regs[1] <= rx_data;
end
end
end
endmodule // axi4LiteReg