240 likes | 372 Views
Outline. Logical Operators vs. Bitwise Operators Continuous assignment Statement ( assign ) enable Level-Sensitive Circuits in Verilog Edge Sensitive Circuits in Verilog Test Bench with a vector file. Logical Operators. An Example of Logical Operators. Code. Execution. Bitwise Operators.
E N D
Outline • Logical Operators vs. Bitwise Operators • Continuous assignment Statement (assign) • enable • Level-Sensitive Circuits in Verilog • Edge Sensitive Circuits in Verilog • Test Bench with a vector file
An Example of Logical Operators Code Execution
Bitwise Operators A bitwise operator interprets its operands as vectors and returns a vector.
assign • The assignment is said to be sensitive to the variables in the RHS expression because anytime a variable in the RHS changes during the simulation, the RHS expression is reevaluated and the result is used to update the LHS.
Three-State Output • assign out=enable?in:1’bz; • If enable is true, then Y1 is evaluated. • If enable is false, then Y2 is evaluated.
Testbench with a Test Vector File • Generate a clock • Load test vectors from a file • Edge Sensitive Operation • Load vectors on the rising edge of a clock • Check Resutls on the falling edge of a clock
Clock Generation Statements after an always keyword is subject to an event control expression. The clock will be generated over and over again since it is not subject to any explicit event control expression in this example.
Reading Binary Numbers from a File • $readmemb reads a file of binary numbers into an array called testvectors.
Checking Load Test Vector Check the Results
Input Vectors Purposely introduce an error in the test vectors to determine if the error message is working correctly.