Exemple #1
0
#   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"
    print "producer:", gs.time(), "end"

    # prod_unlim()
Exemple #2
0
        self.file_output.add(self.data)


# The memory module
class memory:
    def doit(self):
        while True:
            gs.wait(self.in1.write_event())  # avoid pending read() at the end
            addr = self.in1.read()
            self.out.write(self.MEM[addr]())

    def __init__(self, in1, out):
        self.in1 = in1
        self.out = out
        gs.spawn(self.doit)
        # Get memory contents as a parameter
        self.MEM = gs.param("MEM")


# Load config file
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)

# Start!
gs.start()
Exemple #3
0
            addr = self.in1.read()
            self.out.write(self.MEM[addr]())

    def __init__(self, in1, out):
        self.in1 = in1
        self.out = out
        gs.spawn(self.doit)
        # Get memory contents as a parameter
        self.MEM = gs.param("MEM")


# Load config file
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"))