Skip to content

Commit 4cc9c9a

Browse files
committed
Add tests
1 parent cdb9de4 commit 4cc9c9a

File tree

13 files changed

+63
-9
lines changed

13 files changed

+63
-9
lines changed

fud/filament.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,9 @@ def interface_gen(file: SourceType.Path) -> SourceType.Stream:
184184
"""
185185
cmd = " ".join(
186186
[
187-
config["stages", self.name, "exec"],
187+
config["stages", FilamentStage.name, "exec"],
188188
"--library",
189-
config["stages", self.name, "library"],
189+
config["stages", FilamentStage.name, "library"],
190190
"--dump-interface",
191191
# We should only run this after the module has been type
192192
# checked.

primitives/reshape.fil

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,15 +204,17 @@ comp CollectValid[W, N]<'G:1>(
204204
let Bits = log2(N)+1; assume Bits > 0;
205205

206206
// Increment the index if the value on the stream is valid
207-
idx := new Prev[Bits, 1]<'G>(mux.out);
207+
idx := new Prev[Bits, 1]<'G>(reset.out);
208208
one := new Const[Bits, 1]<'G>();
209+
zero_idx := new Const[Bits, 0]<'G>();
209210
add := new Add[Bits]<'G>(idx.prev, one.out);
210211
mux := new Mux[Bits]<'G>(valid, add.out, idx.prev);
212+
reset := new Mux[Bits]<'G>(max_reached.out, zero_idx.out, mux.out);
211213

212214
// Are all the blocks valid?
213215
n := new Const[Bits, N]<'G>();
214-
n_sub_1 := new Sub[Bits]<'G>(n.out, one.out);
215-
max_reached := new Eq[Bits]<'G>(n_sub_1.out, idx.prev);
216+
// n_sub_1 := new Sub[Bits]<'G>(n.out, one.out);
217+
max_reached := new Eq[Bits]<'G>(n.out, idx.prev);
216218
block_valid = max_reached.out;
217219

218220
// Take the location index points to within the output block and assign the

primitives/state.fil

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,10 @@ comp Counter[W, N]<'G:1>(
9494
add := new Add[Bits]<'G>(counter.prev, one.out);
9595

9696
max := new Const[Bits, N]<'G>();
97-
eq := new Eq[Bits]<'G>(counter.prev, max.out);
97+
eq := new Eq[Bits]<'G>(add.out, max.out);
9898

9999
zero := new Const[Bits, 0]<'G>();
100-
mux := new Mux[Bits]<'G>(eq.out, counter.prev, zero.out);
100+
mux := new Mux[Bits]<'G>(eq.out, zero.out, add.out);
101101

102102
resized := new ZeroExtend[Bits, W]<'G>(counter.prev);
103103

runt.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ cmd = """
2626

2727
[[tests]]
2828
name = "run"
29-
paths = ["tests/run/*.fil"]
29+
paths = ["tests/run/**/*.fil"]
3030
cmd = """
31-
fud e -s cocotb.data {}.data --to cocotb-out {} -s filament.flags ' --show-models' -q
31+
fud e -s cocotb.data {}.data --to cocotb-out {} -s filament.flags ' --show-models' -s filament.library "." -q
3232
"""
3333

3434
# ============= Testing primitive implementations =============
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{"o1": {"0": [0], "1": [1], "2": [1], "3": [0], "4": [0], "5": [5], "6": [5], "7": [5], "8": [5]}, "o2": {"0": [0], "1": [0], "2": [2], "3": [0], "4": [0], "5": [0], "6": [0], "7": [0], "8": [8]}, "val": {"0": [0], "1": [0], "2": [1], "3": [0], "4": [0], "5": [0], "6": [0], "7": [0], "8": [1]}, "cycles": 9}
2+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import "primitives/core.fil";
2+
import "primitives/reshape.fil";
3+
4+
comp main<'G:1>(
5+
en: interface['G],
6+
in: ['G, 'G+1] 32,
7+
valid: ['G, 'G+1] 1,
8+
) -> (
9+
o1: ['G, 'G+1] 32,
10+
o2: ['G, 'G+1] 32,
11+
val: ['G, 'G+1] 1
12+
) {
13+
cv := new CollectValid[32, 2]<'G>(in, valid);
14+
o1 = cv.out{0};
15+
o2 = cv.out{1};
16+
val = cv.block_valid;
17+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"in": [1,2,3,4,5,6,7,8,9],
3+
"valid": [1,1,0,0,1,0,0,1,0]
4+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{"count": {"0": [0], "1": [1], "2": [2], "3": [0], "4": [1], "5": [2]}, "cycles": 6}
2+

tests/run/primitives/counter.fil

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import "primitives/state.fil";
2+
3+
comp main<'G:1>(en: interface['G], in: ['G, 'G+1] 32) -> (count: ['G, 'G+1] 32) {
4+
counter := new Counter[32, 3]<'G>();
5+
count = counter.out;
6+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"in": [1,2,3,4,5,6]
3+
}

0 commit comments

Comments
 (0)