我正在尝试使用Peter Ashenden的书"VHDL的设计者指南"来学习VHDL,但似乎无法摆脱我错过了与敏感性列表相关的基本项目的感觉.
例如,一个问题是"编写一个表示具有整数输入和输出的简单ALU的模型,以及一个类型为bit的函数选择输入.如果函数选择为'0',则ALU输出应该是输入的总和,否则输出应该是输入的差异."
我的解决方案是
entity ALU is
port (
a : in integer; -- A port
b : in integer; -- B port
sel : in bit; -- Fun select
z : out integer); -- result
end entity ALU;
architecture behav of ALU is
begin -- architecture behav
alu_proc: process is
variable result : integer := 0;
begin -- process alu_proc
wait on sel;
if sel = '0' then
result := a + b;
else
result := a - b; …Run Code Online (Sandbox Code Playgroud) 有没有办法从子类链接调用超类而不强制转换,重写方法或使用接口.比如做的时候
class A {
public:
A& foo() { return *this; }
};
class B : public A {
public:
B& bar() { return *this; }
};
int main(void) {
B b;
b.foo().bar();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
用clang编译时我得到了错误
main.cpp:13:10: error: no member named 'bar' in 'A'
b.foo().bar();
~~~~~~~ ^
1 error generated.
Run Code Online (Sandbox Code Playgroud)
我可以看到为什么(因为A返回对self的引用),但我希望它返回它的子类B类,因为它在该上下文中被调用.这可能吗?或者我需要将B定义为
class B : public A {
public:
B& bar() { return *this; }
B& foo() { A::foo(); return *this; }
};
Run Code Online (Sandbox Code Playgroud)
并使foo()虚拟?
我知道我可以使用net.DialTimeout来检查主机是否可以访问.但据我所知,使用这种方法我无法指定接口或取回主机所接触的接口
我正在寻找ping的功能-I flag,就像
ping -I eth0 www.google.se
但是我宁愿不依靠exec.Command来保持平台的兼容性