小编xeb*_*btl的帖子

我如何参考"罪"?

我可以定义一个子程序并像这样引用它

sub F { q(F here) }
$f = \&F;
print &$f           # prints “F here”
Run Code Online (Sandbox Code Playgroud)

但是我怎么能这样做,例如sin

$f = \&sin;
print &$f           # error: Undefined subroutine &main::sin called
Run Code Online (Sandbox Code Playgroud)

听起来好像我应该可以使用\&MODULE::sin; 明显地cos不在main,但它在哪个模块?我没有看到任何记录.

perl reference subroutine

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

我可以在配置中使用“for all”来绑定生成的实例吗?

我的 VHDL 架构实例化了一堆库单元,其中一些在generate块内,例如

a_inst: foo_cell
  port map ( ... );

b_gen: for i in 1 to 3 generate
  b_inst_i : foo_cell
    port map ( ... );
end generate b_gen;
Run Code Online (Sandbox Code Playgroud)

在配置中,我想将这些实例绑定到库中的特定配置。我想使用for all

for all : foo_cell
  use configuration foo_lib.foo_cell_cfg;
end for;
Run Code Online (Sandbox Code Playgroud)

人们可能期望这也涵盖这些generate块,但不,我发现的最简洁的可能性是

for b_gen
  for all : foo_cell
    use configuration foo_lib.foo_cell_cfg;
  end for;
end for;
Run Code Online (Sandbox Code Playgroud)

需要对每个 重复此操作generate

有没有更简洁的方法来达到相同的结果?

编辑:这是一个可编译的示例(为了简单起见,使用“库单元”work而不是单独的库)

entity foo_cell is
end foo_cell;

architecture RTL of foo_cell is
begin …
Run Code Online (Sandbox Code Playgroud)

vhdl

5
推荐指数
0
解决办法
1142
查看次数

如何跳过Fortran无格式文件中的数组?

我的程序在Fortran中读取"未格式化"的文件.除此之外,这个文件包含一个我的程序不需要的数组,但是它可以变得非常大.我想跳过这个数组.

如果这是编写数据的程序:

program write
  real :: useless(10), useful=42

  open(123, file='foo', form='unformatted')
  write(123) size(useless)
  write(123) useless
  write(123) useful
end program write
Run Code Online (Sandbox Code Playgroud)

然后这适用于阅读:

program read
  integer :: n
  real, allocatable :: useless(:)
  real :: useful

  open(123, file='foo', form='unformatted')
  read(123) n
  allocate(useless(n))
  read(123) useless
  read(123) useful

  print*, useful
end program read
Run Code Online (Sandbox Code Playgroud)

但我想避免分配"无用"数组.我发现了这个

program read2
  integer :: n, i
  real :: useless
  real :: useful

  open(123, file='foo', form='unformatted')
  read(123) n
  do i=1,n
     read(123) useless
  end do
  read(123) useful

  print*, useful
end program read2
Run Code Online (Sandbox Code Playgroud)

不起作用( …

io fortran binaryfiles

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

如何将`logging`警告变成错误?

我使用的库通过logging模块(logging.Logger'swarn()error()方法)发出警告和错误。我想实现一个将警告转换为错误的选项(即,警告失败)。

有没有简单的方法来实现这一目标?

通过查看文档,我看不到现成的解决方案。我认为通过添加自定义Handler对象是可能的,但我不确定如何“正确”做到这一点。任何指针?

python logging

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

标签 统计

binaryfiles ×1

fortran ×1

io ×1

logging ×1

perl ×1

python ×1

reference ×1

subroutine ×1

vhdl ×1