标签: hdl

始终使用@* | 意义和缺点

你能说那是什么意思吗

  • 总是 @ *

使用该语句后是否有任何可能的副作用?

verilog hdl system-verilog

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

在verilog中使用带有for循环的参数进行位选择

我在Verilog中设计一些硬件,但为了保持灵活性,我使用参数来设置宽度,这样我就可以根据需要修改宽度而无需修改代码.我遇到的一个问题是在一段代码中我希望能够并行写入多个单元格.

parameter DATA_WIDTH = 16;
parameter BUFFER_SIZE = 16;
parameter LOAD_WIDTH = DATA_WIDTH*BUFFER_SIZE;

input [LOAD_WIDTH-1:0] i_load_data;

reg [DATA_WIDTH-1:0]    r_data_buf[BUFFER_SIZE-1:0];

...

always@(posedge clk) begin
....
    else if (i_load_flag) begin
        for(i = 0; i < BUFFER_SIZE; i = i + 1)
            r_data_buf[i] <= i_load_data[i * BUFFER_SIZE + BUFFER_SIZE - 1:i * BUFFER_SIZE];
    end
end
Run Code Online (Sandbox Code Playgroud)

我需要将r_data_buf保留为数组,因为必须读取数据的方式.我也不清楚为什么verilog不喜欢这个代码,因为在编译时一切都是常量,或者我如何修复它并仍然得到我想要的行为.

parameters for-loop verilog hdl

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

编译错误,还是对 SystemVerilog 的误解?未声明的端口类型在模拟中有效

我有一个带有多个input logicoutput logic端口的模块,一个端口应该是input foo::bar,其中 foo 是一个包,而 bar 是一个枚举。但是,我离开了input,所以很简单foo::bar。然而,它仍然可以在模拟中工作(测试通过,您可以在波形上看到该值正在正确传输)。

LRM,我们有:

inout_declaration ::= 
  inout port_type list_of_port_identifiers 
input_declaration ::= 
  input port_type list_of_port_identifiers 
  | input data_type list_of_variable_identifiers 
output_declaration ::= 
  output port_type list_of_port_identifiers 
  | output data_type list_of_variable_port_identifiers 
interface_port_declaration ::= 
  interface_identifier list_of_interface_identifiers 
  | interface_identifier . modport_identifier list_of_interface_identifiers 
ref_declaration ::= 
  ref data_type list_of_port_identifiers 
port_type ::=  
  [ net_type_or_trireg ] [ signing ] { packed_dimension } 
Run Code Online (Sandbox Code Playgroud)

它显然不是 inout_dec、input_dec、output_dec 或 ref_dec。深入研究 LRM,net_type_or_triregsupply0 | supply1 | …

hardware hdl system-verilog

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

数组中的个数

我试图在 Verilog 中计算 4 位二进制数中 1 的数量,但我的输出出乎意料。我尝试了几种方法;这是我认为应该工作的一个,但它没有。

module ones(one,in);
input [3:0]in;
output [1:0]one;

assign one = 2'b00; 
assign one = one+in[3]+in[2]+in[1]+in[0] ;

endmodule
Run Code Online (Sandbox Code Playgroud)

verilog dataflow hdl

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

如何在凿子中获取 UInt() 的大小?

也许这很容易,但我不能简单地找到如何在 Chisel 中获取 UInt() 值的位大小?

我知道如何通过声明设置大小:

val a = UInt(INPUT, 16)
Run Code Online (Sandbox Code Playgroud)

但是要获得“a”大小,是否有类似的属性:

val size = a.?
Run Code Online (Sandbox Code Playgroud)

或者 :

val size = width(a)
Run Code Online (Sandbox Code Playgroud)

hdl chisel

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

VHDL 中的通用移位算术

我正在设计通用移位算术运算符。除了按照下面介绍的方式使用 32 位多路复用器(解码器)之外,还有更好的方法来实现它吗?

ENTITY isra IS 
PORT (
  clk:    in std_logic;
  rst:    in std_logic;
  di:     in std_logic_vector (31 downto 0);
  sel:    in std_logic_vector (31  downto 0);
  res:    out std_logic_vector (31 downto 0) := (others => '0')
);
END isra;


PROCESS
  BEGIN
    WAIT UNTIL clk'EVENT AND clk = '1';
    IF rst = '1' THEN
      res <= (others => '0');
    ELSE
    CASE sel IS
        when X"00000001"  => res <= to_stdlogicvector(to_bitvector(a) sra 1);
        when X"00000002"  => res <= to_stdlogicvector(to_bitvector(a) sra 2);
        ...
        when …
Run Code Online (Sandbox Code Playgroud)

circuit fpga vhdl hdl

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

<= a + 1是VHDL的一个好习惯吗?

如果我在VHDL过程中编写语句来指定a为+ 1,这是一个好习惯吗?

我对此感到困惑,因为模拟器工作正常,但当我尝试在FPGA中实现它时,综合工具抱怨创建锁存器.

这是什么意思?

hardware vhdl hdl modelsim xilinx

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

Verilog:如何取绝对值

在 verilog 中,我有一个二进制值数组。如何取减去值的绝对值?

Verilog 代码:

module aaa(clk);
  input clk;

  reg [7:0] a [1:9];  
  reg [7:0] s [1:9];

  always@(posedge clk)  
  begin
    s[1] = a[1] - a[2];
    s[2] = a[2] - a[3];
    s[3] = a[1] + a[3];
  end
endmodule
Run Code Online (Sandbox Code Playgroud)

我想我s[1]s[2]值总是正的。我怎样才能在可综合的 verilog 中做到这一点?

我试过使用signed reg,但它显示一个错误。

verilog hdl vlsi

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

systemVerilog 嵌套叉

我遇到了别人写的代码,我不明白它是如何工作的?

 // Task A
 task sub_run_a();
    while ($time < 50us) begin
    #1us;
    $display("sub_run_a(): ping at time %d", $time);
  end
endtask : sub_run_a

// Task B
task sub_run_b();
  #5us;
  $display("sub_run_b() finished");
endtask : sub_run_b

// Task C
task sub_run_c();
  #10us;
  $display("sub_run_c() finished");
endtask : sub_run_c
Run Code Online (Sandbox Code Playgroud)

这就是测试台的设置方式:

fork 
  fork
    sub_run_c();  
    sub_run_b();
  join
    sub_run_a();
join_any
Run Code Online (Sandbox Code Playgroud)

看仿真结果,好像所有的任务都是并行运行的,不明白是怎么回事。

是不是任务 A 不应该在任务 B 和任务 C 完成之前开始?

但是,情况并非如此,因为这是输出:

# KERNEL: sub_run_a(): ping at time                 1000
# KERNEL: sub_run_a(): ping at time                 2000
# KERNEL: sub_run_a(): ping at …
Run Code Online (Sandbox Code Playgroud)

verilog hdl system-verilog

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

如何在 Chisel 中正确定义输出 Reg

您可能知道 Verilog 中的“输出 reg”,这是非常有用的功能。
但是在 Chisel 中,我找不到如何做类似的事情。当我需要寄存器输出时,我应该这样做:

package filter

import chisel3._

class TestReg extends Module {
    val io = IO( new Bundle {
        val din  = Input(SInt(32.W))
        val ena  = Input(Bool())
        val dout = Output(SInt())
    })

    val dout = RegInit(0.S(32.W))
    when (io.ena) {
        dout := io.din + 77.S
    }
    io.dout <> dout
}
Run Code Online (Sandbox Code Playgroud)

是否有更“短”的方式来创建输出 reg?
我正在寻找的是在 IO 包中定义 Reg 并将其写入 register
类似这样的东西:

class TestReg extends Module {
    val io = IO( new Bundle {
        val din  = Input(SInt(32.W))
        val ena …
Run Code Online (Sandbox Code Playgroud)

hdl register-transfer-level chisel

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