quick.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

   

space.gif

   

space.gif

  ../../images/main/bullet_green_ball.gif Counters
   

space.gif

   

space.gif

  ../../images/main/bulllet_4dots_orange.gif 8-Bit Up Counter
   

space.gif


  1 //-----------------------------------------------------
  2 // Design Name : up_counter
  3 // File Name   : up_counter.cpp
  4 // Function    : Up counter
  5 // Coder       : Deepak Kumar Tala
  6 //-----------------------------------------------------
  7 #include "systemc.h"
  8 
  9 SC_MODULE (up_down_counter) {
 10   //-----------Input Ports---------------
 11   sc_in    <bool> enable, clk, reset;
 12   //-----------Output Ports---------------
 13   sc_out   <sc_uint<8> > out;
 14   //------------Internal Variables--------
 15   sc_uint<8>  count;
 16 
 17   //-------------Code Starts Here---------
 18   void counter () {
 19     if (reset.read()) { 
 20       count = 0 ;
 21     } else if (enable.read()) {
 22       count = count + 1;
 23     }
 24     out.write(count);
 25   }
 26 
 27   SC_CTOR(up_down_counter) {
 28     SC_METHOD (counter);
 29       sensitive << clk.pos();
 30   }
 31 
 32 };
You could download file sc_examples here
   

space.gif

  ../../images/main/bulllet_4dots_orange.gif 8-Bit Up Counter With Load
   

space.gif


  1 //-----------------------------------------------------
  2 // Design Name : up_counter_load
  3 // File Name   : up_counter_load.cpp
  4 // Function    : Up counter with load
  5 // Coder       : Deepak Kumar Tala
  6 //-----------------------------------------------------
  7 #include "systemc.h"
  8 
  9 SC_MODULE (up_counter_load) {
 10   //-----------Input Ports---------------
 11   sc_in    <sc_uint<8> > data;
 12   sc_in    <bool> load, enable, clk, reset;
 13   //-----------Output Ports---------------
 14   sc_out   <sc_uint<8> > out;
 15   //------------Internal Variables--------
 16   sc_uint<8>  count;
 17 
 18   void counter () {
 19     if (reset.read()) { 
 20       count = 0 ;
 21     } else if (enable.read()) {
 22       if (load.read()) {
 23         count = data.read();
 24       } else {
 25         count = count + 1;
 26       }
 27     }
 28     out.write(count);
 29   }
 30 
 31   SC_CTOR(up_counter_load) {
 32     SC_METHOD (counter);
 33       sensitive << clk.pos();
 34   }
 35 };
You could download file sc_examples here
   

space.gif

  ../../images/main/bulllet_4dots_orange.gif 8-Bit Up/Down Counter
   

space.gif


  1 //-----------------------------------------------------
  2 // Design Name : up_down_counter
  3 // File Name   : up_down_counter.cpp
  4 // Function    : Up down counter
  5 // Coder       : Deepak Kumar Tala
  6 //-----------------------------------------------------
  7 #include "systemc.h"
  8 
  9 SC_MODULE (up_down_counter) {
 10   //-----------Input Ports---------------
 11   sc_in    <bool>        clk;
 12   sc_in    <bool>        reset;
 13   sc_in    <bool>        enable;
 14   sc_in    <bool>        up_down;
 15   //-----------Output Ports---------------
 16   sc_out   <sc_uint<8> > out;
 17   
 18   //------------Internal Variables--------
 19   sc_uint<8>  count;
 20 
 21   //-------------Code Starts Here---------
 22   void counter () {
 23     if (reset.read()) { 
 24       count = 0 ;
 25     } else if (enable.read()) {
 26       if (up_down.read()) {
 27         count = count + 1;
 28       } else {
 29         count = count - 1;
 30       }
 31     }
 32     out.write(count);
 33   }
 34 
 35   SC_CTOR(up_down_counter) {
 36     SC_METHOD (counter);
 37       sensitive << clk.pos();
 38   }
 39 
 40 };
You could download file sc_examples here
   

space.gif

   

space.gif

   

space.gif

   

space.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

  

Copyright © 1998-2014

Deepak Kumar Tala - All rights reserved

Do you have any Comment? mail me at:deepak@asic-world.com