verilog synthesis

各厂商综合工具,对HDL综合时都定义了一些综合属性这些属性可指定a declaration,a module item,a statement, or a port connection 不同的综合方式。

语法为:

/* synthesis, <any_company_specific_attribute = value_or_optional_value */

下面就是Altera的几个常用的Synthesis attributes

Noprune

A Verilog HDL synthesis attribute that prevents the Quartus II software from removing a register that does not directly or indirectly feed a top-level output or bidir pin.

For example:

reg reg1 /* synthesis noprune */;

keep

A Verilog HDL synthesis attribute that directs Analysis & Synthesis to not minimize or remove a particular net when optimizing combinational logic.

For example:

wire keep_wire /* synthesis keep */;

preserve

A Verilog HDL synthesis attribute that directs Analysis & Synthesis to not minimize or remove a particular register when eliminating redundant registers or registers with constant drivers.

For example:

reg reg1 /* synthesis preserve */;

ram_init_file

A Verilog HDL synthesis attribute that specifies initial contents of an inferred memory.

For example:

reg [7:0] mem[0:255] /* synthesis ram_init_file = " my_init_file.mif" */;

ramstyle

A Verilog HDL synthesis attribute that specifies the type of TriMatrix Memory block to use when implementing an inferred RAM.

M512", "M4K", "M9K", "M144K", "MLAB", "M-RAM”

For example:

reg [0:7] my_ram[0:63] /* synthesis ramstyle = "M512" */;

translate_off or translate_on

Verilog HDL synthesis directives that direct Analysis & Synthesis to ignore portions of the design code that are specific to simulation and not relevant to logic synthesis.

For example:

parameter tpd = 2; // Generic delays

// synthesis translate_off

#tpd;

// synthesis translate_on

关于状态机有下面三个综合属性:

full_case
A Verilog HDL synthesis attribute that directs Analysis & Synthesis to treat unspecified state values in a Verilog Design File Case Statement as don't care values, and therefore to treat the Case Statement as "full".

仅用于Verilog ,与case 语句一起使用表明所有可能的状态都已经给出不需要其他逻辑保持信号的值.

module full_case (a, sel, y);
   input [3:0] a;
   input [1:0] sel;
   output y;
   reg y;
   always @(a or sel)                case (sel)      // synthesis full_case
         2'b00: y="a"[0];
         2'b01: y="a"[1];
         2'b10: y="a"[2];
      endcase
endmodule

parallel_case
A Verilog HDL synthesis attribute that directs Analysis & Synthesis to implement parallel logic rather than a priority scheme for all case item expressions in a Verilog Design File Case Statement.

仅用于Verilog ,与case 语句一起使用强制生成一个并行的多路选择结构而不是一个优
先译码结构.

module parallel_case (sel, a, b, c);
   input [2:0] sel;
   output a, b, c;
   reg a, b, c;
   always @(sel)                  begin
      {a, b, c} = 3'b0;
      casez (sel)                // synthesis parallel_case
         3'b1??: a = 1'b1;
         3'b?1?: b = 1'b1;
         3'b??1: c = 1'b1;
      endcase
   end
endmodule

syn_encoding
A Verilog HDL synthesis attribute that determines how the Quartus II software should encode the states of an inferred state machine.
强制重新状态机的状态编码方式.有default,one-hot,sequential,gray,johnson,compact,user几种编码方式

(* syn_encoding = "user" *) reg [1:0] state;
parameter init = 0, last = 3, next = 1, later = 2;

always @ (state) begin
case (state)
init:
out = 2'b01;
next:
out = 2'b10;
later:
out = 2'b11;
last:
out = 2'b00;
endcase
end

In the above example, the states will be encoded as follows:

init   = "00"
last   = "11"
next   = "01"
later   = "10"

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: Verilog是一种硬件描述语言,用于设计和描述数字电路。RTL综合是将Verilog代码转化为电路网表的过程,它是一种重要的设计方法。为了获得高效、可靠和可维护的电路设计,Verilog编码风格在RTL综合起着关键作用。 首先,RTL综合需要使用规范的结构体和信号命名。可以使用模块层次结构,并使用模块注释以提高可读性。对于信号命名,应使用有意义且清晰的名称,以便更好地理解信号的功能和作用。 其次,在RTL综合,应尽量使用阻塞赋值或组合逻辑。阻塞赋值使用"="操作符,表示并行的赋值关系;组合逻辑使用非阻塞赋值,使用"<="操作符,表示时序上的赋值关系。正确使用这些赋值方式,能够避免潜在的时序和逻辑错误,提高代码的可靠性。 此外,应避免在时序逻辑使用过多的非阻塞赋值和条件语句。过多的非阻塞赋值可能导致意外的组合逻辑关系。而条件语句可能导致状态机的复杂性增加,使逻辑难以理解和维护。因此,在RTL综合,应尽量保持代码简洁和清晰。 最后,在RTL综合,应尽量避免使用不确定性的语法和功能。例如,应明确指定信号的宽度,而不是依赖于默认宽度。此外,应注意时序和同步问题,避免设计的竞争和冲突。 综上所述,RTL综合Verilog编码风格应遵循规范的结构体和信号命名、合理使用阻塞赋值和组合逻辑、避免过多的非阻塞赋值和条件语句,以及避免不确定性的语法和功能。这些编码风格能够提高代码的可读性、可维护性和可靠性,从而提高RTL综合的效果。 ### 回答2: Verilog是一种硬件描述语言(HDL),用于描述和设计数字逻辑电路。RTL综合是将Verilog代码转换为门级网表或等效的硬件电路。因此,在编写Verilog代码时,需要遵循一定的编码风格,以便在RTL综合过程达到更好的综合结果。 首先,为了实现可读性和维护性,应尽量使用自注释,清晰简洁的变量和模块命名方式。代码应具有良好的结构,并使用缩进和空格来增强可读性。 其次,应该遵循“单一责任原则”,每个模块应该只实现一个功能或任务,并应该避免使用全局变量。这样可以简化代码的阅读和理解,并提高代码重用性。 除此之外,应尽量避免使用复杂的内部逻辑结构,例如嵌套的if-else语句。可以使用case语句或选择语句来替代,以提高可读性和RTL综合效果。 另外,应该避免使用不必要的延迟和无用的逻辑操作。尽量将逻辑操作放在always块,以防止无谓的综合结果。 此外,在使用Verilog代码时,还应遵循以下几个细则: 1. 连接应该采用连线和端口来实现,而不是使用存储器等间变量。 2. 逻辑应该是连续的,避免在顺序块引入额外的延迟。 3. 常量和参数应该使用参数化和宏定义来提高代码的可重用性和灵活性。 总结起来,RTL综合的Verilog编码风格应具备可读性、维护性、简洁性和高效性。通过遵循以上几点,能够优化综合结果,并提供更可靠、可复用和高效的硬件设计。 ### 回答3: Verilog是一种常用于硬件描述语言(HDL)的编程语言,用于设计和编写数字逻辑电路。RTL合成是将RTL代码转化为硬件电路的过程,编写Verilog代码时需要遵循一些编码风格以便于RTL合成。以下是一些常见的Verilog RTL合成编码风格: 1. 模块化设计:将大的电路设计划分为小的模块,每个模块负责完成特定的功能。每个模块应该有明确的输入和输出,并且模块之间应该是独立的。 2. 时钟和时序:在设计使用明确的时钟信号,并确保时序逻辑正确。时钟的生成和接收应该按照规范的方式进行。 3. 寄存器传输级(RTL)描述:使用连续赋值风格(Continuous Assignment)来描述数据通路,以便RTL合成工具能够生成正确的硬件电路。连续赋值风格使用“assign”关键字,并将信号和表达式连接在一起。 4. 按位操作:在RTL代码使用位操作符,如与(&)、或(|)、非(~)、异或(^)等,以实现逻辑运算。 5. 使用非阻塞赋值:在时序逻辑,使用非阻塞赋值方式(<=)来赋值寄存器,以便确保正确的时序关系。 6. 输入和输出端口:按照需要为每个模块定义明确的输入和输出端口,并使用合适的类型和位宽来定义它们。 7. 注释和命名:在代码添加注释,以便能够更好地理解代码的功能和结构。此外,采用清晰的命名规范,以便于他人理解和维护代码。 8. 避免不确定行为:在编写代码时避免使用不确定行为,如不明确赋值、未初始化变量等。这些不确定行为可能会导致RTL合成工具生成不可预测的硬件电路。 综上所述,对于RTL合成,使用模块化设计、时序正确的时钟和非阻塞赋值,遵循连续赋值风格、位操作等编码风格可以帮助编写高效、可合成的Verilog代码

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值