Beispiel #1
0
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;
}
Beispiel #2
0
int main(int argc, char *argv[]){

 if(argc == 3 && (strlen(argv[1]) == strlen(argv[2]))){
  
  //We only need the size of one because they are equal   
  size_t argSize = strlen(argv[1]);
  //Print the result
  printf("Result of NAND: ");
  //Loop through the command line args 
  for(int i = 0; i < argSize; i++){
      printf("%c", nand_gate(argv[1][i], argv[2][i]));
  }
  puts("\n"); 
 }
  return 0;
}
Beispiel #3
0
int main(int argc, char* argv[])
{
	printf(" a | b | a NAND b | a NOR b | a XOR b | a XNOR b\n");
	printf("---+---+----------+---------+---------+----------\n");	
	for(int a = 0; a < 2; a++)
	{
		for(int b = 0; b < 2; b++)
		{
			printf(" %d | %d |     %d    |    %d    |    %d     |     %d\n",
				a, b, 
				nand_gate(a, b), 
				nor_gate(a, b),
				xor_gate(a, b),
				xnor_gate(a, b));
		}
	}
	return 0;
}