- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
对于以下片段,Chisel 没有合成:
import Chisel._
import Node._
import scala.collection.mutable.HashMap
class PseudoLRU(val num_ways: Int) extends Module
{
val num_levels = log2Up(num_ways)
val io = new Bundle {
val last_used_cline = UInt(INPUT, width = num_levels)
val update_state = Bool(INPUT)
}
val state = Reg(Vec.fill(num_ways-1){Bool()})
private val msb = num_levels - 1
when (io.update_state) {
// process level 0
state(0) := !io.last_used_cline(msb, msb) // get the most significant bit
// process other levels
for (level <- 1 until num_levels) {
val offset = UInt((1 << level) - 1, width = log2Up(num_ways-1))
val bit_index = io.last_used_cline(msb, msb - level + 1) + offset
val pos = msb - level
val bit = io.last_used_cline(pos, pos)
state(bit_index) := !bit
}
}
}
object test_driver {
def main(args: Array[String]): Unit = {
val plru_inst = () => Module(new PseudoLRU(num_ways = 16))
chiselMain(args, plru_inst)
}
}
如果手动展开循环 for (level <- 1 until num_levels) 并折叠常量,则同样的行为:
when (io.update_state) {
state( 0 ) := !io.last_used_cline(3, 3)
state( io.last_used_cline(3, 3) + UInt(1, width = 3) ) := !io.last_used_cline(2, 2)
state( io.last_used_cline(3, 2) + UInt(3, width = 3) ) := !io.last_used_cline(1, 1)
state( io.last_used_cline(3, 1) + UInt(7, width = 3) ) := !io.last_used_cline(0, 0)
}
为两个片段(原始和展开/实例化的 16 种情况)生成的 verilog(和类似的 C++ 代码):
module PseudoLRU(input reset,
input [3:0] io_last_used_cline,
input io_update_state
);
wire T0;
wire[151:0] T1;
assign T0 = ! reset;
endmodule
不太明白为什么只有虚拟结构我应该怎么做才能强制执行逻辑综合?谢谢!
最佳答案
如果信号没有连接到任何东西,Chisel 将积极修剪您设计中的信号。
在您的情况下,您似乎没有来自 PsuedoLRU 的输出,只有输入“last_used_cline”和“update_state”。这就像在 C/C++ 中编写一个函数而不对函数的结果做任何事情。
现在在 C 中,您可以将变量标记为“volatile”以欺骗编译器保留您的代码(您 promise 其他人将使用该变量的值)。在 Chisel 中,您可以使用“debug()”强制信号存在。
我相信要强制你的 Vec of Regs 存在,你可以这样做:
for (i <- 0 until num_ways)
debug(state(i))
关于scala - Chisel 既不为 verilog 也不为 C++ 合成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20019839/
如标题所示,结构 Verilog 和行为 Verilog 之间的主要区别是什么? 最佳答案 根据 IEEE 标准,这些术语没有严格的定义。然而,习惯上,结构 是指使用模块实例来描述设计(尤其是对于较低
我正在尝试简单地转换流程图 state machine进入 Verilog代码。 但是我不知何故被以下内容困住了,因为我对 Verilog 几乎没有任何了解,所以我可能会遗漏一些东西。 状态机检测到
是否可以在 verilog 中参数化位域?本质上,我想使用参数或替代方法来定义位范围。我能想到的唯一方法是使用如下所示的`define,但似乎应该有更好的方法。 `define BITFIELD_SE
初学者在这里。我正在尝试在 Verilog 中编写一个简单的 16 位微处理器并在 Spartan 6 上实现它。 ALU 实现所有有符号操作(根本没有无符号操作)。所有输入都是连线并带有符号。结果存
我写了一些 Verilog 代码,其中部分代码如下: int i; add_bit = 1'b0; for (i = 0; i < add_len; i++)
我需要在我的 Verilog 代码中使用有理数。我寻找了任何资源,但找不到有关此问题的任何信息。如何在 Verilog 中定义有理数。 最佳答案 Verilog 有一个 real用于实数(浮点)数的数
我正在自学verilog。我正在阅读的这本书在介绍章节中指出,要执行除法,我们使用“/”运算符或“%”运算符。后面几章都说除法对于verilog来说太复杂了,不能综合,所以要进行除法就引入了很长的算法
是否可以在 Verilog 中创建 parameter 数组?例如,类似于以下内容: parameter[TOTAL-1 : 0] PARAM_ARRAY = {1, 0, 0, 2} 如果不可能,那
例如,假设我有一个 reg [7:0] myReg我给它赋值 -8'D69 我知道 Verilog 将它存储为 2 的补码,所以它应该存储为 10111011 我现在的问题是是否要对其执行操作,例如
我正在尝试编写一个用于遗传算法的适应度函数,该函数包含指数部分。那么我该如何实现这个函数( e^x ),其中 e :the base=2.7 ,x:exponent 在 verilog HDL 语言中
我在verilog中有一个语句,看起来像integer level = log(N)(其中N是一个参数,级别待确定)但我知道我无法在verilog中执行复杂的数学语句,所以我想知道是否有替代解决方案来
在 Verilog 中,您可以简单地使用模块语法创建模块。如何创建多个模块并调用另一个模块? 我的主模块有以下模块: module Lab7Part1(SW, HEX0, HEX1, HEX2, HE
在使用自上而下的方法在 verilog 中设计电路时,我可以从电路的行为开始,然后定义每个模块中的细节,以构建可综合的结构电路。但我怎么知道我的代码是否可综合呢?是否有任何指南可以遵循来支持 veri
如果我有一个 if 语句,例如: if(risingEdge && cnt == 3'b111) begin ... end 如果risingEdge不为真,它会检查cnt吗? 这在 HDL 内部
我一直在尝试构建一个模块,该模块返回(3 位)输入的二进制补码表示(第一位是符号)。我认为以下代码在概念上是正确的,但我可能遗漏了它的结构:当我尝试编译时,出现以下错误: (vlog-2110) Il
我对 HDL 语言非常陌生。我有一个关于如何对移位寄存器进行编程的问题。 (我知道我转向另一个方向)。为什么本书使用 wire[N-1:0] r_next?我的实现有什么缺点?谢谢 我的第一次尝试如下
郑重声明,我是一个十足的 Verilog 新手。我正在编写一个使用一些双向总线的模块。 inout wire [KEY_SIZE-1:0] prevKey; inout wire [TAG_SIZE-
我进行了搜索以了解 verilog 中的行为代码和数据流代码之间的区别。最后我找不到很好的例子,到处都在讲述他们所做的事情。例如: “它非常简单。名称本身就解释了它们是什么。数据流是描述程序的一种方式
在 Verilog 中,您可以简单地使用模块语法创建模块。您如何创建多个模块并从另一个模块调用一个? 我有以下模块是我的主要模块: module Lab7Part1(SW, HEX0, HEX1, H
我正在学习 verilog 分层事件队列。我对非事件事件有一点疑问。我知道它们是在当前模拟时间完成所有事件事件后执行的。但是我写了一个简单的代码来更好地理解这个概念,但我得到的结果让我感到困惑。这是我
我是一名优秀的程序员,十分优秀!