ERROR: HDL COMPILER 806 - verilog

I have written a verilog code for scrolling hello world on seven segment display of BASYS2 board. But after compiling this code i am getting an error like this-
"ERROR:HDLCompiler:806 - "C:/Users/vishakha.ramani/Xilinx/scrollsevensegment/ssevenseg.v" Line 214: Syntax error near "endmodule"."
Kindly tell me where I am making a mistake.
enter code here
module ssevenseg(
input clock,
input reset,
output a,
output b,
output c,
output d,
output e,
output f,
output g,
output [3:0] en
);
reg [3:0] in0, in1, in2, in3; // registers to hold the LED value i.e data to be displayed
reg [28:0] tick_tock; // to count for every 1s i.e holds count of 50 M
wire click;
always #(posedge clock or posedge reset)
begin
if(reset)
tick_tock <= 0;
else if ( tick_tock==50000000)
tick_tock <= 0;
else
tick_tock <= tick_tock+1;
end
assign click = (( tick_tock==50000000)?1'b1:1'b0); // click every second
reg [3:0] count1; // to hold the count upto 9
always #(posedge click or posedge reset)
begin
if (reset)
count1 <= 0;
else
count1 <= count1 + 1;
end
always # (*)
begin
case (count1)
8'b00000000 :
begin
in0 = 4'b0001; // H
in1 = 4'b0010; // E
in2 = 4'b0011; // L
in3 = 4'b0011; // L
end
8'b00000001 :
begin
in0 = 4'b0010; // E
in1 = 4'b0011; // L
in2 = 4'b0011; // L
in3 = 4'b0100; // O
end
8'b00000010 :
begin
in0 = 4'b0011; // L
in1 = 4'b0011; // L
in2 = 4'b0100; // O
in3 = 4'b0101; // E
end
8'b00000011 :
begin
in0 = 4'b0011; // L
in1 = 4'b0100; // O
in2 = 4'b0101; // E
in3 = 4'b0100; // O
end
8'b00000100 :
begin
in0 = 4'b0100; // O
in1 = 4'b0101; // E
in2 = 4'b0100; // O
in3 = 4'b0110; // r
end
8'b00000101 :
begin
in0 = 4'b0101; // E
in1 = 4'b0100; // O
in2 = 4'b0110; // r
in3 = 4'b0011; // L
end
8'b00000110 :
begin
in0 = 4'b0100;
in1 = 4'b0110;
in2 = 4'b0011;
in3 = 4'b0111;
end
endcase
end
localparam N = 18;
reg [N-1:0]count; // the 18 bit counter that allows us to multiplex at 1000Hz
always # (posedge clock or posedge reset )
begin
if (reset)
count <= 0;
else
count <= count +1;
end
reg [3:0] display;
reg [3:0] temp_en;
always # (*)
begin
case(count[N-1:N-2])
2'b00 :
begin
display = in0;
temp_en = 4'b0111;
end
2'b01:
begin
display = in1;
temp_en = 4'b1011;
end
2'b10:
begin
display = in2;
temp_en = 4'b1101;
end
2'b11:
begin
display = in3;
temp_en = 4'b1110;
end
endcase
end
assign en = temp_en;
reg [6:0] temp_display;
always #(*)
begin
case (display)
4'b0000 : temp_display = 7'b1111110; // if we give input '0' nothing except '-' will be displayed
4'b0001 : temp_display = 7'b1001000; // This will display 'H'
4'b0010 : temp_display = 7'b0110000; // to display 'E'
4'b0011 : temp_display = 7'b1110001; // to display 'L'
4'b0100 : temp_display = 7'b0000001; // to display 'O'
4'b0101 : temp_display = 7'b1111010; // to display 'r'
4'b0110 : temp_display = 7'b1000010; // to display 'd'
default : temp_display = 7'b1111111; // blank
endcase
end
assign {a,b,c,d,e,f,g} = temp_display
endmodule

You appear to be missing a semicolon after the second-last statement:
assign {a,b,c,d,e,f,g} = temp_display

Related

Signal is connected to following multiple drivers in verilog

`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 20:07:59 12/16/2017
// Design Name:
// Module Name: keyscan
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module keyscan(key, clk, reset, keyout);
input [9:0] key;
input clk, reset;
output reg [127:0] keyout;
reg [3:0] keyp [31:0] ;
reg [3:0] key_bcd;
integer i, count;
///////ERROR help me ㅠ.ㅠ
always # (posedge reset) begin
if(reset==1) begin
for(i=0; i<32; i=i+1)begin
keyp[i] <= 4'hF;
end
key_bcd <= 4'b1111;
count <= 0;
end
end
always # (*) begin
case(key)
10'b0000000001 :
begin
key_bcd = 4'b0000; //0
count = count + 1;
end
10'b0000000010 :
begin
key_bcd = 4'b0001; // 1
count = count + 1;
end
10'b0000000100 :
begin
key_bcd = 4'b0010; // 2
count = count + 1;
end
10'b0000001000 :
begin
key_bcd = 4'b0011; // 3
count = count + 1;
end
10'b0000010000 :
begin
key_bcd = 4'b0100; // 4
count = count + 1;
end
10'b0000100000 :
begin
key_bcd = 4'b0101; // 5
count = count + 1;
end
10'b0001000000 :
begin
key_bcd = 4'b0110; // 6
count = count + 1;
end
10'b0010000000 :
begin
key_bcd = 4'b0111; // 7
count = count + 1;
end
10'b0100000000 :
begin
key_bcd = 4'b1000; // 8
count = count + 1;
end
10'b1000000000 :
begin
key_bcd = 4'b1001; // 9
count = count + 1;
end
default : key_bcd = 4'b1111; // ??
endcase
if(count == 32)
count = 0;
end
always# (count) begin
if(key_bcd != 4'b1111)
keyp[count-1] <= key_bcd;
end
always# (posedge clk)begin
keyout = {keyp[31],124'hfffffffffffffffffffffffffffffff};
end
endmodule
ERROR ㅠ.ㅠ
HDLCompiler:1401 - "C:\Users\com603\Desktop\verilog\aqx\keyscanf.v" Line 44: Signal keyp[31][3] in unit keyscanf is connected to following multiple drivers:
you have 2 always block which drive the same register keyp:
always # (posedge reset) begin
if(reset==1) begin
for(i=0; i<32; i=i+1)begin
keyp[i] <= 4'hF; // <<<<<<<<<<<<<<<<<
end
...
and
always# (count) begin
if(key_bcd != 4'b1111)
keyp[count-1] <= key_bcd; // <<<<<<<<<<<<<<<<<
end
In simulation it will produce unpredictible result since the last driver will win. But there is no way to say which one is the last. Synthesis should complain about it.
You need to find a way to combine both statements in the same always block.
First of all you need to synchronize your code using clock. You even have clk as an input, so use with #(posedge clk) in your block.
I guess something like the following should work:
always # (posedge clk or posedge reset) begin
if(reset==1) begin
for(i=0; i<32; i=i+1)begin
keyp[i] <= 4'hF;
end
key_bcd <= 4'b1111;
end
else if(key_bcd != 4'b1111)
keyp[count-1] <= key_bcd;
end

Error (10663): Verilog HDL Port Connection error at DSD_Project.v(34): output or inout port "hit" must be connected to a structural net expression

module DSD_Project(flag0, flag1, hit0, hit1,room_counter,someone_inRoom,someone_Spying,hit0_LED, hit1_LED,echo0_LED, echo1_LED, anti_theft_output,reset_Antitheft_output,echo0, echo1, CLOCK_50,anti_theft, reset_Antitheft);
output reg hit0_LED = 1'b0;
output reg hit1_LED = 1'b0;
output reg echo0_LED = 1'b0;
output reg echo1_LED = 1'b0;
output reg flag0 = 1'b0;
output reg flag1 = 1'b0;
output reg hit0 = 1'b0;
output reg hit1 = 1'b0;
output reg room_counter = 1'b0;
output reg someone_inRoom = 1'b0;
output reg someone_Spying = 1'b0;
output reg anti_theft_output = 1'b0;
output reg reset_Antitheft_output = 1'b0;
input echo0; // input_signal from the sensor 1
input echo1;// input_signal from the sensor 2
input CLOCK_50;
input anti_theft ; //= 1'b0; // switch button
input reset_Antitheft; // = 1'b0; // push button
sensor s1(hit0, echo0) ; // , CLOCK_50);
sensor s2(hit1, echo1) ; // , CLOCK_50);
always#(posedge CLOCK_50)
begin
hit0_LED <= hit0;
hit1_LED <= hit1;
echo0_LED <= echo0;
echo1_LED <= echo1;
end
//anti_theft: seting and reseting the output
//always#(anti_theft) //or reset_Antitheft)
//begin
//anti_theft_output <= anti_theft ;
//reset_Antitheft_output <= reset_Antitheft ;
//end
always#(posedge hit0 or posedge hit1)
begin
if (hit0 == 1 && hit1== 0)
begin
flag0<= 1;
//flag1<= 0;
if(flag1==0)
begin
hit0=0;
room_counter <= room_counter +1 ;
someone_inRoom <=1 ;
if(anti_theft == 1)
someone_Spying <= 1;
end
else
flag1<=0;
end
else
begin
if ((hit0 == 0) && (hit1 == 1))
begin
//flag0<=0;
flag1<=1;
if(flag0 == 0)
begin
hit1=0;
room_counter <= room_counter -1 ;
if(room_counter==0)
begin
someone_inRoom <=0 ;
end
end
else
flag0<=0;
end
end
end
always#(reset_Antitheft)
begin
if( (anti_theft==1) && (someone_Spying == 1) )
begin
anti_theft_output <= 0 ;
someone_Spying <= 0 ;
end
end
endmodule
module sensor(hit, input_signal); //, CLOCK_50);
input input_signal;
output reg hit = 1'b0;
//reg [25:0] clock_counter;
always#(input_signal) // posedge CLOCK_50 ||
begin
//if (clock_counter == 8_000_000)
begin
if (input_signal==1)
begin
hit <= 1;
end
else
begin
hit <= 0;
end
end
//else
// clock_counter <= clock_counter+1;
end
endmodule
ScreenShoot
As you would know, the problem is with the following lines:
sensor s1(hit0, echo0) ; // , CLOCK_50);
sensor s2(hit1, echo1) ; // , CLOCK_50);
In sensor, the first port, hit is a output. However, you're attempting to connect it to a reg, as you specified in the lines above:
output reg hit0 = 1'b0;
output reg hit1 = 1'b0;
You should use these signals as wires, not regs.

How to change the code. verilog testbench code

I make a design for an adder but the result is wrong.
module FMUL(CLK, St, F1, E1, F2, E2, F, V, done);
input CLK;
input St;
input [3:0] F1;
input [3:0] E1;
input [3:0] F2;
input [3:0] E2;
output[6:0] F;
output V;
output done;
reg[6:0] F;
reg done;
reg V;
reg[3:0] A;
reg[3:0] B;
reg[3:0] C;
reg[4:0] X;
reg[4:0] Y;
reg Load;
reg Adx;
reg SM8;
reg RSF;
reg LSF;
reg AdSh;
reg Sh;
reg Cm;
reg Mdone;
reg[1:0] PS1;
reg[1:0] NS1;
reg[2:0] State;
reg[2:0] Nextstate;
initial
begin
State = 0;
PS1 = 0;
NS1 = 0;
Nextstate=0;
end
always #(PS1 or St or Mdone or X or A or B)
begin : main_control
Load = 1'b0;
Adx = 1'b0;
NS1 = 0;
SM8 = 1'b0;
RSF = 1'b0;
LSF = 1'b0;
V = 1'b0;
F = 7'b0000000;
done = 1'b0;
case (PS1)
0 :
begin
F = 7'b0000000;
done = 1'b0;
V = 1'b0;
if(St == 1'b1)
begin
Load = 1'b1;
NS1 = 1;
end
end
1 :
begin
Adx = 1'b1;
NS1 = 2;
end
2 :
begin
if(Mdone == 1'b1)
begin
if(A==0)
begin
SM8 = 1'b1;
end
else if(A == 4 & B == 0)
begin
RSF = 1'b1;
end
else if (A[2] == A[1])
begin
LSF = 1'b1;
end
NS1 = 3;
end
else
begin
NS1 = 2;
end
end
3 : begin
if(X[4] != X[3])
begin
V = 1'b1;
end
else
begin
V = 1'b0;
end
done = 1'b1;
F = {A[2:0],B};
if(St==1'b0)
begin
NS1 = 0;
end
end
endcase
end
always #(State or Adx or B)
begin : mul2c
AdSh = 1'b0;
Sh = 1'b0;
Cm = 1'b0;
Mdone = 1'b0;
Nextstate = 0;
case(State)
0 :
begin
if(Adx==1'b1)
begin
if((B[0]) == 1'b1)
begin
AdSh = 1'b1;
end
else
begin
Sh = 1'b1;
end
Nextstate = 1;
end
end
1,2 :
begin
if((B[0])==1'b1)
begin
AdSh = 1'b1;
end
else
begin
Sh = 1'b1;
end
Nextstate = State + 1;
end
3:
begin
if((B[0])==1'b1)
begin
Cm = 1'b1;
AdSh = 1'b1;
end
else
begin
Sh = 1'b1;
end
Nextstate = 4;
end
4:
begin
Mdone = 1'b1;
Nextstate = 0;
end
endcase
end
wire [3:0] addout;
assign addout = (Cm == 1'b0)? (A+C) : (A-C);
always #(posedge CLK)
begin : update
PS1 <= NS1;
State <= Nextstate;
if(Load == 1'b1)
begin
X <= {E1[3], E1};
Y <= {E2[3], E2};
A <= 4'b0000;
B <= F1;
C <= F2;
end
if(Adx == 1'b1)
begin
X <= X+Y;
end
if(SM8 == 1'b1)
begin
X <= 5'b11000;
end
if(RSF == 1'b1)
begin
A <= {1'b0, A[3:1]};
B <= {A[0], B[3:1]};
X <= X+1;
end
if(LSF == 1'b1)
begin
A <= {A[2:0], B[3]};
B <= {B[2:0], 1'b0};
X <= X+31;
end
if(AdSh == 1'b1)
begin
A <= {(C[3]^Cm), addout[3:1]};
B <= {addout[0], B[3:1]};
end
if(Sh == 1'b1)
begin
A <= {A[3], A[3:1]};
B <= {A[0], B[3:1]};
end
end
endmodule
test bench.
module tb_FMUL();
wire[6:0] F;
wire done;
wire V;
reg[3:0] A;
reg[3:0] B;
reg[3:0] C;
reg[4:0] X;
reg[4:0] Y;
reg Load;
reg Adx;
reg SM8;
reg RSF;
reg LSF;
reg AdSh;
reg Sh;
reg Cm;
reg Mdone;
reg[1:0] PS1;
reg[1:0] NS1;
reg[2:0] State;
reg[2:0] Nextstate;
reg CLK;
reg St;
reg [3:0] F1;
reg [3:0] E1;
reg [3:0] F2;
reg [3:0] E2;
FMUL u0(CLK, St, F1, E1, F2, E2, F, V, done);
always
begin
#10 CLK <= ~CLK;
end
initial
begin
#100 F1 = 2.125;
E1 = 5; F2 = 5.1; E2 = 1; St=0;
#100 F1 = 1.125;
E1 = 5; F2 = 2.1; E2 = 2; St=0;
#100 F1 = 5.125;
E1 = 5; F2 = 3.1; E2 = 3; St=0;
end
endmodule
The simulation results waveform.
enter image description here
I refer to the book.There is no code test bench.
So I made. But did't operate.
also CLK not is not changed.
please review the testbench code.
You have (at least) two problems:
Your clock needs to be initialised (eg to 1'b0):
initial CLK = 1'b0;
The initial value of any wire or reg in Verilog is 1'bx; ~1'bx is 1'bx; so CLK remains at 1'bx.
Your simulation doesn't stop. I added a call to $finish in the main initial block.
https://www.edaplayground.com/x/r4U

coffee vending machine simulation in verilog with test bench issue

I have written a verilog code for a simple coffee vending machine with inputs
25ps,50ps,75ps and 1
as
"00","01","10" and "11"
respectively. Coffee cost is 1 rs. If more than 1rs is inserted, the balance will be returned. That balance will be
01, 10, 11
as
25ps, 50ps, 1rs
respectively. I simulate this without test bench. simulation takes double clock pulse for output.(when i put 25 ps 8 times or 8 clock pulses is required for getting output. expected clock pulse is 4). Why this is happens? and also i didn't get output when using the test bench.
please help me to correct the test bench and my programme. Is clock frequency divider is necessary while doing the programme in fpga board to see output? It is working as expected when i programmed into fpga board.Im using Xilinx vivado 2015.2 tool and zynq board.Please help me to solve these issues
//programme
module main(
input clk,
input rst,
input [1:0] money,
output coffee,
output [1:0] balance
);
reg coff;
reg [1:0] bal;
reg [2:0] pr_st;
reg [2:0] nx_st;
parameter [2:0] A=3'b000;
parameter [2:0] B=3'b001;
parameter [2:0] C=3'b010;
parameter [2:0] D=3'b011;
parameter [2:0] E=3'b100;
parameter [2:0] F=3'b101;
parameter [2:0] G=3'b110;
parameter [2:0] H=3'b111;
always # (posedge clk or posedge rst)
begin
if(rst)
pr_st <= A;
else
pr_st <= nx_st;
end
always #(posedge clk)
begin
case(pr_st)
A : if(money == 2'b00) // input money is 25ps
begin
nx_st <= B;
end
else if(money == 2'b01) // input money is 50ps
begin
nx_st <= C;
end
else if(money == 2'b10) // input money is 75ps
begin
nx_st <= D;
end
else if(money == 2'b11)
begin
nx_st <= E;
end
B : if(money == 2'b00)
begin
nx_st <= C;
end
else if(money == 2'b01)
begin
nx_st <= D;
end
else if(money == 2'b10)
begin
nx_st <= E;
end
else if(money == 2'b11)
begin
nx_st <= F;
end
C : if(money == 2'b00)
begin
nx_st <= D;
end
else if(money == 2'b01)
begin
nx_st <= E;
end
else if(money == 2'b10)
begin
nx_st <= F;
end
else if(money == 2'b11)
begin
nx_st <= G;
end
D : if(money == 2'b00)
begin
nx_st <= E;
end
else if(money == 2'b01)
begin
nx_st <= F;
end
else if(money == 2'b10)
begin
nx_st <= G;
end
else if(money == 2'b11)
begin
nx_st <= H;
end
E : nx_st <= A;
F : nx_st <= A;
G : nx_st <= A;
H : nx_st <= A;
default : nx_st <= A;
endcase
end
//output logic
always #( posedge clk or pr_st)
begin
case(pr_st)
A: begin
coff <= 1'b0;
bal <= 2'b00;
end
B: begin
coff <= 1'b0;
bal <= 2'b00;
end
C: begin
coff <= 1'b0;
bal <= 2'b00;
end
D: begin
coff <= 1'b0;
bal <= 2'b00;
end
E: begin
coff <= 1'b1;
bal<= 2'b00;
end
F: begin
coff <= 1'b1;
bal <= 2'b01;
end
G: begin
coff <= 1'b1;
bal <= 2'b10;
end
H: begin
coff <= 1'b1;
bal <= 2'b11;
end
default : begin
off <=1'b0;
bal <= 2'b00;
end
endcase
end
assign coffee = coff;
assign balance = bal;
endmodule
//test bench
module tb_main(
);
reg clk;
reg rst;
reg [1:0] money;
wire coffee;
wire [1:0] balance;
main dut( clk, rst, money, coffee, balance);
always
begin
#200 clock = ~clk;
end
initial
begin
rst = 1'b1;
#100 rst = 1'b0;
money = 2'b00; // putting 25ps four times to get coffee
#400 money = 2'b01; //putting 50ps two times to get coffee
#200 money = 2'b10;// putting 75ps two times to get coffee
#200 money = 2'b11;// putting 1 rs single time to g
#100 money = 2'b01; // putting 1st 25ps and 50ps i n second clock cycle
#100 money = 2'b10;
#200
$finish
end
endmodule
You need to initialize your clock signal to a known value in the testbench. You should speed up the clock because your money input changes faster than the clock:
initial clk = 0;
always begin
#10 clk = ~clk;
end

Verilog code for shift and add multiplier

Good day guys, I'm created a Shift - And - Add multiplier. I'm confused on why my output is wrong and always at 85. Is it something with the Test bench ? It's working by the way.
new1.v
`define M ACC[0]
module mult4X4 (Clk, St, Mplier, Mcand, Done, Result);
input Clk,St;
input [3:0] Mplier, Mcand;
output Done;
output [7:0] Result;
reg [3:0] State;
reg [8:0] ACC;
initial
begin
State = 0;
ACC = 0;
end
always #(posedge Clk)
begin
case (State)
0:
begin
if(St == 1'b1)
begin
ACC[8:4] <= 5'b00000 ;
ACC[3:0] <= Mplier ;
State <= 1;
end
end
1,3,5,7 :
begin
if(`M==1'b1)
begin
ACC[8:4] <= {1'b0, ACC[7:4]} + Mcand ;
State <= State +1;
end
else
begin
ACC <= {1'b0, ACC[8:1]};
State <= State + 2;
end
end
2,4,6,8 :
begin
ACC <= {1'b0, ACC[8:1]};
State <= State +1;
end
9:
begin
State <= 0;
end
endcase
end
assign Done = (State == 9) ? 1'b1 : 1'b0 ;
assign Result = (State == 9) ? ACC[7:0] : 8'b01010101;
endmodule
tb_new1.v
module tb_mult4X4;
reg Clk,St,nReset;
reg [3:0] Mplier;
reg [3:0] Mcand;
wire Done;
wire [7:0] Result;
mult4X4 UUT (Clk,St,Mplier,Mcand,Done,Result);
initial begin
$dumpfile ("mult4X4.vpd");
$dumpvars;
end
initial
Clk = 0;
always
#5 Clk =~Clk;
initial begin
nReset = 0;
St = 0;
Mcand = 4'b1101;
Mplier = 4'b1011;
#10
nReset = 1;
St = 1;
Mcand = 4'b1111;
Mplier = 4'b1001;
#10
Mcand = 4'b0101;
Mplier = 4'b1010;
#10
Mcand = 4'b1111;
Mplier = 4'b1111;
#10
Mcand = 4'b1101;
Mplier = 4'b1010;
$finish;
end
endmodule
I ran though the code so many times and everything seems to be following my FSM. Can anyone please point out where went wrong. Really confused on this one
#10 is way to short. Your RTL requires 10 clocks to complete but you change the input every clock (half clk is #5).
Use #100 or better yet #(posedge Done); (which makes the test-bench to wait for done regardless the number of clocks that is required).

Resources