Download Describing Synthesizable RTL in SystemC
Transcript
Toggle Flip-Flop With Asynchronous Reset. Example 4-9 is a
SystemC description for a toggle flip-flop with asynchronous reset.
The asynchronous reset signal is specified in the sensitivity list.
Figure 4-9 shows the inferred flip-flop.
Example 4-9 Toggle Flip-Flop With Asynchronous Reset
#include "systemc.h"
SC_MODULE( tff2 ) {
sc_in<bool> reset, clk;
sc_inout<bool> q; // to read q for toggle
void t_async_reset_fcn();
SC_CTOR( tff2 ) {
SC_METHOD( t_async_reset_fcn);
sensitive_pos << clk << reset;
}
};
void tff2::t_async_reset_fcn () {
if (reset.read())
q.write(0);
else
q.write(!q.read());
}
Figure 4-9 Toggle Flip-Flop With Asynchronous Reset
RTL Coding Guidelines: Register Inference
4-15