1
\$\begingroup\$

For the following code,I get several errors:

1)Target <mem> of concurrent assignment or output port connection should be a net type.

2)in_d0_ is not a constant

How this issue can be solved?

module module_cell44( in_d0,in_d1,in_d2,in_d3,out_61,out_68,clk );
    parameter DATA_WIDTH = 16;
    parameter ADDR_WIDTH = 8;
    parameter ADDR_DEPTH = 1 << ADDR_WIDTH;

// Interfaces
input clk;

input [DATA_WIDTH - 1:0] in_d0,in_d1,in_d2,in_d3;
output [DATA_WIDTH - 1:0] out_61,out_68;
reg [DATA_WIDTH - 1:0] out_61,in_d0_,in_d1_;
//Cell`s memory array
reg [DATA_WIDTH - 1:0] mem[0:ADDR_DEPTH - 1];


// Procedural Assignments

always @ ( posedge clk )
begin
in_d0_ <= in_d0;
in_d1_ <= in_d1;
mem[in_d2]<=in_d3;
end


// Continues Assinmnents

 assign mem[in_d0_] = in_d1_;

endmodule
\$\endgroup\$
3
  • \$\begingroup\$ The above code on EDA Playground (compiled with Questa): edaplayground.com/s/4/108 \$\endgroup\$
    – Victor L
    Aug 25, 2013 at 16:37
  • \$\begingroup\$ @VictorLyuboslavsky - the error is in xilinx 14.1 \$\endgroup\$
    – YAKOVM
    Aug 25, 2013 at 19:19
  • \$\begingroup\$ Sometimes I use other tools to get different error/warning messages, which helps with debug. \$\endgroup\$
    – Victor L
    Aug 25, 2013 at 19:36

2 Answers 2

5
\$\begingroup\$

You cannot drive a reg type via a continuous assignment (only a wire may be driven in this way).

If this is just modelling combinatorial logic, you could use a combinatorial always block:

always @* begin
    mem[in_d0_] = in_d1_;
end

However, this doesn't seem to make much sense to me for writing to a memory module, which is usually something that is written on a clock edge. Perhaps you want to make this a clocked block:

always @(posedge clk)
    mem[in_d0_] = in_d1_;
end
\$\endgroup\$
2
  • \$\begingroup\$ -if i perform assign out61 = in_d0_ + in_d1_;instead of mem[in_d0_] = in_d1_. It is compiled ok,despite in_d0_ and in_d1_ are reg types.Why he problem occurs in mem only? \$\endgroup\$
    – YAKOVM
    Aug 25, 2013 at 19:44
  • \$\begingroup\$ It works because outputs are wire types by default. If you change it to a reg type, then it will not work. Declaring output reg [DATA_WIDTH - 1:0] out_61 will give an error if you try to assign to it. \$\endgroup\$
    – Tim
    Aug 25, 2013 at 20:00
0
\$\begingroup\$

Although it is Cliff's proposal to remove Type Reg, as part of that, he explains Verilog types in detail in this paper.

This paper will detail the differences between register and net data types and propose an enhancement to the Verilog language that would eliminate the need to declare register data types altogether

A Proposal To Remove Those Ugly Register Data Types From Verilog

\$\endgroup\$
2
  • \$\begingroup\$ Please provide a brief synopsis of the link, as links go down and then your answer is worthless, answers are forever \$\endgroup\$
    – Voltage Spike
    Apr 26, 2018 at 19:04
  • \$\begingroup\$ Good point... the link has survived 20+ years, but, no telling... ...This paper will detail the differences between register and net data types and propose an enhancement to the Verilog language that would eliminate the need to declare register data types altogether \$\endgroup\$
    – CapnJJ
    Apr 26, 2018 at 19:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.