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

                    Thal And Out Agency railway station See also References External links Navigation menuOfficial Web Site of Pakistan RailwaysArchivedOfficial Web Site of Pakistan Railwayseeexpanding ite

                    Understanding generators in Python2019 Community Moderator ElectionGenerator function not working pythonFor loop not executing two timesGenerators - Printing generated valuesWhy can a python generator only be used once?What exactly do generators do?What does the “yield” keyword do?What does “list comprehension” mean? How does it work and how can I use it?sklearn Kfold acces single fold instead of for loopIs a generator the callable? Which is the generator?Apply Border To Range Of Cells Using OpenpyxlCalling an external command in PythonWhat are metaclasses in Python?What is the difference between @staticmethod and @classmethod?Finding the index of an item given a list containing it in PythonDifference between append vs. extend list methods in PythonHow can I safely create a nested directory in Python?Does Python have a ternary conditional operator?Understanding slice notationUnderstanding Python super() with __init__() methodsDoes Python have a string 'contains' substring method?

                    How can I change the color of pagination dots of UIPageControl?How to change UIPageControl dotsIs there a way to change page indicator dots colorCustomize dot with image of UIPageControl at index 0 of UIPageControlNo visible @interface for 'NSObject<PageControlDelegate>' declares the selector 'pageControlPageDidChange:'How to change the color of pagination dots in UIPageControl with a different color per pagepagecontrol indicator custom image instead of DefaultChanging the colour of UIPageControl dots in MonoTouchpagecontrol selectable page visibility color?Alternative way to load ViewControllers on a UIPageControlHow to set only layer.border-color for UIpage control dots in swiftHow can I develop for iPhone using a Windows development machine?How to change the name of an iOS app?UITableView - change section header coloruipagecontrol indicator(dot)issueCustom UIPageControl dots color not changingchange the interspace between UIPageControl dotsHow to change Status Bar text color in iOSHow can I change image tintColor in iOS and WatchKitUIPageControl dots with larger space in between each dotsHow to change the color of pagination dots in UIPageControl with a different color per page