-
Notifications
You must be signed in to change notification settings - Fork 0
/
s02_stream_rs.sv
88 lines (78 loc) · 2.09 KB
/
s02_stream_rs.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// vi:set ft=verilog ts=4 sw=4 expandtab ai si:
// loywong@gamil.com 20180821
`default_nettype none
module StreamRSLite
#(
parameter DW = 32
)(
input wire clk, rst,
input wire [DW-1:0] s_axis_tdata,
input wire s_axis_tlast,
input wire s_axis_tvalid,
output logic s_axis_tready,
output logic [DW-1:0] m_axis_tdata,
output logic m_axis_tlast,
output logic m_axis_tvalid,
input wire m_axis_tready
);
wire in_hs = s_axis_tvalid & s_axis_tready;
wire out_hs = m_axis_tvalid & m_axis_tready;
always_ff @(posedge clk) begin : proc_store
if(rst) begin
s_axis_tready <= 1'b1;
m_axis_tvalid <= 1'b0;
end
else if(in_hs) begin
s_axis_tready <= 1'b0;
m_axis_tvalid <= 1'b1;
end
else if(out_hs) begin
s_axis_tready <= 1'b1;
m_axis_tvalid <= 1'b0;
end
end
always_ff @(posedge clk) begin : proc_asm
if(rst) begin
m_axis_tlast <= '0;
m_axis_tdata <= '0;
end
else if(in_hs) begin
m_axis_tlast <= s_axis_tlast;
m_axis_tdata <= s_axis_tdata;
end
end
endmodule // MemAssem
module StreamIfRSLite
(
Axi4StreamIf.slave s,
Axi4StreamIf.master m
);
wire in_hs = s.tvalid & s.tready;
wire out_hs = m.tvalid & m.tready;
wire clk = s.clk;
wire rst = ~s.reset_n;
always_ff @(posedge clk) begin : proc_store
if(rst) begin
s.tready <= 1'b1;
m.tvalid <= 1'b0;
end
else if(in_hs) begin
s.tready <= 1'b0;
m.tvalid <= 1'b1;
end
else if(out_hs) begin
s.tready <= 1'b1;
m.tvalid <= 1'b0;
end
end
always_ff @(posedge clk) begin : proc_asm
if(rst) begin
m.tlast <= '0;
m.tdata <= '0;
end
else if(in_hs) begin
m.tlast <= s.tlast;
m.tdata <= s.tdata;
end
end
endmodule // MemAssem