1 / 11

Chapter 3 : Combination and Sequential Circuits Modeling

Chapter 3 : Combination and Sequential Circuits Modeling. 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

Télécharger la présentation

Chapter 3 : Combination and Sequential Circuits Modeling

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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<int> a, b, c; sc_out<int> 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<bool> source; Sc_out<bool> drain; Sc_signal<bool> 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<bool> sc_in_clk clk; sc_in<bool> rst; sc_out<int> 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. Port Read and Write Issues • Code SC_MODULE (xor) { sc_in<sc_uint<4> > bre, sty; sc_out<sc_uint<4> > tap; void proc_xor() { tap = bre ^ sty;}; SC_CTOR (xor) { SC_METHOD (proc_xor); sensitive << bre << sty; } }; • Compiler error error C2678: 二元運算子 '^' : 找不到使用左方運算元型別 'sc_in<T>' 的運算子 (或是沒有可接受的轉換) with [ T=sc_dt::sc_uint<4> ]

  7. Port Read and Write Issues (cont.) • Code SC_MODULE (xor) { sc_in<sc_uint<4> > bre, sty; sc_out<sc_uint<4> > 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);

More Related