rename fire/fire_data to firing/firing_data

This commit is contained in:
Jacob Lifshay 2024-10-06 19:04:48 -07:00
parent e05c368688
commit 2e8b73d2fc
Signed by: programmerjake
SSH key fingerprint: SHA256:B1iRVvUJkvd7upMIiMqn6OyxvD2SgJkAH3ZnUOj6z+c

View file

@ -12,28 +12,28 @@ pub struct ReadyValid<T> {
impl<T: Type> ReadyValid<T> { impl<T: Type> ReadyValid<T> {
#[hdl] #[hdl]
pub fn fire(expr: Expr<Self>) -> Expr<Bool> { pub fn firing(expr: Expr<Self>) -> Expr<Bool> {
#[hdl] #[hdl]
let fire: Bool = wire(); let firing: Bool = wire();
#[hdl] #[hdl]
match expr.data { match expr.data {
HdlNone => connect(fire, false), HdlNone => connect(firing, false),
HdlSome(_) => connect(fire, expr.ready), HdlSome(_) => connect(firing, expr.ready),
} }
fire firing
} }
#[hdl] #[hdl]
pub fn fire_data(expr: impl ToExpr<Type = Self>) -> Expr<HdlOption<T>> { pub fn firing_data(expr: impl ToExpr<Type = Self>) -> Expr<HdlOption<T>> {
let expr = expr.to_expr(); let expr = expr.to_expr();
let option_ty = Expr::ty(expr).data; let option_ty = Expr::ty(expr).data;
#[hdl] #[hdl]
let fire_data = wire(option_ty); let firing_data = wire(option_ty);
connect(fire_data, option_ty.HdlNone()); connect(firing_data, option_ty.HdlNone());
#[hdl] #[hdl]
if expr.ready { if expr.ready {
connect(fire_data, expr.data); connect(firing_data, expr.data);
} }
fire_data firing_data
} }
#[hdl] #[hdl]
pub fn map<R: Type>( pub fn map<R: Type>(
@ -82,11 +82,11 @@ pub fn queue<T: Type>(
let write_port = mem.new_write_port(); let write_port = mem.new_write_port();
#[hdl] #[hdl]
let inp_fire: Bool = wire(); let inp_firing: Bool = wire();
connect(inp_fire, ReadyValid::fire(inp)); connect(inp_firing, ReadyValid::firing(inp));
#[hdl] #[hdl]
let out_fire: Bool = wire(); let out_firing: Bool = wire();
connect(out_fire, ReadyValid::fire(out)); connect(out_firing, ReadyValid::firing(out));
#[hdl] #[hdl]
let indexes_equal: Bool = wire(); let indexes_equal: Bool = wire();
connect(indexes_equal, inp_index_reg.cmp_eq(out_index_reg)); connect(indexes_equal, inp_index_reg.cmp_eq(out_index_reg));
@ -101,7 +101,7 @@ pub fn queue<T: Type>(
connect(read_port.en, true); connect(read_port.en, true);
connect(read_port.clk, cd.clk); connect(read_port.clk, cd.clk);
connect(write_port.addr, inp_index_reg); connect(write_port.addr, inp_index_reg);
connect(write_port.en, inp_fire); connect(write_port.en, inp_firing);
connect(write_port.clk, cd.clk); connect(write_port.clk, cd.clk);
connect(write_port.data, HdlOption::unwrap_or(inp.data, ty.uninit())); connect(write_port.data, HdlOption::unwrap_or(inp.data, ty.uninit()));
connect(write_port.mask, splat_mask(ty, true.to_expr())); connect(write_port.mask, splat_mask(ty, true.to_expr()));
@ -126,12 +126,12 @@ pub fn queue<T: Type>(
} }
#[hdl] #[hdl]
if inp_fire.cmp_ne(out_fire) { if inp_firing.cmp_ne(out_firing) {
connect(maybe_full_reg, inp_fire); connect(maybe_full_reg, inp_firing);
} }
#[hdl] #[hdl]
if inp_fire { if inp_firing {
#[hdl] #[hdl]
if inp_index_reg.cmp_eq(capacity.get() - 1) { if inp_index_reg.cmp_eq(capacity.get() - 1) {
connect_any(inp_index_reg, 0_hdl_u0); connect_any(inp_index_reg, 0_hdl_u0);
@ -141,7 +141,7 @@ pub fn queue<T: Type>(
} }
#[hdl] #[hdl]
if out_fire { if out_firing {
#[hdl] #[hdl]
if out_index_reg.cmp_eq(capacity.get() - 1) { if out_index_reg.cmp_eq(capacity.get() - 1) {
connect_any(out_index_reg, 0_hdl_u0); connect_any(out_index_reg, 0_hdl_u0);
@ -258,9 +258,9 @@ mod tests {
connect(next_expected_count, expected_count_reg); connect(next_expected_count, expected_count_reg);
connect(expected_count_reg, next_expected_count); connect(expected_count_reg, next_expected_count);
#[hdl] #[hdl]
if ReadyValid::fire(dut.inp) & !ReadyValid::fire(dut.out) { if ReadyValid::firing(dut.inp) & !ReadyValid::firing(dut.out) {
connect_any(next_expected_count, expected_count_reg + 1u8); connect_any(next_expected_count, expected_count_reg + 1u8);
} else if !ReadyValid::fire(dut.inp) & ReadyValid::fire(dut.out) { } else if !ReadyValid::firing(dut.inp) & ReadyValid::firing(dut.out) {
connect_any(next_expected_count, expected_count_reg - 1u8); connect_any(next_expected_count, expected_count_reg - 1u8);
} }
hdl_assert(cd.clk, expected_count_reg.cmp_eq(dut.count), ""); hdl_assert(cd.clk, expected_count_reg.cmp_eq(dut.count), "");
@ -289,7 +289,7 @@ mod tests {
let stored_inp_data_reg = reg_builder().clock_domain(cd).reset(0u8); let stored_inp_data_reg = reg_builder().clock_domain(cd).reset(0u8);
#[hdl] #[hdl]
if let HdlSome(data) = ReadyValid::fire_data(dut.inp) { if let HdlSome(data) = ReadyValid::firing_data(dut.inp) {
#[hdl] #[hdl]
if inp_index_reg.cmp_lt(index_max) { if inp_index_reg.cmp_lt(index_max) {
connect_any(inp_index_reg, inp_index_reg + 1u8); connect_any(inp_index_reg, inp_index_reg + 1u8);
@ -311,7 +311,7 @@ mod tests {
let stored_out_data_reg = reg_builder().clock_domain(cd).reset(0u8); let stored_out_data_reg = reg_builder().clock_domain(cd).reset(0u8);
#[hdl] #[hdl]
if let HdlSome(data) = ReadyValid::fire_data(dut.out) { if let HdlSome(data) = ReadyValid::firing_data(dut.out) {
#[hdl] #[hdl]
if out_index_reg.cmp_lt(index_max) { if out_index_reg.cmp_lt(index_max) {
connect_any(out_index_reg, out_index_reg + 1u8); connect_any(out_index_reg, out_index_reg + 1u8);