Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 3 : Combination and Sequential Circuits Modeling.

Similar presentations


Presentation on theme: "Chapter 3 : Combination and Sequential Circuits Modeling."— Presentation transcript:

1 Chapter 3 : Combination and Sequential Circuits Modeling

2 SC_MODULE SC_MODULE (module_name) { // declarations of ports : input, output and inout // Declarations of signals used in inter-process // Communication // Process method declarations // Other (non-process) methods // Child module instantiation pointer declarations // Data variable declarations SC_CTOR (module_name) { //Child module instantiations and interconnections SC_METHOD (process_method_name); // Sensitivity list for process SC_THREAD (process_method_name); // Sensitivity list for process

3 Combination Logic : Single Process SC_MODULE (mac) { sc_in a, b, c; sc_out sum; void proc_mac() { sum = a * b + c;}; SC_CTOR(mac) { SC_METHOD(proc_mac) sensitive << a << b << c; } };

4 Combination Logic Multiple Processes SC_MODULE (mult_procs) { Sc_int source; Sc_out drain; Sc_signal connect1, connect2; void mult_procs_1() { connect1 = !source;); void mult_procs_2() { connect2 = !connect;}; void mult_procs_3() { drain = !connect2;}; SC_CTOR (mult_procs) { SC_METHOD (mult_procs_1); sensitvie << source; SC_METHOD (mult_procs_2); sensitvie << connect1; SC_METHOD (mult_procs_3); sensitvie << connect2; } };

5 Sequential Logic Example SC_MODULE (count4) { //sc_in_clk  sc_in sc_in_clk clk; sc_in rst; sc_out cout; int curValue; void proc_mac() { curValue = rst ? 0 : curValue + 1; cout = curValue;}; SC_CTOR(mac) { SC_METHOD(proc_mac) sensitive_pos << clk << rst; //async reset sensitive_pos << clk; //sync reset } };

6 Code SC_MODULE (xor) { sc_in > bre, sty; sc_out > tap; void proc_xor() { tap = bre ^ sty;}; SC_CTOR (xor) { SC_METHOD (proc_xor); sensitive << bre << sty; } }; Compiler error error C2678: 二元運算子 '^' : 找不到使用左方運算元型別 'sc_in ' 的運算子 ( 或是沒有可接受的轉換 ) with [ T=sc_dt::sc_uint ] Port Read and Write Issues

7 Port Read and Write Issues (cont.) Code SC_MODULE (xor) { sc_in > bre, sty; sc_out > tap; void proc_xor() { tap = bre.read() ^ sty.read();}; tap.write(bre.read() ^ sty.read()); SC_CTOR (xor) { SC_METHOD (proc_xor); sensitive << bre << sty; } }; Suggestion  Explicitly use port’s read and write method

8 Process Function Call No hierarchy  Processes can’t call other processes directly Sensitivity List

9 Process : SC_METHOD vs SC_THREAD SC_METHOD void full_adder::proc_full_adder() { sum = a ^ b ^ carry; co = (a & b) | (b & carry) | (carry & a); } SC_THREAD void full_adder::proc_full_adder() { while (true) { sum = a ^ b ^ carry; co = (a & b) | (b & carry) | (carry & a); wait(); }

10 Process : SC_THREAD example void blah::proc() { while (true) { if (mem_ready) { tdata.range(7,0) = data8.read(); wait(); tdata.range(15,8) = data8.read(); wait(); tdata.range(23,16) = data8.read(); wait(); …. } … }

11 Process : wait and wait_until Wait()  No argument  Process will be reactivated when certain variables, specified in sensitivity list, changes Wait_until()  Need argument(s)  Prcoess will be reactivated when expression is true  Example // now wait for ready signal from memory // controller wait_until(mem_ready.delayed() == true);


Download ppt "Chapter 3 : Combination and Sequential Circuits Modeling."

Similar presentations


Ads by Google