[myhdl-list] syntax sugar?
Brought to you by:
jandecaluwe
From: Haitao Z. <ha...@gm...> - 2005-03-02 20:20:14
|
One thing I miss in the MyHDL idiom is the simple concurrent statement: a <= expr or assign a = expr In myhdl one has to do def assign_blk(): while 1: yield signals in expr a.next = expr or: def assign_blk(): def blk(): a.next = expr return always_comb(blk) AND one needs to keep track of all the generators: assign_blk_list.append(assign_blk()) Now of course the regular HDL statement and the myhdl are semantically equivalent, so you may call the regular concurrent assignment simple syntax sugar. But it does hide the details from the user and it is a very good abstraction that can be consistently understood. In a real design when one does a fair amount of concurrent assignment the tedium of using the myhdl syntax could quickly add up. I understand since myhdl is embedded in pure python it has to use all the defs to control the evaluation and the partial evaluation. One possibility is to add syntax sugar like the following: assign("a", "expr") And then hide the details in the assign function. One can try to dynamically generate the necessary code in the assign function and call exec, however this does not work with the inspect function used by toVerilog and always_comb. I am not up to the task of adding this capability natively to the myhdl codebase. Another way to get around it may be to use code generation tools to transform the short hand. However with the tools I looked up on the web (Cog, Cheetah etc) the solution seems to be worse than the problem. Another nice to have (syntax sugar) is to be able to simply say: clocked( <code block> ) instead of def clocked_blk(): while 1: yield posedge(clk) <code block> clocked_blk_list.append(clocked_blk()) Comes in handy for all synchronous designs, but does not make as much difference as the cocurrent assignment. This one is no longer python semantics unless we put all <code block> in a '''string''', but that would mess up the code highlighting in my editor :( Haitao |