Using standart Python modules

I need to write a data filter and it would be perfect if I can use regular expression module for this.

I receive input data, than I should check it and mark as valid.
I tried to write something like this, but it is wrong:

from myhdl import *
import re

def HelloWorld( Clock, valid_data, input_data):
check = bool()

def checker(s):
    return re.match("(^[a-z])", str(s), flags=0)

check = checker(input_data) 

def top():   
    if check  : = input_data

return top

Can I use “re.” module inside my code?


It depends; inside code used for simulation yes; inside code to be converted no.
Your code sample is incomplete, but assuming that input_data is a Signal(intbv()[8:]), thus representing a single character you can rewrite your test as:

    if input_data >= ord('a') and input_data <= ord('z'): = input_data

Of course this may get tedious for more complicated cases. In that case you may outsource the check to a function, but if it needs to convert this function would still have to use the above code style.

Thank you very much!