Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Verilog HDL语法错误_Verilog_Fpga - Fatal编程技术网

Verilog HDL语法错误

Verilog HDL语法错误,verilog,fpga,Verilog,Fpga,各位,只是一个关于如何修复下面的Verilog代码的快速问题,我不断地遇到错误。有什么建议吗 module bcd_to_seven_seg( B, S); input wire [3:0]B; output wire [6:0]S; reg [6:0] rS; assign S = rS; always @(B) begin case({B}) 4'b0000: rS= 7b'1000000; 4'b0001: rS= 7b'1111001; 4'b0010: rS= 7

各位,只是一个关于如何修复下面的Verilog代码的快速问题,我不断地遇到错误。有什么建议吗

module bcd_to_seven_seg( B, S);

input wire [3:0]B;
output wire [6:0]S;

reg [6:0] rS;
assign S = rS;

always @(B)
begin
  case({B})
  4'b0000: rS= 7b'1000000;
  4'b0001: rS= 7b'1111001;
  4'b0010: rS= 7b'0100100;
  4'b0011: rS= 7b'0110000;
  4'b0100: rS= 7b'0011001;
  4'b0101: rS= 7b'0010010;
  4'b0110: rS= 7b'0000010;
  4'b0111: rS= 7b'1111000;
  4'b1000: rS= 7b'0000000;
  4'b1001: rS= 7b'0010000;
  endcase

end

endmodule
这里是错误

7'表示七位数

b表示您使用的是二进制文件

0010001是你的电话号码


我们都犯了同样的错误

应该是7b而不是7b

卢比=7'b1000000

语法错误 <'>放在位数之后,即:7,在上述情况下,不放在“b”之后(表示二进制数字)

例如:70亿美元;
7'b1100100

我已经重新编写了您的代码,并在代码出现问题的地方添加了注释。在建模组合逻辑时请小心,因为您的代码编写方式可能会推断出锁存,因为case语句没有默认语句。 我已将默认情况写为x,您可以根据需要对其进行编辑

module bcd_to_seven_seg( B, S);

input wire [3:0]B;
output wire [6:0]S;

reg [6:0] rS;
assign S = rS;

always @(*)                 //Model combinational blocks as always@(*)to avoid latch
begin                       
case(B)                      //Concantenation operator {} not needed
  4'b0000: rS= 7'b1000000;   //Use 7'b instead of 7b'
  4'b0001: rS= 7'b1111001;
  4'b0010: rS= 7'b0100100;
  4'b0011: rS= 7'b0110000;
  4'b0100: rS= 7'b0011001;
  4'b0101: rS= 7'b0010010;
  4'b0110: rS= 7'b0000010;
  4'b0111: rS= 7'b1111000;
  4'b1000: rS= 7'b0000000;
  4'b1001: rS= 7'b0010000;
  default: rs= 7'dx;          //Use default statement else a latch may get inferred
endcase

end

endmodule

你应该使用
7'b
而不是
7b'
。啊,那是个愚蠢的错误。谢谢你的帮助!但是,这并没有给现有答案增加多少内容?不鼓励只使用代码的答案。请单击“编辑”并添加一些文字,总结您的代码如何解决问题,或者解释您的答案与以前的答案有何不同。谢谢
7'b0010001
module bcd_to_seven_seg( B, S);

input wire [3:0]B;
output wire [6:0]S;

reg [6:0] rS;
assign S = rS;

always @(*)                 //Model combinational blocks as always@(*)to avoid latch
begin                       
case(B)                      //Concantenation operator {} not needed
  4'b0000: rS= 7'b1000000;   //Use 7'b instead of 7b'
  4'b0001: rS= 7'b1111001;
  4'b0010: rS= 7'b0100100;
  4'b0011: rS= 7'b0110000;
  4'b0100: rS= 7'b0011001;
  4'b0101: rS= 7'b0010010;
  4'b0110: rS= 7'b0000010;
  4'b0111: rS= 7'b1111000;
  4'b1000: rS= 7'b0000000;
  4'b1001: rS= 7'b0010000;
  default: rs= 7'dx;          //Use default statement else a latch may get inferred
endcase

end

endmodule