Skip to content

Commit 4ccc4ba

Browse files
authored
Merge pull request #8 from thiskappaisgrey/thiskappaisgrey/lakeroad-backend-tests
Add a new test for the not cell.
2 parents c6fa24e + dfbafc8 commit 4ccc4ba

File tree

4 files changed

+47
-1
lines changed

4 files changed

+47
-1
lines changed

backends/lakeroad/lakeroad.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1246,6 +1246,7 @@ struct LakeroadWorker {
12461246
}
12471247

12481248
// The let-bound ID string of the expression to extract from.
1249+
// FIXME: On certain inputs - this never terminates. Not sure if this is a problem
12491250
auto extract_from_expr = get_expression_for_signal(sigmap(sig.chunks()[0].wire), -1);
12501251
auto new_id = get_new_id_str();
12511252
auto extract_expr = stringf("(Op1 (Extract %d %d) %s)", (chunk.offset + chunk.width - 1) + chunk.wire->start_offset,
@@ -1291,7 +1292,7 @@ struct LakeroadWorker {
12911292
f << "\n; cells\n";
12921293
for (auto cell : module->cells()) {
12931294

1294-
if (cell->type.in(ID($logic_not))) {
1295+
if (cell->type.in(ID($logic_not), ID($not))) {
12951296
// Unary ops.
12961297
assert(cell->connections().size() == 2);
12971298
auto y = sigmap(cell->getPort(ID::Y));
@@ -1301,6 +1302,8 @@ struct LakeroadWorker {
13011302
std::string op_str;
13021303
if (cell->type == ID($logic_not))
13031304
op_str = "(LogicNot)";
1305+
else if (cell->type == ID($not))
1306+
op_str = "(Not)";
13041307
else
13051308
log_error("This should be unreachable. You are missing an else if branch.\n");
13061309

backends/lakeroad/tests/simple-mux.ys

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
read_verilog -sv <<EOF
2+
module test(input [2:0] a, output [2:0] out);
3+
// assign out = ~ a;
4+
always_comb begin
5+
case (a)
6+
2'b01: out = 2'b10;
7+
2'b00: out = 2'b10;
8+
2'b10: out = 2'b00;
9+
2'b11: out = 2'b01;
10+
default: out = 2'b01;
11+
endcase
12+
end
13+
endmodule
14+
EOF
15+
# Optimize out the mux to simple gates.
16+
prep -top test; pmuxtree;
17+
proc; opt; memory; opt;
18+
techmap; opt;
19+
abc; opt;
20+
write_lakeroad
21+
# Writing the verilog first with "-noattr" doesn't cause infinite loop
22+
# write_verilog -noattr simple-mux.v
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
read_verilog -sv <<EOF
2+
/* This module is generated by using "simple-mux.ys" + "write_verilog -noattr simple-mux.v". Delete this once you find the problem(most likely due to attributes). */
3+
module test(a, out);
4+
wire _0_;
5+
input [2:0] a;
6+
wire [2:0] a;
7+
output [2:0] out;
8+
wire [2:0] out;
9+
assign _0_ = a[0] & a[1];
10+
assign out[1] = ~(a[1] | a[2]);
11+
assign out[0] = a[2] | _0_;
12+
assign out[2] = 1'h0;
13+
endmodule
14+
EOF
15+
write_lakeroad

backends/lakeroad/tests/simple-not.ys

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
read_verilog -sv <<EOF
2+
module test(input a, output out);
3+
assign out = ~ a;
4+
endmodule
5+
EOF
6+
write_lakeroad

0 commit comments

Comments
 (0)