标签: verilog

在verilog中为模块实例中的寄存器赋值

我是 verilog 的初学者。我试图执行此代码以将值存储在另一个模块实例中的寄存器中。这是两个模块。

module main;
reg [15:0] A;
wire [15:0] B;
initial
begin
    A = 16'h1212;
end
copy a(B,A);
endmodule  

module copy(B,A);
input [15:0] A;
output reg [15:0] B;
initial
   B=A;
endmodule
Run Code Online (Sandbox Code Playgroud)

代码编译良好,但执行时 B 的值是“未知”。如果这样的分配不可能,是否有其他方法可以将值分配给模块实例中的寄存器(从该实例的输入)?

我正在使用 ModelSim Altera 网络版 6.3

verilog

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

在Verilog中创建可以存储实际值的数组

谁能告诉我如何创建一个可以real在 Verilog 中存储值的数组?我尝试了以下方法,但没有成功:

real [31:0] in1_table [0:256];

arrays verilog system-verilog

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

使用 if/else 和 case 语句时出现错误号 10170

我正在尝试编译以下代码,但每当我这样做时,我都会收到错误:

'10170 FSM.v(9) 文本“case”附近的 Verilog HDL 语法错误;期待一个操作数'

'10170 FSM.v(9) 文本“)”附近的 Verilog HDL 语法错误;预期“<=”或“=”

'10170 FSM.v(11) 文本“4”附近的 Verilog HDL 语法错误;期待“结束”

module FSM (in0, in1, in2, in3, S, out0, out1, out2, out3); 
input in0, in1, in2, in3, S;
output out0, out1, out2, out3;
reg out0, out1, out2, out3;
always @(in0 or in1 or in2 or in3 or S)
begin
    if(S == 0) begin
    {
        case({in3, in2, in1, in0})
            4'b0000: {out3, out2, out1, out0} = 4'b0000; //0->0
            4'b0001: {out3, out2, out1, out0} = …
Run Code Online (Sandbox Code Playgroud)

verilog

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

Verilog“输入、输出或输入输出未出现在端口列表中”

我不明白这个错误是什么意思。我想制作一个带有内存的简单计算器,但是这个错误跳出来了,我无法得到什么

** 错误:C:\Users\Kainy\Desktop\LOGIC\calculator\cal.v(14):输入、输出或输入输出未出现在端口列表:f1 中。** 错误:C:\Users\Kainy\Desktop\LOGIC\calculator\cal.v(15):输入、输出或输入输出未出现在端口列表中:f2。

方法。好像我的f1,f2有一些无效的东西,我该如何修复它?

module cal( a,b,c,op,clk,reset,en,r_w);     
input [3:0] a;
input [3:0] b; 
input [7:0] c; 
input [2:0] op; 
input clk;
input reset;
input en;
input r_w;



output reg [7:0] f1;
output reg [7:0] f2; 


wire [7:0] f3;




always@(a or b or op) begin
case(op)
3'b000: begin
 f1 = a;
 f3 = f1;
end

3'b001: begin
 f1 = b;
 f3 = f1;
end


3'b010: begin 
 f1 = a+b;
 f3 = f1;
end

3'b011: begin
 f1 = a - …
Run Code Online (Sandbox Code Playgroud)

port verilog out inout

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

如何克服“警告:instruction_reg 的端口 8(目标)需要 8 位,结果为 1。” 在verilog中?

我的任务是使用 verilog 实现带有数据存储器的处理器。指令是硬编码的(32 位指令)。我已完成数据存储器的插入。对于加载和存储指令,但是当编译时我得到 - “警告:instruction_reg 的端口 8(目标)需要 8 位,得到 1。”

这是指令集架构的 verilog 代码

<pre><code>
//ALU created

module ALU(out,DATA1,DATA2,Select); //module for ALU
input [7:0]DATA1,DATA2;//8 bit data inputs
    input [2:0] Select;//three bit selection 
    output [7:0]out;//8 bit data output
    reg out;//outputt register
    always@(DATA1,DATA2,Select)
    begin
        case(Select)
            3'b000: out=DATA1;//forward
            3'b001: out=DATA1+DATA2;//add
            3'b010: out=DATA1 & DATA2;//and
            3'b011: out=DATA1| DATA2; //or

        endcase
    end

endmodule
//here no need of its test bench

//registerFile created in part2
module Register(clk,busy_wait,INaddr,IN,OUT1addr,OUT1,OUT2addr,OUT2);
    input clk;
 input [2:0] INaddr;
 input [7:0] IN;
 input …
Run Code Online (Sandbox Code Playgroud)

warnings verilog processor cpu-registers iverilog

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

Xilinx中出现意外警告

在下面的代码中,我存储了按钮播放器1和播放器2按下的历史记录.代码编译没有错误但有警告.我无法解决这些警告.我在这里发布代码.

module game(clk50,red,green,blue,hsync,vsync, button,led);

input [8:0] button;
 input clk50;
 output  red;
 output  green;
 output  blue,led;
 output hsync;
 output vsync;
 // divide input clock by two, and use a global 
// clock buffer for the derived clock
reg clk25_int;
always @(posedge clk50) begin
clk25_int <= ~clk25_int;
end
wire clk25;
BUFG bufg_inst(clk25, clk25_int);
wire [9:0] xpos;
wire [9:0] ypos;

Grid_Display Grid_Displayinst(clk25,xpos, ypos, red, green, blue, button,led);

endmodule

module Grid_Display(clk25,xpos,ypos,red,green,blue, button,led);

 input clk25;
 input [9:0] xpos;//responsible for current pixel display location
 input [9:0] …
Run Code Online (Sandbox Code Playgroud)

verilog xilinx

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

缩进在Verilog中是否重要?

缩进在Verilog HDL中是否与在Python中一样重要?
或者更像是C++,重要的是你是否正确放置了{和}块?

编辑:这是我的教科书中写的:

always @(A or B or select)
  if(select == 1) m_out = A;
  else m_out = B;
Run Code Online (Sandbox Code Playgroud)

这里看起来块是由缩进定义的.为什么会这样?

verilog

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

verilog为什么不在寄存器文件中产生正确的结果?

我正在制作8x32b寄存器文件是我的verilog代码

module register_file(clk, reset, dstW, valW, write, srcA, srcB, valA, valB   );
    input clk;
    input reset;
    input[2:0] dstW;
    input[31:0] valW;
    input write;
    input[2:0] srcA;
    input[2:0] srcB;
    output[31:0] valA;
    output[31:0] valB;

     reg[31:0] r0eax, r1ecx, r2edx, r3ebx, r4esi, r5edi, r6esp, r7edi;

     wire[31:0] reg_input_0, reg_input_1, reg_input_2, reg_input3, reg_input4,
        reg_input5, reg_input6, reg_input7;

     wire[7:0] decoder_out, select;

     assign valA = 
        (srcA == 3'b000) ? r0eax:
        (srcA == 3'b001) ? r1ecx:
        (srcA == 3'b010) ? r2edx:
        (srcA == 3'b011) ? r3ebx:
        (srcA == 3'b100) ? r4esi:
        (srcA …
Run Code Online (Sandbox Code Playgroud)

verilog

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

尝试使用if/else块时,在verilog(vcs)中出现奇怪错误

我正在尝试为2的恭维加法器编写"逆变器"功能.我的导师希望我使用if/else语句来实现它.该模块应该采用8位数字并翻转位(零到1/1到零).我写了这个模块:

    module inverter(b, bnot);
    input [7:0] b;
    output [7:0]bnot;

    if (b[0] == 0) begin
    assign bnot[0] = 1;
    end else begin
    assign bnot[0] = 0;
    end

    //repeat for bits 1-7
Run Code Online (Sandbox Code Playgroud)

当我尝试使用此命令编译和编译时,我收到以下错误:

    vcs +v2k inverter.v
    Error-[V2005S] Verilog 2005 IEEE 1364-2005 syntax used.
    inverter.v, 16
    Please compile with -sverilog or -v2005 to support this construct: generate
   blocks without generate/endgenerate keywords.
Run Code Online (Sandbox Code Playgroud)

所以我添加了-v2005参数,然后我收到此错误:

  vcs +v2k -v2005 inverter.v
 Elaboration time unknown or bad value encountered for generate if-statement
 condition expression.
 Please make sure it is …
Run Code Online (Sandbox Code Playgroud)

verilog

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

Verilog:将寄存器分配给寄存器

在下面的Verilog中,分配寄存器rotationDoneR分配给信号,然后将另一个寄存器rotationDoneRR分配给同一个寄存器.这是否意味着两个寄存器保持相同的值并且条件永远不变?

input wire RotationDone; // from the module definition

reg rotationDoneR;
reg rotationDoneRR;

rotationDoneR <= RotationDone; 
rotationDoneRR <= rotationDoneR;  

if ( rotationDoneR && (! rotationDoneRR ) ) begin 
    InterruptToCPU <= 1; 
end 
Run Code Online (Sandbox Code Playgroud)

谢谢你的任何澄清!

verilog variable-assignment

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