我需要在Veriog中实现4对1的功能.输入为4位,0-15之间的数字.输出是单个位,0或1.每个输入提供不同的输出,并且从输入到输出的映射是已知的,但输入和输出本身不是.我希望vcs能够成功优化代码,并使其尽可能短/整齐.到目前为止我的解
wire [3:0] a;
wire b;
wire [15:0] c;
assign c = 16'b0100110010111010; //for example but could be any constant
assign b = c[a];
Run Code Online (Sandbox Code Playgroud)
必须声明c是丑陋的,我不知道vcs是否会识别那里的K-map.这项工作以及案例陈述或联合正常形式的作业是否有效?
我正在为iOS创建合成器.在玩完并试图学习核心音频之后,我遇到了一个我无法理解的问题.我的正弦波会定期发出咔哒声,我猜这与相位有关.我看过几本关于这个主题的指南和书籍,并且都表明我正确地做了.
如果有人愿意为我查看我的代码,我将不胜感激.
static OSStatus renderInput(void *inRefCon, AudioUnitRenderActionFlags *ioActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber, UInt32 inNumberFrames, AudioBufferList *ioData)
{
// Get a reference to the object that was passed with the callback
// In this case, the AudioController passed itself so
// that you can access its data.
AudioController *THIS = (AudioController*)inRefCon;
// Get a pointer to the dataBuffer of the AudioBufferList
AudioSampleType *outA = (AudioSampleType *)ioData->mBuffers[0].mData;
float freq = THIS->Frequency;
float phase = THIS->sinPhase;
float envValue;
float sinSignal;
// The …Run Code Online (Sandbox Code Playgroud) 它在任何地方都被提到这个作为指导,但经过多次思考后我想知道如果我们在Always Block for Combinatorial中使用Nonblocking语句会造成什么伤害.我不会将两者混合在一起.但我觉得当我们在Always Block中使用Nonblocking for Combinatorial语句时,它更准确地代表了硬件.不是吗?
例如,如果我们采取以下电路:

在此图中,当输入a,b,c被提供时,输出x1和x将不会立即可用.将有门延迟.第一个x1将可用,然后x将可用.如果我们使用阻止语句,它们都可以立即使用 如果我们使用非阻塞,它更准确地类似于硬件.
例如,如果我们根据上图获取以下代码
module block_nonblock(output logic x,x1,y,y1,input logic a,b,c);
always@* begin : BLOCKING
x1 = a & b;
x = x1 & c;
end
always@* begin : NONBLOCKING
y1 <= a & b;
y <= y1 & c;
end
endmodule
Run Code Online (Sandbox Code Playgroud)
这综合为:

两者都被合成为和门,并给出相同的模拟结果,但是当我们检查增量时间输出的变化时,我觉得与阻塞相比,非阻塞更准确地匹配硬件.
我还经历了:IEEE P1364.1/D1.6Verilog®寄存器传输级综合标准草案,它规定了使用非阻塞进行顺序建模,但没有具体使用阻塞来使用Always Block进行组合建模.它说不要在组合语句中混合使用两者(阻塞和非阻塞).
因此,我们不应该在处理纯组合逻辑的总块中使用非阻塞用于组合语句(非顺序/不涉及时钟)
verilog synthesis fpga register-transfer-level system-verilog
我有一些我正在为一堂课写的VHDL代码.但是,综合工具将cell3,cell2和cell1识别为"死"代码,并且不会合成它.
我真的不知道是什么导致细胞3,2,1在合成中被去除; 我已经回顾了5次以上并且询问了几个不同的人,我找不到"为什么".
不寻找解决方案,只是指向原因的指针.
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity multiply is
Port ( a : in STD_LOGIC_VECTOR (3 downto 0);
b : in STD_LOGIC;
clk : in STD_LOGIC;
rst : in STD_LOGIC;
p : out STD_LOGIC);
end multiply;
architecture Behavioral of multiply is
component cell_a port(
s: in std_logic;
c: in std_logic;
a: in std_logic;
b: in std_logic;
clk: in std_logic;
c_out: out std_logic;
s_out: out std_logic);
end component;
signal c_s_0: std_logic; --loopback wire for cell …Run Code Online (Sandbox Code Playgroud) I recall seeing a paper a while back for an algorithm that could automatically and seamlessly "graft" texture from parts of an image onto another part of an image.
The approach was something along the lines of the following:
You'd build up a databases of small squares of pixels (perhaps 8X8) from the parts of the picture that are present.
然后,选择一个空像素(纹理嫁接的“目标”)进行填充,然后在数据库中查找与周围像素最匹配的正方形之一。然后,您将根据找到的正方形中相应像素的颜色为空像素着色。然后,选择另一个空白像素并重复进行,直到没有剩余的空白像素为止。
当然,这只是一个模糊的描述,因为我找不到对该算法的任何引用来刷新我对细节的记忆!有人可以帮忙吗?
我用VHDL编写了一个程序(用于Xilinx Spartan-6),按下按钮时递增计数器,当按下另一个按钮时将其重置为零.
但是,我的进程会抛出WARNING:Xst:647 - Input is never used. This port will be preserved and left unconnected...重置变量的错误- 尽管事实上它既用于进程的灵敏度又用作条件(同样多button,但不会被标记!).
binary_proc : process(CLK_1Hz, button, reset) --include all inputs on sensitivity list
begin
if rising_edge(CLK_1Hz) and button = '1' then
binary <= binary + 1;
else if reset = '1' then
binary <= (others => '0');
end if;
end if;
end process;
Run Code Online (Sandbox Code Playgroud)
但更奇怪的是,我可以通过简单地使用两个if语句而不仅仅是if-else if语句来解决这个问题,如下所示;
binary_proc : process(CLK_1Hz, button, reset) --include all inputs on sensitivity list
begin
if rising_edge(CLK_1Hz) and button …Run Code Online (Sandbox Code Playgroud) 这主要是出于好奇.
我最近一直在研究的一些VHDL代码中的一个片段类似于以下内容:
led_q <= (pwm_d and ch_ena) when pwm_ena = '1' else ch_ena;
Run Code Online (Sandbox Code Playgroud)
当然,这是一种多模式表达.但它也等同于以下基本逻辑表达式(至少在忽略非二进制状态时):
led_q <= ch_ena and (pwm_d or not pwm_ena);
Run Code Online (Sandbox Code Playgroud)
当在FPGA中实际实现时,逻辑利用率或效率方面的"比"更好吗?是否最好使用一个而不是另一个,或者编译器是否足够智能以自己选择"最佳"?
(好奇的是,表达式的目的是定义LED的状态 - 如果ch_ena为假,它应该始终关闭,因为通道被禁用,否则它应该是固定的或根据闪烁pwm_d,根据pwm_ena(PWM启用).我认为第一种形式比第二种形式更明显地描述了这一点,尽管实现第二种形式并不太难.)
综合完成后,我会收到许多文件,如 .fw、.mcs、.prm 和 .bit 文件,我们可以将 .bit 文件以外的其他文件转储到 FPGA 中吗?项目模式和非项目模式哪个更有优势?编码是在 verilog 中完成的。
我是电路综合的初学者,我经常遇到net这个词,但我永远无法找到它的标准定义.在我看来,它指的是任何一种"黑匣子",它接收输入并产生输出.所以它可以是一个大电路内的子电路,它可以是一个门阵列.我的理解是否正确?
如果对于给定的进程,我声明一个变量(假设是一个1位变量variable temp : std_logic;),那么如果给定的条件返回true,我可以为变量赋值,即
if (xyz=1) then --Assuming that this condition returns TRUE
temp:= '1';
Run Code Online (Sandbox Code Playgroud)
?? 这种逻辑是否可以用于ASIC?