Skip to content

Commit 9ae242a

Browse files
author
Bas Niekel
committed
added data name to buffer slot namer, changed generators accordingly
1 parent d97f53a commit 9ae242a

10 files changed

Lines changed: 70 additions & 15 deletions

File tree

experimental/lib/Support/FlowExpression.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,7 @@ LogicalResult FlowEquationExtractor::extractBufferOp(BufferOp bufferOp) {
448448
// Then, `in` is set to `next`
449449
auto slot = FlowVariable(FlowInternalState(slotNamer));
450450
FlowVariable next = in.nextInternal();
451+
slot.indexTokenTracker = in.indexTokenTracker;
451452
if (failed(extractSlotEquation(in, next, slot))) {
452453
return failure();
453454
}

experimental/tools/unit-generators/smv/generators/handshake/buffers/fifo_break_none.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def _generate_one_slot_break_none_dataless(name):
3131
DEFINE
3232
outs_valid := full | ins_valid;
3333
ins_ready := (!full) | outs_ready;
34+
slot_0_full := full;
3435
"""
3536

3637

@@ -52,6 +53,8 @@ def _generate_one_slot_break_none(name, data_type):
5253
outs := full ? reg : ins;
5354
outs_valid := full | ins_valid;
5455
ins_ready := (!full) | outs_ready;
56+
slot_0_full := full;
57+
data_0 := reg;
5558
"""
5659

5760

experimental/tools/unit-generators/smv/generators/handshake/buffers/one_slot_break_dv.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ def _generate_one_slot_break_dv(name, data_type):
4646
DEFINE
4747
ins_ready := inner_one_slot_break_dv.ins_ready;
4848
outs_valid := inner_one_slot_break_dv.outs_valid;
49+
outs_valid_i := inner_one_slot_break_dv.outs_valid_i;
4950
outs := data;
50-
slot_0_full := inner_one_slot_break_dv.outs_valid_i;
5151
5252
{_generate_one_slot_break_dv_dataless(f"{name}__one_slot_break_dv_dataless")}
5353
"""

experimental/tools/unit-generators/smv/generators/handshake/buffers/one_slot_break_r.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ def _generate_one_slot_break_r_dataless(name):
2424
DEFINE
2525
ins_ready := !full;
2626
outs_valid := ins_valid | full;
27-
28-
slot_0_full := full;
2927
"""
3028

3129

@@ -46,7 +44,7 @@ def _generate_one_slot_break_r(name, data_type):
4644
outs_valid := inner_one_slot_break_r.outs_valid;
4745
outs := inner_one_slot_break_r.full ? data : ins;
4846
49-
slot_0_full := inner_one_slot_break_r.slot_0_full;
47+
full := inner_one_slot_break_r.full;
5048
5149
{_generate_one_slot_break_r_dataless(f"{name}__one_slot_break_r_dataless")}
5250
"""

experimental/tools/unit-generators/smv/generators/handshake/control_merge.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def _generate_control_merge_dataless(name, size, index_type):
3636
index_valid := inner_fork.outs_1_valid;
3737
index := inner_one_slot_break_r.outs;
3838
39-
slot_full := inner_one_slot_break_r.slot_0_full;
39+
slot_full := inner_one_slot_break_r.full;
4040
data := inner_one_slot_break_r.data;
4141
4242
outs_sent := inner_fork.outs_0_sent;

experimental/tools/unit-generators/smv/generators/handshake/load.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ def _generate_load(name, data_type, addr_type):
2525
dataOut := inner_data_one_slot_break_r.outs;
2626
dataOut_valid := inner_data_one_slot_break_r.outs_valid;
2727
28-
addr_full := inner_addr_one_slot_break_r.slot_0_full;
29-
data_full := inner_data_one_slot_break_r.slot_0_full;
28+
addr_full := inner_addr_one_slot_break_r.full;
29+
data_full := inner_data_one_slot_break_r.full;
3030
3131
{generate_one_slot_break_r(f"{name}__addr_one_slot_break_r", {ATTR_BITWIDTH: addr_type.bitwidth})}
3232
{generate_one_slot_break_r(f"{name}__data_one_slot_break_r", {ATTR_BITWIDTH: data_type.bitwidth})}

experimental/tools/unit-generators/smv/generators/handshake/sink.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@
44
def generate_sink(name, params):
55
data_type = SmvScalarType(params[ATTR_BITWIDTH])
66

7+
if "pyTest" in params:
8+
return _generate_iog_terminating_sink_dataless(name)
79
if data_type.bitwidth == 0:
810
return _generate_sink_dataless(name)
911
else:
1012
return _generate_sink(name, data_type)
1113

1214

15+
1316
def _generate_sink_dataless(name):
1417
return f"""
1518
MODULE {name}(ins_valid)
@@ -28,3 +31,14 @@ def _generate_sink(name, data_type):
2831
DEFINE
2932
ins_ready := TRUE;
3033
"""
34+
35+
def _generate_iog_terminating_sink_dataless(name):
36+
return f"""
37+
MODULE {name}(ins_valid)
38+
39+
VAR
40+
slot_full : bool;
41+
-- output
42+
DEFINE
43+
ins_ready := !slot_full;
44+
"""

include/dynamatic/Dialect/Handshake/HandshakeOpInternalStateNamer.h

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,9 @@ struct ConstrainedEagerForkSentNamer : ConstrainedNamer {
194194
struct BufferSlotFullNamer : InternalStateNamer {
195195
BufferSlotFullNamer() = default;
196196
BufferSlotFullNamer(const std::string &opName, const std::string &slotName,
197-
size_t slotSize)
197+
const std::string &dataName, size_t slotSize)
198198
: InternalStateNamer(TYPE::BufferSlotFull), opName(opName),
199-
slotName(slotName), slotSize(slotSize) {}
199+
slotName(slotName), dataName(dataName), slotSize(slotSize) {}
200200
~BufferSlotFullNamer() = default;
201201

202202
static inline bool classof(const InternalStateNamer *fp) {
@@ -206,12 +206,13 @@ struct BufferSlotFullNamer : InternalStateNamer {
206206
ConstrainedBufferSlotFullNamer constrain(int32_t value);
207207

208208
inline std::string getSMVName() const override {
209-
return llvm::formatv("{0}.{1}_full", opName, slotName).str();
209+
return llvm::formatv("{0}.{1}", opName, slotName).str();
210210
}
211211
inline llvm::json::Value toInnerJSON() const override {
212212
return llvm::json::Object({
213213
{OPERATION_LIT, opName},
214214
{SLOT_NAME_LIT, slotName},
215+
{DATA_NAME_LIT, dataName},
215216
{SLOT_SIZE_LIT, slotSize},
216217
});
217218
}
@@ -221,9 +222,11 @@ struct BufferSlotFullNamer : InternalStateNamer {
221222

222223
std::string opName;
223224
std::string slotName;
225+
std::string dataName;
224226
size_t slotSize;
225227
static constexpr llvm::StringLiteral OPERATION_LIT = "operation";
226228
static constexpr llvm::StringLiteral SLOT_NAME_LIT = "slot_name";
229+
static constexpr llvm::StringLiteral DATA_NAME_LIT = "data_name";
227230
static constexpr llvm::StringLiteral SLOT_SIZE_LIT = "slot_size";
228231
};
229232

@@ -234,8 +237,11 @@ struct ConstrainedBufferSlotFullNamer : ConstrainedNamer {
234237
~ConstrainedBufferSlotFullNamer() = default;
235238

236239
inline std::string getSMVName() const override {
237-
return llvm::formatv("{0} & ({1}.data = {2})", base.getSMVName(),
238-
base.opName, smvValue(base.slotSize, value))
240+
// Assuming buffer1 contains a 32bit slot:
241+
// buffer1.slot_full & (buffer1.slot_data = 0ud32_1)
242+
return llvm::formatv("{0} & ({1}.{2} = {3})", base.getSMVName(),
243+
base.opName, base.dataName,
244+
smvValue(base.slotSize, value))
239245
.str();
240246
}
241247

lib/Dialect/Handshake/HandshakeInterfaces.cpp

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,8 @@ std::vector<BufferSlotFullNamer> ControlMergeOp::getInternalSlotStateNamers() {
418418
"Cannot get names of slot states for operation without name");
419419
handshake::ChannelType ct = getIndex().getType();
420420

421-
ret[0] = BufferSlotFullNamer(nameAttr.str(), "slot", ct.getDataBitWidth());
421+
ret[0] = BufferSlotFullNamer(nameAttr.str(), "slot_full", "data",
422+
ct.getDataBitWidth());
422423
return ret;
423424
}
424425

@@ -429,9 +430,11 @@ std::vector<BufferSlotFullNamer> LoadOp::getInternalSlotStateNamers() {
429430
assert(nameAttr &&
430431
"Cannot get names of slot states for operation without name");
431432

432-
ret[0] = BufferSlotFullNamer(nameAttr.str(), ADDR_SLOT_LIT.str(),
433+
ret[0] = BufferSlotFullNamer(nameAttr.str(), ADDR_SLOT_LIT.str() + "_full",
434+
"NOT_ACCESSIBLE",
433435
getAddress().getType().getDataBitWidth());
434-
ret[1] = BufferSlotFullNamer(nameAttr.str(), DATA_SLOT_LIT.str(),
436+
ret[1] = BufferSlotFullNamer(nameAttr.str(), DATA_SLOT_LIT.str() + "_full",
437+
"NOT_ACCESSIBLE",
435438
getData().getType().getDataBitWidth());
436439
return ret;
437440
}
@@ -454,10 +457,39 @@ std::vector<BufferSlotFullNamer> BufferOp::getInternalSlotStateNamers() {
454457
assert(false && "Operand of BufferOp is not a channel");
455458
}
456459

460+
BufferType t = getBufferType();
461+
switch (t) {
462+
case BufferType::ONE_SLOT_BREAK_DV:
463+
assert(ret.size() == 1);
464+
ret[0] = BufferSlotFullNamer(nameAttr.str(), "outs_valid_i", "data", width);
465+
break;
466+
case BufferType::ONE_SLOT_BREAK_R:
467+
assert(ret.size() == 1);
468+
ret[0] = BufferSlotFullNamer(nameAttr.str(), "full", "data", width);
469+
break;
470+
case BufferType::FIFO_BREAK_NONE:
471+
if (ret.size() == 1) {
472+
ret[0] = BufferSlotFullNamer(nameAttr.str(), "full", "reg", width);
473+
} else {
474+
for (size_t i = 0; i < ret.size(); ++i) {
475+
ret[i] = BufferSlotFullNamer(nameAttr.str(),
476+
llvm::formatv("b{0}.full", i).str(),
477+
llvm::formatv("b{0}.reg", i).str(), width);
478+
}
479+
}
480+
break;
481+
case BufferType::FIFO_BREAK_DV:
482+
case BufferType::ONE_SLOT_BREAK_DVR:
483+
case BufferType::SHIFT_REG_BREAK_DV:
484+
llvm::report_fatal_error(
485+
llvm::formatv("no name for buffer slot of type {0}", t));
486+
}
487+
/*
457488
for (size_t i = 0; i < getNumSlots(); ++i) {
458489
ret[i] =
459490
BufferSlotFullNamer(nameAttr.str(), "slot_" + std::to_string(i), width);
460491
}
492+
*/
461493
return ret;
462494
}
463495

lib/Dialect/Handshake/HandshakeOpInternalStateNamer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ BufferSlotFullNamer::fromInnerJSON(const llvm::json::Value &value,
114114
auto prop = std::make_unique<BufferSlotFullNamer>();
115115
if (!mapper || !mapper.map(OPERATION_LIT, prop->opName) ||
116116
!mapper.map(SLOT_NAME_LIT, prop->slotName) ||
117+
!mapper.map(DATA_NAME_LIT, prop->dataName) ||
117118
!mapper.map(SLOT_SIZE_LIT, prop->slotSize))
118119
return nullptr;
119120
return prop;

0 commit comments

Comments
 (0)