tailieunhanh - Useful Modeling Techniques part 1

[ Team LiB ] Procedural Continuous Assignments We studied procedural assignments in Section , Procedural Assignments. Procedural assignments assign a value to a register. | Team LiB Procedural Continuous Assignments We studied procedural assignments in Section Procedural Assignments. Procedural assignments assign a value to a register. The value stays in the register until another procedural assignment puts another value in that register. Procedural continuous assignments behave differently. They are procedural statements which allow values of expressions to be driven continuously onto registers or nets for limited periods of time. Procedural continuous assignments override existing assignments to a register or net. They provide an useful extension to the regular procedural assignment statement. assign and deassign The keywords assign and deassign are used to express the first type of procedural continuous assignment. The left-hand side of procedural continuous assignments can be only be a register or a concatenation of registers. It cannot be a part or bit select of a net or an array of registers. Procedural continuous assignments override the effect of regular procedural assignments. Procedural continuous assignments are normally used for controlled periods of time. A simple example is the negative edge-triggered D-flipflop with asynchronous reset that we modeled in Example 6-8. In Example 9-1 we now model the same D_FF using assign and deassign statements. Example 9-1 D-Flipflop with Procedural Continuous Assignments Negative edge-triggered D-flipflop with asynchronous reset module edge_dff q qbar d clk reset Inputs and outputs output q qbar input d clk reset reg q qbar declare q and qbar are registers always @ negedge clk assign value of q qbar at active edge of clock. begin q d qbar d end always @ reset Override the regular assignments to q and qbar whenever reset goes high. Use of procedural continuous assignments. if reset begin if reset is high override regular assignments to q with the new values using procedural continuous assignment. assign q 1 b0 assign qbar 1 b1 end else begin If reset goes low remove the .