print "controler:", gs.time(), "start" print "controler:", gs.time(), "waiting 5 ns to pause thread", thread.name gs.wait(5, gs.NS) print "controler:", gs.time(), "pausing thread", thread.name, "NOW!" thread.pause() print "controler:", gs.time(), "waiting 3 ns to resume thread", thread.name gs.wait(3) print "controler:", gs.time(), "resuming thread", thread.name, "NOW!" thread.resume() print "controler:", gs.time(), "waiting 5 ns to pause thread", thread.name gs.wait(5, gs.NS) print "controler:", gs.time(), "pausing thread", thread.name, "NOW!" thread.pause() print "controler:", gs.time(), "waiting 3 ns to resume thread", thread.name gs.wait(3) print "controler:", gs.time(), "resuming thread", thread.name, "NOW!" thread.resume() print "controler:", gs.time(), "waiting 10 ns to kill thread", thread.name gs.wait(10) print "controler:", gs.time(), "killing thread", thread.name, "NOW!" thread.kill() prod = gs.spawn(producer) gs.spawn(lambda: controler(prod)) gs.start()
# the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # If you have a applicable agreement with GreenSocs Ltd, the terms of that # agreement prevail. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA # 02110-1301 USA # # ENDLICENSETEXT import gs from sender import sender from receiver import receiver # Describe the system sender1 = sender() receiver1 = receiver() # Start! gs.start()
gs.config_lua("test_gs_param.cfg.lua") # Describe the system addr = gs.fifo() data = gs.fifo() cpu1 = cpu(addr,data) memory1 = memory(addr,data) # Try an Array Parameter ap = gs.param("test_array") print ap for a in ap: print a()+20 # Test the callbacks def pp(x): print x gs.end_of_elaboration(lambda: pp("eoe")) gs.end_of_simulation(lambda: pp("ssss")) gs.end_of_simulation(lambda: pp("eos")) # A simple process to keep the kernel alive a bit def goon(): for i in range(4): gs.wait(25+25*i,gs.NS) print gs.simulation_time() gs.spawn(goon) # Start! gs.start(100,gs.NS) #gs.start()
# but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA # 02110-1301 USA # # ENDLICENSETEXT import gs import random print "Start the simulation before defining the system" gs.start(1,gs.US) print "Simulation started:", gs.time() f = gs.fifo(2) def producer(): print "producer:", gs.time(), "start" f.write(1) print "producer:", gs.time(), "wrote 1" f.write(2) print "producer:", gs.time(), "wrote 2" f.write(3) print "producer:", gs.time(), "wrote 3" f.write(4) print "producer:", gs.time(), "wrote 4"
# Try an Array Parameter ap = gs.param("test_array") print ap for a in ap: print a() + 20 # Test the callbacks def pp(x): print x gs.end_of_elaboration(lambda: pp("eoe")) gs.end_of_simulation(lambda: pp("ssss")) gs.end_of_simulation(lambda: pp("eos")) # A simple process to keep the kernel alive a bit def goon(): for i in range(4): gs.wait(25 + 25 * i, gs.NS) print gs.simulation_time() gs.spawn(goon) # Start! gs.start(100, gs.NS) #gs.start()