Why is iverilog complaining about my testbench module?Data memory unitPart select behaves strangely in simulator when it goes through a wireVerilog Error: output or inout port “Q” must be connected to a structural net expressionHow to use structural unit?How do you manipulate input arrays in an always block (verilog)?iverilog syntax for include?how to solve counter for seg controller faultiverilog testbench error: input is declared as wire, but it isn'tVerilog - Issue with Main Module for Adderregarding always block in implementing ARM cpu in verilogWhy is iverilog complaining about this expression/port width?

The screen of my macbook suddenly broken down how can I do to recover

What is Cash Advance APR?

Multiplicative persistence

Electoral considerations aside, what are potential benefits, for the US, of policy changes proposed by the tweet recognizing Golan annexation?

What was the exact wording from Ivanhoe of this advice on how to free yourself from slavery?

Pre-mixing cryogenic fuels and using only one fuel tank

Closed-form expression for certain product

How much character growth crosses the line into breaking the character

What is this called? Old film camera viewer?

Lowest total scrabble score

Redundant comparison & "if" before assignment

Why should universal income be universal?

lightning-datatable row number error

Loading commands from file

Removing files under particular conditions (number of files, file age)

Is there any references on the tensor product of presentable (1-)categories?

New brakes for 90s road bike

How should I respond when I lied about my education and the company finds out through background check?

Travelling outside the UK without a passport

Yosemite Fire Rings - What to Expect?

How do you make your own symbol when Detexify fails?

What does routing an IP address mean?

Why is it that I can sometimes guess the next note?

How to explain what's wrong with this application of the chain rule?



Why is iverilog complaining about my testbench module?


Data memory unitPart select behaves strangely in simulator when it goes through a wireVerilog Error: output or inout port “Q” must be connected to a structural net expressionHow to use structural unit?How do you manipulate input arrays in an always block (verilog)?iverilog syntax for include?how to solve counter for seg controller faultiverilog testbench error: input is declared as wire, but it isn'tVerilog - Issue with Main Module for Adderregarding always block in implementing ARM cpu in verilogWhy is iverilog complaining about this expression/port width?













0















I'm writing a verilog module for my CompSci class and this module specifically is the data memory module. Structurally and analytically, I'm looking at it and it should work based off of the other files that I have, but I'm not sure why this one specifically is acting up and giving me all x's. Hoping a fresh set of eyes can help find the error I missed. Thanks in advance.



datamem.v:



module datamem(Ina, Inb, enable, readwrite, dataOut, clk, rst);

input wire [31:0] Ina;
input wire [31:0] Inb;
input wire enable;
input wire readwrite;
input wire clk;
input wire rst;

reg [31:0] memory[0:65535];
output reg [31:0] dataOut;

always @(memory[Ina]) begin
dataOut = memory[Ina];
end

always @(posedge clk) begin
if(1'b1 == readwrite) begin
memory[Ina] = Inb;
end
end

endmodule


datamem_tb.v:



module datamem_tb();

reg [31:0] Ina;
reg [31:0] Inb;
reg enable;
reg readwrite;
reg clk;
reg rst;

wire [31:0] dataOut;

datamem DUT (Ina, Inb, enable, readwrite, dataOut, clk, rst);

initial
begin

Ina <= 32'd0;
Inb <= 32'd0;
enable <= 0;
readwrite <= 0;

#20 Ina <= 32'd1234;
#20 Inb <= 32'd1234;
#20 Ina <= 32'd0517;
#20 Inb <= 32'd10259;

end

always @(Ina or Inb)
#1 $display("| Ina = %d | Inb = %d | dataOut = %d |", Ina, Inb, dataOut);

endmodule









share|improve this question


























    0















    I'm writing a verilog module for my CompSci class and this module specifically is the data memory module. Structurally and analytically, I'm looking at it and it should work based off of the other files that I have, but I'm not sure why this one specifically is acting up and giving me all x's. Hoping a fresh set of eyes can help find the error I missed. Thanks in advance.



    datamem.v:



    module datamem(Ina, Inb, enable, readwrite, dataOut, clk, rst);

    input wire [31:0] Ina;
    input wire [31:0] Inb;
    input wire enable;
    input wire readwrite;
    input wire clk;
    input wire rst;

    reg [31:0] memory[0:65535];
    output reg [31:0] dataOut;

    always @(memory[Ina]) begin
    dataOut = memory[Ina];
    end

    always @(posedge clk) begin
    if(1'b1 == readwrite) begin
    memory[Ina] = Inb;
    end
    end

    endmodule


    datamem_tb.v:



    module datamem_tb();

    reg [31:0] Ina;
    reg [31:0] Inb;
    reg enable;
    reg readwrite;
    reg clk;
    reg rst;

    wire [31:0] dataOut;

    datamem DUT (Ina, Inb, enable, readwrite, dataOut, clk, rst);

    initial
    begin

    Ina <= 32'd0;
    Inb <= 32'd0;
    enable <= 0;
    readwrite <= 0;

    #20 Ina <= 32'd1234;
    #20 Inb <= 32'd1234;
    #20 Ina <= 32'd0517;
    #20 Inb <= 32'd10259;

    end

    always @(Ina or Inb)
    #1 $display("| Ina = %d | Inb = %d | dataOut = %d |", Ina, Inb, dataOut);

    endmodule









    share|improve this question
























      0












      0








      0








      I'm writing a verilog module for my CompSci class and this module specifically is the data memory module. Structurally and analytically, I'm looking at it and it should work based off of the other files that I have, but I'm not sure why this one specifically is acting up and giving me all x's. Hoping a fresh set of eyes can help find the error I missed. Thanks in advance.



      datamem.v:



      module datamem(Ina, Inb, enable, readwrite, dataOut, clk, rst);

      input wire [31:0] Ina;
      input wire [31:0] Inb;
      input wire enable;
      input wire readwrite;
      input wire clk;
      input wire rst;

      reg [31:0] memory[0:65535];
      output reg [31:0] dataOut;

      always @(memory[Ina]) begin
      dataOut = memory[Ina];
      end

      always @(posedge clk) begin
      if(1'b1 == readwrite) begin
      memory[Ina] = Inb;
      end
      end

      endmodule


      datamem_tb.v:



      module datamem_tb();

      reg [31:0] Ina;
      reg [31:0] Inb;
      reg enable;
      reg readwrite;
      reg clk;
      reg rst;

      wire [31:0] dataOut;

      datamem DUT (Ina, Inb, enable, readwrite, dataOut, clk, rst);

      initial
      begin

      Ina <= 32'd0;
      Inb <= 32'd0;
      enable <= 0;
      readwrite <= 0;

      #20 Ina <= 32'd1234;
      #20 Inb <= 32'd1234;
      #20 Ina <= 32'd0517;
      #20 Inb <= 32'd10259;

      end

      always @(Ina or Inb)
      #1 $display("| Ina = %d | Inb = %d | dataOut = %d |", Ina, Inb, dataOut);

      endmodule









      share|improve this question














      I'm writing a verilog module for my CompSci class and this module specifically is the data memory module. Structurally and analytically, I'm looking at it and it should work based off of the other files that I have, but I'm not sure why this one specifically is acting up and giving me all x's. Hoping a fresh set of eyes can help find the error I missed. Thanks in advance.



      datamem.v:



      module datamem(Ina, Inb, enable, readwrite, dataOut, clk, rst);

      input wire [31:0] Ina;
      input wire [31:0] Inb;
      input wire enable;
      input wire readwrite;
      input wire clk;
      input wire rst;

      reg [31:0] memory[0:65535];
      output reg [31:0] dataOut;

      always @(memory[Ina]) begin
      dataOut = memory[Ina];
      end

      always @(posedge clk) begin
      if(1'b1 == readwrite) begin
      memory[Ina] = Inb;
      end
      end

      endmodule


      datamem_tb.v:



      module datamem_tb();

      reg [31:0] Ina;
      reg [31:0] Inb;
      reg enable;
      reg readwrite;
      reg clk;
      reg rst;

      wire [31:0] dataOut;

      datamem DUT (Ina, Inb, enable, readwrite, dataOut, clk, rst);

      initial
      begin

      Ina <= 32'd0;
      Inb <= 32'd0;
      enable <= 0;
      readwrite <= 0;

      #20 Ina <= 32'd1234;
      #20 Inb <= 32'd1234;
      #20 Ina <= 32'd0517;
      #20 Inb <= 32'd10259;

      end

      always @(Ina or Inb)
      #1 $display("| Ina = %d | Inb = %d | dataOut = %d |", Ina, Inb, dataOut);

      endmodule






      verilog iverilog






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 8 at 4:30









      Barnabas BullionBarnabas Bullion

      133




      133






















          1 Answer
          1






          active

          oldest

          votes


















          1














          A few things as to why you are getting all 'x:



          1. You never run the clock, you need to add something like the following to have the clock toggle:

           initial begin
          clk = 1'b0;
          forever #5 clk = ~clk;
          end


          1. You never assert readwrite which is required to write to your memory module (you set it to 0 on line 20 and never change it). Without being written to, memory will retain its original value of 'x for every element

          Aside from that, there are a few other issues with your module:



          1. Use implicit sensitive lists (instead of always @(memory[inA]) use always @(*))

          2. Use non-blocking assignment for your memory write (memory[inA] <= inB)

          3. Consider using $monitor instead of $display for your print statements to avoid timing issues, and you only need call it at the beginning of your initial block in your testbench (http://referencedesigner.com/tutorials/verilog/verilog_09.php)

          4. Your rst and enable arent connected to anything.

          Another example of a memory unit implementation can be found here:
          Data memory unit






          share|improve this answer
























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55056750%2fwhy-is-iverilog-complaining-about-my-testbench-module%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            A few things as to why you are getting all 'x:



            1. You never run the clock, you need to add something like the following to have the clock toggle:

             initial begin
            clk = 1'b0;
            forever #5 clk = ~clk;
            end


            1. You never assert readwrite which is required to write to your memory module (you set it to 0 on line 20 and never change it). Without being written to, memory will retain its original value of 'x for every element

            Aside from that, there are a few other issues with your module:



            1. Use implicit sensitive lists (instead of always @(memory[inA]) use always @(*))

            2. Use non-blocking assignment for your memory write (memory[inA] <= inB)

            3. Consider using $monitor instead of $display for your print statements to avoid timing issues, and you only need call it at the beginning of your initial block in your testbench (http://referencedesigner.com/tutorials/verilog/verilog_09.php)

            4. Your rst and enable arent connected to anything.

            Another example of a memory unit implementation can be found here:
            Data memory unit






            share|improve this answer





























              1














              A few things as to why you are getting all 'x:



              1. You never run the clock, you need to add something like the following to have the clock toggle:

               initial begin
              clk = 1'b0;
              forever #5 clk = ~clk;
              end


              1. You never assert readwrite which is required to write to your memory module (you set it to 0 on line 20 and never change it). Without being written to, memory will retain its original value of 'x for every element

              Aside from that, there are a few other issues with your module:



              1. Use implicit sensitive lists (instead of always @(memory[inA]) use always @(*))

              2. Use non-blocking assignment for your memory write (memory[inA] <= inB)

              3. Consider using $monitor instead of $display for your print statements to avoid timing issues, and you only need call it at the beginning of your initial block in your testbench (http://referencedesigner.com/tutorials/verilog/verilog_09.php)

              4. Your rst and enable arent connected to anything.

              Another example of a memory unit implementation can be found here:
              Data memory unit






              share|improve this answer



























                1












                1








                1







                A few things as to why you are getting all 'x:



                1. You never run the clock, you need to add something like the following to have the clock toggle:

                 initial begin
                clk = 1'b0;
                forever #5 clk = ~clk;
                end


                1. You never assert readwrite which is required to write to your memory module (you set it to 0 on line 20 and never change it). Without being written to, memory will retain its original value of 'x for every element

                Aside from that, there are a few other issues with your module:



                1. Use implicit sensitive lists (instead of always @(memory[inA]) use always @(*))

                2. Use non-blocking assignment for your memory write (memory[inA] <= inB)

                3. Consider using $monitor instead of $display for your print statements to avoid timing issues, and you only need call it at the beginning of your initial block in your testbench (http://referencedesigner.com/tutorials/verilog/verilog_09.php)

                4. Your rst and enable arent connected to anything.

                Another example of a memory unit implementation can be found here:
                Data memory unit






                share|improve this answer















                A few things as to why you are getting all 'x:



                1. You never run the clock, you need to add something like the following to have the clock toggle:

                 initial begin
                clk = 1'b0;
                forever #5 clk = ~clk;
                end


                1. You never assert readwrite which is required to write to your memory module (you set it to 0 on line 20 and never change it). Without being written to, memory will retain its original value of 'x for every element

                Aside from that, there are a few other issues with your module:



                1. Use implicit sensitive lists (instead of always @(memory[inA]) use always @(*))

                2. Use non-blocking assignment for your memory write (memory[inA] <= inB)

                3. Consider using $monitor instead of $display for your print statements to avoid timing issues, and you only need call it at the beginning of your initial block in your testbench (http://referencedesigner.com/tutorials/verilog/verilog_09.php)

                4. Your rst and enable arent connected to anything.

                Another example of a memory unit implementation can be found here:
                Data memory unit







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Mar 8 at 5:12









                dave_59

                20.7k21639




                20.7k21639










                answered Mar 8 at 4:51









                UnnUnn

                2,722822




                2,722822





























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55056750%2fwhy-is-iverilog-complaining-about-my-testbench-module%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    How to get text form Clipboard with JavaScript in Firefox 56?How to validate an email address in JavaScript?How do JavaScript closures work?How do I remove a property from a JavaScript object?How do you get a timestamp in JavaScript?How do I copy to the clipboard in JavaScript?How do I include a JavaScript file in another JavaScript file?Get the current URL with JavaScript?How to replace all occurrences of a string in JavaScriptHow to check whether a string contains a substring in JavaScript?How do I remove a particular element from an array in JavaScript?

                    Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme

                    List of MPs elected to the English parliament in 1640 (April) Contents List of constituencies and members See also Notes References Navigation menueNational Archives – The Glynde Place ArchivesCobbett's Parliamentary history of England, from the Norman Conquest in 1066 to the year 1803'Aldermen in Parliament', The Aldermen of the City of London: Temp. Henry III – 1912onepage&q&f&#61, false 229