Skip to content

Commit 4fb4106

Browse files
committed
Set zero latency for Cat, Slice, Pointer with a constant ptr, and _BinaryShiftOperator with a constant shift-amount.
1 parent a5d1105 commit 4fb4106

File tree

4 files changed

+236
-233
lines changed

4 files changed

+236
-233
lines changed

tests/extension/stream_/average/test_stream_average.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@
147147
reg signed [32-1:0] __delay_data_31;
148148
reg signed [32-1:0] _plus_data_25;
149149
reg signed [32-1:0] __delay_data_32;
150-
reg signed [32-1:0] _sra_data_26;
151-
reg signed [32-1:0] __delay_data_33;
150+
wire signed [32-1:0] _sra_data_26;
151+
assign _sra_data_26 = _plus_data_25 >>> 3'sd3;
152152
reg signed [32-1:0] _plus_data_28;
153153
assign zdata = _plus_data_28;
154154
@@ -173,8 +173,6 @@
173173
__delay_data_31 <= 0;
174174
_plus_data_25 <= 0;
175175
__delay_data_32 <= 0;
176-
_sra_data_26 <= 0;
177-
__delay_data_33 <= 0;
178176
_plus_data_28 <= 0;
179177
end else begin
180178
_plus_data_2 <= xdata + 1'sd0;
@@ -196,9 +194,7 @@
196194
__delay_data_31 <= __delay_data_30;
197195
_plus_data_25 <= _plus_data_21 + _plus_data_24;
198196
__delay_data_32 <= __delay_data_31;
199-
_sra_data_26 <= _plus_data_25 >>> 3'sd3;
200-
__delay_data_33 <= __delay_data_32;
201-
_plus_data_28 <= _sra_data_26 + __delay_data_33;
197+
_plus_data_28 <= _sra_data_26 + __delay_data_32;
202198
end
203199
end
204200

tests/extension/stream_/sra_round/stream_sra_round.py

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
1414
from pprint import pprint
1515

16+
1617
def mkMain():
1718
# input variiable
1819
x = stream.Variable('xdata')
@@ -27,7 +28,7 @@ def mkMain():
2728
st = stream.Stream(z)
2829
m = st.to_module('main')
2930

30-
#st.draw_graph()
31+
# st.draw_graph()
3132

3233
return m, st.pipeline_depth()
3334

@@ -82,9 +83,9 @@ def mkTest(numports=8):
8283
send_count = m.Reg('send_count', 32, initval=0)
8384
send_fsm.If(reset_done).goto_next()
8485

85-
test_val_boader = [-2147483648,-10, 1, 2147483637]
86+
test_val_boader = [-2147483648, -10, 1, 2147483637]
8687
test_window = 9
87-
test_shift = [0,1,2,3,15,16,17,30,31,32]
88+
test_shift = [0, 1, 2, 3, 15, 16, 17, 30, 31, 32]
8889

8990
for i in test_shift:
9091
for j in test_val_boader:
@@ -101,23 +102,25 @@ def mkTest(numports=8):
101102
Display('xdata=%d', xdata),
102103
Display('ydata=%d', ydata)
103104
)
104-
send_fsm.goto_next(cond=send_count==test_window)
105+
send_fsm.goto_next(cond=send_count == test_window)
105106

106107
recv_fsm = FSM(m, 'recv_fsm', clk, rst)
107108
recv_count = m.Reg('recv_count', 32, initval=0)
108109
recv_fsm.If(reset_done).goto_next()
109110

110-
recv_fsm(
111-
recv_count(0),
112-
)
113-
recv_fsm.goto_next()
111+
if latency >= 1:
112+
recv_fsm(
113+
recv_count(0),
114+
)
115+
recv_fsm.goto_next()
114116

115-
recv_fsm.If(recv_count < latency-2)(
116-
recv_count.inc()
117-
).Else(
118-
recv_count(0)
119-
)
120-
recv_fsm.goto_next(cond=recv_count>=latency-2)
117+
if latency >= 2:
118+
recv_fsm.If(recv_count < latency - 2)(
119+
recv_count.inc()
120+
).Else(
121+
recv_count(0)
122+
)
123+
recv_fsm.goto_next(cond=recv_count >= latency - 2)
121124

122125
for i in test_shift:
123126
for j in test_val_boader:
@@ -130,7 +133,7 @@ def mkTest(numports=8):
130133
Display('zdata=%d', zdata),
131134
recv_count.inc()
132135
)
133-
recv_fsm.goto_next(cond=recv_count==test_window)
136+
recv_fsm.goto_next(cond=recv_count == test_window)
134137

135138
recv_fsm(
136139
end_of_sim(1)
@@ -148,15 +151,20 @@ def mkTest(numports=8):
148151
sim = simulation.Simulator(test)
149152
rslt = sim.run() # display=False
150153
#rslt = sim.run(display=True)
151-
#print(rslt)
152-
153-
vx = list(map(lambda x: int(str.split(x,"=")[1]), filter(lambda x: "xdata" in x , str.split(rslt, "\n"))))
154-
vy = list(map(lambda x: int(str.split(x,"=")[1]), filter(lambda x: "ydata" in x , str.split(rslt, "\n"))))
155-
vz = list(map(lambda x: int(str.split(x,"=")[1]), filter(lambda x: "zdata" in x , str.split(rslt, "\n"))))
156-
ez = list(map(lambda x,y: int( Decimal(str(x/(2.0**y))).quantize(Decimal('0'), rounding=ROUND_HALF_UP)), vx,vy))
157-
158-
pprint(list(zip(vx,vy,vz,ez)))
159-
assert(all(map(lambda v, e: v==e, vz, ez)))
154+
# print(rslt)
155+
156+
vx = list(map(lambda x: int(str.split(x, "=")[1]), filter(
157+
lambda x: "xdata" in x, str.split(rslt, "\n"))))
158+
vy = list(map(lambda x: int(str.split(x, "=")[1]), filter(
159+
lambda x: "ydata" in x, str.split(rslt, "\n"))))
160+
vz = list(map(lambda x: int(str.split(x, "=")[1]), filter(
161+
lambda x: "zdata" in x, str.split(rslt, "\n"))))
162+
ez = list(map(lambda x, y:
163+
int(Decimal(str(x / (2.0**y))).quantize(
164+
Decimal('0'), rounding=ROUND_HALF_UP)), vx, vy))
165+
166+
pprint(list(zip(vx, vy, vz, ez)))
167+
assert(all(map(lambda v, e: v == e, vz, ez)))
160168

161169
# launch waveform viewer (GTKwave)
162170
# sim.view_waveform() # background=False

0 commit comments

Comments
 (0)