对于uni的项目,我应该在FPGA中打印一个迷宫,数据应首先写在ROM中,然后从中读取。从32位数据我得到2个团队,根据他们的编码我给他们一些特定的颜色。
当我在quartus中运行我的代码时,我得到编译错误:
错误:“无法解析多个常量驱动程序”。
我的rom代码是:
module thirdLab(
input logic clk,
input logic rst,
input logic [3:0] address,
output logic [31:0] data,
output logic hsync,
output logic vsync,
output logic [3:0] red,
output logic [3:0] green,
output logic [3:0] blue);
logic half_clock;
logic [9:0] x;
logic [9:0] y;
//Decision help variables.
logic [1:0] decBits0;
logic [1:0] decBits1;
logic [1:0] decBits2;
logic [1:0] decBits3;
logic [1:0] decBits4;
logic [1:0] decBits5;
logic [1:0] decBits6;
logic [1:0] decBits7;
logic [1:0] decBits8;
logic [1:0] decBits9;
logic [1:0] decBits10;
logic [1:0] decBits11;
logic [1:0] decBits12;
logic [1:0] decBits13;
logic [1:0] decBits14;
logic [1:0] decBits15;
always_ff @(posedge clk)
begin
if(!rst)
half_clock <=0;
else
if(half_clock)
half_clock <=0;
else
half_clock <=1;
end
always_ff @(posedge clk)
begin
if(!rst)
x <=0;
else
if (half_clock)
if (x==799)
x <= 0;
else
x <= x+1;
end
always_ff @(posedge clk)
begin
if(!rst)
y <=0;
else
if (half_clock)
if (x==799)
if (y==523)
y <=0;
else
y <= y+1;
end
always_comb
begin
if (x>=655 && x<752)
hsync =0;
else
hsync =1;
if (y>=490 && y<493)
vsync =0;
else
vsync =1;
end
//Initialize rom memory.
always_comb
begin
case (address)
4'b0000: data = 32'b00_00_01_10_00_00_00_01_00_01_00_00_01_01_01_00;
4'b0001: data = 32'b00_00_01_00_00_00_00_01_01_01_00_01_00_00_01_00;
4'b0011: data = 32'b01_00_00_00_00_00_00_00_01_00_00_01_00_00_01_00;
4'b0100: data = 32'b00_01_00_00_00_00_00_01_00_00_01_01_01_01_01_01;
4'b0101: data = 32'b00_00_01_00_00_00_00_00_00_00_00_01_00_01_01_01;
4'b0110: data = 32'b01_01_01_01_01_01_01_01_01_00_00_01_00_00_00_00;
4'b0111: data = 32'b00_01_01_00_01_01_00_01_00_01_00_00_00_00_01_00;
4'b1000: data = 32'b01_00_01_01_00_00_01_01_01_00_00_01_00_00_01_00;
4'b1001: data = 32'b11_00_00_00_00_01_01_01_01_00_00_01_01_00_01_00;
4'b1010: data = 32'b00_00_01_00_01_00_01_01_01_01_00_00_00_00_01_00;
4'b1011: data = 32'b01_01_01_00_10_00_00_01_01_01_00_01_01_01_01_00;
default: data = 32'b00_01_01_00_00_00_00_00_01_00_00_01_00_00_01_00;
endcase
end
//Internal memory, accessed through address only.
reg [31:0] mem [12];
always_ff @(posedge clk)
begin
data <= mem[address];
decBits0 <= data[1:0];
decBits1 <= data[3:2];
decBits2 <= data[5:4];
decBits3 <= data[7:6];
decBits4 <= data[9:8];
decBits5 <= data[11:10];
decBits6 <= data[13:12];
decBits7 <= data[15:14];
decBits8 <= data[17:16];
decBits9 <= data[19:18];
decBits10 <= data[21:20];
decBits11 <= data[23:22];
decBits12 <= data[25:24];
decBits13 <= data[27:26];
decBits14 <= data[29:28];
decBits15 <= data[31:30];
end
答案 0 :(得分:1)
“多个驱动程序”错误消息表示您在两个不同的位置驱动相同的信号。在两个始终块或两个分配中,或者在系统Verilog中,始终为块和赋值。
通常,编译器错误消息应该告诉您错误发生的位置。但我不知道Quartus所以可能情况并非如此。
您必须查看代码中的每个变量并检查为其分配值的位置,然后检查是否还在不同的位置分配值(在不同的always或assign中)。
我使用您的代码执行了此操作,发现变量数据在两个不同的始终块中分配了一个值。