Error: (vsim -3389), - verilog

I don't understand why I'm getting this error when using model-sim, I've tried a lot of fixes but don't seem to get around this.
This is what my modelsim transcript says:
** Error: (vsim-3389) C:/Users/VRN/Desktop/sha256/t_processing.v(31): Port 'a_in' not found in the connected module (5th connection).
# Time: 0 ps Iteration: 0 Instance: /t_processing/uut File: C:/Users/VRN/Desktop/sha256/interative_processing.v
7 similar errors with the input ports
`timescale 1ns / 1ps
module interative_processing(clk,rst,w,k,counter_iteration,padding_done,a_out,b_out,c_out,d_out,e_out,f_out,g_out,h_out
);
input clk,rst,padding_done;
input [6:0] counter_iteration;
input [31:0] w,k;
output reg [31:0] a_out,b_out,c_out,d_out,e_out,f_out,g_out,h_out;
reg temp_case,temp_if;
reg [31:0] a_temp,b_temp,c_temp,d_temp,e_temp,f_temp,g_temp,h_temp;
reg [31:0] semation_0,semation_1,ch,maj;
always#(posedge clk)
begin
if(rst==0)
begin
temp_case=1'b0;
a_out=32'h6a09e667;
b_out=32'hbb67ae85;
c_out=32'h3c6ef372;
d_out=32'ha54ff53a;
e_out=32'h510e527f;
f_out=32'h9b05688c;
g_out=32'h1f83d9ab;
h_out=32'h5be0cd19;
end
else
begin
semation_0=({a_out[1:0],a_out[31:2]}) ^ ({a_out[12:0],a_out[31:13]}) ^ ({a_out[21:0],a_out[31:22]}); //last 22 ROTR22
semation_1=({e_out[5:0],e_out[31:6]}) ^ ({e_out[10:0],e_out[31:11]}) ^ ({e_out[24:0],e_out[31:25]});
maj=(a_out & b_out) ^ (a_out & c_out) ^ (b_out & c_out);
ch=(e_out & f_out) ^ (~e_out & g_out);
if(counter_iteration==65)
begin
a_out=a_out;
b_out=b_out;
c_out=c_out;
d_out=d_out;
e_out=e_out;
f_out=f_out;
g_out=g_out;
h_out=h_out;
end
else
begin
if(padding_done==1)
begin
case(temp_case)
1'b0: temp_case=1'b1;
1'b1: temp_if=1'b1;
endcase
end
if(temp_if==1 && counter_iteration!=64)
begin
a_temp= h_out + semation_1 + ch + k + w + semation_0 + maj; // T2= semation_0 + maj(a,b,c);
b_temp= a_out;
c_temp= b_out;
d_temp= c_out;
e_temp= d_out + h_out + semation_1 + ch + k + w; //T1 = h_out + semation_1 + ch + k + w;
f_temp= e_out;
g_temp= f_out;
h_temp= g_out;
a_out=a_temp;
b_out=b_temp;
c_out=c_temp;
d_out=d_temp; //alternative of non-blocking though
e_out=e_temp;
f_out=f_temp;
g_out=g_temp;
h_out=h_temp;
end
end
end
end
endmodule
and my testbench:
`timescale 1ns / 1ps
module t_processing;
// Inputs
reg clk;
reg rst;
reg [31:0] w;
reg [31:0] k;
reg [31:0] a_in;
reg [31:0] b_in;
reg [31:0] c_in;
reg [31:0] d_in;
reg [31:0] e_in;
reg [31:0] f_in;
reg [31:0] g_in;
reg [31:0] h_in;
// Outputs
wire [31:0] a_out;
wire [31:0] b_out;
wire [31:0] c_out;
wire [31:0] d_out;
wire [31:0] e_out;
wire [31:0] f_out;
wire [31:0] g_out;
wire [31:0] h_out;
// Instantiate the Unit Under Test (UUT)
interative_processing uut (
.clk(clk),
.rst(rst),
.w(w),
.k(k),
.a_in(a_in),
.b_in(b_in),
.c_in(c_in),
.d_in(d_in),
.e_in(e_in),
.f_in(f_in),
.g_in(g_in),
.h_in(h_in),
.a_out(a_out),
.b_out(b_out),
.c_out(c_out),
.d_out(d_out),
.e_out(e_out),
.f_out(f_out),
.g_out(g_out),
.h_out(h_out)
);
initial begin
// Initialize Inputs
clk = 0;
rst = 0;
w = 0;
k = 0;
a_in = 0;
b_in = 0;
c_in = 0;
d_in = 0;
e_in = 0;
f_in = 0;
g_in = 0;
h_in = 0;
end
initial
begin // Wait 100 ns for global reset to finish
#100;
end
initial clk=1'b0;
always #(clk) clk<= #5 ~clk;
initial
begin
rst = 1'b0;
#10 rst = 1'b1;
k = 32'hc67178f2;
w = 32'h12b1edeb;
a_in = 32'hd39a2165;
c_in = 32'hb85e2ce9;
d_in = 32'hb6ae8fff;
e_in = 32'hfb121210;
f_in = 32'h948d25b6;
g_in = 32'h961f4894;
h_in = 32'hb21bad3d;
b_in= 32'h04d24d6c;
end
endmodule

Here's a list of the input/output ports you've defined in the interactive_processing module.
input wire clk,
input wire rst,
input wire padding_done;
input wire [6:0] counter_iteration;
input wire [31:0] w,
input wire [31:0] k,
output reg [31:0] a_out,
output reg [31:0] b_out,
output reg [31:0] c_out,
output reg [31:0] d_out,
output reg [31:0] e_out,
output reg [31:0] f_out,
output reg [31:0] g_out,
output reg [31:0] h_out
Here's the list of inputs and outputs you're trying to pass to the interactive_processing module.
.clk(clk),
.rst(rst),
.w(w),
.k(k),
.a_in(a_in),
.b_in(b_in),
.c_in(c_in),
.d_in(d_in),
.e_in(e_in),
.f_in(f_in),
.g_in(g_in),
.h_in(h_in),
.a_out(a_out),
.b_out(b_out),
.c_out(c_out),
.d_out(d_out),
.e_out(e_out),
.f_out(f_out),
.g_out(g_out),
.h_out(h_out)
The compiler has no idea what to do with a__in through h__in because you haven't defined them as inputs to the module.

Related

verilog AND gate when 32 not working correctly

The AND gate
module andgate
#(parameter Port_Num = 2,
parameter WIDTH=8)
(
input [(WIDTH-1):0] a,
input [(WIDTH-1):0] b,
input [(WIDTH-1):0] c,
input [(WIDTH-1):0] d,
input [(WIDTH-1):0] e,
input [(WIDTH-1):0] f,
input [(WIDTH-1):0] g,
input [(WIDTH-1):0] h,
output [(WIDTH-1):0] q
);
assign q = (a & b & c & d & e & f & g & h);
endmodule
The angate_sim
`timescale 1ns / 1ps
module andgate_sim();
// input
reg a=0;
reg b=0;
reg c=1;
reg d=1;
reg e=1;
reg f=1;
reg g=1;
reg h=1;
//outbut
wire q;
andgate #(8,1) u(.a(a),.b(b),.c(c),.d(d),.e(e),.f(f),.g(g),.h(h),.q(q));
always #100 a=~a;
initial begin
#100 a=1;
#100 begin a=0;b=1;end
#100 a=1;
#60000000 $finish;
end
initial
begin
$dumpfile("wave2.vcd");
$dumpvars(0, andgate_sim);
end
endmodule
When I test the testbench, it worked correctly like this
iverilog -o Ex2 andgate.v andgate_sim.v
vvp -n Ex2 -lxt2
gtkwave wave2.vcd
The successful wave in wave2.vcd
Then I tried to make a AND gate*32 just like this
`timescale 1ns / 1ps
module andgate32_sim( );
// input
reg [31:0] a=32'h00000000;
reg [31:0] b=32'h00000000;
reg [31:0] c=32'hffffffff;
reg [31:0] d=32'hffffffff;
reg [31:0] e=32'hffffffff;
reg [31:0] f=32'hffffffff;
reg [31:0] g=32'hffffffff;
reg [31:0] h=32'hffffffff;
//outbut
wire [31:0] q;
andgate #(8,32) u(.a(a),.b(b),.c(c),.d(d),.e(e),.f(f),.g(g),.h(h),.q(q));
always #100
begin
a <= 32'hffffffff;
end
always #200
begin
a <= 32'h00000000;
b <= 32'hffffffff;
end
always #300
begin
a <= 32'h007fa509;
end
always #400
begin
a <= 32'hffffffff;
end
initial begin
#100 a <= 32'hffffffff;
#100 begin a <= 32'h00000000;b <= 32'hffffffff;end
#100 a <= 32'h007fa509;
#100 a <= 32'hffffffff;
#60000000 $finish;
end
initial
begin
$dumpfile("wave2-2.vcd");
$dumpvars(0, andgate32_sim);
end
endmodule
But when I did the steps like before
iverilog -o Ex2 andgate.v andgate32_sim.v
vvp -n Ex22 -lxt2
gtkwave wave2-2.vcd
There was nothing in the wave like this
No waves in the wave2-2.vcd
Actaully, it should be something in the wave2-2.vcd.
Could you please help me ?
You are trying to run another compiled testbench "Ex22" instead of "Ex2".
Hint: You can use parameters and pass them to the instantiation, as:
localparam WIDTH = 32;
localparam Port_Num = 8;
// input
reg [WIDTH-1:0] a=32'h00000000;
reg [WIDTH-1:0] b=32'h00000000;
reg [WIDTH-1:0] c=32'hffffffff;
reg [WIDTH-1:0] d=32'hffffffff;
reg [WIDTH-1:0] e=32'hffffffff;
reg [WIDTH-1:0] f=32'hffffffff;
reg [WIDTH-1:0] g=32'hffffffff;
reg [WIDTH-1:0] h=32'hffffffff;
//outbut
wire [WIDTH-1:0] q;
andgate #(.Port_Num (Port_Num), .WIDTH (WIDTH)) u(.a(a),.b(b),.c(c),.d(d),.e(e),.f(f),.g(g),.h(h),.q(q));

Arithmetic right shift not working in Verilog HDL

I am building a shift-unit that is capable of arithmetic and logical right shift, and logical left shift depending on the control signals given to it. However, the arithmetic right shift operator output generates output similar to that logical right shift operator, i.e. sign extension does not occur.
Main code
`timescale 1ns / 1ps
module shift_unit(
input [15:0] a,
input [3:0] b,
input clk,
input isLSL,
input isLSR,
input isASR,
output reg [15:0] result
);
wire [15:0] LSL_result, LSR_result, ASR_result;
LSL lsl(a, b, clk, isLSL, LSL_result);
LSR lsr(a, b, clk, isLSR, LSR_result);
ASR asr(a, b, clk, isASR, ASR_result);
always#(posedge clk) begin
case({isLSL, isLSR, isASR})
3'b001: result <= ASR_result;
3'b010: result <= LSR_result;
3'b100: result <= LSL_result;
endcase
end
endmodule
LSL code:
`timescale 1ns / 1ps
module LSL(
input [15:0] a,
input [3:0] b,
input clk,
input isLSL,
output [15:0] out
);
reg [15:0] result;
always#(posedge clk) begin
if(isLSL) result = a << b;
end
assign out = result;
endmodule
LSR code:
`timescale 1ns / 1ps
module LSR(
input [15:0] a,
input [3:0] b,
input clk,
input isLSR,
output [15:0] out
);
reg [15:0] result;
always#(posedge clk) begin
if(isLSR) result = a >> b;
end
assign out = result;
endmodule
ASR code:
`timescale 1ns / 1ps
module ASR(
input [15:0] a,
input [3:0] b,
input clk,
input isASR,
output [15:0] out
);
reg [15:0] result;
always#(posedge clk) begin
if(isASR) result = a >>> b;
end
assign out = result;
endmodule
And finally, the testbench:
`timescale 1ns / 1ps
module shift_unit_test;
reg [15:0] a;
reg [3:0] b;
reg clk;
reg isLSL;
reg isLSR;
reg isASR;
wire [15:0] result;
shift_unit uut (
.a(a),
.b(b),
.clk(clk),
.isLSL(isLSL),
.isLSR(isLSR),
.isASR(isASR),
.result(result)
);
always #5 clk = ~clk;
initial begin
clk = 1'b0;
a = 16'b1100101011001010;
b = 4;
{isLSL, isLSR, isASR} = 3'b100; #100;
{isLSL, isLSR, isASR} = 3'b010; #100;
{isLSL, isLSR, isASR} = 3'b001; #100;
end
endmodule
The above code has been modelled using Xilinx ISE 14.7.
Any help would be greatly appreciated.
You need to be working with signed signals to get sign extension.
module ASR(
input wire signed [15:0] a,
input [3:0] b,
input clk,
input isASR,
output reg signed [15:0] out
);
always#(posedge clk) begin
if(isASR) out = a >>> b;
end
endmodule

Red outputs lines - Verilog simulation

I try to simulate in Modelsim my code on Verilog. When I'm simulating it, it shows me X(red) outputs lines. This is my code and testbench:
module alu64bit (
input wire [63:0] a, // Input bit a
input wire [63:0] b, // Input bit b
input wire cin, // Carry in
input wire [1:0] op, // Operation
output wire [63:0] s, // Output S
output wire cout // Carry out
);
wire [63:0] cin_out;
assign cout = cin_out[63];
assign cin = cin_out[0];
genvar i;
generate
for(i=0; i <= 63; i = i + 1) begin
alu1bit alu (.s(s[i]),.cout(cin_out[i+1]),.a(a[i]),.b(b[i]),.cin(cin_out[i]),.op(op));
end
endgenerate
// End of your code
endmodule
TB:
module alu64bit_test;
reg [63:0] a;
reg [63:0] b;
reg [1:0] op;
reg cin;
wire [63:0] s;
wire cout;
alu64bit uut (
.a(a),
.b(b),
.cin(cin),
.op(op),
.s(s),
.cout(cout)
);
initial begin
a = 64'hffffffffffffffff;
b = 64'h0000000000000000;
cin = 0;
op[1] = 1;
op[0] = 0;
#100;
end
endmodule
enter image description here
Can somebody help me with this problem? Thank You!

Modules in Verilog do not respond to input signals

My current task is to create a memory driver. The specific issue is that I have a shift register designed to concatenate four 8-bit words into one 32-bit and then send that to the output. The module works when being simulated by itself but it fails to respond when connected to other modules. Here's the code :
The shift register code :
module shiftReg (
data_8,
clk,
valid1,
rstn,
data_32,
valid_fifo,
count,
REGA,
REGB,
REGC,
REGD
);
input wire [7:0] data_8;
input wire valid1;
input wire clk;
input wire rstn;
output reg [31:0] data_32;
output reg valid_fifo;
output reg [3:0] count;
output reg [7:0] REGA;
output reg [7:0] REGB;
output reg [7:0] REGC;
output reg [7:0] REGD;
initial
begin
count <= 4'b0001;
REGA <= 8'b0;
REGB <= 8'b0;
REGC <= 8'b0;
REGD <= 8'b0;
valid_fifo <= 1'b0;
end
always #(posedge valid1)
begin
if(~rstn)
begin
count = 4'b0001;
REGA = 0;
REGB = 0;
REGC = 0;
REGD = 0;
end
else if(valid1 == 1'b1)
begin
case (count)
4'b0001: REGA = data_8;
4'b0010: REGB = data_8;
4'b0100: REGC = data_8;
4'b1000: REGD = data_8;
endcase
valid_fifo = 1'b0;
end
if(count == 4'b1000)
begin
data_32 = {REGD,REGC,REGB,REGA};
valid_fifo = 1'b1;
count = 4'b0001;
end
else
begin
count = count << 1;
end
end
endmodule
The module where I am instantiating it is called altogether.
Here is the code :
module altogether (
input wire BUTTON_AT,
input wire CLK_AT,
input wire RSTN_AT,
output wire MEM_FULL_AT,
output wire EMPTY_AT,
inout wire VALID_IN_AT,
inout wire [7:0] DATA_8_AT,
inout wire VALID1_AT,
inout wire [31:0] DATA_32_AT,
inout wire STOP_AT,
inout wire VALID_FIFO_AT,
inout wire [31:0] DATA_AT,
inout wire WR_AT,
inout wire [6:0] ADDR_AT,
output wire [7:0] REG_A_AT,
output wire [7:0] REG_B_AT,
output wire [7:0] REG_C_AT,
output wire [7:0] REG_D_AT,
output wire [3:0] COUNT_AT
);
shiftReg shift_register (
.data_8(DATA_8_AT),
.clk(CLK_AT),
.valid1(VALID_1_AT),
.rstn(RSTN_AT),
.data_32(DATA_32_AT),
.valid_fifo(VALID_FIFO_AT),
.REGA(REG_A_AT),
.REGB(REG_B_AT),
.REGC(REG_C_AT),
.REGD(REG_D_AT),
.count(COUNT_AT)
);
For some reason, the valid == 1'b1 condition is not executed when I put the shift register along with everything else. I have really run out of ideas, hope someone manages to look at it and give me an insight.
Somewhere during synthesis you probably got warning that you're using VALID_1_AT signal, which has no driver. That's because in altogether module declaration you define VALID1_AT signal (notice _ missing in signal name). That's why valid1 in your shift register is not driven at all.
You should change:
.valid1(VALID_1_AT)
into:
.valid1(VALID1_AT)
to make it works.

Error in testbench as Inout port 'A' of 'DIGITADD' must be a net

module DIGITADD(
input [3:0] A,
input [3:0] B,
input CIN,
output COUT,
output [3:0] SUM
);
reg [4:0] s2;
assign SUM = s2[3:0];
assign COUT = s2[4];
//BCD ADDER PART
always # ( * )
begin
s2 = A + B + CIN;
if (s2 > 9)
begin
s2 = s2 + 6;
end
end
endmodule
TEST BENCH
module DIGITADD_tb(
reg [3:0] A,
reg [3:0] B,
reg CIN,
wire COUT,
wire [3:0] SUM);
DIGITADD uut(
.A(A),
.B(B),
.CIN(CIN),
.COUT(COUT),
.SUM(SUM));
initial begin
$dumpfile("dump.vcd");
$dumpvars(1,DIGITADD_tb);
#10;
#10 A=4'b0000;B=4'b0011;CIN=1'b0;
#10 A=4'b0111;B=4'b1000;CIN=1'b1;
$finish;
end
endmodule
You have added local variables in your testbench in the style of a port list:
module DIGITADD_tb(
reg [3:0] A,
reg [3:0] B,
reg CIN,
wire COUT,
wire [3:0] SUM);
Should be:
module DIGITADD_tb(); //<-- no ports
reg [3:0] A; //<-- semicolon
reg [3:0] B;
reg CIN;
wire COUT;
wire [3:0] SUM;

Resources