verilog

localparam after wire declaration

旧街凉风 提交于 2019-12-11 19:17:31
问题 For a very strange reason (scripts we use) I need to be able to declare a localparam AFTER I declare wires and regs in a module: module blah (clk, rst, in, out); input clk; input rst; input [2:0] in; output [3:0] out; wire res; localparam NUMBER=5; ... is this legal verilog code? I would also appreciate a link to the relevant seciton in the documentation. Thanks! 回答1: This is valid Verilog (2001). Verilog 2001 saw the introduction of localparam , for all versions it is still syntactically

Instantiation of a module in verilog

感情迁移 提交于 2019-12-11 19:12:44
问题 I am getting an error in instantiating a module in verilog file. I am instantiating like this: module lab3(input clk,set,reset,plus,minus,start,button,output reg [3:0]led,output reg [6:0]y); wire [3:0] indicesgu[3:0]; reg [1:0] going; reg alsogoing,yes; if (going==1 && alsogoing) begin up_counter up_0 ( indicesgu , indices , alsogoing ); end endmodule and my up_counter module starts as: module up_counter(input [3:0] indices_in [3:0],output [3:0]indices[3:0],output alsogoing); reg [3:0]indices

In SystemC, can the sc_signal_in/out type port be bound to the primary channel sc_buffer?

ε祈祈猫儿з 提交于 2019-12-11 18:37:52
问题 I am using SystemC for modelling, and I am a little bit confused about the "channel", which includes signal, buffer and fifo. So could anyone tell me the difference of signal and buffer? Is it the same as the difference between the wire and register variable in Verilog HDL? Can signal be bound to the buffer variable? 回答1: sc_buffer and sc_signal are both primitive channels that implement sc_signal_inout_if ; a 'buffer' is an object of type sc_buffer , while a 'signal' is an object of type sc

Please Explain these verilog code?

拈花ヽ惹草 提交于 2019-12-11 18:06:17
问题 code of booth multiplier is :- module ni(prod, a, b, busy, mc, mp, clk, start); output [15:0] prod; output [7:0] a, b; output busy; input [7:0] mc, mp; input clk, start; reg [7:0] A, Q, M; reg Q_1; reg [3:0] count; wire [7:0] sum, difference; always @(posedge clk) begin if (start) begin A <= 8'b0; M <= mc; Q <= mp; Q_1 <= 1'b0; count <= 4'b0; end else begin case ({Q[0], Q_1}) 2'b0_1 : {A, Q, Q_1} <= {sum[7], sum, Q}; 2'b1_0 : {A, Q, Q_1} <= {difference[7], difference, Q}; default: {A, Q, Q_1}

Why are the outputs of this pseudo random number generator (LFSR) so predictable?

你说的曾经没有我的故事 提交于 2019-12-11 18:06:06
问题 Recently I asked here, how to generate random numbers in hardware and was told to use an LFSR. It will be random but will start repeating after a certain value. The problem is that the random numbers generated are so predictable that the next value can be easily guessed. For example check the simulation below: The next "random" number can be guessed by adding the previous number with a +1 of itself. Can someone please verify if this is normal and to be expected. Here is the code I used for

Verilog: creating many registers of varying length/ the generate/genvar command

坚强是说给别人听的谎言 提交于 2019-12-11 17:57:26
问题 In a module I would like to make many registers of varying length, and send information between those registers each clock cycle. Specifically, I am trying to create a module which adds all the elements in a list efficiently by adding their elements pairwise into a new list, then continuing until there is one element. Something like the following, where the input represents 4 lists of length 16 of 8 bit integers (this code passes synthesis and implementation, although I have not tested it so

What is the exact criteria for an inout port, when sometimes inout and output ports can be interchangeably used in Verilog?

↘锁芯ラ 提交于 2019-12-11 17:48:08
问题 In the below module, ideally cnt, width & start should be inout port, instead of output port. But I tried with those ports as output ports and still I am able to run it without any error. So can inout and output ports be used interchangeably in Verilog? If no, then what is the exact criteria, where inout port must be used (output port can't be used in that case)? module (clk, rst, cnt, start, width, signal); input clk, rst, signal; output reg [11:0] cnt, width; output reg start; always @

Verilog: Common bus implementation issue

有些话、适合烂在心里 提交于 2019-12-11 17:15:32
问题 I've been coding a 16-bit RISC microprocessor in Verilog, and I've hit yet another hurdle. After the code writing task was over, I tried to synthesize it. Found a couple of accidental mistakes and I fixed them. Then boom, massive error. The design comprises of four 16-bit common buses. For some reason, I'm getting a multiple driver error for these buses from the synthesis tool. The architecture of the computer is inspired by and is almost exactly the same as the Magic-1 by Bill Buzzbee,

Why can't I instantiate inside the procedural block in Verilog

限于喜欢 提交于 2019-12-11 17:03:03
问题 I need to instantiate some modules whose requirements pop up during the procedural block.But I am not allowed to instantiate inside the procedural block.Where else should I instantiate these modules so that I could access them in the procedural block. I just need 1 instantiation and so I am not using generate statement.I am simply instantiating it using ... Center data_cent(.clk(clk),.dummy_4(dummy_6)); But upon checking the syntax it gives an error stating " data_cent is not a task". I am

How to reseed the RNG of a static process?

…衆ロ難τιáo~ 提交于 2019-12-11 16:33:59
问题 I have an always process running in my testbench that calls $urandom_range() Is it possible to reseed this while im running my testbench? I guess it has something to do with srandom but can't get it to work. 回答1: It is possible to seed the random number generator for the thread (ie that used by $urandom etc) by calling $urandom with an integer argument, eg: $urandom(12345); You mention srandom . This is another way to interact with the thread’s random number generator and that is by using the