int sc_main(int argc, char * argv[]){ sc_time PERIOD(10,SC_NS); sc_time DELAY(10,SC_NS); sc_clock clock("clock",PERIOD,0.5,DELAY,true); Flip_Flop_JK ff("ff"); Testbench tb("tb"); sc_signal<bool> s0_sg,s1_sg,s2_sg,s3_sg; ff.j_in(s0_sg); ff.k_in(s1_sg); ff.q_out(s2_sg); ff.nq_out(s3_sg); ff.clk_in(clock); tb.j_out(s0_sg); tb.k_out(s1_sg); tb.q_in(s2_sg); tb.nq_in(s3_sg); tb.clock_in(clock); sc_start(); return 0; }
int sc_main(int argc, char* argv[]){ sc_time PERIOD(10,SC_NS); // NS, SEC, SC sc_time DELAY(10,SC_NS); sc_clock clock("clock", PERIOD, 0.5, DELAY, true); And_Gate ag1("ag1"); TestBench tb("tb"); sc_signal<bool> a_sg, b_sg, z_sg; ag1.a_in(a_sg); ag1.b_in(b_sg); ag1.z_out(z_sg); tb.clk_in(clock); tb.a_out(a_sg); tb.b_out(b_sg); tb.z_in(z_sg); sc_start(); return 0; }
void start_noise(void) { nport = CreatePort(NULL,0); chipnoisedata = (UBYTE *)AllocMem(sizeof(noisedata), MEMF_CHIP); memcpy(chipnoisedata, noisedata, sizeof(noisedata)); audioreq = (struct IOAudio *)CreateExtIO(nport, sizeof(*audioreq)*2); modifyreq = audioreq+1; audioreq->ioa_Data = amap; audioreq->ioa_Length = sizeof(amap); OpenDevice(AUDIONAME, 0, &(audioreq->ioa_Request), 0); audioreq->ioa_Request.io_Command = CMD_WRITE; audioreq->ioa_Request.io_Message.mn_Length = sizeof(audioreq); audioreq->ioa_Data = chipnoisedata; audioreq->ioa_Length = sizeof(noisedata); audioreq->ioa_Period = PERIOD(440, sizeof(noisedata)); audioreq->ioa_Volume = 40; audioreq->ioa_Request.io_Flags = ADIOF_PERVOL; audioreq->ioa_Cycles = 0; /* Infinity */ memcpy(modifyreq, audioreq, sizeof(*audioreq)); modifyreq->ioa_Request.io_Command = ADCMD_PERVOL; BeginIO(&(audioreq->ioa_Request)); }
int sc_main(int argc,char *argv[]){ sc_time PERIOD(10,SC_NS); sc_time DELAY(10,SC_NS); sc_clock clock("clock",PERIOD,0.5,DELAY,true); Nand_Gate nand_gate("nand_gate"); Testbench test("test"); sc_signal<bool> a_sg, b_sg, c_sg; nand_gate.a_in(a_sg); nand_gate.b_in(b_sg); nand_gate.c_out(c_sg); test.clk_in(clock); test.c_in(c_sg); test.a_out(a_sg); test.b_out(b_sg); sc_start(); return 0; }
void imx233_pwm_setup(int channel, int period, int cdiv, int active, int active_state, int inactive, int inactive_state) { /* stop */ bool enable = imx233_pwm_is_enabled(channel); if(enable) imx233_pwm_enable(channel, false); /* setup pin */ imx233_pinctrl_setup_vpin(VPIN_PWM(channel), "pwm", PINCTRL_DRIVE_4mA, false); /* watch the order ! active THEN period * NOTE: the register value is period-1 */ HW_PWM_ACTIVEn(channel) = BF_OR2(PWM_ACTIVEn, ACTIVE(active), INACTIVE(inactive)); HW_PWM_PERIODn(channel) = BF_OR4(PWM_PERIODn, PERIOD(period - 1), ACTIVE_STATE(active_state), INACTIVE_STATE(inactive_state), CDIV(cdiv)); /* restore */ imx233_pwm_enable(channel, enable); }
int sc_main(int argc,char *argv[]) { sc_time PERIOD(10,SC_NS); sc_time DELAY(10,SC_NS); sc_clock clock("clock",PERIOD,0.5,DELAY,true); Xor_GateComp xorcomp_gate("xorcomp_gate"); TestBench test("test"); sc_signal<bool> a_sg, b_sg, c_sg; //Se declaran los 'cables' o señales que conectaran el modulo con el testbench //Comienza la conexion entre el modulo y el testbench meidante los cables anteriormente declarados xorcomp_gate.a_In_Xor(a_sg); xorcomp_gate.b_In_Xor(b_sg); xorcomp_gate.c_Out_Xor(c_sg); test.Clock_In(clock); test.c_In_Test(c_sg); test.a_Out_Test(a_sg); test.b_Out_Test(b_sg); sc_start(); return 0; }
#define AIS1_Hz 466.164 #define A1_Hz 440.000 #define GIS1_Hz 415.305 #define G1_Hz 391.995 #define FIS1_Hz 369.994 #define F1_Hz 349.228 #define E1_Hz 329.628 #define DIS1_Hz 311.127 #define D1_Hz 293.665 #define CIS1_Hz 277.183 #define C1_Hz 261.626 #define PERIOD(f) ((uint32_t) ((8000000+f##_Hz) / (2*f##_Hz))) const uint32_t note_period[13] = { PERIOD(C1), PERIOD(CIS1), PERIOD(D1), PERIOD(DIS1), PERIOD(E1), PERIOD(F1), PERIOD(FIS1), PERIOD(G1), PERIOD(GIS1), PERIOD(A1), PERIOD(AIS1), PERIOD(H1), PERIOD(C2), }; typedef enum note_e {
int main(int argc, char *argv[]) { double maxp = (double)MAXPERIODK*sizeof(noisedata)/K; double minp = (double)MINPERIODK*sizeof(noisedata)/K; double octaves; #ifdef DEBUG printf("maxp, minp = %f, %f\n",maxp, minp); #endif atexit( mytidyup ); IntuitionBase = OpenLibrary("intuition.library",0); log10of2 = log10(2.); octaves = log2(maxp/minp); #ifdef DEBUG printf("octaves = %f\n",octaves); #endif powerbase = pow(2, octaves); freqbase = 1./maxp; #ifdef DEBUG printf("freqbase = %f\n",freqbase); #endif #ifdef DEBUG printf("maxfreq = %f\n",(double)(1.0)/minp); #endif w = (struct Window *)OpenWindow(&nw); printf("Wait for it!\n"); makefreqtable(w->Width); printf("Ok go\n"); start_noise(); while(1) { struct IntuiMessage *m; ULONG class; USHORT code; SHORT mousex, mousey; int exitflag = 0; WaitPort(w->UserPort); m = (struct IntuiMessage *)GetMsg(w->UserPort); class = m->Class; code = m->Code; mousex = m->MouseX; mousey = m->MouseY; ReplyMsg((struct Message *)m); switch( class ) { case CLOSEWINDOW : exitflag = 1; break; case NEWSIZE: makefreqtable(w->Width); break; case MOUSEBUTTONS : switch( code ) { case SELECTDOWN: ReportMouse(w,1); break; case SELECTUP: ReportMouse(w,0); continue; case MENUDOWN: case MENUUP: continue; } /* Fall through on SELECTDOWN */ case MOUSEMOVE: { double newfreq; int newp; if( mousex > w->Width ) mousex = w->Width; else if( mousex < 0 ) mousex = 0; if( mousey > w->Height ) mousey = w->Height; else if( mousey < 0 ) mousey = 0; newfreq = freqtable[mousex]; #ifdef DEBUG printf("newfreq = %f\n",newfreq); #endif newp = (int)PERIOD(newfreq, sizeof(noisedata)); #ifdef DEBUG printf("newp = %d\n",newp); #endif modifynoise( newp, (mousey*MAXVOLUME)/w->Height); } break; } if( exitflag ) break; } return( 0 ); }