0

我需要将此代码转换为 python 中的 myhdl 以用于我的学校工作,任何人都可以帮助我吗?

library ieee;
use ieee.std_logic_1164.all;

entity simple_example is
    port (
        a : in std_logic;
        b : in std_logic;
        o : out std_logic   
    );
end simple_example;

architecture simple_example of simple_example is
    signal s : std_logic;
begin

    s <= a and b;
    o <= s or b;

end simple_example;
4

1 回答 1

0

您可以参考以下文档:http ://docs.myhdl.org/en/stable/manual/preface.html#

您可能会发现以下内容很有帮助:

from myhdl import *

@block
def simple_example(a , b, o):
    """
        input: a, b
        output: o
    """
    @always_comb
    def behave():
        s = a and b
        o = s or b
    return instances()


"""
Verification
"""

x = Signal(bool(0))
y = Signal(bool(0))
z = Signal(bool(0))

test = simple_example(x, y, z)
test.convert(hdl="VHDL", initial_values=True)
于 2021-09-17T14:41:39.803 回答