示例#1
0
def create_regfile():
    """
    [0] 0x0018: control register
    [1] 0x0020:
    [2] 0x0040:
    [3] 0x0080:
    [4] 0x0100: regro (read-only)
    [5] 0x0200: status (read-only, with namedbits)
    :return:
    """
    global regdef
    print("creating test register file")
    regfile = RegisterFile()
    regfile.base_address = 0

    # --register 0--
    reg = Register('control', width=8, access='rw', default=0, addr=0x0018)
    reg.comment = "register 0"
    reg.add_namedbits('enable', slice(1, 0))  # read-only namedbit
    reg.add_namedbits('loop', slice(2, 1))    # read-only namedbit
    regfile.add_register(reg)
    
    # -- more registers register --
    for addr, default in zip((0x20, 0x40, 0x80),
                             (0xDE, 0xCA, 0xFB)):
        reg = Register('reg%s' % (addr,), 8, 'rw', default, addr)
        regfile.add_register(reg)

    # -- read only register --
    reg = Register('regro', 8, 'ro', 0xAA, 0x100)
    regfile.add_register(reg)

    # another read only register, with named bits
    reg = Register('status', 8, 'ro', 0, 0x200)
    reg.add_namedbits('error', slice(1, 0))  # bit 0, read-write namedbit
    reg.add_namedbits('ok', slice(2, 1))     # bit 1, read-write namedbit
    reg.add_namedbits('cnt', slice(8, 2))    # bits 7-2, read-write namedbit
    regfile.add_register(reg)

    return regfile
示例#2
0
def create_regfile():
    """
    [0] 0x0018: control register
    [1] 0x0020:
    [2] 0x0040:
    [3] 0x0080:
    [4] 0x0100: regro (read-only)
    [5] 0x0200: status (read-only, with namedbits)
    :return:
    """
    global regdef
    print("creating test register file")
    regfile = RegisterFile()
    regfile.base_address = 0

    # --register 0--
    reg = Register('control', width=8, access='rw', default=0, addr=0x0018)
    reg.comment = "register 0"
    reg.add_namedbits('enable', slice(1, 0))  # read-only namedbit
    reg.add_namedbits('loop', slice(2, 1))  # read-only namedbit
    regfile.add_register(reg)

    # -- more registers register --
    for addr, default in zip((0x20, 0x40, 0x80), (0xDE, 0xCA, 0xFB)):
        reg = Register('reg%s' % (addr, ), 8, 'rw', default, addr)
        regfile.add_register(reg)

    # -- read only register --
    reg = Register('regro', 8, 'ro', 0xAA, 0x100)
    regfile.add_register(reg)

    # another read only register, with named bits
    reg = Register('status', 8, 'ro', 0, 0x200)
    reg.add_namedbits('error', slice(1, 0))  # bit 0, read-write namedbit
    reg.add_namedbits('ok', slice(2, 1))  # bit 1, read-write namedbit
    reg.add_namedbits('cnt', slice(8, 2))  # bits 7-2, read-write namedbit
    regfile.add_register(reg)

    return regfile
示例#3
0
def create_regfile():
    # create a register file
    regfile = RegisterFile()

    # create a status register and add it to the register file
    reg = Register('status', width=8, access='ro', default=0)
    regfile.add_register(reg)

    # create a control register with named bits and add
    reg = Register('control', width=8, access='rw', default=1)
    reg.add_namedbits('enable', bits=0, comment="enable the component")
    reg.add_namedbits('pause', bits=1, comment="pause current operation")
    reg.add_namedbits('mode', bits=(4, 2), comment="select mode")
    regfile.add_register(reg)

    return regfile
示例#4
0
import myhdl
from myhdl import Signal, intbv, always
from rhea.system import Register, RegisterFile
from . import led_stroby, led_count, led_dance


# create a register file
regfile = RegisterFile()

# create a status register and add it to the register file
reg = Register('status', width=8, access='ro', default=0)
regfile.add_register(reg)

# create a control register with named bits and add
reg = Register('control', width=8, access='rw', default=1)
reg.add_namedbits('enable', bits=0, comment="enable the compoent")
reg.add_namedbits('pause', bits=1, comment="pause current operation")
reg.add_namedbits('mode', bits=(4, 2), comment="select mode")
regfile.add_register(reg)


@myhdl.block
def led_blinker(glbl, membus, leds):
    clock = glbl.clock
    # instantiate the register interface module and add the 
    # register file to the list of memory-spaces
    regfile.base_address = 0x8240
    regfile_inst = membus.add(glbl, regfile)    
    
    # instantiate different LED blinking modules
    led_modules = (led_stroby, led_dance, led_count,)