#ifndef __SYSC_CPU_ADDER16BIT_HPP #define __SYSC_CPU_ADDER16BIT_HPP #include "systemc.h" #include "../cpu_and/cpu_and.hpp" #include "../cpu_or/cpu_or.hpp" #include "../cpu_not/cpu_not.hpp" #include "../cpu_full_adder/cpu_full_adder.hpp" SC_MODULE (cpu_adder16bit) { const static int ADD_N=16; //Inputs sc_in in_a[ADD_N]; sc_in in_b[ADD_N]; sc_in in_carry; sc_out out_sum[ADD_N]; sc_out out_carry; cpu_full_adder *fulladder[ADD_N]; sc_signal sig_fadd[ADD_N-1]; void do_adder16bit() { /* if (in_sel.read() == 0) { out_c.write(in_a.read()); } if (in_sel.read() == 1) { out_c.write(in_b.read()); } */ } SC_CTOR(cpu_adder16bit) { int i; for (i=0;i<16;i++) { const int sz=16; char *s=(char *)malloc(sz); //need to free s? snprintf(s,sz,"FULLADD%02d",i); fulladder[i] = new cpu_full_adder(s); } for (i=0;i<16;i++) { fulladder[i]->in_a(in_a[i]); fulladder[i]->in_b(in_b[i]); fulladder[i]->out_sum(out_sum[i]); } fulladder[0]->in_c(in_carry); fulladder[ADD_N-1]->out_carry(out_carry); for (i=1;iin_c(sig_fadd[i-1]); fulladder[i-1]->out_carry(sig_fadd[i-1]); } //SC_METHOD(do_dmux); //sensitive << in_a << in_b << in_sel; } }; #endif