OpenCores
URL https://opencores.org/ocsvn/hdl-deflate/hdl-deflate/trunk

Subversion Repositories hdl-deflate

[/] [hdl-deflate/] [trunk/] [test_deflate.py] - Diff between revs 4 and 5

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 4 Rev 5
Line 5... Line 5...
 
 
from myhdl import delay, now, Signal, intbv, ResetSignal, Simulation, \
from myhdl import delay, now, Signal, intbv, ResetSignal, Simulation, \
                  Cosimulation, block, instance, StopSimulation, modbv, \
                  Cosimulation, block, instance, StopSimulation, modbv, \
                  always, always_seq, always_comb, enum, Error
                  always, always_seq, always_comb, enum, Error
 
 
from deflate import IDLE, WRITE, READ, STARTC, STARTD, LBSIZE, IBSIZE, CWINDOW
from deflate import IDLE, WRITE, READ, STARTC, STARTD, LBSIZE, IBSIZE, \
 
                    CWINDOW, COMPRESS
 
 
MAXW = 2 * CWINDOW
MAXW = 2 * CWINDOW
 
 
COSIMULATION = True
COSIMULATION = True
COSIMULATION = False
COSIMULATION = False
Line 53... Line 54...
        str_data = "".join([str(random.randrange(0,2))
        str_data = "".join([str(random.randrange(0,2))
                             for i in range(1000)])
                             for i in range(1000)])
        b_data = str_data.encode('utf-8')
        b_data = str_data.encode('utf-8')
    else:
    else:
        raise Error("unknown test mode")
        raise Error("unknown test mode")
    b_data = b_data[:IBSIZE-4]
    # print(str_data)
 
    b_data = b_data[:IBSIZE - 4 - 20]
    zl_data = zlib.compress(b_data)
    zl_data = zlib.compress(b_data)
    print("From %d to %d bytes" % (len(b_data), len(zl_data)))
    print("From %d to %d bytes" % (len(b_data), len(zl_data)))
    print(zl_data)
    print(zl_data)
    return b_data, zl_data
    return b_data, zl_data
 
 
Line 102... Line 104...
                    # print("write", i)
                    # print("write", i)
                    i_data.next = zl_data[i]
                    i_data.next = zl_data[i]
                    i_addr.next = i
                    i_addr.next = i
                    i = i + 1
                    i = i + 1
                else:
                else:
                    print("Wait for space")
                    # print("Wait for space")
 
                    pass
                tick()
                tick()
                yield delay(5)
                yield delay(5)
                tick()
                tick()
                yield delay(5)
                yield delay(5)
            i_mode.next = IDLE
            i_mode.next = IDLE
Line 444... Line 447...
            else:
            else:
                print(len(UDATA))
                print(len(UDATA))
                print("DECOMPRESS test OK!, pausing", tbi)
                print("DECOMPRESS test OK!, pausing", tbi)
                i_mode.next = IDLE
                i_mode.next = IDLE
                tbi.next = 0
                tbi.next = 0
 
                if not COMPRESS:
 
                    tstate.next = tb_state.CPAUSE
 
                else:
                tstate.next = tb_state.PAUSE
                tstate.next = tb_state.PAUSE
                # tstate.next = tb_state.HALT
                # tstate.next = tb_state.HALT
                # state.next = tb_state.CPAUSE
                # state.next = tb_state.CPAUSE
                resume.next = 1
                resume.next = 1
                # tstate.next = tb_state.CWRITE
                # tstate.next = tb_state.CWRITE
Line 566... Line 572...
                print(len(UDATA))
                print(len(UDATA))
                print("ALL OK!", tbi)
                print("ALL OK!", tbi)
                led2_r.next = 0
                led2_r.next = 0
                i_mode.next = IDLE
                i_mode.next = IDLE
                resume.next = 1
                resume.next = 1
                if SLOWDOWN <= 4:
 
                    raise StopSimulation()
 
                """
                """
                """
                """
                tstate.next = tb_state.CPAUSE
                tstate.next = tb_state.CPAUSE
                # tstate.next = tb_state.HALT
                # tstate.next = tb_state.HALT
 
 
        elif tstate == tb_state.CPAUSE:
        elif tstate == tb_state.CPAUSE:
 
            if SLOWDOWN <= 4:
 
                raise StopSimulation()
            if resume == 0:
            if resume == 0:
                print("--------------RESET-------------")
                print("--------------RESET-------------")
                o_led.next = o_led + 1
                o_led.next = o_led + 1
                tstate.next = tb_state.RESET
                tstate.next = tb_state.RESET
            else:
            else:

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.