Skip to content

Commit

Permalink
Minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
minseongg committed Oct 2, 2024
1 parent 00ddf44 commit ceac807
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion doc/docs/contributors.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Here is a list of all the people who have worked on HazardFlow:
- [Gieun Jeong](https://cp.kaist.ac.kr/gieun.jeong/)
- Jihoon Kim

**Previous Contributos**
**Previous Contributors**

- Seunghyeon Jeong
- Tanapoom Sermchaiwong
6 changes: 3 additions & 3 deletions doc/docs/tutorial/fir_filter.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ As in the above figure, it can be divide into 3 submodules: `window`, `weight`,

* It keeps the weight vector `[b0, b1, b2]` persistent throughout the program.
* It takes the input vector `[v0, v1, v2]` and returns the output vector `[b0·v0, b1·v1, b2·v2]`.
* This submodule can be simply represented by a `map` combinator.

**`sum` submodule:**

Expand Down Expand Up @@ -88,9 +89,8 @@ impl<P: Copy + Default> Valid<P> {
It takes an `Valid<P>` and returns `Valid<Array<P, N>>`.
It tracks the latest `N` valid input signals.
The [`fsm_map` interface combinator](https://kaist-cp.github.io/hazardflow/docs/hazardflow_designs/std/hazard/struct.I.html#method.fsm_map) is provided by the HazardFlow HDL standard library.
It transforms the ingress payload to the egress payload, calculates the next state for the next clock cycle, and leaves the resolver signal untouched.
It takes an initial state, and an anonymous function, and returns a new interface.
The initial state is defined as `P::default().repeat::<N>()` in our example.
It computes the egress payload and the next state based on the ingress payload and the current state, and updates the state when the ingress tranfser happens.
The initial state is defined as `P::default().repeat::<{ N - 1 }>()` in our example.
The anonymous function is where we specify the fsm logic from the `(ingress payload, current state)` to the `(egress payload, next state)`.

<!--
Expand Down
17 changes: 13 additions & 4 deletions hazardflow-designs/src/examples/custom_fifo.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
//! Masked Merge implementation
//! Custom FIFO implementation
use crate::prelude::*;
use crate::std::*;

const N: usize = 5;
const M: usize = 5;

/// Masked merge trait
pub trait MaskedMergeExt<P: Copy + Default, const N: usize>: Interface
where [(); clog2(N)]:
Expand Down Expand Up @@ -40,12 +43,18 @@ where [(); clog2(N)]:

/// Masked Merge Combinator
#[synthesize]
pub fn custom_fifo(ingress: [Vr<u32>; 5]) -> Vr<u32> {
pub fn custom_fifo(ingress: [Vr<u32>; N]) -> Vr<u32> {
ingress
.masked_merge()
.map_resolver::<((), FifoS<(u32, U<{ clog2(5) }>), 5>)>(|er| {
.map_resolver::<((), FifoS<(u32, U<{ clog2(N) }>), M>)>(|er| {
let (_, fifo_s) = er.inner;
fifo_s.inner.fold(Array::from([false; 5]), |acc, (_p, idx)| acc.set(idx, true))
range::<N>().fold(Array::from([false; N]), |acc, i| {
if i.resize() >= fifo_s.len {
acc
} else {
acc.set(fifo_s.inner[wrapping_add(fifo_s.raddr, i, M.into_u())].1, true)
}
})
})
.transparent_fifo()
.map(|(ip, _idx)| ip)
Expand Down

0 comments on commit ceac807

Please sign in to comment.