fn emit_event_trigger(
        &mut self,
        edge: ast::EdgeIdent,
        prev: HybridValue,
        now: HybridValue,
    ) -> Result<HybridValue> {
        let ty = self.value_type(now);

        // Check if a posedge happened.
        let posedge = match edge {
            ast::EdgeIdent::Posedge | ast::EdgeIdent::Edge => {
                let zero = self.emit_zero_for_type_both(ty.clone());
                let prev_eq_0 = self.mk_cmp(CmpPred::Eq, prev, zero);
                let now_neq_0 = self.mk_cmp(CmpPred::Neq, now, zero);
                let value = self.mk_and(prev_eq_0, now_neq_0);
                self.builder.set_name(value.0, "posedge".to_string());
                Some(value)
            }
            _ => None,
        };

        // Check if a negedge happened.
        let negedge = match edge {
            ast::EdgeIdent::Negedge | ast::EdgeIdent::Edge => {
                let zero = self.emit_zero_for_type_both(ty.clone());
                let prev_neq_0 = self.mk_cmp(CmpPred::Neq, prev, zero);
                let now_eq_0 = self.mk_cmp(CmpPred::Eq, now, zero);
                let value = self.mk_and(prev_neq_0, now_eq_0);
                self.builder.set_name(value.0, "negedge".to_string());
                Some(value)
            }
            _ => None,
        };

        // Combine the two edge triggers, or emit an implicit edge check if none
        // of the above edges was checked.
        Ok(match (posedge, negedge) {
            (Some(a), Some(b)) => {
                let value = self.mk_or(a, b);
                self.builder.set_name(value.0, "edge".to_string());
                value
            }
            (Some(a), None) => a,
            (None, Some(b)) => b,
            (None, None) => {
                let value = self.mk_cmp(CmpPred::Neq, prev, now);
                self.builder.set_name(value.0, "impledge".to_string());
                value
            }
        })
    }
/// Emit the code to check if a certain edge occurred between two values.
Emit the code to check if a certain edge occurred between two values.
Emit the code to check if a certain edge occurred between two values .
fn emit_event_trigger(
        &mut self,
        edge: ast::EdgeIdent,
        prev: HybridValue,
        now: HybridValue,
    ) -> Result<HybridValue> {
        let ty = self.value_type(now);
        // Check if a posedge happened.
        let posedge = match edge {
            ast::EdgeIdent::Posedge | ast::EdgeIdent::Edge => {
                let zero = self.emit_zero_for_type_both(ty.clone());
                let prev_eq_0 = self.mk_cmp(CmpPred::Eq, prev, zero);
                let now_neq_0 = self.mk_cmp(CmpPred::Neq, now, zero);
                let value = self.mk_and(prev_eq_0, now_neq_0);
                self.builder.set_name(value.0, "posedge".to_string());
                Some(value)
            }
            _ => None,
        };
        // Check if a negedge happened.
        let negedge = match edge {
            ast::EdgeIdent::Negedge | ast::EdgeIdent::Edge => {
                let zero = self.emit_zero_for_type_both(ty.clone());
                let prev_neq_0 = self.mk_cmp(CmpPred::Neq, prev, zero);
                let now_eq_0 = self.mk_cmp(CmpPred::Eq, now, zero);
                let value = self.mk_and(prev_neq_0, now_eq_0);
                self.builder.set_name(value.0, "negedge".to_string());
                Some(value)
            }
            _ => None,
        };
        // Combine the two edge triggers, or emit an implicit edge check if none
        // of the above edges was checked.
        Ok(match (posedge, negedge) {
            (Some(a), Some(b)) => {
                let value = self.mk_or(a, b);
                self.builder.set_name(value.0, "edge".to_string());
                value
            }
            (Some(a), None) => a,
            (None, Some(b)) => b,
            (None, None) => {
                let value = self.mk_cmp(CmpPred::Neq, prev, now);
                self.builder.set_name(value.0, "impledge".to_string());
                value
            }
        })
    }
fn emit_event_trigger ( & mut self , edge : ast :: EdgeIdent , prev : HybridValue , now : HybridValue , ) -> Result < HybridValue > { let ty = self . value_type ( now ) ; // Check if a posedge happened. let posedge = match edge { ast :: EdgeIdent :: Posedge | ast :: EdgeIdent :: Edge => { let zero = self . emit_zero_for_type_both ( ty . clone ( ) ) ; let prev_eq_0 = self . mk_cmp ( CmpPred :: Eq , prev , zero ) ; let now_neq_0 = self . mk_cmp ( CmpPred :: Neq , now , zero ) ; let value = self . mk_and ( prev_eq_0 , now_neq_0 ) ; self . builder . set_name ( value . 0 , " " . to_string ( ) ) ; Some ( value ) } _ => None , } ; // Check if a negedge happened. let negedge = match edge { ast :: EdgeIdent :: Negedge | ast :: EdgeIdent :: Edge => { let zero = self . emit_zero_for_type_both ( ty . clone ( ) ) ; let prev_neq_0 = self . mk_cmp ( CmpPred :: Neq , prev , zero ) ; let now_eq_0 = self . mk_cmp ( CmpPred :: Eq , now , zero ) ; let value = self . mk_and ( prev_neq_0 , now_eq_0 ) ; self . builder . set_name ( value . 0 , " " . to_string ( ) ) ; Some ( value ) } _ => None , } ; // Combine the two edge triggers, or emit an implicit edge check if none // of the above edges was checked. Ok ( match ( posedge , negedge ) { ( Some ( a ) , Some ( b ) ) => { let value = self . mk_or ( a , b ) ; self . builder . set_name ( value . 0 , " " . to_string ( ) ) ; value } ( Some ( a ) , None ) => a , ( None , Some ( b ) ) => b , ( None , None ) => { let value = self . mk_cmp ( CmpPred :: Neq , prev , now ) ; self . builder . set_name ( value . 0 , " " . to_string ( ) ) ; value } } ) }
Emit the code to check if a certain edge occurred between two values.
Emit the code to check if a certain edge occurred between two values .
&mut self
edge
ast::EdgeIdent
prev
HybridValue
now
HybridValue
&mut self
edge
ast::EdgeIdent
prev
HybridValue
now
HybridValue