小编bai*_*ibo的帖子

Verilog转移延伸结果?

我们有以下代码行,我们知道它regF是16位长,regDregE8位,长8位,长regC3位,假设无符号:

regF <= regF + ( ( regD << regC ) & { 16{ regE [ regC ]} }) ;
Run Code Online (Sandbox Code Playgroud)

我的问题是:移位是regD << regC假设结果是8位还是会因为&16位向量的按位而扩展到16位?

verilog synthesis hdl flip-flop

2
推荐指数
1
解决办法
704
查看次数

if else if else子句序列的逻辑等价

我严重睡眠不足,我需要帮助重写这个小的Python逻辑

for _ in range(100):
    if a:
        continue
    elif b:
        continue
    elif c and d:
        continue
    else:
        e()
Run Code Online (Sandbox Code Playgroud)

我希望有类似的东西

if (some_exprt of a,b,c,d):
    e()
Run Code Online (Sandbox Code Playgroud)

我得到的是:

if not a and  not b and (not c or not d):
   e()
Run Code Online (Sandbox Code Playgroud)

但是我真的不知道这是否正确,我是对的吗?

python logic equivalence control-flow

1
推荐指数
1
解决办法
358
查看次数

std :: sort throws Segmentation Fault C++

这是我的代码

bool cmp (const char &a, const char &b)
{   
    if ((int) a == (int) b)
    {
        return false;
    }

    if ((int) a > (int) b)
    {
        return false;
    }
    return true;
}   
std::sort(
        dfaVector.at(0).getSigma().begin(),
        dfaVector.at(0).getSigma().end(),
        cmp);
Run Code Online (Sandbox Code Playgroud)

getSigma()返回std::vector<char>,它们不是空的 - 我检查了一下.如果你愿意,我可以从gdb发布堆栈跟踪.我正在使用g ++ 4.8,OS Mint 14

回答

正如@livingissuicide所建议的那样,问题是getSigma()需要返回一个引用(即......常量,@ PhoenixX_2).解释为什么 它需要返回一个引用(以及为什么只是一个简单的副本是不够的)是因为

问题是有两个getSigma调用,产生两个不同的向量.传递给sort的一对迭代器不是有效范围 - 两个迭代器指向不同的容器.

解释由@IgorTandetnik提供.

c++ sorting stl segmentation-fault

0
推荐指数
1
解决办法
1371
查看次数